From 89f687bc1c044f603acb6e268490feb665a2bdd6 Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Thu, 8 Oct 2026 22:15:55 -0700 Subject: [PATCH 01/22] Add Web PubSub Chat topics and collection APIs --- .../README.md | 372 +++- .../_metadata.json | 4 +- .../api.md | 1093 ++++++++---- .../api.metadata.yml | 5 +- .../apiview-properties.json | 23 +- .../assets.json | 2 +- .../messaging/webpubsubchatservice/_client.py | 2 +- .../webpubsubchatservice/_configuration.py | 4 +- .../_operations/_operations.py | 1532 +++++++++++++++-- .../webpubsubchatservice/_validation.py | 66 + .../webpubsubchatservice/aio/_client.py | 2 +- .../aio/_configuration.py | 4 +- .../aio/_operations/_operations.py | 1208 ++++++++++++- .../webpubsubchatservice/models/__init__.py | 6 + .../webpubsubchatservice/models/_enums.py | 11 + .../webpubsubchatservice/models/_models.py | 98 ++ .../messaging/webpubsubchatservice/types.py | 39 +- .../create_or_replace_role.py | 2 +- .../create_or_replace_room.py | 2 +- .../create_or_replace_room_member.py | 2 +- .../create_or_replace_topic.py | 44 + .../create_or_replace_user.py | 2 +- .../generated_samples/delete_message.py | 2 +- .../generated_samples/delete_role.py | 2 +- .../generated_samples/delete_room.py | 2 +- .../generated_samples/delete_room_member.py | 2 +- .../generated_samples/delete_topic.py | 42 + .../generated_samples/delete_user.py | 2 +- .../generated_samples/get_conversation.py | 2 +- .../generated_samples/get_role.py | 2 +- .../generated_samples/get_room.py | 2 +- .../generated_samples/get_topic.py | 43 + .../generated_samples/get_user.py | 2 +- .../generated_samples/list_messages.py | 2 +- .../generated_samples/list_roles.py | 2 +- .../generated_samples/list_room_members.py | 2 +- .../generated_samples/list_rooms.py | 41 + .../generated_samples/list_rooms_for_user.py | 43 + .../generated_samples/list_topics.py | 43 + .../generated_samples/list_users.py | 41 + .../generated_samples/update_message.py | 2 +- .../generated_samples/update_topic.py | 44 + .../test_web_pub_sub_chat_service.py | 106 ++ .../test_web_pub_sub_chat_service_async.py | 106 ++ .../pyproject.toml | 1 - .../samples/sample_client_access.py | 4 +- .../samples/sample_client_access_async.py | 4 +- .../samples/sample_errors.py | 34 + .../samples/sample_logging.py | 39 + .../samples/sample_message_history.py | 26 - .../samples/sample_message_history_async.py | 30 - .../samples/sample_readme_snippets.py | 159 ++ .../samples/sample_roles_and_permissions.py | 60 +- .../sample_roles_and_permissions_async.py | 62 +- .../tests/test_client.py | 11 +- .../tests/test_topics.py | 222 +++ .../tests/test_topics_live.py | 123 ++ .../tests/test_topics_live_async.py | 136 ++ .../tests/testcase.py | 6 +- .../tsp-location.yaml | 2 +- 60 files changed, 5167 insertions(+), 810 deletions(-) create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_validation.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_topic.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_topic.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_topic.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_rooms.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_rooms_for_user.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_topics.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_users.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/update_topic.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_errors.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_logging.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_message_history.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_message_history_async.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_readme_snippets.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_topics.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_topics_live.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_topics_live_async.py diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md index 4991c0acda10..ecb75a6a771c 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/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, users, and the rooms associated with a user. +- Create, list, update, and soft delete room topics. - Get room conversations and query persisted message history. - Update and delete persisted messages. - Generate client access credentials for Chat WebSocket clients. @@ -16,6 +18,7 @@ Use this client library in an application server to: | [API reference documentation][api_reference] | [Product documentation][product_docs] | [Samples][samples] +| [Generated samples][generated_samples] | [Changelog][changelog] ## Getting started @@ -142,9 +145,23 @@ A conversation is a message thread that belongs to a room. Every room has a defa 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. +### Topic + +A topic is a named thread within a room with its own conversation. The service assigns its +ID, creation time, creator, conversation ID, and ETag in responses. Topic IDs are specified +by the application in the request path. Topics have a lifecycle state of `Normal`, `Archived`, +or `SoftDeleted`. Creating a topic requires a title; updating a topic can change its title +and state. Deleting a topic is a soft delete. + +The default service API version is `2026-08-01-preview`, which adds topics and the +room, user, and user-room collection operations. + ## Examples -The following sections show common scenarios. See the [package samples][samples] for complete synchronous and asynchronous programs. +The following sections show common scenarios. Each operation snippet assumes an +authenticated `client`, created as shown in Getting started. The async snippet +uses a client from `azure.messaging.webpubsubchatservice.aio`. +See the [package samples][samples] for complete synchronous and asynchronous programs. ### Generate client access credentials @@ -153,99 +170,296 @@ Generate credentials that a Chat WebSocket client can use to connect as a specif ```python -import os -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient - -connection_string = os.environ["WPS_CHAT_CONNECTION_STRING"] -with WebPubSubChatServiceClient.from_connection_string( - connection_string, - os.environ.get("WPS_CHAT_HUB", "test_hub"), -) as client: - access = client.get_client_access_token(user_id="sample-user") - # Give access["url"] to the intended client to connect; it includes the access token. - # Print only the token-free base URL here. Do not log access["url"]. - print(access["baseUrl"]) +access = client.get_client_access_token(user_id="sample-user") +# Give access["url"] to the intended client to connect; it includes the access token. +# Print only the token-free base URL here. Do not log access["url"]. +print(access["baseUrl"]) ``` The returned URL contains an access token. Send it only to the intended client, and do not log or persist it in production. -### Create and list roles +### Create a role + +Use the `ChatRole` model and `ChatPermission` enum instead of a dictionary with +permission string literals. This example assumes `os` is imported. + + ```python from azure.messaging.webpubsubchatservice.models import ChatPermission, ChatRole -role_name = "user.moderator" -try: - role = client.create_or_replace_role( - role_name, - ChatRole(permissions=[ChatPermission.USER_CREATE_ROOM]), - ) - print(role.name, role.permissions) +role = client.create_or_replace_role( + os.environ.get("WPS_CHAT_ROLE_NAME", "user.python_sample"), + ChatRole(permissions=[ChatPermission.USER_CREATE_ROOM]), +) +print(role.name, role.permissions) +``` + + + +See [sample_roles_and_permissions.py](samples/sample_roles_and_permissions.py) +and [sample_roles_and_permissions_async.py](samples/sample_roles_and_permissions_async.py) +for runnable model-and-enum examples. The selected role is created or replaced +and remains in the hub; these samples do not create users or rooms. + +### List roles - for listed_role in client.list_roles(): - print(listed_role.name) -finally: - client.delete_role(role_name) + + +```python +for role in client.list_roles(): + print(role.name) ``` -### Create a user, room, and room membership + + +### Create a user + +The user role `user.room_creator` must already exist. + + ```python -from azure.messaging.webpubsubchatservice.models import ( - ChatPermission, - ChatRole, - ChatRoom, - ChatRoomMember, - HumanChatUser, -) +from azure.messaging.webpubsubchatservice.models import HumanChatUser -client.create_or_replace_role( - "user.room_creator", - ChatRole(permissions=[ChatPermission.USER_CREATE_ROOM]), -) -client.create_or_replace_role( - "room.contributor", - ChatRole(permissions=[ChatPermission.ROOM_PUBLISH_MESSAGE]), -) -client.create_or_replace_user( +user = client.create_or_replace_user( "alice", HumanChatUser(nickname="Alice", role_name="user.room_creator"), ) +print(user.id, user.nickname) +``` + + + +### Create a room + + + +```python +from azure.messaging.webpubsubchatservice.models import ChatRoom + room = client.create_or_replace_room("general", ChatRoom(title="General")) +print(room.id, room.default_conversation) +``` + + + +### Add a room member + +The room `general`, user `alice`, and room role `room.contributor` must already exist. + + + +```python +from azure.messaging.webpubsubchatservice.models import ChatRoomMember + member = client.create_or_replace_room_member( - room.id, + "general", "alice", ChatRoomMember(role_name="room.contributor"), ) print(member.user_id, member.role_name) ``` -Delete dependent resources in reverse order when they are no longer needed: room, user, and then roles. + ### List persisted messages +Set `WPS_CHAT_CONVERSATION_ID` to an existing conversation ID. + + + ```python -room = client.get_room("general") -for message in client.list_messages(room.default_conversation): +import os + +for message in client.list_messages(os.environ["WPS_CHAT_CONVERSATION_ID"]): print(message.id, message.created_by, message.content.text) ``` + + +### Manage room topics + +These examples use an existing room identified by `WPS_CHAT_ROOM_ID` and a +topic ID specified by `WPS_CHAT_TOPIC_ID`. + +#### Create a topic + + + +```python +import os +from azure.messaging.webpubsubchatservice.models import ChatTopic + +topic = client.create_or_replace_topic( + os.environ["WPS_CHAT_ROOM_ID"], + os.environ["WPS_CHAT_TOPIC_ID"], + ChatTopic({"title": "Announcements"}), +) +print(topic.id, topic.etag) +``` + + + +#### List topics + + + +```python +import os + +for topic in client.list_topics(os.environ["WPS_CHAT_ROOM_ID"], max_page_size=10): + print(topic.id, topic.title, topic.conversation_id) +``` + + + +#### Get a topic + + + +```python +import os + +topic = client.get_topic(os.environ["WPS_CHAT_ROOM_ID"], os.environ["WPS_CHAT_TOPIC_ID"]) +print(topic.id, topic.title, topic.state, topic.etag) +``` + + + +#### Archive a topic + +Set `WPS_CHAT_TOPIC_ETAG` to the ETag returned by a previous create or get +operation. + + + +```python +import os +from azure.core import MatchConditions +from azure.messaging.webpubsubchatservice.models import ChatTopic, ChatTopicState + +topic = client.update_topic( + os.environ["WPS_CHAT_ROOM_ID"], + os.environ["WPS_CHAT_TOPIC_ID"], + ChatTopic(title="Announcements", state=ChatTopicState.ARCHIVED), + etag=os.environ["WPS_CHAT_TOPIC_ETAG"], + match_condition=MatchConditions.IfNotModified, +) +print(topic.id, topic.state, topic.etag) +``` + + + +#### Soft delete a topic + +Set `WPS_CHAT_TOPIC_ETAG` to the current ETag, including any change from an update. + + + +```python +import os +from azure.core import MatchConditions + +client.delete_topic( + os.environ["WPS_CHAT_ROOM_ID"], + os.environ["WPS_CHAT_TOPIC_ID"], + etag=os.environ["WPS_CHAT_TOPIC_ETAG"], + match_condition=MatchConditions.IfNotModified, +) +``` + + + +Use the topic's `conversation_id` with `get_conversation` and `list_messages`. + +For conditional updates and deletes, pass the current ETag with +`MatchConditions.IfNotModified`. A stale ETag prevents overwriting a topic +that another caller has changed. Deleting a topic is a soft delete. + +For individual API calls, see the generated samples for +[create or replace](generated_samples/create_or_replace_topic.py), +[list](generated_samples/list_topics.py), [get](generated_samples/get_topic.py), +[update](generated_samples/update_topic.py), and +[delete](generated_samples/delete_topic.py). + +### List rooms and users + +#### List rooms + + + +```python +for room in client.list_rooms(max_page_size=10): + print(room.id, room.title) +``` + + + +#### List users + + + +```python +for user in client.list_users(max_page_size=10): + print(user.id, user.kind) +``` + + + +#### List rooms for a user + +Set `WPS_CHAT_USER_ID` to an existing user ID. + + + +```python +import os + +for room in client.list_rooms_for_user(os.environ["WPS_CHAT_USER_ID"]): + print(room.id, room.title) +``` + + + +For basic list calls, see [list_rooms.py](generated_samples/list_rooms.py), +[list_users.py](generated_samples/list_users.py), and +[list_rooms_for_user.py](generated_samples/list_rooms_for_user.py). +Listing rooms for a user requires an existing user ID. + +Collection iterators automatically fetch subsequent pages. + ### Use the asynchronous client +Run this snippet inside an async function with an authenticated async `client`; see +[sample_client_access_async.py](samples/sample_client_access_async.py) +for the complete program. + + + ```python -from azure.identity.aio import DefaultAzureCredential -from azure.messaging.webpubsubchatservice.aio import WebPubSubChatServiceClient +access = await client.get_client_access_token(user_id="sample-user") +# Give access["url"] to the intended client to connect; it includes the access token. +# Print only the token-free base URL here. Do not log access["url"]. +print(access["baseUrl"]) +``` -credential = DefaultAzureCredential() -client = WebPubSubChatServiceClient(endpoint, hub, credential) -try: - async for role in client.list_roles(): - print(role.name) -finally: - await client.close() - await credential.close() + + +### Run the samples + +Set `WPS_CHAT_CONNECTION_STRING` and optionally `WPS_CHAT_HUB` (default: `test_hub`). +The role samples accept `WPS_CHAT_ROLE_NAME` (default: `user.python_sample`). +Use a role name reserved for the sample: an existing role with that name is +replaced. Install `aiohttp` to run async samples. + +From the package directory, run, for example: + +```bash +python samples/sample_roles_and_permissions.py +python samples/sample_roles_and_permissions_async.py ``` ## Troubleshooting @@ -254,21 +468,35 @@ finally: Service operations raise `HttpResponseError` or a more specific subclass when a request fails: +The [sample_errors.py](samples/sample_errors.py) example reads an existing role, +prints the status on failure, and re-raises the error. Set `WPS_CHAT_ROLE_NAME` +to the role to read (default: `user.python_sample`). + + + ```python +import os from azure.core.exceptions import HttpResponseError try: - room = client.get_room("room-id") + role = client.get_role(os.environ.get("WPS_CHAT_ROLE_NAME", "user.python_sample")) + print(role.name, role.permissions) except HttpResponseError as error: print(f"Chat service request failed with status {error.status_code}") + raise ``` + + ### Logging This library uses the standard Python [logging][python_logging] library. Enable HTTP logging for a client by passing `logging_enable=True`: + + ```python import logging +import os import sys from azure.identity import DefaultAzureCredential @@ -278,14 +506,18 @@ logger = logging.getLogger("azure") logger.setLevel(logging.DEBUG) logger.addHandler(logging.StreamHandler(stream=sys.stdout)) -client = WebPubSubChatServiceClient( - endpoint, - hub, - DefaultAzureCredential(), - logging_enable=True, -) +with DefaultAzureCredential() as credential: + with WebPubSubChatServiceClient( + os.environ["WPS_CHAT_ENDPOINT"], + os.environ.get("WPS_CHAT_HUB", "test_hub"), + credential, + logging_enable=True, + ) as client: + print(type(client).__name__) ``` + + HTTP logs can contain sensitive information. Do not enable detailed logging in production without reviewing how logs are collected and protected. For more information, see [Configure logging in the Azure SDK for Python][azure_sdk_logging]. ### Authentication and authorization @@ -300,14 +532,25 @@ If a newly sent message does not appear immediately, confirm that the sending us ## Next steps -Explore the [complete package samples][samples] to learn how to: +Explore the [README snippet sources](samples/sample_readme_snippets.py) and +[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. - Generate client access credentials. - Query, update, and delete message history. +- Manage topic lifecycles and iterate over room and user collections. - Use synchronous and asynchronous clients. +See also the [generated operation samples][generated_samples], produced from the +specification's examples. Each file demonstrates one operation. Replace +`ENDPOINT`, `HUB`, and any example resource identifiers before running them, +and configure authentication as described in each file. These generated files +are refreshed during SDK generation. The README snippet source contains +independent functions, not a combined workflow or a standalone program. +The runnable hand-written samples demonstrate model and permission-enum usage, +authentication, client access credentials, errors, and logging. + ## Additional resources - [Azure Web PubSub documentation][webpubsub_docs] @@ -327,6 +570,7 @@ This project has adopted the [Microsoft Open Source Code of Conduct][code_of_con [api_reference]: https://learn.microsoft.com/python/api/overview/azure/messaging-webpubsubchatservice-readme?view=azure-python-preview [product_docs]: https://learn.microsoft.com/azure/azure-web-pubsub/chat-overview [samples]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples +[generated_samples]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples [changelog]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md [azure_sub]: https://azure.microsoft.com/free/ [webpubsub_docs]: https://learn.microsoft.com/azure/azure-web-pubsub/ diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/_metadata.json b/sdk/webpubsub/azure-messaging-webpubsubchatservice/_metadata.json index 46cdcde90533..317a1629c2c5 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/_metadata.json +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/_metadata.json @@ -1,6 +1,6 @@ { - "apiVersion": "2026-02-01-preview", + "apiVersion": "2026-08-01-preview", "apiVersions": { - "WebPubSubChat": "2026-02-01-preview" + "WebPubSubChat": "2026-08-01-preview" } } \ No newline at end of file diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md index 4e1036da346a..8f19e3275a2f 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md @@ -7,23 +7,23 @@ namespace azure.messaging.webpubsubchatservice USER_NORMAL = user.normal - class azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient(WebPubSubChatServiceClientGenerated): implements ContextManager + class azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient(WebPubSubChatServiceClientGenerated): implements ContextManager def __init__( - self, - endpoint: str, - hub: str, - credential: Union[TokenCredential, AzureKeyCredential], - *, - api_version: Optional[str] = ..., + self, + endpoint: str, + hub: str, + credential: Union[TokenCredential, AzureKeyCredential], + *, + api_version: Optional[str] = ..., **kwargs: Any ) -> None: ... @classmethod def from_connection_string( - cls, - conn_str: str, - hub: str, + cls, + conn_str: str, + hub: str, **kwargs: Any ) -> WebPubSubChatServiceClient: ... @@ -31,337 +31,475 @@ namespace azure.messaging.webpubsubchatservice @overload def create_or_replace_role( - self, - role_name: str, - resource: ChatRole, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + role_name: str, + resource: ChatRole, + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRole: ... @overload def create_or_replace_role( - self, - role_name: str, - resource: ChatRole, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + role_name: str, + resource: ChatRole, + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRole: ... @overload def create_or_replace_role( - self, - role_name: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + role_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRole: ... @overload def create_or_replace_room( - self, - room_id: str, - resource: ChatRoom, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + room_id: str, + resource: ChatRoom, + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRoom: ... @overload def create_or_replace_room( - self, - room_id: str, - resource: ChatRoom, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + room_id: str, + resource: ChatRoom, + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRoom: ... @overload def create_or_replace_room( - self, - room_id: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + room_id: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRoom: ... @overload def create_or_replace_room_member( - self, - room_id: str, - user_id: str, - resource: ChatRoomMember, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + room_id: str, + user_id: str, + resource: ChatRoomMember, + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRoomMember: ... @overload def create_or_replace_room_member( - self, - room_id: str, - user_id: str, - resource: ChatRoomMember, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + room_id: str, + user_id: str, + resource: ChatRoomMember, + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRoomMember: ... @overload def create_or_replace_room_member( - self, - room_id: str, - user_id: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + room_id: str, + user_id: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRoomMember: ... + @overload + def create_or_replace_topic( + self, + room_id: str, + topic_id: str, + resource: ChatTopic, + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., + **kwargs: Any + ) -> ChatTopic: ... + + @overload + def create_or_replace_topic( + self, + room_id: str, + topic_id: str, + resource: ChatTopic, + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., + **kwargs: Any + ) -> ChatTopic: ... + + @overload + def create_or_replace_topic( + self, + room_id: str, + topic_id: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., + **kwargs: Any + ) -> ChatTopic: ... + @overload def create_or_replace_user( - self, - user_id: str, - resource: ChatUser, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + user_id: str, + resource: ChatUser, + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatUser: ... @overload def create_or_replace_user( - self, - user_id: str, - resource: ChatUser, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + user_id: str, + resource: ChatUser, + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatUser: ... @overload def create_or_replace_user( - self, - user_id: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + user_id: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatUser: ... @distributed_trace def delete_message( - self, - conversation_id: str, - message_id: str, - *, - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + conversation_id: str, + message_id: str, + *, + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> None: ... @distributed_trace def delete_role( - self, - role_name: str, - *, - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + role_name: str, + *, + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> None: ... @distributed_trace def delete_room( - self, - room_id: str, - *, - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + room_id: str, + *, + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> None: ... @distributed_trace def delete_room_member( - self, - room_id: str, - user_id: str, - *, - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + room_id: str, + user_id: str, + *, + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., + **kwargs: Any + ) -> None: ... + + @distributed_trace + @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'room_id', 'topic_id', 'etag', 'match_condition']}, api_versions_list=['2026-08-01-preview']) + def delete_topic( + self, + room_id: str, + topic_id: str, + *, + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> None: ... @distributed_trace def delete_user( - self, - user_id: str, - *, - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + user_id: str, + *, + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> None: ... @distributed_trace def get_client_access_token( - self, - *, - minutes_to_expire: int = 60, - user_id: Optional[str] = ..., + self, + *, + minutes_to_expire: int = 60, + user_id: Optional[str] = ..., **kwargs: Any ) -> Dict[str, Any]: ... @distributed_trace def get_conversation( - self, - conversation_id: str, + self, + conversation_id: str, **kwargs: Any ) -> ChatConversation: ... @distributed_trace def get_role( - self, - role_name: str, + self, + role_name: str, **kwargs: Any ) -> ChatRole: ... @distributed_trace def get_room( - self, - room_id: str, + self, + room_id: str, **kwargs: Any ) -> ChatRoom: ... + @distributed_trace + @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'room_id', 'topic_id', 'accept']}, api_versions_list=['2026-08-01-preview']) + def get_topic( + self, + room_id: str, + topic_id: str, + **kwargs: Any + ) -> ChatTopic: ... + @distributed_trace def get_user( - self, - user_id: str, + self, + user_id: str, **kwargs: Any ) -> ChatUser: ... @distributed_trace def list_messages( - self, - conversation_id: str, - *, - earliest_message_id: Optional[str] = ..., - latest_message_id: Optional[str] = ..., - max_page_size: Optional[int] = ..., + self, + conversation_id: str, + *, + earliest_message_id: Optional[str] = ..., + latest_message_id: Optional[str] = ..., + max_page_size: Optional[int] = ..., **kwargs: Any ) -> ItemPaged[ChatMessage]: ... @distributed_trace def list_roles( - self, - *, - continuation_token_parameter: Optional[str] = ..., - max_page_size: Optional[int] = ..., + self, + *, + continuation_token_parameter: Optional[str] = ..., + max_page_size: Optional[int] = ..., **kwargs: Any ) -> ItemPaged[ChatRole]: ... @distributed_trace def list_room_members( - self, - room_id: str, - *, - continuation_token_parameter: Optional[str] = ..., - max_page_size: Optional[int] = ..., + self, + room_id: str, + *, + continuation_token_parameter: Optional[str] = ..., + max_page_size: Optional[int] = ..., **kwargs: Any ) -> ItemPaged[ChatRoomMember]: ... + @distributed_trace + @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'max_page_size', 'continuation_token_parameter', 'accept']}, api_versions_list=['2026-08-01-preview']) + def list_rooms( + self, + *, + continuation_token_parameter: Optional[str] = ..., + max_page_size: Optional[int] = ..., + **kwargs: Any + ) -> ItemPaged[ChatRoom]: ... + + @distributed_trace + @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'user_id', 'accept']}, api_versions_list=['2026-08-01-preview']) + def list_rooms_for_user( + self, + user_id: str, + **kwargs: Any + ) -> ItemPaged[ChatUserRoom]: ... + + @distributed_trace + @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'room_id', 'max_page_size', 'continuation_token_parameter', 'accept']}, api_versions_list=['2026-08-01-preview']) + def list_topics( + self, + room_id: str, + *, + continuation_token_parameter: Optional[str] = ..., + max_page_size: Optional[int] = ..., + **kwargs: Any + ) -> ItemPaged[ChatTopic]: ... + + @distributed_trace + @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'max_page_size', 'continuation_token_parameter', 'accept']}, api_versions_list=['2026-08-01-preview']) + def list_users( + self, + *, + continuation_token_parameter: Optional[str] = ..., + max_page_size: Optional[int] = ..., + **kwargs: Any + ) -> ItemPaged[ChatUser]: ... + def send_request( - self, - request: HttpRequest, - *, - stream: bool = False, + self, + request: HttpRequest, + *, + stream: bool = False, **kwargs: Any ) -> HttpResponse: ... @overload def update_message( - self, - conversation_id: str, - message_id: str, - resource: ChatMessage, - *, - content_type: str = "application/merge-patch+json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + conversation_id: str, + message_id: str, + resource: ChatMessage, + *, + content_type: str = "application/merge-patch+json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatMessage: ... @overload def update_message( - self, - conversation_id: str, - message_id: str, - resource: ChatMessage, - *, - content_type: str = "application/merge-patch+json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + conversation_id: str, + message_id: str, + resource: ChatMessage, + *, + content_type: str = "application/merge-patch+json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatMessage: ... @overload def update_message( - self, - conversation_id: str, - message_id: str, - resource: IO[bytes], - *, - content_type: str = "application/merge-patch+json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + conversation_id: str, + message_id: str, + resource: IO[bytes], + *, + content_type: str = "application/merge-patch+json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatMessage: ... + @overload + def update_topic( + self, + room_id: str, + topic_id: str, + resource: ChatTopic, + *, + content_type: str = "application/merge-patch+json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., + **kwargs: Any + ) -> ChatTopic: ... + + @overload + def update_topic( + self, + room_id: str, + topic_id: str, + resource: ChatTopic, + *, + content_type: str = "application/merge-patch+json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., + **kwargs: Any + ) -> ChatTopic: ... + + @overload + def update_topic( + self, + room_id: str, + topic_id: str, + resource: IO[bytes], + *, + content_type: str = "application/merge-patch+json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., + **kwargs: Any + ) -> ChatTopic: ... + namespace azure.messaging.webpubsubchatservice.aio - class azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient(WebPubSubChatServiceClientGenerated): implements AsyncContextManager + class azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient(WebPubSubChatServiceClientGenerated): implements AsyncContextManager def __init__( - self, - endpoint: str, - hub: str, - credential: Union[AsyncTokenCredential, AzureKeyCredential], - *, - api_version: Optional[str] = ..., + self, + endpoint: str, + hub: str, + credential: Union[AsyncTokenCredential, AzureKeyCredential], + *, + api_version: Optional[str] = ..., **kwargs: Any ) -> None: ... @classmethod def from_connection_string( - cls, - conn_str: str, - hub: str, + cls, + conn_str: str, + hub: str, **kwargs: Any ) -> WebPubSubChatServiceClient: ... @@ -369,317 +507,455 @@ namespace azure.messaging.webpubsubchatservice.aio @overload async def create_or_replace_role( - self, - role_name: str, - resource: ChatRole, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + role_name: str, + resource: ChatRole, + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRole: ... @overload async def create_or_replace_role( - self, - role_name: str, - resource: ChatRole, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + role_name: str, + resource: ChatRole, + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRole: ... @overload async def create_or_replace_role( - self, - role_name: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + role_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRole: ... @overload async def create_or_replace_room( - self, - room_id: str, - resource: ChatRoom, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + room_id: str, + resource: ChatRoom, + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRoom: ... @overload async def create_or_replace_room( - self, - room_id: str, - resource: ChatRoom, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + room_id: str, + resource: ChatRoom, + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRoom: ... @overload async def create_or_replace_room( - self, - room_id: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + room_id: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRoom: ... @overload async def create_or_replace_room_member( - self, - room_id: str, - user_id: str, - resource: ChatRoomMember, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + room_id: str, + user_id: str, + resource: ChatRoomMember, + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRoomMember: ... @overload async def create_or_replace_room_member( - self, - room_id: str, - user_id: str, - resource: ChatRoomMember, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + room_id: str, + user_id: str, + resource: ChatRoomMember, + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRoomMember: ... @overload async def create_or_replace_room_member( - self, - room_id: str, - user_id: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + room_id: str, + user_id: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRoomMember: ... + @overload + async def create_or_replace_topic( + self, + room_id: str, + topic_id: str, + resource: ChatTopic, + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., + **kwargs: Any + ) -> ChatTopic: ... + + @overload + async def create_or_replace_topic( + self, + room_id: str, + topic_id: str, + resource: ChatTopic, + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., + **kwargs: Any + ) -> ChatTopic: ... + + @overload + async def create_or_replace_topic( + self, + room_id: str, + topic_id: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., + **kwargs: Any + ) -> ChatTopic: ... + @overload async def create_or_replace_user( - self, - user_id: str, - resource: ChatUser, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + user_id: str, + resource: ChatUser, + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatUser: ... @overload async def create_or_replace_user( - self, - user_id: str, - resource: ChatUser, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + user_id: str, + resource: ChatUser, + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatUser: ... @overload async def create_or_replace_user( - self, - user_id: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + user_id: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatUser: ... @distributed_trace_async async def delete_message( - self, - conversation_id: str, - message_id: str, - *, - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + conversation_id: str, + message_id: str, + *, + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> None: ... @distributed_trace_async async def delete_role( - self, - role_name: str, - *, - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + role_name: str, + *, + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> None: ... @distributed_trace_async async def delete_room( - self, - room_id: str, - *, - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + room_id: str, + *, + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> None: ... @distributed_trace_async async def delete_room_member( - self, - room_id: str, - user_id: str, - *, - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + room_id: str, + user_id: str, + *, + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., + **kwargs: Any + ) -> None: ... + + @distributed_trace_async + @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'room_id', 'topic_id', 'etag', 'match_condition']}, api_versions_list=['2026-08-01-preview']) + async def delete_topic( + self, + room_id: str, + topic_id: str, + *, + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> None: ... @distributed_trace_async async def delete_user( - self, - user_id: str, - *, - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + user_id: str, + *, + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> None: ... @distributed_trace_async async def get_client_access_token( - self, - *, - minutes_to_expire: int = 60, - user_id: Optional[str] = ..., + self, + *, + minutes_to_expire: int = 60, + user_id: Optional[str] = ..., **kwargs: Any ) -> Dict[str, Any]: ... @distributed_trace_async async def get_conversation( - self, - conversation_id: str, + self, + conversation_id: str, **kwargs: Any ) -> ChatConversation: ... @distributed_trace_async async def get_role( - self, - role_name: str, + self, + role_name: str, **kwargs: Any ) -> ChatRole: ... @distributed_trace_async async def get_room( - self, - room_id: str, + self, + room_id: str, **kwargs: Any ) -> ChatRoom: ... + @distributed_trace_async + @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'room_id', 'topic_id', 'accept']}, api_versions_list=['2026-08-01-preview']) + async def get_topic( + self, + room_id: str, + topic_id: str, + **kwargs: Any + ) -> ChatTopic: ... + @distributed_trace_async async def get_user( - self, - user_id: str, + self, + user_id: str, **kwargs: Any ) -> ChatUser: ... @distributed_trace def list_messages( - self, - conversation_id: str, - *, - earliest_message_id: Optional[str] = ..., - latest_message_id: Optional[str] = ..., - max_page_size: Optional[int] = ..., + self, + conversation_id: str, + *, + earliest_message_id: Optional[str] = ..., + latest_message_id: Optional[str] = ..., + max_page_size: Optional[int] = ..., **kwargs: Any ) -> AsyncItemPaged[ChatMessage]: ... @distributed_trace def list_roles( - self, - *, - continuation_token_parameter: Optional[str] = ..., - max_page_size: Optional[int] = ..., + self, + *, + continuation_token_parameter: Optional[str] = ..., + max_page_size: Optional[int] = ..., **kwargs: Any ) -> AsyncItemPaged[ChatRole]: ... @distributed_trace def list_room_members( - self, - room_id: str, - *, - continuation_token_parameter: Optional[str] = ..., - max_page_size: Optional[int] = ..., + self, + room_id: str, + *, + continuation_token_parameter: Optional[str] = ..., + max_page_size: Optional[int] = ..., **kwargs: Any ) -> AsyncItemPaged[ChatRoomMember]: ... + @distributed_trace + @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'max_page_size', 'continuation_token_parameter', 'accept']}, api_versions_list=['2026-08-01-preview']) + def list_rooms( + self, + *, + continuation_token_parameter: Optional[str] = ..., + max_page_size: Optional[int] = ..., + **kwargs: Any + ) -> AsyncItemPaged[ChatRoom]: ... + + @distributed_trace + @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'user_id', 'accept']}, api_versions_list=['2026-08-01-preview']) + def list_rooms_for_user( + self, + user_id: str, + **kwargs: Any + ) -> AsyncItemPaged[ChatUserRoom]: ... + + @distributed_trace + @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'room_id', 'max_page_size', 'continuation_token_parameter', 'accept']}, api_versions_list=['2026-08-01-preview']) + def list_topics( + self, + room_id: str, + *, + continuation_token_parameter: Optional[str] = ..., + max_page_size: Optional[int] = ..., + **kwargs: Any + ) -> AsyncItemPaged[ChatTopic]: ... + + @distributed_trace + @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'max_page_size', 'continuation_token_parameter', 'accept']}, api_versions_list=['2026-08-01-preview']) + def list_users( + self, + *, + continuation_token_parameter: Optional[str] = ..., + max_page_size: Optional[int] = ..., + **kwargs: Any + ) -> AsyncItemPaged[ChatUser]: ... + def send_request( - self, - request: HttpRequest, - *, - stream: bool = False, + self, + request: HttpRequest, + *, + stream: bool = False, **kwargs: Any ) -> Awaitable[AsyncHttpResponse]: ... @overload async def update_message( - self, - conversation_id: str, - message_id: str, - resource: ChatMessage, - *, - content_type: str = "application/merge-patch+json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + conversation_id: str, + message_id: str, + resource: ChatMessage, + *, + content_type: str = "application/merge-patch+json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatMessage: ... @overload async def update_message( - self, - conversation_id: str, - message_id: str, - resource: ChatMessage, - *, - content_type: str = "application/merge-patch+json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + conversation_id: str, + message_id: str, + resource: ChatMessage, + *, + content_type: str = "application/merge-patch+json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatMessage: ... @overload async def update_message( - self, - conversation_id: str, - message_id: str, - resource: IO[bytes], - *, - content_type: str = "application/merge-patch+json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + conversation_id: str, + message_id: str, + resource: IO[bytes], + *, + content_type: str = "application/merge-patch+json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatMessage: ... + @overload + async def update_topic( + self, + room_id: str, + topic_id: str, + resource: ChatTopic, + *, + content_type: str = "application/merge-patch+json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., + **kwargs: Any + ) -> ChatTopic: ... + + @overload + async def update_topic( + self, + room_id: str, + topic_id: str, + resource: ChatTopic, + *, + content_type: str = "application/merge-patch+json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., + **kwargs: Any + ) -> ChatTopic: ... + + @overload + async def update_topic( + self, + room_id: str, + topic_id: str, + resource: IO[bytes], + *, + content_type: str = "application/merge-patch+json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., + **kwargs: Any + ) -> ChatTopic: ... + namespace azure.messaging.webpubsubchatservice.models @@ -690,8 +966,8 @@ namespace azure.messaging.webpubsubchatservice.models @overload def __init__( - self, - *, + self, + *, parent_room: str ) -> None: ... @@ -708,9 +984,9 @@ namespace azure.messaging.webpubsubchatservice.models @overload def __init__( - self, - *, - content: MessageContent, + self, + *, + content: MessageContent, created_by: str ) -> None: ... @@ -734,8 +1010,8 @@ namespace azure.messaging.webpubsubchatservice.models @overload def __init__( - self, - *, + self, + *, permissions: list[Union[str, ChatPermission]] ) -> None: ... @@ -751,8 +1027,8 @@ namespace azure.messaging.webpubsubchatservice.models @overload def __init__( - self, - *, + self, + *, title: str ) -> None: ... @@ -767,8 +1043,8 @@ namespace azure.messaging.webpubsubchatservice.models @overload def __init__( - self, - *, + self, + *, role_name: str ) -> None: ... @@ -776,6 +1052,33 @@ namespace azure.messaging.webpubsubchatservice.models def __init__(self, mapping: Mapping[str, Any]) -> None: ... + class azure.messaging.webpubsubchatservice.models.ChatTopic(_Model): + conversation_id: str + created_at: datetime + created_by: str + etag: str + id: str + state: Union[str, ChatTopicState] + title: str + + @overload + def __init__( + self, + *, + state: Union[str, ChatTopicState], + title: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.messaging.webpubsubchatservice.models.ChatTopicState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + ARCHIVED = "Archived" + NORMAL = "Normal" + SOFT_DELETED = "SoftDeleted" + + class azure.messaging.webpubsubchatservice.models.ChatUser(_Model): etag: str id: str @@ -784,9 +1087,9 @@ namespace azure.messaging.webpubsubchatservice.models @overload def __init__( - self, - *, - kind: str, + self, + *, + kind: str, nickname: str ) -> None: ... @@ -798,6 +1101,23 @@ namespace azure.messaging.webpubsubchatservice.models HUMAN = "Human" + class azure.messaging.webpubsubchatservice.models.ChatUserRoom(_Model): + default_conversation: str + etag: str + id: str + title: str + + @overload + def __init__( + self, + *, + title: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + class azure.messaging.webpubsubchatservice.models.HumanChatUser(ChatUser, discriminator='Human'): etag: str id: str @@ -807,9 +1127,9 @@ namespace azure.messaging.webpubsubchatservice.models @overload def __init__( - self, - *, - nickname: str, + self, + *, + nickname: str, role_name: str ) -> None: ... @@ -823,9 +1143,9 @@ namespace azure.messaging.webpubsubchatservice.models @overload def __init__( - self, - *, - binary: Optional[bytes] = ..., + self, + *, + binary: Optional[bytes] = ..., text: Optional[str] = ... ) -> None: ... @@ -877,6 +1197,23 @@ namespace azure.messaging.webpubsubchatservice.types userId: str + class azure.messaging.webpubsubchatservice.types.ChatTopic(TypedDict, total=False): + key "conversationId": Required[str] + key "createdAt": Required[str] + key "createdBy": Required[str] + key "etag": Required[str] + key "id": Required[str] + key "state": Required[Union[str, ChatTopicState]] + key "title": Required[str] + conversationId: str + createdAt: str + createdBy: str + etag: str + id: str + state: Union[str, ChatTopicState] + title: str + + class azure.messaging.webpubsubchatservice.types.ChatUser(TypedDict, total=False): key "etag": Required[str] key "id": Required[str] diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml index b80e4c3b6af7..efb34228ab94 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml @@ -1,3 +1,4 @@ -apiMdSha256: 0e0114ad50923e1ebecf18b76ada92c10de2d7e1318c6428a108f33e95f77593 +apiMdSha256: 334d932dcbe42254466b2f5c35cf88e11d76f52e8c0cdecb366bc6e69a1b3a39 +packageVersion: 1.0.0b1 parserVersion: 0.3.31 -pythonVersion: 3.12.13 +pythonVersion: 3.12.10 diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json b/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json index ff91009b463c..4348c877fe48 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json @@ -6,10 +6,13 @@ "azure.messaging.webpubsubchatservice.models.ChatRole": "WebPubSubChat.ChatRole", "azure.messaging.webpubsubchatservice.models.ChatRoom": "WebPubSubChat.ChatRoom", "azure.messaging.webpubsubchatservice.models.ChatRoomMember": "WebPubSubChat.ChatRoomMember", + "azure.messaging.webpubsubchatservice.models.ChatTopic": "WebPubSubChat.ChatTopic", "azure.messaging.webpubsubchatservice.models.ChatUser": "WebPubSubChat.ChatUser", + "azure.messaging.webpubsubchatservice.models.ChatUserRoom": "WebPubSubChat.ChatUserRoom", "azure.messaging.webpubsubchatservice.models.HumanChatUser": "WebPubSubChat.HumanChatUser", "azure.messaging.webpubsubchatservice.models.MessageContent": "WebPubSubChat.MessageContent", "azure.messaging.webpubsubchatservice.models.ChatPermission": "WebPubSubChat.ChatPermission", + "azure.messaging.webpubsubchatservice.models.ChatTopicState": "WebPubSubChat.ChatTopicState", "azure.messaging.webpubsubchatservice.models.ChatUserKind": "WebPubSubChat.ChatUserKind", "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.get_conversation": "WebPubSubChat.WebPubSubChatServiceClient.getConversation", "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.get_conversation": "WebPubSubChat.WebPubSubChatServiceClient.getConversation", @@ -27,24 +30,40 @@ "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.create_or_replace_role": "WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole", "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.delete_role": "WebPubSubChat.WebPubSubChatServiceClient.deleteRole", "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.delete_role": "WebPubSubChat.WebPubSubChatServiceClient.deleteRole", + "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.list_rooms": "WebPubSubChat.WebPubSubChatServiceClient.listRooms", + "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.list_rooms": "WebPubSubChat.WebPubSubChatServiceClient.listRooms", "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.create_or_replace_room": "WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom", "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.create_or_replace_room": "WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom", "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.get_room": "WebPubSubChat.WebPubSubChatServiceClient.getRoom", "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.get_room": "WebPubSubChat.WebPubSubChatServiceClient.getRoom", "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.delete_room": "WebPubSubChat.WebPubSubChatServiceClient.deleteRoom", "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.delete_room": "WebPubSubChat.WebPubSubChatServiceClient.deleteRoom", + "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.list_topics": "WebPubSubChat.WebPubSubChatServiceClient.listTopics", + "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.list_topics": "WebPubSubChat.WebPubSubChatServiceClient.listTopics", + "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.create_or_replace_topic": "WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic", + "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.create_or_replace_topic": "WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic", + "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.get_topic": "WebPubSubChat.WebPubSubChatServiceClient.getTopic", + "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.get_topic": "WebPubSubChat.WebPubSubChatServiceClient.getTopic", + "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.update_topic": "WebPubSubChat.WebPubSubChatServiceClient.updateTopic", + "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.update_topic": "WebPubSubChat.WebPubSubChatServiceClient.updateTopic", + "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.delete_topic": "WebPubSubChat.WebPubSubChatServiceClient.deleteTopic", + "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.delete_topic": "WebPubSubChat.WebPubSubChatServiceClient.deleteTopic", "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.list_room_members": "WebPubSubChat.WebPubSubChatServiceClient.listRoomMembers", "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.list_room_members": "WebPubSubChat.WebPubSubChatServiceClient.listRoomMembers", "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.create_or_replace_room_member": "WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember", "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.create_or_replace_room_member": "WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember", "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.delete_room_member": "WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember", "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.delete_room_member": "WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember", + "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.list_users": "WebPubSubChat.WebPubSubChatServiceClient.listUsers", + "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.list_users": "WebPubSubChat.WebPubSubChatServiceClient.listUsers", "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.get_user": "WebPubSubChat.WebPubSubChatServiceClient.getUser", "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.get_user": "WebPubSubChat.WebPubSubChatServiceClient.getUser", "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.create_or_replace_user": "WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser", "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.create_or_replace_user": "WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser", "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.delete_user": "WebPubSubChat.WebPubSubChatServiceClient.deleteUser", - "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.delete_user": "WebPubSubChat.WebPubSubChatServiceClient.deleteUser" + "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.delete_user": "WebPubSubChat.WebPubSubChatServiceClient.deleteUser", + "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.list_rooms_for_user": "WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser", + "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.list_rooms_for_user": "WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser" }, - "CrossLanguageVersion": "dd550ec76602" + "CrossLanguageVersion": "7f78e3e74021" } \ No newline at end of file diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/assets.json b/sdk/webpubsub/azure-messaging-webpubsubchatservice/assets.json index cfeddc2beb3a..23b47f079d5c 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/assets.json +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/webpubsub/azure-messaging-webpubsubchatservice", - "Tag": "python/webpubsub/azure-messaging-webpubsubchatservice_05cae67921" + "Tag": "python/webpubsub/azure-messaging-webpubsubchatservice_1aa22820d8" } diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_client.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_client.py index 8257c317d31c..88c902598b22 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_client.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_client.py @@ -40,7 +40,7 @@ class WebPubSubChatServiceClient( alpha-numeric characters or underscore. Required. :type hub: str :keyword api_version: The API version to use for this operation. Known values are - "2026-02-01-preview" and None. Default value is None. If not set, the operation's default API + "2026-08-01-preview" and None. Default value is None. If not set, the operation's default API version will be used. Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_configuration.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_configuration.py index 0a49b3f1374b..834deb1ccf70 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_configuration.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_configuration.py @@ -31,14 +31,14 @@ class WebPubSubChatServiceClientConfiguration: # pylint: disable=too-many-insta alpha-numeric characters or underscore. Required. :type hub: str :keyword api_version: The API version to use for this operation. Known values are - "2026-02-01-preview" and None. Default value is None. If not set, the operation's default API + "2026-08-01-preview" and None. Default value is None. If not set, the operation's default API version will be used. Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, endpoint: str, credential: "TokenCredential", hub: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2026-02-01-preview") + api_version: str = kwargs.pop("api_version", "2026-08-01-preview") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_operations/_operations.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_operations/_operations.py index b4b9bdd60061..4657924e7dfc 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_operations/_operations.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_operations/_operations.py @@ -35,6 +35,7 @@ from .._utils.model_base import SdkJSONEncoder, _deserialize from .._utils.serialization import Serializer from .._utils.utils import ClientMixinABC, prep_if_match, prep_if_none_match +from .._validation import api_version_validation T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] @@ -49,7 +50,7 @@ def build_web_pub_sub_chat_service_get_conversation_request( # pylint: disable= _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -82,7 +83,7 @@ def build_web_pub_sub_chat_service_list_messages_request( # pylint: disable=nam _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -121,7 +122,7 @@ def build_web_pub_sub_chat_service_delete_message_request( # pylint: disable=na _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) # Construct URL _url = "/api/hubs/{hub}/chat/conversations/{conversationId}/messages/{messageId}" path_format_arguments = { @@ -159,7 +160,7 @@ def build_web_pub_sub_chat_service_update_message_request( # pylint: disable=na _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -195,7 +196,7 @@ def build_web_pub_sub_chat_service_list_roles_request( # pylint: disable=name-t _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -227,7 +228,7 @@ def build_web_pub_sub_chat_service_get_role_request( # pylint: disable=name-too _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -260,7 +261,7 @@ def build_web_pub_sub_chat_service_create_or_replace_role_request( # pylint: di _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -300,7 +301,7 @@ def build_web_pub_sub_chat_service_delete_role_request( # pylint: disable=name- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) # Construct URL _url = "/api/hubs/{hub}/chat/roles/{roleName}" path_format_arguments = { @@ -324,6 +325,38 @@ def build_web_pub_sub_chat_service_delete_role_request( # pylint: disable=name- return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) +def build_web_pub_sub_chat_service_list_rooms_request( # pylint: disable=name-too-long + hub: str, *, max_page_size: Optional[int] = None, continuation_token_parameter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/api/hubs/{hub}/chat/rooms" + path_format_arguments = { + "hub": _SERIALIZER.url("hub", hub, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if max_page_size is not None: + _params["maxpagesize"] = _SERIALIZER.query("max_page_size", max_page_size, "int") + if continuation_token_parameter is not None: + _params["continuationToken"] = _SERIALIZER.query( + "continuation_token_parameter", continuation_token_parameter, "str" + ) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + def build_web_pub_sub_chat_service_create_or_replace_room_request( # pylint: disable=name-too-long room_id: str, hub: str, @@ -336,7 +369,7 @@ def build_web_pub_sub_chat_service_create_or_replace_room_request( # pylint: di _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -371,7 +404,7 @@ def build_web_pub_sub_chat_service_get_room_request( # pylint: disable=name-too _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -403,7 +436,7 @@ def build_web_pub_sub_chat_service_delete_room_request( # pylint: disable=name- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) # Construct URL _url = "/api/hubs/{hub}/chat/rooms/{roomId}" path_format_arguments = { @@ -427,6 +460,195 @@ def build_web_pub_sub_chat_service_delete_room_request( # pylint: disable=name- return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) +def build_web_pub_sub_chat_service_list_topics_request( # pylint: disable=name-too-long + room_id: str, + hub: str, + *, + max_page_size: Optional[int] = None, + continuation_token_parameter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/api/hubs/{hub}/chat/rooms/{roomId}/topics" + path_format_arguments = { + "hub": _SERIALIZER.url("hub", hub, "str"), + "roomId": _SERIALIZER.url("room_id", room_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if max_page_size is not None: + _params["maxpagesize"] = _SERIALIZER.query("max_page_size", max_page_size, "int") + if continuation_token_parameter is not None: + _params["continuationToken"] = _SERIALIZER.query( + "continuation_token_parameter", continuation_token_parameter, "str" + ) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_chat_service_create_or_replace_topic_request( # pylint: disable=name-too-long + room_id: str, + topic_id: str, + hub: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/api/hubs/{hub}/chat/rooms/{roomId}/topics/{topicId}" + path_format_arguments = { + "hub": _SERIALIZER.url("hub", hub, "str"), + "roomId": _SERIALIZER.url("room_id", room_id, "str"), + "topicId": _SERIALIZER.url("topic_id", topic_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_chat_service_get_topic_request( # pylint: disable=name-too-long + room_id: str, topic_id: str, hub: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/api/hubs/{hub}/chat/rooms/{roomId}/topics/{topicId}" + path_format_arguments = { + "hub": _SERIALIZER.url("hub", hub, "str"), + "roomId": _SERIALIZER.url("room_id", room_id, "str"), + "topicId": _SERIALIZER.url("topic_id", topic_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_chat_service_update_topic_request( # pylint: disable=name-too-long + room_id: str, + topic_id: str, + hub: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/api/hubs/{hub}/chat/rooms/{roomId}/topics/{topicId}" + path_format_arguments = { + "hub": _SERIALIZER.url("hub", hub, "str"), + "roomId": _SERIALIZER.url("room_id", room_id, "str"), + "topicId": _SERIALIZER.url("topic_id", topic_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_web_pub_sub_chat_service_delete_topic_request( # pylint: disable=name-too-long + room_id: str, + topic_id: str, + hub: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) + # Construct URL + _url = "/api/hubs/{hub}/chat/rooms/{roomId}/topics/{topicId}" + path_format_arguments = { + "hub": _SERIALIZER.url("hub", hub, "str"), + "roomId": _SERIALIZER.url("room_id", room_id, "str"), + "topicId": _SERIALIZER.url("topic_id", topic_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + def build_web_pub_sub_chat_service_list_room_members_request( # pylint: disable=name-too-long room_id: str, hub: str, @@ -438,7 +660,7 @@ def build_web_pub_sub_chat_service_list_room_members_request( # pylint: disable _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -478,7 +700,7 @@ def build_web_pub_sub_chat_service_create_or_replace_room_member_request( # pyl _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -520,7 +742,7 @@ def build_web_pub_sub_chat_service_delete_room_member_request( # pylint: disabl _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) # Construct URL _url = "/api/hubs/{hub}/chat/rooms/{roomId}/members/{userId}" path_format_arguments = { @@ -545,13 +767,45 @@ def build_web_pub_sub_chat_service_delete_room_member_request( # pylint: disabl return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) +def build_web_pub_sub_chat_service_list_users_request( # pylint: disable=name-too-long + hub: str, *, max_page_size: Optional[int] = None, continuation_token_parameter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/api/hubs/{hub}/chat/users" + path_format_arguments = { + "hub": _SERIALIZER.url("hub", hub, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if max_page_size is not None: + _params["maxpagesize"] = _SERIALIZER.query("max_page_size", max_page_size, "int") + if continuation_token_parameter is not None: + _params["continuationToken"] = _SERIALIZER.query( + "continuation_token_parameter", continuation_token_parameter, "str" + ) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + def build_web_pub_sub_chat_service_get_user_request( # pylint: disable=name-too-long user_id: str, hub: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -584,7 +838,7 @@ def build_web_pub_sub_chat_service_create_or_replace_user_request( # pylint: di _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -624,7 +878,7 @@ def build_web_pub_sub_chat_service_delete_user_request( # pylint: disable=name- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) # Construct URL _url = "/api/hubs/{hub}/chat/users/{userId}" path_format_arguments = { @@ -648,6 +902,33 @@ def build_web_pub_sub_chat_service_delete_user_request( # pylint: disable=name- return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) +def build_web_pub_sub_chat_service_list_rooms_for_user_request( # pylint: disable=name-too-long + user_id: str, hub: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/api/hubs/{hub}/chat/users/{userId}/rooms" + path_format_arguments = { + "hub": _SERIALIZER.url("hub", hub, "str"), + "userId": _SERIALIZER.url("user_id", user_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + def build_web_pub_sub_chat_service_generate_client_token_request( # pylint: disable=name-too-long hub: str, *, @@ -685,7 +966,7 @@ def build_web_pub_sub_chat_service_generate_client_token_request( # pylint: dis return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class _WebPubSubChatServiceClientOperationsMixin( +class _WebPubSubChatServiceClientOperationsMixin( # pylint: disable=too-many-public-methods ClientMixinABC[PipelineClient[HttpRequest, HttpResponse], WebPubSubChatServiceClientConfiguration] ): @@ -1585,14 +1866,121 @@ def delete_role( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore - @overload - def create_or_replace_room( - self, - room_id: str, - resource: _models.ChatRoom, - *, - content_type: str = "application/json", - etag: Optional[str] = None, + @distributed_trace + @api_version_validation( + method_added_on="2026-08-01-preview", + params_added_on={ + "2026-08-01-preview": ["api_version", "hub", "max_page_size", "continuation_token_parameter", "accept"] + }, + api_versions_list=["2026-08-01-preview"], + ) + def list_rooms( + self, *, max_page_size: Optional[int] = None, continuation_token_parameter: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.ChatRoom"]: + """List rooms with pagination. + + List rooms with pagination. + + :keyword max_page_size: The maximum number of result items per page. Default value is None. + :paramtype max_page_size: int + :keyword continuation_token_parameter: Continuation token for pagination. Default value is + None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of ChatRoom + :rtype: ~azure.core.paging.ItemPaged[~azure.messaging.webpubsubchatservice.models.ChatRoom] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models.ChatRoom]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_web_pub_sub_chat_service_list_rooms_request( + hub=self._config.hub, + max_page_size=max_page_size, + continuation_token_parameter=continuation_token_parameter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + list[_models.ChatRoom], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @overload + def create_or_replace_room( + self, + room_id: str, + resource: _models.ChatRoom, + *, + content_type: str = "application/json", + etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> _models.ChatRoom: @@ -1697,17 +2085,799 @@ def create_or_replace_room( :param room_id: Room identifier. Required. :type room_id: str - :param resource: The resource instance. Is either a ChatRoom type or a IO[bytes] type. + :param resource: The resource instance. Is either a ChatRoom type or a IO[bytes] type. + Required. + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoom or + ~azure.messaging.webpubsubchatservice.types.ChatRoom or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ChatRoom. The ChatRoom is compatible with MutableMapping + :rtype: ~azure.messaging.webpubsubchatservice.models.ChatRoom + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ChatRoom] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_web_pub_sub_chat_service_create_or_replace_room_request( + room_id=room_id, + hub=self._config.hub, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ChatRoom, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_room(self, room_id: str, **kwargs: Any) -> _models.ChatRoom: + """Get room information. + + Get room information. + + :param room_id: Room identifier. Required. + :type room_id: str + :return: ChatRoom. The ChatRoom is compatible with MutableMapping + :rtype: ~azure.messaging.webpubsubchatservice.models.ChatRoom + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ChatRoom] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_chat_service_get_room_request( + room_id=room_id, + hub=self._config.hub, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ChatRoom, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete_room( # pylint: disable=inconsistent-return-statements + self, + room_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> None: + """Delete a room. + + Delete a room. + + :param room_id: Room identifier. Required. + :type room_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_chat_service_delete_room_request( + room_id=room_id, + hub=self._config.hub, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + @api_version_validation( + method_added_on="2026-08-01-preview", + params_added_on={ + "2026-08-01-preview": [ + "api_version", + "hub", + "room_id", + "max_page_size", + "continuation_token_parameter", + "accept", + ] + }, + api_versions_list=["2026-08-01-preview"], + ) + def list_topics( + self, + room_id: str, + *, + max_page_size: Optional[int] = None, + continuation_token_parameter: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.ChatTopic"]: + """List topics in a room with pagination. + + List topics in a room with pagination. + + :param room_id: Room identifier. Required. + :type room_id: str + :keyword max_page_size: The maximum number of result items per page. Default value is None. + :paramtype max_page_size: int + :keyword continuation_token_parameter: Continuation token for pagination. Default value is + None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of ChatTopic + :rtype: ~azure.core.paging.ItemPaged[~azure.messaging.webpubsubchatservice.models.ChatTopic] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models.ChatTopic]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_web_pub_sub_chat_service_list_topics_request( + room_id=room_id, + hub=self._config.hub, + max_page_size=max_page_size, + continuation_token_parameter=continuation_token_parameter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + list[_models.ChatTopic], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @overload + def create_or_replace_topic( + self, + room_id: str, + topic_id: str, + resource: _models.ChatTopic, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ChatTopic: + """Create or replace a topic. + + Create or replace a topic with a client-specified ID. + + :param room_id: Room identifier. Required. + :type room_id: str + :param topic_id: Topic identifier unique within the room. Required. + :type topic_id: str + :param resource: The resource instance. Required. + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ChatTopic. The ChatTopic is compatible with MutableMapping + :rtype: ~azure.messaging.webpubsubchatservice.models.ChatTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_replace_topic( + self, + room_id: str, + topic_id: str, + resource: _types.ChatTopic, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ChatTopic: + """Create or replace a topic. + + Create or replace a topic with a client-specified ID. + + :param room_id: Room identifier. Required. + :type room_id: str + :param topic_id: Topic identifier unique within the room. Required. + :type topic_id: str + :param resource: The resource instance. Required. + :type resource: ~azure.messaging.webpubsubchatservice.types.ChatTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ChatTopic. The ChatTopic is compatible with MutableMapping + :rtype: ~azure.messaging.webpubsubchatservice.models.ChatTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_replace_topic( + self, + room_id: str, + topic_id: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ChatTopic: + """Create or replace a topic. + + Create or replace a topic with a client-specified ID. + + :param room_id: Room identifier. Required. + :type room_id: str + :param topic_id: Topic identifier unique within the room. Required. + :type topic_id: str + :param resource: The resource instance. Required. + :type resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ChatTopic. The ChatTopic is compatible with MutableMapping + :rtype: ~azure.messaging.webpubsubchatservice.models.ChatTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + @api_version_validation( + method_added_on="2026-08-01-preview", + params_added_on={ + "2026-08-01-preview": [ + "api_version", + "hub", + "room_id", + "topic_id", + "content_type", + "accept", + "etag", + "match_condition", + ] + }, + api_versions_list=["2026-08-01-preview"], + ) + def create_or_replace_topic( + self, + room_id: str, + topic_id: str, + resource: Union[_models.ChatTopic, _types.ChatTopic, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ChatTopic: + """Create or replace a topic. + + Create or replace a topic with a client-specified ID. + + :param room_id: Room identifier. Required. + :type room_id: str + :param topic_id: Topic identifier unique within the room. Required. + :type topic_id: str + :param resource: The resource instance. Is either a ChatTopic type or a IO[bytes] type. + Required. + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopic or + ~azure.messaging.webpubsubchatservice.types.ChatTopic or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ChatTopic. The ChatTopic is compatible with MutableMapping + :rtype: ~azure.messaging.webpubsubchatservice.models.ChatTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ChatTopic] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_web_pub_sub_chat_service_create_or_replace_topic_request( + room_id=room_id, + topic_id=topic_id, + hub=self._config.hub, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ChatTopic, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + @api_version_validation( + method_added_on="2026-08-01-preview", + params_added_on={"2026-08-01-preview": ["api_version", "hub", "room_id", "topic_id", "accept"]}, + api_versions_list=["2026-08-01-preview"], + ) + def get_topic(self, room_id: str, topic_id: str, **kwargs: Any) -> _models.ChatTopic: + """Get topic information. + + Get topic information. + + :param room_id: Room identifier. Required. + :type room_id: str + :param topic_id: Topic identifier unique within the room. Required. + :type topic_id: str + :return: ChatTopic. The ChatTopic is compatible with MutableMapping + :rtype: ~azure.messaging.webpubsubchatservice.models.ChatTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ChatTopic] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_chat_service_get_topic_request( + room_id=room_id, + topic_id=topic_id, + hub=self._config.hub, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ChatTopic, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update_topic( + self, + room_id: str, + topic_id: str, + resource: _models.ChatTopic, + *, + content_type: str = "application/merge-patch+json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ChatTopic: + """Update a topic. + + Update a topic. + + :param room_id: Room identifier. Required. + :type room_id: str + :param topic_id: Topic identifier unique within the room. Required. + :type topic_id: str + :param resource: The resource instance. Required. + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ChatTopic. The ChatTopic is compatible with MutableMapping + :rtype: ~azure.messaging.webpubsubchatservice.models.ChatTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_topic( + self, + room_id: str, + topic_id: str, + resource: _types.ChatTopic, + *, + content_type: str = "application/merge-patch+json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ChatTopic: + """Update a topic. + + Update a topic. + + :param room_id: Room identifier. Required. + :type room_id: str + :param topic_id: Topic identifier unique within the room. Required. + :type topic_id: str + :param resource: The resource instance. Required. + :type resource: ~azure.messaging.webpubsubchatservice.types.ChatTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ChatTopic. The ChatTopic is compatible with MutableMapping + :rtype: ~azure.messaging.webpubsubchatservice.models.ChatTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_topic( + self, + room_id: str, + topic_id: str, + resource: IO[bytes], + *, + content_type: str = "application/merge-patch+json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ChatTopic: + """Update a topic. + + Update a topic. + + :param room_id: Room identifier. Required. + :type room_id: str + :param topic_id: Topic identifier unique within the room. Required. + :type topic_id: str + :param resource: The resource instance. Required. + :type resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ChatTopic. The ChatTopic is compatible with MutableMapping + :rtype: ~azure.messaging.webpubsubchatservice.models.ChatTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + @api_version_validation( + method_added_on="2026-08-01-preview", + params_added_on={ + "2026-08-01-preview": [ + "api_version", + "hub", + "room_id", + "topic_id", + "content_type", + "accept", + "etag", + "match_condition", + ] + }, + api_versions_list=["2026-08-01-preview"], + ) + def update_topic( + self, + room_id: str, + topic_id: str, + resource: Union[_models.ChatTopic, _types.ChatTopic, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ChatTopic: + """Update a topic. + + Update a topic. + + :param room_id: Room identifier. Required. + :type room_id: str + :param topic_id: Topic identifier unique within the room. Required. + :type topic_id: str + :param resource: The resource instance. Is either a ChatTopic type or a IO[bytes] type. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoom or - ~azure.messaging.webpubsubchatservice.types.ChatRoom or IO[bytes] + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopic or + ~azure.messaging.webpubsubchatservice.types.ChatTopic or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :return: ChatRoom. The ChatRoom is compatible with MutableMapping - :rtype: ~azure.messaging.webpubsubchatservice.models.ChatRoom + :return: ChatTopic. The ChatTopic is compatible with MutableMapping + :rtype: ~azure.messaging.webpubsubchatservice.models.ChatTopic :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1728,17 +2898,18 @@ def create_or_replace_room( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ChatRoom] = kwargs.pop("cls", None) + cls: ClsType[_models.ChatTopic] = kwargs.pop("cls", None) - content_type = content_type or "application/json" + content_type = content_type or "application/merge-patch+json" _content = None if isinstance(resource, (IOBase, bytes)): _content = resource else: _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_web_pub_sub_chat_service_create_or_replace_room_request( + _request = build_web_pub_sub_chat_service_update_topic_request( room_id=room_id, + topic_id=topic_id, hub=self._config.hub, etag=etag, match_condition=match_condition, @@ -1761,7 +2932,7 @@ def create_or_replace_room( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200]: if _stream: try: response.read() # Load the body in memory and close the socket @@ -1776,7 +2947,7 @@ def create_or_replace_room( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.ChatRoom, response.json()) + deserialized = _deserialize(_models.ChatTopic, response.json()) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1784,84 +2955,30 @@ def create_or_replace_room( return deserialized # type: ignore @distributed_trace - def get_room(self, room_id: str, **kwargs: Any) -> _models.ChatRoom: - """Get room information. - - Get room information. - - :param room_id: Room identifier. Required. - :type room_id: str - :return: ChatRoom. The ChatRoom is compatible with MutableMapping - :rtype: ~azure.messaging.webpubsubchatservice.models.ChatRoom - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.ChatRoom] = kwargs.pop("cls", None) - - _request = build_web_pub_sub_chat_service_get_room_request( - room_id=room_id, - hub=self._config.hub, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.ChatRoom, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete_room( # pylint: disable=inconsistent-return-statements + @api_version_validation( + method_added_on="2026-08-01-preview", + params_added_on={ + "2026-08-01-preview": ["api_version", "hub", "room_id", "topic_id", "etag", "match_condition"] + }, + api_versions_list=["2026-08-01-preview"], + ) + def delete_topic( # pylint: disable=inconsistent-return-statements self, room_id: str, + topic_id: str, *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> None: - """Delete a room. + """Soft delete a topic. - Delete a room. + Soft delete a topic. :param room_id: Room identifier. Required. :type room_id: str + :param topic_id: Topic identifier unique within the room. Required. + :type topic_id: str :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. :paramtype etag: str @@ -1890,8 +3007,9 @@ def delete_room( # pylint: disable=inconsistent-return-statements cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_web_pub_sub_chat_service_delete_room_request( + _request = build_web_pub_sub_chat_service_delete_topic_request( room_id=room_id, + topic_id=topic_id, hub=self._config.hub, etag=etag, match_condition=match_condition, @@ -2313,6 +3431,113 @@ def delete_room_member( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore + @distributed_trace + @api_version_validation( + method_added_on="2026-08-01-preview", + params_added_on={ + "2026-08-01-preview": ["api_version", "hub", "max_page_size", "continuation_token_parameter", "accept"] + }, + api_versions_list=["2026-08-01-preview"], + ) + def list_users( + self, *, max_page_size: Optional[int] = None, continuation_token_parameter: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.ChatUser"]: + """List all users with pagination. + + List all users with pagination. + + :keyword max_page_size: The maximum number of result items per page. Default value is None. + :paramtype max_page_size: int + :keyword continuation_token_parameter: Continuation token for pagination. Default value is + None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of ChatUser + :rtype: ~azure.core.paging.ItemPaged[~azure.messaging.webpubsubchatservice.models.ChatUser] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models.ChatUser]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_web_pub_sub_chat_service_list_users_request( + hub=self._config.hub, + max_page_size=max_page_size, + continuation_token_parameter=continuation_token_parameter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + list[_models.ChatUser], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + @distributed_trace def get_user(self, user_id: str, **kwargs: Any) -> _models.ChatUser: """Get a user's profile. @@ -2651,6 +3876,105 @@ def delete_user( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore + @distributed_trace + @api_version_validation( + method_added_on="2026-08-01-preview", + params_added_on={"2026-08-01-preview": ["api_version", "hub", "user_id", "accept"]}, + api_versions_list=["2026-08-01-preview"], + ) + def list_rooms_for_user(self, user_id: str, **kwargs: Any) -> ItemPaged["_models.ChatUserRoom"]: + """List rooms for a user with pagination. + + List rooms for a user with pagination. + + :param user_id: User identifier. Required. + :type user_id: str + :return: An iterator like instance of ChatUserRoom + :rtype: ~azure.core.paging.ItemPaged[~azure.messaging.webpubsubchatservice.models.ChatUserRoom] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models.ChatUserRoom]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_web_pub_sub_chat_service_list_rooms_for_user_request( + user_id=user_id, + hub=self._config.hub, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + list[_models.ChatUserRoom], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + @distributed_trace def _generate_client_token( self, diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_validation.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_validation.py new file mode 100644 index 000000000000..f5af3a4eb8a2 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_validation.py @@ -0,0 +1,66 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools + + +def api_version_validation(**kwargs): + params_added_on = kwargs.pop("params_added_on", {}) + method_added_on = kwargs.pop("method_added_on", "") + api_versions_list = kwargs.pop("api_versions_list", []) + + def _index_with_default(value: str, default: int = -1) -> int: + """Get the index of value in lst, or return default if not found. + + :param value: The value to search for in the api_versions_list. + :type value: str + :param default: The default value to return if the value is not found. + :type default: int + :return: The index of the value in the list, or the default value if not found. + :rtype: int + """ + try: + return api_versions_list.index(value) + except ValueError: + return default + + def decorator(func): + @functools.wraps(func) + def wrapper(*args, **kwargs): + try: + # this assumes the client has an _api_version attribute + client = args[0] + client_api_version = client._config.api_version # pylint: disable=protected-access + except AttributeError: + return func(*args, **kwargs) + + if _index_with_default(method_added_on) > _index_with_default(client_api_version): + raise ValueError( + f"'{func.__name__}' is not available in API version " + f"{client_api_version}. Pass service API version {method_added_on} or newer to your client." + ) + + unsupported = { + parameter: api_version + for api_version, parameters in params_added_on.items() + for parameter in parameters + if parameter in kwargs and _index_with_default(api_version) > _index_with_default(client_api_version) + } + if unsupported: + raise ValueError( + "".join( + [ + f"'{param}' is not available in API version {client_api_version}. " + f"Use service API version {version} or newer.\n" + for param, version in unsupported.items() + ] + ) + ) + return func(*args, **kwargs) + + return wrapper + + return decorator diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_client.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_client.py index 6abc2e988347..862a1a451bfe 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_client.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_client.py @@ -40,7 +40,7 @@ class WebPubSubChatServiceClient( alpha-numeric characters or underscore. Required. :type hub: str :keyword api_version: The API version to use for this operation. Known values are - "2026-02-01-preview" and None. Default value is None. If not set, the operation's default API + "2026-08-01-preview" and None. Default value is None. If not set, the operation's default API version will be used. Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_configuration.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_configuration.py index 564c0963ed46..57ae09abfe43 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_configuration.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_configuration.py @@ -31,14 +31,14 @@ class WebPubSubChatServiceClientConfiguration: # pylint: disable=too-many-insta alpha-numeric characters or underscore. Required. :type hub: str :keyword api_version: The API version to use for this operation. Known values are - "2026-02-01-preview" and None. Default value is None. If not set, the operation's default API + "2026-08-01-preview" and None. Default value is None. If not set, the operation's default API version will be used. Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, endpoint: str, credential: "AsyncTokenCredential", hub: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2026-02-01-preview") + api_version: str = kwargs.pop("api_version", "2026-08-01-preview") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_operations/_operations.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_operations/_operations.py index 17d17a8452df..d3c5e3589ff6 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_operations/_operations.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_operations/_operations.py @@ -36,31 +36,40 @@ build_web_pub_sub_chat_service_create_or_replace_role_request, build_web_pub_sub_chat_service_create_or_replace_room_member_request, build_web_pub_sub_chat_service_create_or_replace_room_request, + build_web_pub_sub_chat_service_create_or_replace_topic_request, build_web_pub_sub_chat_service_create_or_replace_user_request, build_web_pub_sub_chat_service_delete_message_request, build_web_pub_sub_chat_service_delete_role_request, build_web_pub_sub_chat_service_delete_room_member_request, build_web_pub_sub_chat_service_delete_room_request, + build_web_pub_sub_chat_service_delete_topic_request, build_web_pub_sub_chat_service_delete_user_request, build_web_pub_sub_chat_service_generate_client_token_request, build_web_pub_sub_chat_service_get_conversation_request, build_web_pub_sub_chat_service_get_role_request, build_web_pub_sub_chat_service_get_room_request, + build_web_pub_sub_chat_service_get_topic_request, build_web_pub_sub_chat_service_get_user_request, build_web_pub_sub_chat_service_list_messages_request, build_web_pub_sub_chat_service_list_roles_request, build_web_pub_sub_chat_service_list_room_members_request, + build_web_pub_sub_chat_service_list_rooms_for_user_request, + build_web_pub_sub_chat_service_list_rooms_request, + build_web_pub_sub_chat_service_list_topics_request, + build_web_pub_sub_chat_service_list_users_request, build_web_pub_sub_chat_service_update_message_request, + build_web_pub_sub_chat_service_update_topic_request, ) from ..._utils.model_base import SdkJSONEncoder, _deserialize from ..._utils.utils import ClientMixinABC +from ..._validation import api_version_validation from .._configuration import WebPubSubChatServiceClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -class _WebPubSubChatServiceClientOperationsMixin( +class _WebPubSubChatServiceClientOperationsMixin( # pylint: disable=too-many-public-methods ClientMixinABC[AsyncPipelineClient[HttpRequest, AsyncHttpResponse], WebPubSubChatServiceClientConfiguration] ): @@ -962,6 +971,114 @@ async def delete_role( if cls: return cls(pipeline_response, None, {}) # type: ignore + @distributed_trace + @api_version_validation( + method_added_on="2026-08-01-preview", + params_added_on={ + "2026-08-01-preview": ["api_version", "hub", "max_page_size", "continuation_token_parameter", "accept"] + }, + api_versions_list=["2026-08-01-preview"], + ) + def list_rooms( + self, *, max_page_size: Optional[int] = None, continuation_token_parameter: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.ChatRoom"]: + """List rooms with pagination. + + List rooms with pagination. + + :keyword max_page_size: The maximum number of result items per page. Default value is None. + :paramtype max_page_size: int + :keyword continuation_token_parameter: Continuation token for pagination. Default value is + None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of ChatRoom + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.messaging.webpubsubchatservice.models.ChatRoom] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models.ChatRoom]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_web_pub_sub_chat_service_list_rooms_request( + hub=self._config.hub, + max_page_size=max_page_size, + continuation_token_parameter=continuation_token_parameter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + list[_models.ChatRoom], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + @overload async def create_or_replace_room( self, @@ -1083,8 +1200,791 @@ async def create_or_replace_room( :paramtype etag: str :keyword match_condition: The match condition to use upon the etag. Default value is None. :paramtype match_condition: ~azure.core.MatchConditions - :return: ChatRoom. The ChatRoom is compatible with MutableMapping - :rtype: ~azure.messaging.webpubsubchatservice.models.ChatRoom + :return: ChatRoom. The ChatRoom is compatible with MutableMapping + :rtype: ~azure.messaging.webpubsubchatservice.models.ChatRoom + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ChatRoom] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_web_pub_sub_chat_service_create_or_replace_room_request( + room_id=room_id, + hub=self._config.hub, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ChatRoom, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_room(self, room_id: str, **kwargs: Any) -> _models.ChatRoom: + """Get room information. + + Get room information. + + :param room_id: Room identifier. Required. + :type room_id: str + :return: ChatRoom. The ChatRoom is compatible with MutableMapping + :rtype: ~azure.messaging.webpubsubchatservice.models.ChatRoom + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ChatRoom] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_chat_service_get_room_request( + room_id=room_id, + hub=self._config.hub, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ChatRoom, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete_room( + self, + room_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> None: + """Delete a room. + + Delete a room. + + :param room_id: Room identifier. Required. + :type room_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_chat_service_delete_room_request( + room_id=room_id, + hub=self._config.hub, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + @api_version_validation( + method_added_on="2026-08-01-preview", + params_added_on={ + "2026-08-01-preview": [ + "api_version", + "hub", + "room_id", + "max_page_size", + "continuation_token_parameter", + "accept", + ] + }, + api_versions_list=["2026-08-01-preview"], + ) + def list_topics( + self, + room_id: str, + *, + max_page_size: Optional[int] = None, + continuation_token_parameter: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.ChatTopic"]: + """List topics in a room with pagination. + + List topics in a room with pagination. + + :param room_id: Room identifier. Required. + :type room_id: str + :keyword max_page_size: The maximum number of result items per page. Default value is None. + :paramtype max_page_size: int + :keyword continuation_token_parameter: Continuation token for pagination. Default value is + None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of ChatTopic + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.messaging.webpubsubchatservice.models.ChatTopic] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models.ChatTopic]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_web_pub_sub_chat_service_list_topics_request( + room_id=room_id, + hub=self._config.hub, + max_page_size=max_page_size, + continuation_token_parameter=continuation_token_parameter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + list[_models.ChatTopic], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @overload + async def create_or_replace_topic( + self, + room_id: str, + topic_id: str, + resource: _models.ChatTopic, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ChatTopic: + """Create or replace a topic. + + Create or replace a topic with a client-specified ID. + + :param room_id: Room identifier. Required. + :type room_id: str + :param topic_id: Topic identifier unique within the room. Required. + :type topic_id: str + :param resource: The resource instance. Required. + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ChatTopic. The ChatTopic is compatible with MutableMapping + :rtype: ~azure.messaging.webpubsubchatservice.models.ChatTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_replace_topic( + self, + room_id: str, + topic_id: str, + resource: _types.ChatTopic, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ChatTopic: + """Create or replace a topic. + + Create or replace a topic with a client-specified ID. + + :param room_id: Room identifier. Required. + :type room_id: str + :param topic_id: Topic identifier unique within the room. Required. + :type topic_id: str + :param resource: The resource instance. Required. + :type resource: ~azure.messaging.webpubsubchatservice.types.ChatTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ChatTopic. The ChatTopic is compatible with MutableMapping + :rtype: ~azure.messaging.webpubsubchatservice.models.ChatTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_replace_topic( + self, + room_id: str, + topic_id: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ChatTopic: + """Create or replace a topic. + + Create or replace a topic with a client-specified ID. + + :param room_id: Room identifier. Required. + :type room_id: str + :param topic_id: Topic identifier unique within the room. Required. + :type topic_id: str + :param resource: The resource instance. Required. + :type resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ChatTopic. The ChatTopic is compatible with MutableMapping + :rtype: ~azure.messaging.webpubsubchatservice.models.ChatTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + @api_version_validation( + method_added_on="2026-08-01-preview", + params_added_on={ + "2026-08-01-preview": [ + "api_version", + "hub", + "room_id", + "topic_id", + "content_type", + "accept", + "etag", + "match_condition", + ] + }, + api_versions_list=["2026-08-01-preview"], + ) + async def create_or_replace_topic( + self, + room_id: str, + topic_id: str, + resource: Union[_models.ChatTopic, _types.ChatTopic, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ChatTopic: + """Create or replace a topic. + + Create or replace a topic with a client-specified ID. + + :param room_id: Room identifier. Required. + :type room_id: str + :param topic_id: Topic identifier unique within the room. Required. + :type topic_id: str + :param resource: The resource instance. Is either a ChatTopic type or a IO[bytes] type. + Required. + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopic or + ~azure.messaging.webpubsubchatservice.types.ChatTopic or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ChatTopic. The ChatTopic is compatible with MutableMapping + :rtype: ~azure.messaging.webpubsubchatservice.models.ChatTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ChatTopic] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_web_pub_sub_chat_service_create_or_replace_topic_request( + room_id=room_id, + topic_id=topic_id, + hub=self._config.hub, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ChatTopic, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + @api_version_validation( + method_added_on="2026-08-01-preview", + params_added_on={"2026-08-01-preview": ["api_version", "hub", "room_id", "topic_id", "accept"]}, + api_versions_list=["2026-08-01-preview"], + ) + async def get_topic(self, room_id: str, topic_id: str, **kwargs: Any) -> _models.ChatTopic: + """Get topic information. + + Get topic information. + + :param room_id: Room identifier. Required. + :type room_id: str + :param topic_id: Topic identifier unique within the room. Required. + :type topic_id: str + :return: ChatTopic. The ChatTopic is compatible with MutableMapping + :rtype: ~azure.messaging.webpubsubchatservice.models.ChatTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ChatTopic] = kwargs.pop("cls", None) + + _request = build_web_pub_sub_chat_service_get_topic_request( + room_id=room_id, + topic_id=topic_id, + hub=self._config.hub, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ChatTopic, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update_topic( + self, + room_id: str, + topic_id: str, + resource: _models.ChatTopic, + *, + content_type: str = "application/merge-patch+json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ChatTopic: + """Update a topic. + + Update a topic. + + :param room_id: Room identifier. Required. + :type room_id: str + :param topic_id: Topic identifier unique within the room. Required. + :type topic_id: str + :param resource: The resource instance. Required. + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ChatTopic. The ChatTopic is compatible with MutableMapping + :rtype: ~azure.messaging.webpubsubchatservice.models.ChatTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_topic( + self, + room_id: str, + topic_id: str, + resource: _types.ChatTopic, + *, + content_type: str = "application/merge-patch+json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ChatTopic: + """Update a topic. + + Update a topic. + + :param room_id: Room identifier. Required. + :type room_id: str + :param topic_id: Topic identifier unique within the room. Required. + :type topic_id: str + :param resource: The resource instance. Required. + :type resource: ~azure.messaging.webpubsubchatservice.types.ChatTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ChatTopic. The ChatTopic is compatible with MutableMapping + :rtype: ~azure.messaging.webpubsubchatservice.models.ChatTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_topic( + self, + room_id: str, + topic_id: str, + resource: IO[bytes], + *, + content_type: str = "application/merge-patch+json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ChatTopic: + """Update a topic. + + Update a topic. + + :param room_id: Room identifier. Required. + :type room_id: str + :param topic_id: Topic identifier unique within the room. Required. + :type topic_id: str + :param resource: The resource instance. Required. + :type resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ChatTopic. The ChatTopic is compatible with MutableMapping + :rtype: ~azure.messaging.webpubsubchatservice.models.ChatTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + @api_version_validation( + method_added_on="2026-08-01-preview", + params_added_on={ + "2026-08-01-preview": [ + "api_version", + "hub", + "room_id", + "topic_id", + "content_type", + "accept", + "etag", + "match_condition", + ] + }, + api_versions_list=["2026-08-01-preview"], + ) + async def update_topic( + self, + room_id: str, + topic_id: str, + resource: Union[_models.ChatTopic, _types.ChatTopic, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ChatTopic: + """Update a topic. + + Update a topic. + + :param room_id: Room identifier. Required. + :type room_id: str + :param topic_id: Topic identifier unique within the room. Required. + :type topic_id: str + :param resource: The resource instance. Is either a ChatTopic type or a IO[bytes] type. + Required. + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopic or + ~azure.messaging.webpubsubchatservice.types.ChatTopic or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ChatTopic. The ChatTopic is compatible with MutableMapping + :rtype: ~azure.messaging.webpubsubchatservice.models.ChatTopic :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1105,17 +2005,18 @@ async def create_or_replace_room( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ChatRoom] = kwargs.pop("cls", None) + cls: ClsType[_models.ChatTopic] = kwargs.pop("cls", None) - content_type = content_type or "application/json" + content_type = content_type or "application/merge-patch+json" _content = None if isinstance(resource, (IOBase, bytes)): _content = resource else: _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_web_pub_sub_chat_service_create_or_replace_room_request( + _request = build_web_pub_sub_chat_service_update_topic_request( room_id=room_id, + topic_id=topic_id, hub=self._config.hub, etag=etag, match_condition=match_condition, @@ -1138,7 +2039,7 @@ async def create_or_replace_room( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200]: if _stream: try: await response.read() # Load the body in memory and close the socket @@ -1153,7 +2054,7 @@ async def create_or_replace_room( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.ChatRoom, response.json()) + deserialized = _deserialize(_models.ChatTopic, response.json()) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1161,84 +2062,30 @@ async def create_or_replace_room( return deserialized # type: ignore @distributed_trace_async - async def get_room(self, room_id: str, **kwargs: Any) -> _models.ChatRoom: - """Get room information. - - Get room information. - - :param room_id: Room identifier. Required. - :type room_id: str - :return: ChatRoom. The ChatRoom is compatible with MutableMapping - :rtype: ~azure.messaging.webpubsubchatservice.models.ChatRoom - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.ChatRoom] = kwargs.pop("cls", None) - - _request = build_web_pub_sub_chat_service_get_room_request( - room_id=room_id, - hub=self._config.hub, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.ChatRoom, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete_room( + @api_version_validation( + method_added_on="2026-08-01-preview", + params_added_on={ + "2026-08-01-preview": ["api_version", "hub", "room_id", "topic_id", "etag", "match_condition"] + }, + api_versions_list=["2026-08-01-preview"], + ) + async def delete_topic( self, room_id: str, + topic_id: str, *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, **kwargs: Any ) -> None: - """Delete a room. + """Soft delete a topic. - Delete a room. + Soft delete a topic. :param room_id: Room identifier. Required. :type room_id: str + :param topic_id: Topic identifier unique within the room. Required. + :type topic_id: str :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. :paramtype etag: str @@ -1267,8 +2114,9 @@ async def delete_room( cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_web_pub_sub_chat_service_delete_room_request( + _request = build_web_pub_sub_chat_service_delete_topic_request( room_id=room_id, + topic_id=topic_id, hub=self._config.hub, etag=etag, match_condition=match_condition, @@ -1690,6 +2538,114 @@ async def delete_room_member( if cls: return cls(pipeline_response, None, {}) # type: ignore + @distributed_trace + @api_version_validation( + method_added_on="2026-08-01-preview", + params_added_on={ + "2026-08-01-preview": ["api_version", "hub", "max_page_size", "continuation_token_parameter", "accept"] + }, + api_versions_list=["2026-08-01-preview"], + ) + def list_users( + self, *, max_page_size: Optional[int] = None, continuation_token_parameter: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.ChatUser"]: + """List all users with pagination. + + List all users with pagination. + + :keyword max_page_size: The maximum number of result items per page. Default value is None. + :paramtype max_page_size: int + :keyword continuation_token_parameter: Continuation token for pagination. Default value is + None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of ChatUser + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.messaging.webpubsubchatservice.models.ChatUser] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models.ChatUser]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_web_pub_sub_chat_service_list_users_request( + hub=self._config.hub, + max_page_size=max_page_size, + continuation_token_parameter=continuation_token_parameter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + list[_models.ChatUser], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + @distributed_trace_async async def get_user(self, user_id: str, **kwargs: Any) -> _models.ChatUser: """Get a user's profile. @@ -2028,6 +2984,106 @@ async def delete_user( if cls: return cls(pipeline_response, None, {}) # type: ignore + @distributed_trace + @api_version_validation( + method_added_on="2026-08-01-preview", + params_added_on={"2026-08-01-preview": ["api_version", "hub", "user_id", "accept"]}, + api_versions_list=["2026-08-01-preview"], + ) + def list_rooms_for_user(self, user_id: str, **kwargs: Any) -> AsyncItemPaged["_models.ChatUserRoom"]: + """List rooms for a user with pagination. + + List rooms for a user with pagination. + + :param user_id: User identifier. Required. + :type user_id: str + :return: An iterator like instance of ChatUserRoom + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.messaging.webpubsubchatservice.models.ChatUserRoom] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models.ChatUserRoom]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_web_pub_sub_chat_service_list_rooms_for_user_request( + user_id=user_id, + hub=self._config.hub, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + list[_models.ChatUserRoom], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + @distributed_trace_async async def _generate_client_token( self, diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/__init__.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/__init__.py index f899728a6f97..c0afafd66acc 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/__init__.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/__init__.py @@ -19,13 +19,16 @@ ChatRole, ChatRoom, ChatRoomMember, + ChatTopic, ChatUser, + ChatUserRoom, HumanChatUser, MessageContent, ) from ._enums import ( # type: ignore ChatPermission, + ChatTopicState, ChatUserKind, ) from ._patch import __all__ as _patch_all @@ -38,10 +41,13 @@ "ChatRole", "ChatRoom", "ChatRoomMember", + "ChatTopic", "ChatUser", + "ChatUserRoom", "HumanChatUser", "MessageContent", "ChatPermission", + "ChatTopicState", "ChatUserKind", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/_enums.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/_enums.py index 1a61c9616269..1e3b31bf8c7e 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/_enums.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/_enums.py @@ -27,6 +27,17 @@ class ChatPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Allows a room operator to remove users from a room.""" +class ChatTopicState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The lifecycle state of a chat topic.""" + + NORMAL = "Normal" + """The topic is active.""" + ARCHIVED = "Archived" + """The topic is archived.""" + SOFT_DELETED = "SoftDeleted" + """The topic has been soft deleted.""" + + class ChatUserKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Discriminator for the kind of chat user.""" diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/_models.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/_models.py index 68fa25ac834e..16971c33e2fa 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/_models.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/_models.py @@ -216,6 +216,61 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) +class ChatTopic(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Represents a chat topic in a room. + + :ivar id: Topic identifier unique within the room. Required. + :vartype id: str + :ivar title: Topic title. Required. + :vartype title: str + :ivar created_at: Timestamp when the topic was created. Required. + :vartype created_at: ~datetime.datetime + :ivar created_by: User who created the topic. Required. + :vartype created_by: str + :ivar state: Current lifecycle state of the topic. Required. Known values are: "Normal", + "Archived", and "SoftDeleted". + :vartype state: str or ~azure.messaging.webpubsubchatservice.models.ChatTopicState + :ivar conversation_id: Conversation associated with this topic. Required. + :vartype conversation_id: str + :ivar etag: The entity tag for this resource. Required. + :vartype etag: str + """ + + id: str = rest_field(visibility=["read"]) + """Topic identifier unique within the room. Required.""" + title: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Topic title. Required.""" + created_at: datetime.datetime = rest_field(name="createdAt", visibility=["read"], format="rfc3339") + """Timestamp when the topic was created. Required.""" + created_by: str = rest_field(name="createdBy", visibility=["read"]) + """User who created the topic. Required.""" + state: Union[str, "_models.ChatTopicState"] = rest_field(visibility=["read", "update"]) + """Current lifecycle state of the topic. Required. Known values are: \"Normal\", \"Archived\", and + \"SoftDeleted\".""" + conversation_id: str = rest_field(name="conversationId", visibility=["read"]) + """Conversation associated with this topic. Required.""" + etag: str = rest_field(visibility=["read"]) + """The entity tag for this resource. Required.""" + + @overload + def __init__( + self, + *, + title: str, + state: Union[str, "_models.ChatTopicState"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + class ChatUser(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only """Represents a user profile in the chat system. This is a discriminated base type; concrete payloads are selected by the ``kind`` field (e.g. ``HumanChatUser``). @@ -262,6 +317,49 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) +class ChatUserRoom(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """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. + + :ivar id: Room identifier. Required. + :vartype id: str + :ivar title: Room title. Required. + :vartype title: str + :ivar default_conversation: Default conversation ID for this room. Required. + :vartype default_conversation: str + :ivar etag: The entity tag for this resource. Required. + :vartype etag: str + """ + + id: str = rest_field(visibility=["read"]) + """Room identifier. Required.""" + title: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Room title. Required.""" + default_conversation: str = rest_field(name="defaultConversation", visibility=["read"]) + """Default conversation ID for this room. Required.""" + etag: str = rest_field(visibility=["read"]) + """The entity tag for this resource. Required.""" + + @overload + def __init__( + self, + *, + title: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + class GenerateClientTokenResponse(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only """Response containing a Web PubSub client access token. diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py index c738d721fea3..189375c7b7b2 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py @@ -12,7 +12,7 @@ from .models._enums import ChatUserKind if TYPE_CHECKING: - from .models import ChatPermission + from .models import ChatPermission, ChatTopicState class ChatMessage(TypedDict, total=False): @@ -106,6 +106,43 @@ class ChatRoomMember(TypedDict, total=False): """The entity tag for this resource. Required.""" +class ChatTopic(TypedDict, total=False): + """Represents a chat topic in a room. + + :ivar id: Topic identifier unique within the room. Required. + :vartype id: str + :ivar title: Topic title. Required. + :vartype title: str + :ivar createdAt: Timestamp when the topic was created. Required. + :vartype createdAt: str + :ivar createdBy: User who created the topic. Required. + :vartype createdBy: str + :ivar state: Current lifecycle state of the topic. Required. Known values are: "Normal", + "Archived", and "SoftDeleted". + :vartype state: Union[str, "ChatTopicState"] + :ivar conversationId: Conversation associated with this topic. Required. + :vartype conversationId: str + :ivar etag: The entity tag for this resource. Required. + :vartype etag: str + """ + + id: Required[str] + """Topic identifier unique within the room. Required.""" + title: Required[str] + """Topic title. Required.""" + createdAt: Required[str] + """Timestamp when the topic was created. Required.""" + createdBy: Required[str] + """User who created the topic. Required.""" + state: Required[Union[str, "ChatTopicState"]] + """Current lifecycle state of the topic. Required. Known values are: \"Normal\", \"Archived\", and + \"SoftDeleted\".""" + conversationId: Required[str] + """Conversation associated with this topic. Required.""" + etag: Required[str] + """The entity tag for this resource. Required.""" + + class HumanChatUser(TypedDict, total=False): """A human end-user, identified by a user role. diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_role.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_role.py index 6ced1c28454a..e0b3453fc157 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_role.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_role.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: 2026-02-01-preview/CreateOrReplaceRole.json +# x-ms-original-file: 2026-08-01-preview/CreateOrReplaceRole.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_room.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_room.py index 1232458595a1..316c879cf38b 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_room.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_room.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: 2026-02-01-preview/CreateOrReplaceRoom.json +# x-ms-original-file: 2026-08-01-preview/CreateOrReplaceRoom.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_room_member.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_room_member.py index 63df38fe4a11..9148863099ba 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_room_member.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_room_member.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: 2026-02-01-preview/CreateOrReplaceRoomMember.json +# x-ms-original-file: 2026-08-01-preview/CreateOrReplaceRoomMember.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_topic.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_topic.py new file mode 100644 index 000000000000..94f745112aaf --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_topic.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-messaging-webpubsubchatservice +# USAGE + python create_or_replace_topic.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WebPubSubChatServiceClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + hub="HUB", + ) + + response = client.create_or_replace_topic( + room_id="general", + topic_id="product-updates", + resource={"state": "Normal", "title": "Product updates"}, + ) + print(response) + + +# x-ms-original-file: 2026-08-01-preview/CreateOrReplaceTopic.json +if __name__ == "__main__": + main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_user.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_user.py index f41d09be86b9..8156c33fd3fc 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_user.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_user.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: 2026-02-01-preview/CreateOrReplaceUser.json +# x-ms-original-file: 2026-08-01-preview/CreateOrReplaceUser.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_message.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_message.py index 8047a19cf905..1527addb226d 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_message.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_message.py @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: 2026-02-01-preview/DeleteMessage.json +# x-ms-original-file: 2026-08-01-preview/DeleteMessage.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_role.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_role.py index 8b6d5dd18751..addfcf6c1f82 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_role.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_role.py @@ -36,6 +36,6 @@ def main(): ) -# x-ms-original-file: 2026-02-01-preview/DeleteRole.json +# x-ms-original-file: 2026-08-01-preview/DeleteRole.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_room.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_room.py index 005baa4924b0..dba2c279bef4 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_room.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_room.py @@ -36,6 +36,6 @@ def main(): ) -# x-ms-original-file: 2026-02-01-preview/DeleteRoom.json +# x-ms-original-file: 2026-08-01-preview/DeleteRoom.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_room_member.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_room_member.py index b6dd41e89d34..ab99523d2bda 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_room_member.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_room_member.py @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: 2026-02-01-preview/DeleteRoomMember.json +# x-ms-original-file: 2026-08-01-preview/DeleteRoomMember.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_topic.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_topic.py new file mode 100644 index 000000000000..67d977717dbf --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_topic.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-messaging-webpubsubchatservice +# USAGE + python delete_topic.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WebPubSubChatServiceClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + hub="HUB", + ) + + client.delete_topic( + room_id="general", + topic_id="product-updates", + ) + + +# x-ms-original-file: 2026-08-01-preview/DeleteTopic.json +if __name__ == "__main__": + main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_user.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_user.py index 2dea2d5b3bdd..902ced02d693 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_user.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_user.py @@ -36,6 +36,6 @@ def main(): ) -# x-ms-original-file: 2026-02-01-preview/DeleteUser.json +# x-ms-original-file: 2026-08-01-preview/DeleteUser.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_conversation.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_conversation.py index 3a0c9ba6c6a8..e28d14316bd9 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_conversation.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_conversation.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: 2026-02-01-preview/GetConversation.json +# x-ms-original-file: 2026-08-01-preview/GetConversation.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_role.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_role.py index 599b5868a943..98bca6032d60 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_role.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_role.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: 2026-02-01-preview/GetRole.json +# x-ms-original-file: 2026-08-01-preview/GetRole.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_room.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_room.py index a64f9fc6642a..690e24b8f7d3 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_room.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_room.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: 2026-02-01-preview/GetRoom.json +# x-ms-original-file: 2026-08-01-preview/GetRoom.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_topic.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_topic.py new file mode 100644 index 000000000000..86ac3e9f5d71 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_topic.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-messaging-webpubsubchatservice +# USAGE + python get_topic.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WebPubSubChatServiceClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + hub="HUB", + ) + + response = client.get_topic( + room_id="general", + topic_id="product-updates", + ) + print(response) + + +# x-ms-original-file: 2026-08-01-preview/GetTopic.json +if __name__ == "__main__": + main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_user.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_user.py index edb48e9c3c33..e3d1f924b73e 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_user.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_user.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: 2026-02-01-preview/GetUser.json +# x-ms-original-file: 2026-08-01-preview/GetUser.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_messages.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_messages.py index 60df639067b5..cfc2db10651e 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_messages.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_messages.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: 2026-02-01-preview/ListMessages.json +# x-ms-original-file: 2026-08-01-preview/ListMessages.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_roles.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_roles.py index f3dfaddc7950..84022601b080 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_roles.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_roles.py @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: 2026-02-01-preview/ListRoles.json +# x-ms-original-file: 2026-08-01-preview/ListRoles.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_room_members.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_room_members.py index 2684841869b8..eae5bf7cb81d 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_room_members.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_room_members.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: 2026-02-01-preview/ListRoomMembers.json +# x-ms-original-file: 2026-08-01-preview/ListRoomMembers.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_rooms.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_rooms.py new file mode 100644 index 000000000000..524984c1a2c1 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_rooms.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-messaging-webpubsubchatservice +# USAGE + python list_rooms.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WebPubSubChatServiceClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + hub="HUB", + ) + + response = client.list_rooms() + for item in response: + print(item) + + +# x-ms-original-file: 2026-08-01-preview/ListRooms.json +if __name__ == "__main__": + main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_rooms_for_user.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_rooms_for_user.py new file mode 100644 index 000000000000..947ee42589ff --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_rooms_for_user.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-messaging-webpubsubchatservice +# USAGE + python list_rooms_for_user.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WebPubSubChatServiceClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + hub="HUB", + ) + + response = client.list_rooms_for_user( + user_id="alex", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2026-08-01-preview/ListRoomsForUser.json +if __name__ == "__main__": + main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_topics.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_topics.py new file mode 100644 index 000000000000..d70491b74985 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_topics.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-messaging-webpubsubchatservice +# USAGE + python list_topics.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WebPubSubChatServiceClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + hub="HUB", + ) + + response = client.list_topics( + room_id="general", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2026-08-01-preview/ListTopics.json +if __name__ == "__main__": + main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_users.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_users.py new file mode 100644 index 000000000000..7c76c30636eb --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_users.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-messaging-webpubsubchatservice +# USAGE + python list_users.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WebPubSubChatServiceClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + hub="HUB", + ) + + response = client.list_users() + for item in response: + print(item) + + +# x-ms-original-file: 2026-08-01-preview/ListUsers.json +if __name__ == "__main__": + main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/update_message.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/update_message.py index 3fd09e877ee4..1e68882d5e4f 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/update_message.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/update_message.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: 2026-02-01-preview/UpdateMessage.json +# x-ms-original-file: 2026-08-01-preview/UpdateMessage.json if __name__ == "__main__": main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/update_topic.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/update_topic.py new file mode 100644 index 000000000000..f15da011222d --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/update_topic.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-messaging-webpubsubchatservice +# USAGE + python update_topic.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = WebPubSubChatServiceClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + hub="HUB", + ) + + response = client.update_topic( + room_id="general", + topic_id="product-updates", + resource={"state": "Archived"}, + ) + print(response) + + +# x-ms-original-file: 2026-08-01-preview/UpdateTopic.json +if __name__ == "__main__": + main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service.py index 12a168e8992f..613f4617bda4 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service.py @@ -108,6 +108,15 @@ def test_delete_role(self, webpubsubchatservice_endpoint): # please add some check logic here by yourself # ... + @WebPubSubChatServicePreparer() + @recorded_by_proxy + def test_list_rooms(self, webpubsubchatservice_endpoint): + client = self.create_client(endpoint=webpubsubchatservice_endpoint) + response = client.list_rooms() + result = [r for r in response] + # please add some check logic here by yourself + # ... + @WebPubSubChatServicePreparer() @recorded_by_proxy def test_create_or_replace_room(self, webpubsubchatservice_endpoint): @@ -142,6 +151,83 @@ def test_delete_room(self, webpubsubchatservice_endpoint): # please add some check logic here by yourself # ... + @WebPubSubChatServicePreparer() + @recorded_by_proxy + def test_list_topics(self, webpubsubchatservice_endpoint): + client = self.create_client(endpoint=webpubsubchatservice_endpoint) + response = client.list_topics( + room_id="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @WebPubSubChatServicePreparer() + @recorded_by_proxy + def test_create_or_replace_topic(self, webpubsubchatservice_endpoint): + client = self.create_client(endpoint=webpubsubchatservice_endpoint) + response = client.create_or_replace_topic( + room_id="str", + topic_id="str", + resource={ + "conversationId": "str", + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "etag": "str", + "id": "str", + "state": "str", + "title": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @WebPubSubChatServicePreparer() + @recorded_by_proxy + def test_get_topic(self, webpubsubchatservice_endpoint): + client = self.create_client(endpoint=webpubsubchatservice_endpoint) + response = client.get_topic( + room_id="str", + topic_id="str", + ) + + # please add some check logic here by yourself + # ... + + @WebPubSubChatServicePreparer() + @recorded_by_proxy + def test_update_topic(self, webpubsubchatservice_endpoint): + client = self.create_client(endpoint=webpubsubchatservice_endpoint) + response = client.update_topic( + room_id="str", + topic_id="str", + resource={ + "conversationId": "str", + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "etag": "str", + "id": "str", + "state": "str", + "title": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @WebPubSubChatServicePreparer() + @recorded_by_proxy + def test_delete_topic(self, webpubsubchatservice_endpoint): + client = self.create_client(endpoint=webpubsubchatservice_endpoint) + response = client.delete_topic( + room_id="str", + topic_id="str", + ) + + # please add some check logic here by yourself + # ... + @WebPubSubChatServicePreparer() @recorded_by_proxy def test_list_room_members(self, webpubsubchatservice_endpoint): @@ -178,6 +264,15 @@ def test_delete_room_member(self, webpubsubchatservice_endpoint): # please add some check logic here by yourself # ... + @WebPubSubChatServicePreparer() + @recorded_by_proxy + def test_list_users(self, webpubsubchatservice_endpoint): + client = self.create_client(endpoint=webpubsubchatservice_endpoint) + response = client.list_users() + result = [r for r in response] + # please add some check logic here by yourself + # ... + @WebPubSubChatServicePreparer() @recorded_by_proxy def test_get_user(self, webpubsubchatservice_endpoint): @@ -211,3 +306,14 @@ def test_delete_user(self, webpubsubchatservice_endpoint): # please add some check logic here by yourself # ... + + @WebPubSubChatServicePreparer() + @recorded_by_proxy + def test_list_rooms_for_user(self, webpubsubchatservice_endpoint): + client = self.create_client(endpoint=webpubsubchatservice_endpoint) + response = client.list_rooms_for_user( + user_id="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service_async.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service_async.py index d523fbf6b6df..9533e64c185b 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service_async.py @@ -109,6 +109,15 @@ async def test_delete_role(self, webpubsubchatservice_endpoint): # please add some check logic here by yourself # ... + @WebPubSubChatServicePreparer() + @recorded_by_proxy_async + async def test_list_rooms(self, webpubsubchatservice_endpoint): + client = self.create_async_client(endpoint=webpubsubchatservice_endpoint) + response = client.list_rooms() + result = [r async for r in response] + # please add some check logic here by yourself + # ... + @WebPubSubChatServicePreparer() @recorded_by_proxy_async async def test_create_or_replace_room(self, webpubsubchatservice_endpoint): @@ -143,6 +152,83 @@ async def test_delete_room(self, webpubsubchatservice_endpoint): # please add some check logic here by yourself # ... + @WebPubSubChatServicePreparer() + @recorded_by_proxy_async + async def test_list_topics(self, webpubsubchatservice_endpoint): + client = self.create_async_client(endpoint=webpubsubchatservice_endpoint) + response = client.list_topics( + room_id="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @WebPubSubChatServicePreparer() + @recorded_by_proxy_async + async def test_create_or_replace_topic(self, webpubsubchatservice_endpoint): + client = self.create_async_client(endpoint=webpubsubchatservice_endpoint) + response = await client.create_or_replace_topic( + room_id="str", + topic_id="str", + resource={ + "conversationId": "str", + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "etag": "str", + "id": "str", + "state": "str", + "title": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @WebPubSubChatServicePreparer() + @recorded_by_proxy_async + async def test_get_topic(self, webpubsubchatservice_endpoint): + client = self.create_async_client(endpoint=webpubsubchatservice_endpoint) + response = await client.get_topic( + room_id="str", + topic_id="str", + ) + + # please add some check logic here by yourself + # ... + + @WebPubSubChatServicePreparer() + @recorded_by_proxy_async + async def test_update_topic(self, webpubsubchatservice_endpoint): + client = self.create_async_client(endpoint=webpubsubchatservice_endpoint) + response = await client.update_topic( + room_id="str", + topic_id="str", + resource={ + "conversationId": "str", + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "etag": "str", + "id": "str", + "state": "str", + "title": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @WebPubSubChatServicePreparer() + @recorded_by_proxy_async + async def test_delete_topic(self, webpubsubchatservice_endpoint): + client = self.create_async_client(endpoint=webpubsubchatservice_endpoint) + response = await client.delete_topic( + room_id="str", + topic_id="str", + ) + + # please add some check logic here by yourself + # ... + @WebPubSubChatServicePreparer() @recorded_by_proxy_async async def test_list_room_members(self, webpubsubchatservice_endpoint): @@ -179,6 +265,15 @@ async def test_delete_room_member(self, webpubsubchatservice_endpoint): # please add some check logic here by yourself # ... + @WebPubSubChatServicePreparer() + @recorded_by_proxy_async + async def test_list_users(self, webpubsubchatservice_endpoint): + client = self.create_async_client(endpoint=webpubsubchatservice_endpoint) + response = client.list_users() + result = [r async for r in response] + # please add some check logic here by yourself + # ... + @WebPubSubChatServicePreparer() @recorded_by_proxy_async async def test_get_user(self, webpubsubchatservice_endpoint): @@ -212,3 +307,14 @@ async def test_delete_user(self, webpubsubchatservice_endpoint): # please add some check logic here by yourself # ... + + @WebPubSubChatServicePreparer() + @recorded_by_proxy_async + async def test_list_rooms_for_user(self, webpubsubchatservice_endpoint): + client = self.create_async_client(endpoint=webpubsubchatservice_endpoint) + response = client.list_rooms_for_user( + user_id="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/pyproject.toml b/sdk/webpubsub/azure-messaging-webpubsubchatservice/pyproject.toml index 2c5f04f55ba8..5081602e9d19 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/pyproject.toml +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/pyproject.toml @@ -54,7 +54,6 @@ exclude = [ "samples*", "generated_samples*", "doc*", - "build*", "azure", "azure.messaging", ] diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_client_access.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_client_access.py index 781283c8fd1d..674b041f7d47 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_client_access.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_client_access.py @@ -6,7 +6,6 @@ def client_access(): - # [START client_access] import os from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient @@ -15,11 +14,12 @@ def client_access(): connection_string, os.environ.get("WPS_CHAT_HUB", "test_hub"), ) as client: + # [START client_access] access = client.get_client_access_token(user_id="sample-user") # Give access["url"] to the intended client to connect; it includes the access token. # Print only the token-free base URL here. Do not log access["url"]. print(access["baseUrl"]) - # [END client_access] + # [END client_access] def main(): diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_client_access_async.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_client_access_async.py index 799072d2bf61..58e50253b88b 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_client_access_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_client_access_async.py @@ -15,14 +15,16 @@ async def main(): from azure.messaging.webpubsubchatservice.aio import WebPubSubChatServiceClient client = WebPubSubChatServiceClient.from_connection_string( - connection_string, + os.environ["WPS_CHAT_CONNECTION_STRING"], os.environ.get("WPS_CHAT_HUB", "test_hub"), ) try: + # [START client_access_async] access = await client.get_client_access_token(user_id="sample-user") # Give access["url"] to the intended client to connect; it includes the access token. # Print only the token-free base URL here. Do not log access["url"]. print(access["baseUrl"]) + # [END client_access_async] finally: await client.close() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_errors.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_errors.py new file mode 100644 index 000000000000..646c05208454 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_errors.py @@ -0,0 +1,34 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +import os + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient + + +def handle_service_errors(client): + # [START handle_service_errors] + import os + from azure.core.exceptions import HttpResponseError + + try: + role = client.get_role(os.environ.get("WPS_CHAT_ROLE_NAME", "user.python_sample")) + print(role.name, role.permissions) + except HttpResponseError as error: + print(f"Chat service request failed with status {error.status_code}") + raise + # [END handle_service_errors] + + +def main(): + if not os.environ.get("WPS_CHAT_CONNECTION_STRING"): + raise SystemExit("Set WPS_CHAT_CONNECTION_STRING to run this sample.") + with WebPubSubChatServiceClient.from_connection_string( + os.environ["WPS_CHAT_CONNECTION_STRING"], os.environ.get("WPS_CHAT_HUB", "test_hub") + ) as client: + handle_service_errors(client) + + +if __name__ == "__main__": + main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_logging.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_logging.py new file mode 100644 index 000000000000..70ab1a4c7361 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_logging.py @@ -0,0 +1,39 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +import os + + +def configure_logging(): + # [START configure_logging] + import logging + import os + import sys + + from azure.identity import DefaultAzureCredential + from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient + + logger = logging.getLogger("azure") + logger.setLevel(logging.DEBUG) + logger.addHandler(logging.StreamHandler(stream=sys.stdout)) + + with DefaultAzureCredential() as credential: + with WebPubSubChatServiceClient( + os.environ["WPS_CHAT_ENDPOINT"], + os.environ.get("WPS_CHAT_HUB", "test_hub"), + credential, + logging_enable=True, + ) as client: + print(type(client).__name__) + # [END configure_logging] + + +def main(): + if not os.environ.get("WPS_CHAT_ENDPOINT"): + raise SystemExit("Set WPS_CHAT_ENDPOINT to run this sample.") + configure_logging() + + +if __name__ == "__main__": + main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_message_history.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_message_history.py deleted file mode 100644 index 5d77b0e68164..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_message_history.py +++ /dev/null @@ -1,26 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------- -import os - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient - - -def main(): - required = ("WPS_CHAT_CONNECTION_STRING", "WPS_CHAT_CONVERSATION_ID") - missing = [name for name in required if not os.environ.get(name)] - if missing: - print(f"Set {', '.join(missing)} to run this sample.") - return - - with WebPubSubChatServiceClient.from_connection_string( - os.environ["WPS_CHAT_CONNECTION_STRING"], - os.environ.get("WPS_CHAT_HUB", "test_hub"), - ) as client: - for message in client.list_messages(os.environ["WPS_CHAT_CONVERSATION_ID"]): - print(message.id, message.created_by, message.content.text) - - -if __name__ == "__main__": - main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_message_history_async.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_message_history_async.py deleted file mode 100644 index 402ea87b518c..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_message_history_async.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------- -import asyncio -import os - - -async def main(): - required = ("WPS_CHAT_CONNECTION_STRING", "WPS_CHAT_CONVERSATION_ID") - missing = [name for name in required if not os.environ.get(name)] - if missing: - print(f"Set {', '.join(missing)} to run this sample.") - return - - from azure.messaging.webpubsubchatservice.aio import WebPubSubChatServiceClient - - client = WebPubSubChatServiceClient.from_connection_string( - os.environ["WPS_CHAT_CONNECTION_STRING"], - os.environ.get("WPS_CHAT_HUB", "test_hub"), - ) - try: - async for message in client.list_messages(os.environ["WPS_CHAT_CONVERSATION_ID"]): - print(message.id, message.created_by, message.content.text) - finally: - await client.close() - - -if __name__ == "__main__": - asyncio.run(main()) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_readme_snippets.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_readme_snippets.py new file mode 100644 index 000000000000..62811040c60e --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_readme_snippets.py @@ -0,0 +1,159 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Atomic README snippet sources; each function uses an authenticated client.""" + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient + + +def list_roles(client: WebPubSubChatServiceClient) -> None: + # [START list_roles] + for role in client.list_roles(): + print(role.name) + # [END list_roles] + + +def create_user(client: WebPubSubChatServiceClient) -> None: + # [START create_user] + from azure.messaging.webpubsubchatservice.models import HumanChatUser + + user = client.create_or_replace_user( + "alice", + HumanChatUser(nickname="Alice", role_name="user.room_creator"), + ) + print(user.id, user.nickname) + # [END create_user] + + +def create_room(client: WebPubSubChatServiceClient) -> None: + # [START create_room] + from azure.messaging.webpubsubchatservice.models import ChatRoom + + room = client.create_or_replace_room("general", ChatRoom(title="General")) + print(room.id, room.default_conversation) + # [END create_room] + + +def add_room_member(client: WebPubSubChatServiceClient) -> None: + # [START add_room_member] + from azure.messaging.webpubsubchatservice.models import ChatRoomMember + + member = client.create_or_replace_room_member( + "general", + "alice", + ChatRoomMember(role_name="room.contributor"), + ) + print(member.user_id, member.role_name) + # [END add_room_member] + + +def list_messages(client: WebPubSubChatServiceClient) -> None: + # [START list_messages] + import os + + for message in client.list_messages(os.environ["WPS_CHAT_CONVERSATION_ID"]): + print(message.id, message.created_by, message.content.text) + # [END list_messages] + + +def create_topic(client: WebPubSubChatServiceClient) -> None: + # [START create_topic] + import os + from azure.messaging.webpubsubchatservice.models import ChatTopic + + topic = client.create_or_replace_topic( + os.environ["WPS_CHAT_ROOM_ID"], + os.environ["WPS_CHAT_TOPIC_ID"], + ChatTopic({"title": "Announcements"}), + ) + print(topic.id, topic.etag) + # [END create_topic] + + +def list_topics(client: WebPubSubChatServiceClient) -> None: + # [START list_topics] + import os + + for topic in client.list_topics(os.environ["WPS_CHAT_ROOM_ID"], max_page_size=10): + print(topic.id, topic.title, topic.conversation_id) + # [END list_topics] + + +def get_topic(client: WebPubSubChatServiceClient) -> None: + # [START get_topic] + import os + + topic = client.get_topic(os.environ["WPS_CHAT_ROOM_ID"], os.environ["WPS_CHAT_TOPIC_ID"]) + print(topic.id, topic.title, topic.state, topic.etag) + # [END get_topic] + + +def archive_topic(client: WebPubSubChatServiceClient) -> None: + # [START archive_topic] + import os + from azure.core import MatchConditions + from azure.messaging.webpubsubchatservice.models import ChatTopic, ChatTopicState + + topic = client.update_topic( + os.environ["WPS_CHAT_ROOM_ID"], + os.environ["WPS_CHAT_TOPIC_ID"], + ChatTopic(title="Announcements", state=ChatTopicState.ARCHIVED), + etag=os.environ["WPS_CHAT_TOPIC_ETAG"], + match_condition=MatchConditions.IfNotModified, + ) + print(topic.id, topic.state, topic.etag) + # [END archive_topic] + + +def delete_topic(client: WebPubSubChatServiceClient) -> None: + # [START delete_topic] + import os + from azure.core import MatchConditions + + client.delete_topic( + os.environ["WPS_CHAT_ROOM_ID"], + os.environ["WPS_CHAT_TOPIC_ID"], + etag=os.environ["WPS_CHAT_TOPIC_ETAG"], + match_condition=MatchConditions.IfNotModified, + ) + # [END delete_topic] + + +def list_rooms(client: WebPubSubChatServiceClient) -> None: + # [START list_rooms] + for room in client.list_rooms(max_page_size=10): + print(room.id, room.title) + # [END list_rooms] + + +def list_users(client: WebPubSubChatServiceClient) -> None: + # [START list_users] + for user in client.list_users(max_page_size=10): + print(user.id, user.kind) + # [END list_users] + + +def list_rooms_for_user(client: WebPubSubChatServiceClient) -> None: + # [START list_rooms_for_user] + import os + + for room in client.list_rooms_for_user(os.environ["WPS_CHAT_USER_ID"]): + print(room.id, room.title) + # [END list_rooms_for_user] + + +async def async_list_roles(endpoint: str, hub: str) -> None: + # [START async_list_roles] + from azure.identity.aio import DefaultAzureCredential + from azure.messaging.webpubsubchatservice.aio import WebPubSubChatServiceClient + + credential = DefaultAzureCredential() + client = WebPubSubChatServiceClient(endpoint, hub, credential) + try: + async for role in client.list_roles(): + print(role.name) + finally: + await client.close() + await credential.close() + # [END async_list_roles] diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions.py index 15240242232a..3c124062fad2 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions.py @@ -3,63 +3,31 @@ # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------- import os -import uuid - -from azure.core.exceptions import HttpResponseError from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient -from azure.messaging.webpubsubchatservice.models import ( - ChatPermission, - ChatRole, - ChatRoom, - ChatRoomMember, - HumanChatUser, -) + + +def create_role(client): + # [START create_role] + from azure.messaging.webpubsubchatservice.models import ChatPermission, ChatRole + + role = client.create_or_replace_role( + os.environ.get("WPS_CHAT_ROLE_NAME", "user.python_sample"), + ChatRole(permissions=[ChatPermission.USER_CREATE_ROOM]), + ) + print(role.name, role.permissions) + # [END create_role] def main(): connection_string = os.environ.get("WPS_CHAT_CONNECTION_STRING") if not connection_string: - print("Set WPS_CHAT_CONNECTION_STRING to run this sample.") - return + raise SystemExit("Set WPS_CHAT_CONNECTION_STRING to run this sample.") - suffix = uuid.uuid4().hex[:8] - user_role = f"user.sample_{suffix}" - room_role = f"room.sample_{suffix}" - user_id = f"sample-user-{suffix}" - room_id = f"sample-room-{suffix}" with WebPubSubChatServiceClient.from_connection_string( connection_string, os.environ.get("WPS_CHAT_HUB", "test_hub"), ) as client: - try: - client.create_or_replace_role(user_role, ChatRole(permissions=[ChatPermission.USER_CREATE_ROOM])) - client.create_or_replace_role(room_role, ChatRole(permissions=[ChatPermission.ROOM_PUBLISH_MESSAGE])) - client.create_or_replace_user( - user_id, - HumanChatUser(nickname="Sample User", role_name=user_role), - ) - client.create_or_replace_room(room_id, ChatRoom(title="Sample Room")) - client.create_or_replace_room_member( - room_id, - user_id, - ChatRoomMember(role_name=room_role), - ) - for member in client.list_room_members(room_id): - print(member.user_id, member.role_name) - except HttpResponseError as error: - print(f"Chat service request failed: {error}") - raise - finally: - for action, args in ( - (client.delete_room, (room_id,)), - (client.delete_user, (user_id,)), - (client.delete_role, (user_role,)), - (client.delete_role, (room_role,)), - ): - try: - action(*args) - except HttpResponseError: - pass + create_role(client) if __name__ == "__main__": diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions_async.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions_async.py index 3bedcefe5599..5cf8807292d8 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions_async.py @@ -4,61 +4,31 @@ # -------------------------------------------------------------------------- import asyncio import os -import uuid - -from azure.core.exceptions import HttpResponseError from azure.messaging.webpubsubchatservice.aio import WebPubSubChatServiceClient -from azure.messaging.webpubsubchatservice.models import ( - ChatPermission, - ChatRole, - ChatRoom, - ChatRoomMember, - HumanChatUser, -) + + +async def create_role(client): + # [START create_role] + from azure.messaging.webpubsubchatservice.models import ChatPermission, ChatRole + + role = await client.create_or_replace_role( + os.environ.get("WPS_CHAT_ROLE_NAME", "user.python_sample"), + ChatRole(permissions=[ChatPermission.USER_CREATE_ROOM]), + ) + print(role.name, role.permissions) + # [END create_role] async def main(): connection_string = os.environ.get("WPS_CHAT_CONNECTION_STRING") if not connection_string: - print("Set WPS_CHAT_CONNECTION_STRING to run this sample.") - return + raise SystemExit("Set WPS_CHAT_CONNECTION_STRING to run this sample.") - suffix = uuid.uuid4().hex[:8] - user_role = f"user.async_sample_{suffix}" - room_role = f"room.async_sample_{suffix}" - user_id = f"async-sample-user-{suffix}" - room_id = f"async-sample-room-{suffix}" - client = WebPubSubChatServiceClient.from_connection_string( + async with WebPubSubChatServiceClient.from_connection_string( connection_string, os.environ.get("WPS_CHAT_HUB", "test_hub"), - ) - try: - await client.create_or_replace_role(user_role, ChatRole(permissions=[ChatPermission.USER_CREATE_ROOM])) - await client.create_or_replace_role(room_role, ChatRole(permissions=[ChatPermission.ROOM_PUBLISH_MESSAGE])) - await client.create_or_replace_user( - user_id, - HumanChatUser(nickname="Async Sample User", role_name=user_role), - ) - await client.create_or_replace_room(room_id, ChatRoom(title="Async Sample Room")) - await client.create_or_replace_room_member( - room_id, - user_id, - ChatRoomMember(role_name=room_role), - ) - async for member in client.list_room_members(room_id): - print(member.user_id, member.role_name) - finally: - for action, args in ( - (client.delete_room, (room_id,)), - (client.delete_user, (user_id,)), - (client.delete_role, (user_role,)), - (client.delete_role, (room_role,)), - ): - try: - await action(*args) - except HttpResponseError: - pass - await client.close() + ) as client: + await create_role(client) if __name__ == "__main__": diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_client.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_client.py index 37fd350352d3..fe0d5540ba69 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_client.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_client.py @@ -30,7 +30,14 @@ class RequestCaptured(Exception): @pytest.mark.parametrize( "operation_name,arguments", - [("list_roles", ()), ("list_messages", ("conversation",)), ("list_room_members", ("room",))], + [ + ("list_roles", ()), + ("list_messages", ("conversation",)), + ("list_room_members", ("room",)), + ("list_rooms", ()), + ("list_users", ()), + ("list_topics", ("room",)), + ], ) def test_max_page_size_uses_original_wire_name(operation_name, arguments): def capture(pipeline_request): @@ -113,7 +120,7 @@ def test_key_credential_request_uses_full_uri_audience_and_sixty_second_token(): claims = jwt.decode(token, ACCESS_KEY, algorithms=["HS256"], audience=request.url) assert claims["aud"] == request.url - assert "api-version=2026-02-01-preview" in request.url + assert "api-version=2026-08-01-preview" in request.url assert 0 < claims["exp"] - int(time.time()) <= 60 finally: client.close() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_topics.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_topics.py new file mode 100644 index 000000000000..162db40aa19b --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_topics.py @@ -0,0 +1,222 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +import datetime +import json +from unittest.mock import AsyncMock, Mock, patch +from urllib.parse import parse_qs, urlparse + +import pytest +from azure.core import MatchConditions +from azure.core.credentials import AzureKeyCredential +from azure.core.exceptions import ResourceModifiedError + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient +from azure.messaging.webpubsubchatservice.aio import WebPubSubChatServiceClient as AsyncClient +from azure.messaging.webpubsubchatservice.models import ( + ChatRoom, + ChatTopic, + ChatTopicState, + ChatUserRoom, + HumanChatUser, +) + +ENDPOINT = "https://example.webpubsub.azure.com" +TOPIC = { + "id": "topic", + "title": "Announcements", + "createdAt": "2026-08-01T00:00:00Z", + "createdBy": "user", + "state": "Normal", + "conversationId": "c.room.topic", + "etag": '"first"', +} +COLLECTIONS = [ + ("list_rooms", (), "rooms", ChatRoom, {"title": "Room", "defaultConversation": "c.room.default"}), + ("list_users", (), "users", HumanChatUser, {"kind": "Human", "nickname": "User", "roleName": "user.member"}), + ("list_topics", ("room",), "rooms/room/topics", ChatTopic, TOPIC), + ("list_rooms_for_user", ("user",), "users/user/rooms", ChatUserRoom, {"title": "Room"}), +] + + +def _response(payload, status=200): + response = Mock(status_code=status, headers={"content-type": "application/json"}, reason="Test response") + response.json.return_value = payload + response.text.return_value = json.dumps(payload) + return Mock(http_response=response) + + +def _paging_responses(path, fields): + next_link = f"{ENDPOINT}/api/hubs/chat/chat/{path}?api-version=2026-08-01-preview&continuationToken=next" + return [ + _response({"value": [{**fields, "id": "first"}], "nextLink": next_link}), + _response({"value": [{**fields, "id": "second"}]}), + ] + + +def _assert_page_requests(run, path): + first, second = [call.args[0] for call in run.call_args_list] + assert first.method == second.method == "GET" + assert urlparse(first.url).path == f"/api/hubs/chat/chat/{path}" + assert parse_qs(urlparse(first.url).query)["maxpagesize"] == ["1"] + assert parse_qs(urlparse(first.url).query)["api-version"] == ["2026-08-01-preview"] + assert parse_qs(urlparse(second.url).query)["continuationToken"] == ["next"] + assert parse_qs(urlparse(second.url).query)["api-version"] == ["2026-08-01-preview"] + + +def _assert_topic_requests(run): + create, get, update, delete = [call.args[0] for call in run.call_args_list] + assert [request.method for request in (create, get, update, delete)] == ["PUT", "GET", "PATCH", "DELETE"] + assert all( + urlparse(request.url).path == "/api/hubs/chat/chat/rooms/room/topics/topic" + for request in (create, get, update, delete) + ) + assert json.loads(create.content) == {"title": "Announcements"} + assert json.loads(update.content) == {"title": "Announcements", "state": "Archived"} + assert update.headers["Content-Type"] == "application/merge-patch+json" + assert update.headers["If-Match"] == '"first"' + assert delete.headers["If-Match"] == '"second"' + + +@pytest.mark.parametrize("operation,args,path,model,fields", COLLECTIONS) +def test_collection_paging_and_continuation(operation, args, path, model, fields): + with WebPubSubChatServiceClient(ENDPOINT, "chat", AzureKeyCredential("test-key")) as client: + with patch.object(client._client._pipeline, "run", side_effect=_paging_responses(path, fields)) as run: + options = {"params": {"maxpagesize": 1}} if operation == "list_rooms_for_user" else {"max_page_size": 1} + pages = getattr(client, operation)(*args, **options).by_page() + first = list(next(pages)) + assert len(first) == 1 + assert isinstance(first[0], model) + assert pages.continuation_token + resumed = getattr(client, operation)(*args, **options).by_page(pages.continuation_token) + second = list(next(resumed)) + assert [item.id for item in first + second] == ["first", "second"] + assert list(resumed) == [] + _assert_page_requests(run, path) + + +@pytest.mark.asyncio +@pytest.mark.parametrize("operation,args,path,model,fields", COLLECTIONS) +async def test_async_collection_paging_and_continuation(operation, args, path, model, fields): + async with AsyncClient(ENDPOINT, "chat", AzureKeyCredential("test-key")) as client: + with patch.object( + client._client._pipeline, "run", new_callable=AsyncMock, side_effect=_paging_responses(path, fields) + ) as run: + options = {"params": {"maxpagesize": 1}} if operation == "list_rooms_for_user" else {"max_page_size": 1} + pages = getattr(client, operation)(*args, **options).by_page() + first = [item async for item in await anext(pages)] + assert len(first) == 1 + assert isinstance(first[0], model) + assert pages.continuation_token + resumed = getattr(client, operation)(*args, **options).by_page(pages.continuation_token) + second = [item async for item in await anext(resumed)] + assert [item.id for item in first + second] == ["first", "second"] + assert [page async for page in resumed] == [] + _assert_page_requests(run, path) + + +def test_topic_serialization_lifecycle_and_etag(): + archived = {**TOPIC, "state": "Archived", "etag": '"second"'} + with WebPubSubChatServiceClient(ENDPOINT, "chat", AzureKeyCredential("test-key")) as client: + with patch.object( + client._client._pipeline, + "run", + side_effect=[_response(TOPIC, 201), _response(TOPIC), _response(archived), _response({}, 204)], + ) as run: + topic = client.create_or_replace_topic( + "room", "topic", ChatTopic({"title": TOPIC["title"], "id": TOPIC["id"], "etag": TOPIC["etag"]}) + ) + assert topic.created_at == datetime.datetime(2026, 8, 1, tzinfo=datetime.timezone.utc) + fetched = client.get_topic("room", "topic") + assert fetched.state == ChatTopicState.NORMAL + updated = client.update_topic( + "room", + "topic", + ChatTopic(title=topic.title, state=ChatTopicState.ARCHIVED), + etag=fetched.etag, + match_condition=MatchConditions.IfNotModified, + ) + assert updated.state == ChatTopicState.ARCHIVED + assert updated.conversation_id == topic.conversation_id + assert ( + client.delete_topic("room", "topic", etag=updated.etag, match_condition=MatchConditions.IfNotModified) + is None + ) + _assert_topic_requests(run) + + +@pytest.mark.asyncio +async def test_async_topic_serialization_lifecycle_and_etag(): + archived = {**TOPIC, "state": "Archived", "etag": '"second"'} + async with AsyncClient(ENDPOINT, "chat", AzureKeyCredential("test-key")) as client: + with patch.object( + client._client._pipeline, + "run", + new_callable=AsyncMock, + side_effect=[_response(TOPIC, 201), _response(TOPIC), _response(archived), _response({}, 204)], + ) as run: + topic = await client.create_or_replace_topic( + "room", "topic", ChatTopic({"title": TOPIC["title"], "id": TOPIC["id"], "etag": TOPIC["etag"]}) + ) + assert topic.created_at == datetime.datetime(2026, 8, 1, tzinfo=datetime.timezone.utc) + fetched = await client.get_topic("room", "topic") + assert fetched.state == ChatTopicState.NORMAL + updated = await client.update_topic( + "room", + "topic", + ChatTopic(title=topic.title, state=ChatTopicState.ARCHIVED), + etag=fetched.etag, + match_condition=MatchConditions.IfNotModified, + ) + assert updated.state == ChatTopicState.ARCHIVED + assert updated.conversation_id == topic.conversation_id + assert ( + await client.delete_topic( + "room", "topic", etag=updated.etag, match_condition=MatchConditions.IfNotModified + ) + is None + ) + _assert_topic_requests(run) + + +def test_topic_stale_etag_surfaces_service_error(): + with WebPubSubChatServiceClient(ENDPOINT, "chat", AzureKeyCredential("test-key")) as client: + with patch.object( + client._client._pipeline, + "run", + return_value=_response({"error": {"code": "PreconditionFailed", "message": "Stale ETag"}}, 412), + ): + with pytest.raises(ResourceModifiedError) as error: + client.update_topic( + "room", + "topic", + ChatTopic(title="Title", state=ChatTopicState.ARCHIVED), + etag='"stale"', + match_condition=MatchConditions.IfNotModified, + ) + assert error.value.status_code == 412 + + +@pytest.mark.asyncio +async def test_async_topic_stale_etag_surfaces_service_error(): + async with AsyncClient(ENDPOINT, "chat", AzureKeyCredential("test-key")) as client: + with patch.object( + client._client._pipeline, + "run", + new_callable=AsyncMock, + return_value=_response({"error": {"code": "PreconditionFailed", "message": "Stale ETag"}}, 412), + ): + with pytest.raises(ResourceModifiedError) as error: + await client.update_topic( + "room", + "topic", + ChatTopic(title="Title", state=ChatTopicState.ARCHIVED), + etag='"stale"', + match_condition=MatchConditions.IfNotModified, + ) + assert error.value.status_code == 412 + + +def test_topic_unknown_state_remains_extensible(): + assert ChatTopic({**TOPIC, "state": "FutureState"}).state == "FutureState" diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_topics_live.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_topics_live.py new file mode 100644 index 000000000000..6634e2c5ebf7 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_topics_live.py @@ -0,0 +1,123 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +from devtools_testutils import recorded_by_proxy +import pytest + +from azure.core import MatchConditions +from azure.core.exceptions import HttpResponseError +from azure.messaging.webpubsubchatservice.models import ( + ChatPermission, + ChatRole, + ChatRoom, + ChatRoomMember, + ChatTopic, + ChatTopicState, + HumanChatUser, +) +from testcase import WebPubSubChatPreparer, WebPubSubChatTest + + +def _assert_resumable_pages(paged): + pages = paged.by_page() + first = list(next(pages)) + assert len(first) == 1 + assert pages.continuation_token + resumed = paged.by_page(pages.continuation_token) + second = list(next(resumed)) + assert len(second) == 1 + assert first[0].id != second[0].id + + +class TestWebPubSubChatTopicsLive(WebPubSubChatTest): + @WebPubSubChatPreparer() + @recorded_by_proxy + def test_topic_lifecycle_and_paging(self, wps_chat_endpoint): + client = self.create_client(wps_chat_endpoint) + # Existing operations are not yet routed under the new version on DevINT. + setup = self.create_client(wps_chat_endpoint, api_version="2026-02-01-preview") + room_id = "python-e2e-topics" + try: + room = setup.create_or_replace_room(room_id, ChatRoom(title="Topic E2E")) + assert all(topic.conversation_id == room.default_conversation for topic in client.list_topics(room_id)) + for topic_id in ("first", "second"): + topic = client.create_or_replace_topic(room_id, topic_id, ChatTopic({"title": topic_id})) + assert topic.id == topic_id + assert topic.title == topic_id + assert topic.state == ChatTopicState.NORMAL + assert topic.created_at + assert topic.created_by + assert topic.etag + conversation = setup.get_conversation(topic.conversation_id) + assert conversation.id == topic.conversation_id + assert conversation.parent_room == room_id + assert list(setup.list_messages(topic.conversation_id)) == [] + + assert {topic.id for topic in client.list_topics(room_id, max_page_size=1)}.issuperset({"first", "second"}) + _assert_resumable_pages(client.list_topics(room_id, max_page_size=1)) + fetched = client.get_topic(room_id, "first") + archived = client.update_topic( + room_id, + "first", + ChatTopic(title="Archived topic", state=ChatTopicState.ARCHIVED), + etag=fetched.etag, + match_condition=MatchConditions.IfNotModified, + ) + assert archived.title == "Archived topic" + assert archived.state == ChatTopicState.ARCHIVED + assert archived.conversation_id == fetched.conversation_id + assert archived.etag != fetched.etag + assert client.get_topic(room_id, "first").state == ChatTopicState.ARCHIVED + with pytest.raises(HttpResponseError) as error: + client.update_topic( + room_id, + "first", + ChatTopic(title="Stale update", state=ChatTopicState.NORMAL), + etag=fetched.etag, + match_condition=MatchConditions.IfNotModified, + ) + assert error.value.status_code == 412 + client.delete_topic(room_id, "first", etag=archived.etag, match_condition=MatchConditions.IfNotModified) + finally: + self.cleanup(setup.delete_room, room_id) + setup.close() + client.close() + + @WebPubSubChatPreparer() + @recorded_by_proxy + def test_room_user_and_user_room_collections(self, wps_chat_endpoint): + client = self.create_client(wps_chat_endpoint) + setup = self.create_client(wps_chat_endpoint, api_version="2026-02-01-preview") + room_ids = ["python-e2e-collection-1", "python-e2e-collection-2"] + user_ids = ["python-e2e-collection-user-1", "python-e2e-collection-user-2"] + user_role = "user.python_e2e_collections" + room_role = "room.python_e2e_collections" + try: + setup.create_or_replace_role(user_role, ChatRole(permissions=[ChatPermission.USER_CREATE_ROOM])) + setup.create_or_replace_role(room_role, ChatRole(permissions=[ChatPermission.ROOM_PUBLISH_MESSAGE])) + for user_id in user_ids: + setup.create_or_replace_user(user_id, HumanChatUser(nickname=user_id, role_name=user_role)) + assert list(client.list_rooms_for_user(user_ids[0])) == [] + for room_id in room_ids: + setup.create_or_replace_room(room_id, ChatRoom(title=room_id)) + setup.create_or_replace_room_member(room_id, user_ids[0], ChatRoomMember(role_name=room_role)) + assert {room.id for room in client.list_rooms(max_page_size=1)}.issuperset(room_ids) + users = list(client.list_users(max_page_size=1)) + assert {user.id for user in users}.issuperset(user_ids) + assert all(isinstance(user, HumanChatUser) for user in users if user.id in user_ids) + assert {room.id for room in client.list_rooms_for_user(user_ids[0])} == set(room_ids) + _assert_resumable_pages(client.list_rooms(max_page_size=1)) + _assert_resumable_pages(client.list_users(max_page_size=1)) + _assert_resumable_pages(client.list_rooms_for_user(user_ids[0], params={"maxpagesize": 1})) + setup.delete_room_member(room_ids[0], user_ids[0]) + assert {room.id for room in client.list_rooms_for_user(user_ids[0])} == {room_ids[1]} + finally: + for room_id in room_ids: + self.cleanup(setup.delete_room, room_id) + for user_id in user_ids: + self.cleanup(setup.delete_user, user_id) + self.cleanup(setup.delete_role, user_role) + self.cleanup(setup.delete_role, room_role) + setup.close() + client.close() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_topics_live_async.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_topics_live_async.py new file mode 100644 index 000000000000..d5fbdc9651bf --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_topics_live_async.py @@ -0,0 +1,136 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +import pytest +from devtools_testutils.aio import recorded_by_proxy_async + +from azure.core import MatchConditions +from azure.core.exceptions import HttpResponseError +from azure.messaging.webpubsubchatservice.models import ( + ChatPermission, + ChatRole, + ChatRoom, + ChatRoomMember, + ChatTopic, + ChatTopicState, + HumanChatUser, +) +from testcase import WebPubSubChatPreparer, WebPubSubChatTest + + +async def _collect(paged): + return [item async for item in paged] + + +async def _assert_resumable_pages(paged): + pages = paged.by_page() + first = await _collect(await anext(pages)) + assert len(first) == 1 + assert pages.continuation_token + resumed = paged.by_page(pages.continuation_token) + second = await _collect(await anext(resumed)) + assert len(second) == 1 + assert first[0].id != second[0].id + + +class TestWebPubSubChatTopicsLiveAsync(WebPubSubChatTest): + @WebPubSubChatPreparer() + @recorded_by_proxy_async + @pytest.mark.asyncio + async def test_async_topic_lifecycle_and_paging(self, wps_chat_endpoint): + client = self.create_async_client(wps_chat_endpoint) + # Existing operations are not yet routed under the new version on DevINT. + setup = self.create_async_client(wps_chat_endpoint, api_version="2026-02-01-preview") + room_id = "python-async-e2e-topics" + try: + room = await setup.create_or_replace_room(room_id, ChatRoom(title="Async Topic E2E")) + assert all( + topic.conversation_id == room.default_conversation + for topic in await _collect(client.list_topics(room_id)) + ) + for topic_id in ("first", "second"): + topic = await client.create_or_replace_topic(room_id, topic_id, ChatTopic({"title": topic_id})) + assert topic.id == topic_id + assert topic.title == topic_id + assert topic.state == ChatTopicState.NORMAL + assert topic.created_at + assert topic.created_by + assert topic.etag + conversation = await setup.get_conversation(topic.conversation_id) + assert conversation.id == topic.conversation_id + assert conversation.parent_room == room_id + assert await _collect(setup.list_messages(topic.conversation_id)) == [] + + assert {topic.id async for topic in client.list_topics(room_id, max_page_size=1)}.issuperset( + {"first", "second"} + ) + await _assert_resumable_pages(client.list_topics(room_id, max_page_size=1)) + fetched = await client.get_topic(room_id, "first") + archived = await client.update_topic( + room_id, + "first", + ChatTopic(title="Archived topic", state=ChatTopicState.ARCHIVED), + etag=fetched.etag, + match_condition=MatchConditions.IfNotModified, + ) + assert archived.title == "Archived topic" + assert archived.state == ChatTopicState.ARCHIVED + assert archived.conversation_id == fetched.conversation_id + assert archived.etag != fetched.etag + assert (await client.get_topic(room_id, "first")).state == ChatTopicState.ARCHIVED + with pytest.raises(HttpResponseError) as error: + await client.update_topic( + room_id, + "first", + ChatTopic(title="Stale update", state=ChatTopicState.NORMAL), + etag=fetched.etag, + match_condition=MatchConditions.IfNotModified, + ) + assert error.value.status_code == 412 + await client.delete_topic( + room_id, "first", etag=archived.etag, match_condition=MatchConditions.IfNotModified + ) + finally: + await self.cleanup_async(setup.delete_room, room_id) + await setup.close() + await client.close() + + @WebPubSubChatPreparer() + @recorded_by_proxy_async + @pytest.mark.asyncio + async def test_async_room_user_and_user_room_collections(self, wps_chat_endpoint): + client = self.create_async_client(wps_chat_endpoint) + setup = self.create_async_client(wps_chat_endpoint, api_version="2026-02-01-preview") + room_ids = ["python-async-e2e-collection-1", "python-async-e2e-collection-2"] + user_ids = ["python-async-e2e-collection-user-1", "python-async-e2e-collection-user-2"] + user_role = "user.python_async_e2e_collections" + room_role = "room.python_async_e2e_collections" + try: + await setup.create_or_replace_role(user_role, ChatRole(permissions=[ChatPermission.USER_CREATE_ROOM])) + await setup.create_or_replace_role(room_role, ChatRole(permissions=[ChatPermission.ROOM_PUBLISH_MESSAGE])) + for user_id in user_ids: + await setup.create_or_replace_user(user_id, HumanChatUser(nickname=user_id, role_name=user_role)) + assert await _collect(client.list_rooms_for_user(user_ids[0])) == [] + for room_id in room_ids: + await setup.create_or_replace_room(room_id, ChatRoom(title=room_id)) + await setup.create_or_replace_room_member(room_id, user_ids[0], ChatRoomMember(role_name=room_role)) + assert {room.id async for room in client.list_rooms(max_page_size=1)}.issuperset(room_ids) + users = await _collect(client.list_users(max_page_size=1)) + assert {user.id for user in users}.issuperset(user_ids) + assert all(isinstance(user, HumanChatUser) for user in users if user.id in user_ids) + assert {room.id async for room in client.list_rooms_for_user(user_ids[0])} == set(room_ids) + await _assert_resumable_pages(client.list_rooms(max_page_size=1)) + await _assert_resumable_pages(client.list_users(max_page_size=1)) + await _assert_resumable_pages(client.list_rooms_for_user(user_ids[0], params={"maxpagesize": 1})) + await setup.delete_room_member(room_ids[0], user_ids[0]) + assert {room.id async for room in client.list_rooms_for_user(user_ids[0])} == {room_ids[1]} + finally: + for room_id in room_ids: + await self.cleanup_async(setup.delete_room, room_id) + for user_id in user_ids: + await self.cleanup_async(setup.delete_user, user_id) + await self.cleanup_async(setup.delete_role, user_role) + await self.cleanup_async(setup.delete_role, room_role) + await setup.close() + await client.close() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/testcase.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/testcase.py index d3a6da4bbc00..c75cc9019a1a 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/testcase.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/testcase.py @@ -22,18 +22,20 @@ class WebPubSubChatTest(AzureRecordedTestCase): - def create_client(self, endpoint): + def create_client(self, endpoint, **kwargs): return WebPubSubChatServiceClient( endpoint, "test_hub", self.get_credential(WebPubSubChatServiceClient), + **kwargs, ) - def create_async_client(self, endpoint): + def create_async_client(self, endpoint, **kwargs): return AsyncWebPubSubChatServiceClient( endpoint, "test_hub", self.get_credential(AsyncWebPubSubChatServiceClient, is_async=True), + **kwargs, ) @staticmethod diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml index fcf7c01e091f..e2838f173bfd 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml @@ -1,5 +1,5 @@ directory: specification/webpubsub/data-plane/WebPubSubChat -commit: 15202f7ede10316a7cecc6911f887eb8655f87ce +commit: d0de34fa02714f3bd535fe2833c645a348a3bcaa repo: Azure/azure-rest-api-specs additionalDirectories: [] entrypointFile: client.tsp From 27a2d80ac93e1f3e5a4a37c7548847917616c9c0 Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Thu, 8 Oct 2026 22:43:55 -0700 Subject: [PATCH 02/22] Name Chat tests by API version and skip blocked legacy suites --- sdk/webpubsub/azure-messaging-webpubsubchatservice/assets.json | 2 +- .../tests/{test_topics.py => test_2026_08_01_preview.py} | 0 .../{test_topics_live.py => test_2026_08_01_preview_live.py} | 0 ...pics_live_async.py => test_2026_08_01_preview_live_async.py} | 0 .../azure-messaging-webpubsubchatservice/tests/test_live.py | 1 + .../tests/test_live_async.py | 1 + 6 files changed, 3 insertions(+), 1 deletion(-) rename sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/{test_topics.py => test_2026_08_01_preview.py} (100%) rename sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/{test_topics_live.py => test_2026_08_01_preview_live.py} (100%) rename sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/{test_topics_live_async.py => test_2026_08_01_preview_live_async.py} (100%) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/assets.json b/sdk/webpubsub/azure-messaging-webpubsubchatservice/assets.json index 23b47f079d5c..cf95420bc727 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/assets.json +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/webpubsub/azure-messaging-webpubsubchatservice", - "Tag": "python/webpubsub/azure-messaging-webpubsubchatservice_1aa22820d8" + "Tag": "python/webpubsub/azure-messaging-webpubsubchatservice_a3e1866f06" } diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_topics.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview.py similarity index 100% rename from sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_topics.py rename to sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview.py diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_topics_live.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live.py similarity index 100% rename from sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_topics_live.py rename to sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live.py diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_topics_live_async.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live_async.py similarity index 100% rename from sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_topics_live_async.py rename to sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live_async.py diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live.py index 44eb9d3ded9c..b9a3101b27da 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live.py @@ -24,6 +24,7 @@ ) +@pytest.mark.skip(reason="Inherited operations await the runtime 2026-08-01-preview routing fix.") class TestWebPubSubChatLive(WebPubSubChatTest): @WebPubSubChatPreparer() @recorded_by_proxy diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live_async.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live_async.py index 157929fe33a8..295ac903799b 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live_async.py @@ -28,6 +28,7 @@ async def _collect(paged): return [item async for item in paged] +@pytest.mark.skip(reason="Inherited operations await the runtime 2026-08-01-preview routing fix.") class TestWebPubSubChatLiveAsync(WebPubSubChatTest): @WebPubSubChatPreparer() @recorded_by_proxy_async From 7b186caefeece032b978d09c244f6876c2f3995b Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Fri, 9 Oct 2026 22:07:56 +1100 Subject: [PATCH 03/22] Fix Chat collection paging and prepare 1.0.0b2 --- .../CHANGELOG.md | 7 ++++ .../README.md | 26 ++++++------ .../api.md | 10 ++++- .../api.metadata.yml | 4 +- .../apiview-properties.json | 2 +- .../_operations/_operations.py | 40 +++++++++++++++++-- .../webpubsubchatservice/_version.py | 2 +- .../aio/_operations/_operations.py | 27 ++++++++++++- .../tests/test_2026_08_01_preview.py | 5 ++- .../tests/test_2026_08_01_preview_live.py | 2 +- .../test_2026_08_01_preview_live_async.py | 2 +- .../tsp-location.yaml | 4 +- 12 files changed, 101 insertions(+), 30 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md index b2d8f64338bc..9006db483fc9 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md @@ -1,5 +1,12 @@ # Release History +## 1.0.0b2 (Unreleased) + +### Features Added + + - Added topic lifecycle operations (create or replace, list, get, update, and soft delete) + - Added room, user, and user-room collection operations + ## 1.0.0b1 (2026-10-08) ### Features Added diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md index ecb75a6a771c..9f934aa57d77 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md @@ -147,7 +147,7 @@ Messages sent to a conversation are delivered in real time to the room's connect ### Topic -A topic is a named thread within a room with its own conversation. The service assigns its +A topic is a named thread within a room with its own conversation. The service returns its ID, creation time, creator, conversation ID, and ETag in responses. Topic IDs are specified by the application in the request path. Topics have a lifecycle state of `Normal`, `Archived`, or `SoftDeleted`. Creating a topic requires a title; updating a topic can change its title @@ -199,8 +199,8 @@ print(role.name, role.permissions) -See [sample_roles_and_permissions.py](samples/sample_roles_and_permissions.py) -and [sample_roles_and_permissions_async.py](samples/sample_roles_and_permissions_async.py) +See [sample_roles_and_permissions.py](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions.py) +and [sample_roles_and_permissions_async.py](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions_async.py) for runnable model-and-enum examples. The selected role is created or replaced and remains in the hub; these samples do not create users or rooms. @@ -380,10 +380,10 @@ For conditional updates and deletes, pass the current ETag with that another caller has changed. Deleting a topic is a soft delete. For individual API calls, see the generated samples for -[create or replace](generated_samples/create_or_replace_topic.py), -[list](generated_samples/list_topics.py), [get](generated_samples/get_topic.py), -[update](generated_samples/update_topic.py), and -[delete](generated_samples/delete_topic.py). +[create or replace](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_topic.py), +[list](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_topics.py), [get](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_topic.py), +[update](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/update_topic.py), and +[delete](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_topic.py). ### List rooms and users @@ -424,9 +424,9 @@ for room in client.list_rooms_for_user(os.environ["WPS_CHAT_USER_ID"]): -For basic list calls, see [list_rooms.py](generated_samples/list_rooms.py), -[list_users.py](generated_samples/list_users.py), and -[list_rooms_for_user.py](generated_samples/list_rooms_for_user.py). +For basic list calls, see [list_rooms.py](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_rooms.py), +[list_users.py](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_users.py), and +[list_rooms_for_user.py](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_rooms_for_user.py). Listing rooms for a user requires an existing user ID. Collection iterators automatically fetch subsequent pages. @@ -434,7 +434,7 @@ Collection iterators automatically fetch subsequent pages. ### Use the asynchronous client Run this snippet inside an async function with an authenticated async `client`; see -[sample_client_access_async.py](samples/sample_client_access_async.py) +[sample_client_access_async.py](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_client_access_async.py) for the complete program. @@ -468,7 +468,7 @@ python samples/sample_roles_and_permissions_async.py Service operations raise `HttpResponseError` or a more specific subclass when a request fails: -The [sample_errors.py](samples/sample_errors.py) example reads an existing role, +The [sample_errors.py](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_errors.py) example reads an existing role, prints the status on failure, and re-raises the error. Set `WPS_CHAT_ROLE_NAME` to the role to read (default: `user.python_sample`). @@ -532,7 +532,7 @@ If a newly sent message does not appear immediately, confirm that the sending us ## Next steps -Explore the [README snippet sources](samples/sample_readme_snippets.py) and +Explore the [README snippet sources](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_readme_snippets.py) and [complete package samples][samples] to learn how to: - Authenticate with a connection string, access key, or Microsoft Entra ID. diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md index 8f19e3275a2f..9592fdae3b77 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md @@ -366,10 +366,13 @@ namespace azure.messaging.webpubsubchatservice ) -> ItemPaged[ChatRoom]: ... @distributed_trace - @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'user_id', 'accept']}, api_versions_list=['2026-08-01-preview']) + @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'user_id', 'max_page_size', 'continuation_token_parameter', 'accept']}, api_versions_list=['2026-08-01-preview']) def list_rooms_for_user( self, user_id: str, + *, + continuation_token_parameter: Optional[str] = ..., + max_page_size: Optional[int] = ..., **kwargs: Any ) -> ItemPaged[ChatUserRoom]: ... @@ -842,10 +845,13 @@ namespace azure.messaging.webpubsubchatservice.aio ) -> AsyncItemPaged[ChatRoom]: ... @distributed_trace - @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'user_id', 'accept']}, api_versions_list=['2026-08-01-preview']) + @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'user_id', 'max_page_size', 'continuation_token_parameter', 'accept']}, api_versions_list=['2026-08-01-preview']) def list_rooms_for_user( self, user_id: str, + *, + continuation_token_parameter: Optional[str] = ..., + max_page_size: Optional[int] = ..., **kwargs: Any ) -> AsyncItemPaged[ChatUserRoom]: ... diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml index efb34228ab94..59491ce85965 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml @@ -1,4 +1,4 @@ -apiMdSha256: 334d932dcbe42254466b2f5c35cf88e11d76f52e8c0cdecb366bc6e69a1b3a39 -packageVersion: 1.0.0b1 +apiMdSha256: 0c69f8dd9983b0c02f1a9926c54a0318c2235a3fde96dc5de5fce6ce63322092 +packageVersion: 1.0.0b2 parserVersion: 0.3.31 pythonVersion: 3.12.10 diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json b/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json index 4348c877fe48..8c50aca07375 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json @@ -65,5 +65,5 @@ "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.list_rooms_for_user": "WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser", "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.list_rooms_for_user": "WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser" }, - "CrossLanguageVersion": "7f78e3e74021" + "CrossLanguageVersion": "9db8b5aee1c7" } \ No newline at end of file diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_operations/_operations.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_operations/_operations.py index 4657924e7dfc..58e50fb82ec7 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_operations/_operations.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_operations/_operations.py @@ -903,7 +903,12 @@ def build_web_pub_sub_chat_service_delete_user_request( # pylint: disable=name- def build_web_pub_sub_chat_service_list_rooms_for_user_request( # pylint: disable=name-too-long - user_id: str, hub: str, **kwargs: Any + user_id: str, + hub: str, + *, + max_page_size: Optional[int] = None, + continuation_token_parameter: Optional[str] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -922,6 +927,12 @@ def build_web_pub_sub_chat_service_list_rooms_for_user_request( # pylint: disab # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if max_page_size is not None: + _params["maxpagesize"] = _SERIALIZER.query("max_page_size", max_page_size, "int") + if continuation_token_parameter is not None: + _params["continuationToken"] = _SERIALIZER.query( + "continuation_token_parameter", continuation_token_parameter, "str" + ) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -3879,16 +3890,37 @@ def delete_user( # pylint: disable=inconsistent-return-statements @distributed_trace @api_version_validation( method_added_on="2026-08-01-preview", - params_added_on={"2026-08-01-preview": ["api_version", "hub", "user_id", "accept"]}, + params_added_on={ + "2026-08-01-preview": [ + "api_version", + "hub", + "user_id", + "max_page_size", + "continuation_token_parameter", + "accept", + ] + }, api_versions_list=["2026-08-01-preview"], ) - def list_rooms_for_user(self, user_id: str, **kwargs: Any) -> ItemPaged["_models.ChatUserRoom"]: + def list_rooms_for_user( + self, + user_id: str, + *, + max_page_size: Optional[int] = None, + continuation_token_parameter: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.ChatUserRoom"]: """List rooms for a user with pagination. List rooms for a user with pagination. :param user_id: User identifier. Required. :type user_id: str + :keyword max_page_size: The maximum number of result items per page. Default value is None. + :paramtype max_page_size: int + :keyword continuation_token_parameter: Continuation token for pagination. Default value is + None. + :paramtype continuation_token_parameter: str :return: An iterator like instance of ChatUserRoom :rtype: ~azure.core.paging.ItemPaged[~azure.messaging.webpubsubchatservice.models.ChatUserRoom] :raises ~azure.core.exceptions.HttpResponseError: @@ -3912,6 +3944,8 @@ def prepare_request(next_link=None): _request = build_web_pub_sub_chat_service_list_rooms_for_user_request( user_id=user_id, hub=self._config.hub, + max_page_size=max_page_size, + continuation_token_parameter=continuation_token_parameter, api_version=self._config.api_version, headers=_headers, params=_params, diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_version.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_version.py index be71c81bd282..bbcd28b4aa67 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_version.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0b1" +VERSION = "1.0.0b2" diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_operations/_operations.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_operations/_operations.py index d3c5e3589ff6..0b8d1febae20 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_operations/_operations.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_operations/_operations.py @@ -2987,16 +2987,37 @@ async def delete_user( @distributed_trace @api_version_validation( method_added_on="2026-08-01-preview", - params_added_on={"2026-08-01-preview": ["api_version", "hub", "user_id", "accept"]}, + params_added_on={ + "2026-08-01-preview": [ + "api_version", + "hub", + "user_id", + "max_page_size", + "continuation_token_parameter", + "accept", + ] + }, api_versions_list=["2026-08-01-preview"], ) - def list_rooms_for_user(self, user_id: str, **kwargs: Any) -> AsyncItemPaged["_models.ChatUserRoom"]: + def list_rooms_for_user( + self, + user_id: str, + *, + max_page_size: Optional[int] = None, + continuation_token_parameter: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.ChatUserRoom"]: """List rooms for a user with pagination. List rooms for a user with pagination. :param user_id: User identifier. Required. :type user_id: str + :keyword max_page_size: The maximum number of result items per page. Default value is None. + :paramtype max_page_size: int + :keyword continuation_token_parameter: Continuation token for pagination. Default value is + None. + :paramtype continuation_token_parameter: str :return: An iterator like instance of ChatUserRoom :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.messaging.webpubsubchatservice.models.ChatUserRoom] @@ -3021,6 +3042,8 @@ def prepare_request(next_link=None): _request = build_web_pub_sub_chat_service_list_rooms_for_user_request( user_id=user_id, hub=self._config.hub, + max_page_size=max_page_size, + continuation_token_parameter=continuation_token_parameter, api_version=self._config.api_version, headers=_headers, params=_params, diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview.py index 162db40aa19b..15f809471591 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview.py @@ -60,6 +60,7 @@ def _assert_page_requests(run, path): assert first.method == second.method == "GET" assert urlparse(first.url).path == f"/api/hubs/chat/chat/{path}" assert parse_qs(urlparse(first.url).query)["maxpagesize"] == ["1"] + assert parse_qs(urlparse(first.url).query)["continuationToken"] == ["initial+/=token"] assert parse_qs(urlparse(first.url).query)["api-version"] == ["2026-08-01-preview"] assert parse_qs(urlparse(second.url).query)["continuationToken"] == ["next"] assert parse_qs(urlparse(second.url).query)["api-version"] == ["2026-08-01-preview"] @@ -83,7 +84,7 @@ def _assert_topic_requests(run): def test_collection_paging_and_continuation(operation, args, path, model, fields): with WebPubSubChatServiceClient(ENDPOINT, "chat", AzureKeyCredential("test-key")) as client: with patch.object(client._client._pipeline, "run", side_effect=_paging_responses(path, fields)) as run: - options = {"params": {"maxpagesize": 1}} if operation == "list_rooms_for_user" else {"max_page_size": 1} + options = {"max_page_size": 1, "continuation_token_parameter": "initial+/=token"} pages = getattr(client, operation)(*args, **options).by_page() first = list(next(pages)) assert len(first) == 1 @@ -103,7 +104,7 @@ async def test_async_collection_paging_and_continuation(operation, args, path, m with patch.object( client._client._pipeline, "run", new_callable=AsyncMock, side_effect=_paging_responses(path, fields) ) as run: - options = {"params": {"maxpagesize": 1}} if operation == "list_rooms_for_user" else {"max_page_size": 1} + options = {"max_page_size": 1, "continuation_token_parameter": "initial+/=token"} pages = getattr(client, operation)(*args, **options).by_page() first = [item async for item in await anext(pages)] assert len(first) == 1 diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live.py index 6634e2c5ebf7..e1906965631b 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live.py @@ -109,7 +109,7 @@ def test_room_user_and_user_room_collections(self, wps_chat_endpoint): assert {room.id for room in client.list_rooms_for_user(user_ids[0])} == set(room_ids) _assert_resumable_pages(client.list_rooms(max_page_size=1)) _assert_resumable_pages(client.list_users(max_page_size=1)) - _assert_resumable_pages(client.list_rooms_for_user(user_ids[0], params={"maxpagesize": 1})) + _assert_resumable_pages(client.list_rooms_for_user(user_ids[0], max_page_size=1)) setup.delete_room_member(room_ids[0], user_ids[0]) assert {room.id for room in client.list_rooms_for_user(user_ids[0])} == {room_ids[1]} finally: diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live_async.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live_async.py index d5fbdc9651bf..0ab753440973 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live_async.py @@ -122,7 +122,7 @@ async def test_async_room_user_and_user_room_collections(self, wps_chat_endpoint assert {room.id async for room in client.list_rooms_for_user(user_ids[0])} == set(room_ids) await _assert_resumable_pages(client.list_rooms(max_page_size=1)) await _assert_resumable_pages(client.list_users(max_page_size=1)) - await _assert_resumable_pages(client.list_rooms_for_user(user_ids[0], params={"maxpagesize": 1})) + await _assert_resumable_pages(client.list_rooms_for_user(user_ids[0], max_page_size=1)) await setup.delete_room_member(room_ids[0], user_ids[0]) assert {room.id async for room in client.list_rooms_for_user(user_ids[0])} == {room_ids[1]} finally: diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml index e2838f173bfd..e73da1923956 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml @@ -1,5 +1,5 @@ directory: specification/webpubsub/data-plane/WebPubSubChat -commit: d0de34fa02714f3bd535fe2833c645a348a3bcaa +commit: 44c2a4f48a4a2e4d77f9658749f990bcf9ab110f repo: Azure/azure-rest-api-specs additionalDirectories: [] -entrypointFile: client.tsp +entrypointFile: client.tsp \ No newline at end of file From 09f9ccbae85193f19ec9e83faa1292d67dba8f44 Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Fri, 9 Oct 2026 22:48:56 +1100 Subject: [PATCH 04/22] Fix Chat sample skips and track review resolutions Report missing live configuration without failing the samples runner, and cover exit status and setup guidance in subprocess regressions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/copilot-instructions.md | 8 ++++++ .../samples/sample_errors.py | 3 +- .../samples/sample_logging.py | 3 +- .../samples/sample_roles_and_permissions.py | 3 +- .../sample_roles_and_permissions_async.py | 3 +- .../tests/test_client.py | 28 +++++++++++++++++++ 6 files changed, 44 insertions(+), 4 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index e972fe6795ce..c023493884b5 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -16,3 +16,11 @@ guidance. local validation. - Prefer focused changes and the smallest existing validation that covers them. Do not claim a check passed unless it was run successfully. + +## Learnings + +When addressing PR feedback, reply in each addressed review thread with the +change or deliberate no-change decision and validation evidence. After pushing, +recheck previously addressed threads and resolve those whose fixes are now +published and verified. Do not leave delivered fixes open, or resolve a thread +merely because a fix exists locally; explain and retain unresolved blockers. diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_errors.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_errors.py index 646c05208454..c87592a687b1 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_errors.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_errors.py @@ -23,7 +23,8 @@ def handle_service_errors(client): def main(): if not os.environ.get("WPS_CHAT_CONNECTION_STRING"): - raise SystemExit("Set WPS_CHAT_CONNECTION_STRING to run this sample.") + print("Set WPS_CHAT_CONNECTION_STRING to run this sample.") + return with WebPubSubChatServiceClient.from_connection_string( os.environ["WPS_CHAT_CONNECTION_STRING"], os.environ.get("WPS_CHAT_HUB", "test_hub") ) as client: diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_logging.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_logging.py index 70ab1a4c7361..9c45013a3ac0 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_logging.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_logging.py @@ -31,7 +31,8 @@ def configure_logging(): def main(): if not os.environ.get("WPS_CHAT_ENDPOINT"): - raise SystemExit("Set WPS_CHAT_ENDPOINT to run this sample.") + print("Set WPS_CHAT_ENDPOINT to run this sample.") + return configure_logging() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions.py index 3c124062fad2..886e5589941d 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions.py @@ -21,7 +21,8 @@ def create_role(client): def main(): connection_string = os.environ.get("WPS_CHAT_CONNECTION_STRING") if not connection_string: - raise SystemExit("Set WPS_CHAT_CONNECTION_STRING to run this sample.") + print("Set WPS_CHAT_CONNECTION_STRING to run this sample.") + return with WebPubSubChatServiceClient.from_connection_string( connection_string, diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions_async.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions_async.py index 5cf8807292d8..03cdb4b8f22d 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions_async.py @@ -22,7 +22,8 @@ async def create_role(client): async def main(): connection_string = os.environ.get("WPS_CHAT_CONNECTION_STRING") if not connection_string: - raise SystemExit("Set WPS_CHAT_CONNECTION_STRING to run this sample.") + print("Set WPS_CHAT_CONNECTION_STRING to run this sample.") + return async with WebPubSubChatServiceClient.from_connection_string( connection_string, diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_client.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_client.py index fe0d5540ba69..3ef6c68a4383 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_client.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_client.py @@ -3,6 +3,8 @@ # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------- import runpy +import subprocess +import sys import time from pathlib import Path from unittest.mock import Mock, patch @@ -271,6 +273,32 @@ def test_client_access_sample_does_not_log_token(monkeypatch, capsys): assert captured.err == "" +@pytest.mark.parametrize( + "sample_name,variable", + [ + ("sample_errors.py", "WPS_CHAT_CONNECTION_STRING"), + ("sample_logging.py", "WPS_CHAT_ENDPOINT"), + ("sample_roles_and_permissions.py", "WPS_CHAT_CONNECTION_STRING"), + ("sample_roles_and_permissions_async.py", "WPS_CHAT_CONNECTION_STRING"), + ], +) +def test_sample_without_configuration_exits_successfully(sample_name, variable, monkeypatch): + monkeypatch.delenv(variable, raising=False) + sample_path = Path(__file__).resolve().parents[1] / "samples" / sample_name + + result = subprocess.run( + [sys.executable, str(sample_path)], + capture_output=True, + text=True, + check=False, + timeout=30, + ) + + assert result.returncode == 0, result.stderr + assert result.stdout == f"Set {variable} to run this sample.\n" + assert result.stderr == "" + + def test_builtin_roles_and_generated_permissions(): assert BuiltInChatRoles.USER_NORMAL == "user.normal" assert BuiltInChatRoles.ROOM_MEMBER == "room.member" From fc16ff691a1c638b5119b3c705a7bb260d766df9 Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Tue, 13 Oct 2026 03:18:26 -0700 Subject: [PATCH 05/22] Restore Chat e2e coverage after canary routing fix Use the default API version for all inherited and new Chat test operations, refresh the published recordings, and clean up WebSocket-created access users. Document the default service API-version change. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../CHANGELOG.md | 4 +++ .../assets.json | 2 +- .../tests/test_2026_08_01_preview_live.py | 33 ++++++++----------- .../test_2026_08_01_preview_live_async.py | 33 ++++++++----------- .../tests/test_live.py | 10 ++++-- .../tests/test_live_async.py | 10 ++++-- 6 files changed, 47 insertions(+), 45 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md index 9006db483fc9..77612dbc4e21 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md @@ -7,6 +7,10 @@ - Added topic lifecycle operations (create or replace, list, get, update, and soft delete) - Added room, user, and user-room collection operations +### Other Changes + + - Changed the default service API version from `2026-02-01-preview` to `2026-08-01-preview` for both existing and newly added Chat operations + ## 1.0.0b1 (2026-10-08) ### Features Added diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/assets.json b/sdk/webpubsub/azure-messaging-webpubsubchatservice/assets.json index cf95420bc727..5cd82829d468 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/assets.json +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/webpubsub/azure-messaging-webpubsubchatservice", - "Tag": "python/webpubsub/azure-messaging-webpubsubchatservice_a3e1866f06" + "Tag": "python/webpubsub/azure-messaging-webpubsubchatservice_6a7c87de21" } diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live.py index e1906965631b..03335b5e37cf 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live.py @@ -35,11 +35,9 @@ class TestWebPubSubChatTopicsLive(WebPubSubChatTest): @recorded_by_proxy def test_topic_lifecycle_and_paging(self, wps_chat_endpoint): client = self.create_client(wps_chat_endpoint) - # Existing operations are not yet routed under the new version on DevINT. - setup = self.create_client(wps_chat_endpoint, api_version="2026-02-01-preview") room_id = "python-e2e-topics" try: - room = setup.create_or_replace_room(room_id, ChatRoom(title="Topic E2E")) + room = client.create_or_replace_room(room_id, ChatRoom(title="Topic E2E")) assert all(topic.conversation_id == room.default_conversation for topic in client.list_topics(room_id)) for topic_id in ("first", "second"): topic = client.create_or_replace_topic(room_id, topic_id, ChatTopic({"title": topic_id})) @@ -49,10 +47,10 @@ def test_topic_lifecycle_and_paging(self, wps_chat_endpoint): assert topic.created_at assert topic.created_by assert topic.etag - conversation = setup.get_conversation(topic.conversation_id) + conversation = client.get_conversation(topic.conversation_id) assert conversation.id == topic.conversation_id assert conversation.parent_room == room_id - assert list(setup.list_messages(topic.conversation_id)) == [] + assert list(client.list_messages(topic.conversation_id)) == [] assert {topic.id for topic in client.list_topics(room_id, max_page_size=1)}.issuperset({"first", "second"}) _assert_resumable_pages(client.list_topics(room_id, max_page_size=1)) @@ -80,28 +78,26 @@ def test_topic_lifecycle_and_paging(self, wps_chat_endpoint): assert error.value.status_code == 412 client.delete_topic(room_id, "first", etag=archived.etag, match_condition=MatchConditions.IfNotModified) finally: - self.cleanup(setup.delete_room, room_id) - setup.close() + self.cleanup(client.delete_room, room_id) client.close() @WebPubSubChatPreparer() @recorded_by_proxy def test_room_user_and_user_room_collections(self, wps_chat_endpoint): client = self.create_client(wps_chat_endpoint) - setup = self.create_client(wps_chat_endpoint, api_version="2026-02-01-preview") room_ids = ["python-e2e-collection-1", "python-e2e-collection-2"] user_ids = ["python-e2e-collection-user-1", "python-e2e-collection-user-2"] user_role = "user.python_e2e_collections" room_role = "room.python_e2e_collections" try: - setup.create_or_replace_role(user_role, ChatRole(permissions=[ChatPermission.USER_CREATE_ROOM])) - setup.create_or_replace_role(room_role, ChatRole(permissions=[ChatPermission.ROOM_PUBLISH_MESSAGE])) + client.create_or_replace_role(user_role, ChatRole(permissions=[ChatPermission.USER_CREATE_ROOM])) + client.create_or_replace_role(room_role, ChatRole(permissions=[ChatPermission.ROOM_PUBLISH_MESSAGE])) for user_id in user_ids: - setup.create_or_replace_user(user_id, HumanChatUser(nickname=user_id, role_name=user_role)) + client.create_or_replace_user(user_id, HumanChatUser(nickname=user_id, role_name=user_role)) assert list(client.list_rooms_for_user(user_ids[0])) == [] for room_id in room_ids: - setup.create_or_replace_room(room_id, ChatRoom(title=room_id)) - setup.create_or_replace_room_member(room_id, user_ids[0], ChatRoomMember(role_name=room_role)) + client.create_or_replace_room(room_id, ChatRoom(title=room_id)) + client.create_or_replace_room_member(room_id, user_ids[0], ChatRoomMember(role_name=room_role)) assert {room.id for room in client.list_rooms(max_page_size=1)}.issuperset(room_ids) users = list(client.list_users(max_page_size=1)) assert {user.id for user in users}.issuperset(user_ids) @@ -110,14 +106,13 @@ def test_room_user_and_user_room_collections(self, wps_chat_endpoint): _assert_resumable_pages(client.list_rooms(max_page_size=1)) _assert_resumable_pages(client.list_users(max_page_size=1)) _assert_resumable_pages(client.list_rooms_for_user(user_ids[0], max_page_size=1)) - setup.delete_room_member(room_ids[0], user_ids[0]) + client.delete_room_member(room_ids[0], user_ids[0]) assert {room.id for room in client.list_rooms_for_user(user_ids[0])} == {room_ids[1]} finally: for room_id in room_ids: - self.cleanup(setup.delete_room, room_id) + self.cleanup(client.delete_room, room_id) for user_id in user_ids: - self.cleanup(setup.delete_user, user_id) - self.cleanup(setup.delete_role, user_role) - self.cleanup(setup.delete_role, room_role) - setup.close() + self.cleanup(client.delete_user, user_id) + self.cleanup(client.delete_role, user_role) + self.cleanup(client.delete_role, room_role) client.close() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live_async.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live_async.py index 0ab753440973..8e7453935db8 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live_async.py @@ -40,11 +40,9 @@ class TestWebPubSubChatTopicsLiveAsync(WebPubSubChatTest): @pytest.mark.asyncio async def test_async_topic_lifecycle_and_paging(self, wps_chat_endpoint): client = self.create_async_client(wps_chat_endpoint) - # Existing operations are not yet routed under the new version on DevINT. - setup = self.create_async_client(wps_chat_endpoint, api_version="2026-02-01-preview") room_id = "python-async-e2e-topics" try: - room = await setup.create_or_replace_room(room_id, ChatRoom(title="Async Topic E2E")) + room = await client.create_or_replace_room(room_id, ChatRoom(title="Async Topic E2E")) assert all( topic.conversation_id == room.default_conversation for topic in await _collect(client.list_topics(room_id)) @@ -57,10 +55,10 @@ async def test_async_topic_lifecycle_and_paging(self, wps_chat_endpoint): assert topic.created_at assert topic.created_by assert topic.etag - conversation = await setup.get_conversation(topic.conversation_id) + conversation = await client.get_conversation(topic.conversation_id) assert conversation.id == topic.conversation_id assert conversation.parent_room == room_id - assert await _collect(setup.list_messages(topic.conversation_id)) == [] + assert await _collect(client.list_messages(topic.conversation_id)) == [] assert {topic.id async for topic in client.list_topics(room_id, max_page_size=1)}.issuperset( {"first", "second"} @@ -92,8 +90,7 @@ async def test_async_topic_lifecycle_and_paging(self, wps_chat_endpoint): room_id, "first", etag=archived.etag, match_condition=MatchConditions.IfNotModified ) finally: - await self.cleanup_async(setup.delete_room, room_id) - await setup.close() + await self.cleanup_async(client.delete_room, room_id) await client.close() @WebPubSubChatPreparer() @@ -101,20 +98,19 @@ async def test_async_topic_lifecycle_and_paging(self, wps_chat_endpoint): @pytest.mark.asyncio async def test_async_room_user_and_user_room_collections(self, wps_chat_endpoint): client = self.create_async_client(wps_chat_endpoint) - setup = self.create_async_client(wps_chat_endpoint, api_version="2026-02-01-preview") room_ids = ["python-async-e2e-collection-1", "python-async-e2e-collection-2"] user_ids = ["python-async-e2e-collection-user-1", "python-async-e2e-collection-user-2"] user_role = "user.python_async_e2e_collections" room_role = "room.python_async_e2e_collections" try: - await setup.create_or_replace_role(user_role, ChatRole(permissions=[ChatPermission.USER_CREATE_ROOM])) - await setup.create_or_replace_role(room_role, ChatRole(permissions=[ChatPermission.ROOM_PUBLISH_MESSAGE])) + await client.create_or_replace_role(user_role, ChatRole(permissions=[ChatPermission.USER_CREATE_ROOM])) + await client.create_or_replace_role(room_role, ChatRole(permissions=[ChatPermission.ROOM_PUBLISH_MESSAGE])) for user_id in user_ids: - await setup.create_or_replace_user(user_id, HumanChatUser(nickname=user_id, role_name=user_role)) + await client.create_or_replace_user(user_id, HumanChatUser(nickname=user_id, role_name=user_role)) assert await _collect(client.list_rooms_for_user(user_ids[0])) == [] for room_id in room_ids: - await setup.create_or_replace_room(room_id, ChatRoom(title=room_id)) - await setup.create_or_replace_room_member(room_id, user_ids[0], ChatRoomMember(role_name=room_role)) + await client.create_or_replace_room(room_id, ChatRoom(title=room_id)) + await client.create_or_replace_room_member(room_id, user_ids[0], ChatRoomMember(role_name=room_role)) assert {room.id async for room in client.list_rooms(max_page_size=1)}.issuperset(room_ids) users = await _collect(client.list_users(max_page_size=1)) assert {user.id for user in users}.issuperset(user_ids) @@ -123,14 +119,13 @@ async def test_async_room_user_and_user_room_collections(self, wps_chat_endpoint await _assert_resumable_pages(client.list_rooms(max_page_size=1)) await _assert_resumable_pages(client.list_users(max_page_size=1)) await _assert_resumable_pages(client.list_rooms_for_user(user_ids[0], max_page_size=1)) - await setup.delete_room_member(room_ids[0], user_ids[0]) + await client.delete_room_member(room_ids[0], user_ids[0]) assert {room.id async for room in client.list_rooms_for_user(user_ids[0])} == {room_ids[1]} finally: for room_id in room_ids: - await self.cleanup_async(setup.delete_room, room_id) + await self.cleanup_async(client.delete_room, room_id) for user_id in user_ids: - await self.cleanup_async(setup.delete_user, user_id) - await self.cleanup_async(setup.delete_role, user_role) - await self.cleanup_async(setup.delete_role, room_role) - await setup.close() + await self.cleanup_async(client.delete_user, user_id) + await self.cleanup_async(client.delete_role, user_role) + await self.cleanup_async(client.delete_role, room_role) await client.close() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live.py index b9a3101b27da..bcadd81ac055 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live.py @@ -24,7 +24,6 @@ ) -@pytest.mark.skip(reason="Inherited operations await the runtime 2026-08-01-preview routing fix.") class TestWebPubSubChatLive(WebPubSubChatTest): @WebPubSubChatPreparer() @recorded_by_proxy @@ -264,15 +263,20 @@ def test_client_access_token( ): token_client = self.create_client(wps_chat_endpoint) key_client = None + token_user_id = "python-e2e-token-access-user" + key_user_id = "python-e2e-key-access-user" try: - token_access = token_client.get_client_access_token(user_id="python-e2e-token-access-user") + token_access = token_client.get_client_access_token(user_id=token_user_id) self.assert_client_access(token_access, wps_chat_endpoint) if wps_chat_disable_local_auth.lower() != "true": key_client = self.create_key_client(wps_chat_connection_string) - key_access = key_client.get_client_access_token(user_id="python-e2e-key-access-user") + key_access = key_client.get_client_access_token(user_id=key_user_id) self.assert_client_access(key_access, wps_chat_endpoint) finally: + self.cleanup(token_client.delete_user, token_user_id) + if key_client: + self.cleanup(token_client.delete_user, key_user_id) token_client.close() if key_client: key_client.close() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live_async.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live_async.py index 295ac903799b..90ecc39aad08 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live_async.py @@ -28,7 +28,6 @@ async def _collect(paged): return [item async for item in paged] -@pytest.mark.skip(reason="Inherited operations await the runtime 2026-08-01-preview routing fix.") class TestWebPubSubChatLiveAsync(WebPubSubChatTest): @WebPubSubChatPreparer() @recorded_by_proxy_async @@ -278,15 +277,20 @@ async def test_async_client_access_token( ): token_client = self.create_async_client(wps_chat_endpoint) key_client = None + token_user_id = "python-async-e2e-token-access-user" + key_user_id = "python-async-e2e-key-access-user" try: - token_access = await token_client.get_client_access_token(user_id="python-async-e2e-token-access-user") + token_access = await token_client.get_client_access_token(user_id=token_user_id) await self.assert_client_access_async(token_access, wps_chat_endpoint) if wps_chat_disable_local_auth.lower() != "true": key_client = self.create_async_key_client(wps_chat_connection_string) - key_access = await key_client.get_client_access_token(user_id="python-async-e2e-key-access-user") + key_access = await key_client.get_client_access_token(user_id=key_user_id) await self.assert_client_access_async(key_access, wps_chat_endpoint) finally: + await self.cleanup_async(token_client.delete_user, token_user_id) + if key_client: + await self.cleanup_async(token_client.delete_user, key_user_id) await token_client.close() if key_client: await key_client.close() From a324cfb26c2de3b51bb1ae82e25c827278169c6e Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Wed, 14 Oct 2026 18:20:17 -0700 Subject: [PATCH 06/22] Use lifecycle request models for Web PubSub Chat Regenerate from Python-only TypeSpec customization, preserving resource responses and wire behavior. Update samples, API documentation, and sync/async request-shape coverage. Pin the published specs fork commit for reproducible generation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../CHANGELOG.md | 6 + .../README.md | 32 ++- .../api.md | 240 +++++++++++----- .../api.metadata.yml | 2 +- .../apiview-properties.json | 10 +- .../_operations/_operations.py | 114 ++++---- .../aio/_operations/_operations.py | 114 ++++---- .../webpubsubchatservice/models/__init__.py | 16 ++ .../webpubsubchatservice/models/_models.py | 261 ++++++++++++++++++ .../messaging/webpubsubchatservice/types.py | 136 +++------ .../test_web_pub_sub_chat_service.py | 36 +-- .../test_web_pub_sub_chat_service_async.py | 36 +-- .../samples/sample_message_management.py | 6 +- .../samples/sample_readme_snippets.py | 20 +- .../samples/sample_roles_and_permissions.py | 4 +- .../sample_roles_and_permissions_async.py | 4 +- .../tests/test_2026_08_01_preview.py | 18 +- .../tests/test_2026_08_01_preview_live.py | 28 +- .../test_2026_08_01_preview_live_async.py | 34 ++- .../tests/test_live.py | 48 ++-- .../tests/test_live_async.py | 54 ++-- .../tests/test_request_models.py | 154 +++++++++++ .../tsp-location.yaml | 4 +- 23 files changed, 913 insertions(+), 464 deletions(-) create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_request_models.py diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md index 77612dbc4e21..9288e50fb6d3 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md @@ -11,6 +11,12 @@ - Changed the default service API version from `2026-02-01-preview` to `2026-08-01-preview` for both existing and newly added Chat operations +### Breaking Changes + + - Create or replace operations now accept dedicated `ChatRoleCreate`, `ChatRoomCreate`, `ChatRoomMemberCreate`, and `ChatUserCreate` (including `HumanChatUserCreate`) request models instead of resource response models. + - Topic creation accepts `ChatTopicCreate`, which requires only `title`. Topic updates accept `ChatTopicUpdate`, whose fields are optional. + - Message updates accept `ChatMessageUpdate`, whose fields are optional, instead of `ChatMessage`. Resource response model names are unchanged. + ## 1.0.0b1 (2026-10-08) ### Features Added diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md index 9f934aa57d77..23481b5ed2e0 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md @@ -182,17 +182,23 @@ The returned URL contains an access token. Send it only to the intended client, ### Create a role -Use the `ChatRole` model and `ChatPermission` enum instead of a dictionary with +Create operations use dedicated request models such as `ChatRoleCreate` and +`ChatRoomCreate`. PATCH operations use `ChatTopicUpdate` and `ChatMessageUpdate`, +whose fields can be omitted to leave existing values unchanged. The operations +return resource models such as `ChatRole`, `ChatRoom`, and `ChatTopic`, which +include service-assigned identifiers and ETags. + +Use the `ChatRoleCreate` model and `ChatPermission` enum instead of a dictionary with permission string literals. This example assumes `os` is imported. ```python -from azure.messaging.webpubsubchatservice.models import ChatPermission, ChatRole +from azure.messaging.webpubsubchatservice.models import ChatPermission, ChatRoleCreate role = client.create_or_replace_role( os.environ.get("WPS_CHAT_ROLE_NAME", "user.python_sample"), - ChatRole(permissions=[ChatPermission.USER_CREATE_ROOM]), + ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM]), ) print(role.name, role.permissions) ``` @@ -222,11 +228,11 @@ The user role `user.room_creator` must already exist. ```python -from azure.messaging.webpubsubchatservice.models import HumanChatUser +from azure.messaging.webpubsubchatservice.models import HumanChatUserCreate user = client.create_or_replace_user( "alice", - HumanChatUser(nickname="Alice", role_name="user.room_creator"), + HumanChatUserCreate(nickname="Alice", role_name="user.room_creator"), ) print(user.id, user.nickname) ``` @@ -238,9 +244,9 @@ print(user.id, user.nickname) ```python -from azure.messaging.webpubsubchatservice.models import ChatRoom +from azure.messaging.webpubsubchatservice.models import ChatRoomCreate -room = client.create_or_replace_room("general", ChatRoom(title="General")) +room = client.create_or_replace_room("general", ChatRoomCreate(title="General")) print(room.id, room.default_conversation) ``` @@ -253,12 +259,12 @@ The room `general`, user `alice`, and room role `room.contributor` must already ```python -from azure.messaging.webpubsubchatservice.models import ChatRoomMember +from azure.messaging.webpubsubchatservice.models import ChatRoomMemberCreate member = client.create_or_replace_room_member( "general", "alice", - ChatRoomMember(role_name="room.contributor"), + ChatRoomMemberCreate(role_name="room.contributor"), ) print(member.user_id, member.role_name) ``` @@ -291,12 +297,12 @@ topic ID specified by `WPS_CHAT_TOPIC_ID`. ```python import os -from azure.messaging.webpubsubchatservice.models import ChatTopic +from azure.messaging.webpubsubchatservice.models import ChatTopicCreate topic = client.create_or_replace_topic( os.environ["WPS_CHAT_ROOM_ID"], os.environ["WPS_CHAT_TOPIC_ID"], - ChatTopic({"title": "Announcements"}), + ChatTopicCreate(title="Announcements"), ) print(topic.id, topic.etag) ``` @@ -339,12 +345,12 @@ operation. ```python import os from azure.core import MatchConditions -from azure.messaging.webpubsubchatservice.models import ChatTopic, ChatTopicState +from azure.messaging.webpubsubchatservice.models import ChatTopicUpdate, ChatTopicState topic = client.update_topic( os.environ["WPS_CHAT_ROOM_ID"], os.environ["WPS_CHAT_TOPIC_ID"], - ChatTopic(title="Announcements", state=ChatTopicState.ARCHIVED), + ChatTopicUpdate(state=ChatTopicState.ARCHIVED), etag=os.environ["WPS_CHAT_TOPIC_ETAG"], match_condition=MatchConditions.IfNotModified, ) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md index 9592fdae3b77..f8052807a1f1 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md @@ -33,7 +33,7 @@ namespace azure.messaging.webpubsubchatservice def create_or_replace_role( self, role_name: str, - resource: ChatRole, + resource: ChatRoleCreate, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -45,7 +45,7 @@ namespace azure.messaging.webpubsubchatservice def create_or_replace_role( self, role_name: str, - resource: ChatRole, + resource: ChatRoleCreate, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -69,7 +69,7 @@ namespace azure.messaging.webpubsubchatservice def create_or_replace_room( self, room_id: str, - resource: ChatRoom, + resource: ChatRoomCreate, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -81,7 +81,7 @@ namespace azure.messaging.webpubsubchatservice def create_or_replace_room( self, room_id: str, - resource: ChatRoom, + resource: ChatRoomCreate, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -106,7 +106,7 @@ namespace azure.messaging.webpubsubchatservice self, room_id: str, user_id: str, - resource: ChatRoomMember, + resource: ChatRoomMemberCreate, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -119,7 +119,7 @@ namespace azure.messaging.webpubsubchatservice self, room_id: str, user_id: str, - resource: ChatRoomMember, + resource: ChatRoomMemberCreate, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -145,7 +145,7 @@ namespace azure.messaging.webpubsubchatservice self, room_id: str, topic_id: str, - resource: ChatTopic, + resource: ChatTopicCreate, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -158,7 +158,7 @@ namespace azure.messaging.webpubsubchatservice self, room_id: str, topic_id: str, - resource: ChatTopic, + resource: ChatTopicCreate, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -183,7 +183,7 @@ namespace azure.messaging.webpubsubchatservice def create_or_replace_user( self, user_id: str, - resource: ChatUser, + resource: ChatUserCreate, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -195,7 +195,7 @@ namespace azure.messaging.webpubsubchatservice def create_or_replace_user( self, user_id: str, - resource: ChatUser, + resource: ChatUserCreate, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -410,7 +410,7 @@ namespace azure.messaging.webpubsubchatservice self, conversation_id: str, message_id: str, - resource: ChatMessage, + resource: ChatMessageUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = ..., @@ -423,7 +423,7 @@ namespace azure.messaging.webpubsubchatservice self, conversation_id: str, message_id: str, - resource: ChatMessage, + resource: ChatMessageUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = ..., @@ -449,7 +449,7 @@ namespace azure.messaging.webpubsubchatservice self, room_id: str, topic_id: str, - resource: ChatTopic, + resource: ChatTopicUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = ..., @@ -462,7 +462,7 @@ namespace azure.messaging.webpubsubchatservice self, room_id: str, topic_id: str, - resource: ChatTopic, + resource: ChatTopicUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = ..., @@ -512,7 +512,7 @@ namespace azure.messaging.webpubsubchatservice.aio async def create_or_replace_role( self, role_name: str, - resource: ChatRole, + resource: ChatRoleCreate, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -524,7 +524,7 @@ namespace azure.messaging.webpubsubchatservice.aio async def create_or_replace_role( self, role_name: str, - resource: ChatRole, + resource: ChatRoleCreate, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -548,7 +548,7 @@ namespace azure.messaging.webpubsubchatservice.aio async def create_or_replace_room( self, room_id: str, - resource: ChatRoom, + resource: ChatRoomCreate, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -560,7 +560,7 @@ namespace azure.messaging.webpubsubchatservice.aio async def create_or_replace_room( self, room_id: str, - resource: ChatRoom, + resource: ChatRoomCreate, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -585,7 +585,7 @@ namespace azure.messaging.webpubsubchatservice.aio self, room_id: str, user_id: str, - resource: ChatRoomMember, + resource: ChatRoomMemberCreate, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -598,7 +598,7 @@ namespace azure.messaging.webpubsubchatservice.aio self, room_id: str, user_id: str, - resource: ChatRoomMember, + resource: ChatRoomMemberCreate, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -624,7 +624,7 @@ namespace azure.messaging.webpubsubchatservice.aio self, room_id: str, topic_id: str, - resource: ChatTopic, + resource: ChatTopicCreate, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -637,7 +637,7 @@ namespace azure.messaging.webpubsubchatservice.aio self, room_id: str, topic_id: str, - resource: ChatTopic, + resource: ChatTopicCreate, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -662,7 +662,7 @@ namespace azure.messaging.webpubsubchatservice.aio async def create_or_replace_user( self, user_id: str, - resource: ChatUser, + resource: ChatUserCreate, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -674,7 +674,7 @@ namespace azure.messaging.webpubsubchatservice.aio async def create_or_replace_user( self, user_id: str, - resource: ChatUser, + resource: ChatUserCreate, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -889,7 +889,7 @@ namespace azure.messaging.webpubsubchatservice.aio self, conversation_id: str, message_id: str, - resource: ChatMessage, + resource: ChatMessageUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = ..., @@ -902,7 +902,7 @@ namespace azure.messaging.webpubsubchatservice.aio self, conversation_id: str, message_id: str, - resource: ChatMessage, + resource: ChatMessageUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = ..., @@ -928,7 +928,7 @@ namespace azure.messaging.webpubsubchatservice.aio self, room_id: str, topic_id: str, - resource: ChatTopic, + resource: ChatTopicUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = ..., @@ -941,7 +941,7 @@ namespace azure.messaging.webpubsubchatservice.aio self, room_id: str, topic_id: str, - resource: ChatTopic, + resource: ChatTopicUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = ..., @@ -1000,6 +1000,22 @@ namespace azure.messaging.webpubsubchatservice.models def __init__(self, mapping: Mapping[str, Any]) -> None: ... + class azure.messaging.webpubsubchatservice.models.ChatMessageUpdate(_Model): + content: Optional[MessageContent] + created_by: Optional[str] + + @overload + def __init__( + self, + *, + content: Optional[MessageContent] = ..., + created_by: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + class azure.messaging.webpubsubchatservice.models.ChatPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): ROOM_HISTORY = "room.history" ROOM_INVITE = "room.invite" @@ -1025,6 +1041,20 @@ namespace azure.messaging.webpubsubchatservice.models def __init__(self, mapping: Mapping[str, Any]) -> None: ... + class azure.messaging.webpubsubchatservice.models.ChatRoleCreate(_Model): + permissions: list[Union[str, ChatPermission]] + + @overload + def __init__( + self, + *, + permissions: list[Union[str, ChatPermission]] + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + class azure.messaging.webpubsubchatservice.models.ChatRoom(_Model): default_conversation: str etag: str @@ -1042,6 +1072,20 @@ namespace azure.messaging.webpubsubchatservice.models def __init__(self, mapping: Mapping[str, Any]) -> None: ... + class azure.messaging.webpubsubchatservice.models.ChatRoomCreate(_Model): + title: str + + @overload + def __init__( + self, + *, + title: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + class azure.messaging.webpubsubchatservice.models.ChatRoomMember(_Model): etag: str role_name: str @@ -1058,6 +1102,20 @@ namespace azure.messaging.webpubsubchatservice.models def __init__(self, mapping: Mapping[str, Any]) -> None: ... + class azure.messaging.webpubsubchatservice.models.ChatRoomMemberCreate(_Model): + role_name: str + + @overload + def __init__( + self, + *, + role_name: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + class azure.messaging.webpubsubchatservice.models.ChatTopic(_Model): conversation_id: str created_at: datetime @@ -1079,12 +1137,42 @@ namespace azure.messaging.webpubsubchatservice.models def __init__(self, mapping: Mapping[str, Any]) -> None: ... + class azure.messaging.webpubsubchatservice.models.ChatTopicCreate(_Model): + title: str + + @overload + def __init__( + self, + *, + title: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + class azure.messaging.webpubsubchatservice.models.ChatTopicState(str, Enum, metaclass=CaseInsensitiveEnumMeta): ARCHIVED = "Archived" NORMAL = "Normal" SOFT_DELETED = "SoftDeleted" + class azure.messaging.webpubsubchatservice.models.ChatTopicUpdate(_Model): + state: Optional[Union[str, ChatTopicState]] + title: Optional[str] + + @overload + def __init__( + self, + *, + state: Optional[Union[str, ChatTopicState]] = ..., + title: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + class azure.messaging.webpubsubchatservice.models.ChatUser(_Model): etag: str id: str @@ -1103,6 +1191,22 @@ namespace azure.messaging.webpubsubchatservice.models def __init__(self, mapping: Mapping[str, Any]) -> None: ... + class azure.messaging.webpubsubchatservice.models.ChatUserCreate(_Model): + kind: str + nickname: str + + @overload + def __init__( + self, + *, + kind: str, + nickname: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + class azure.messaging.webpubsubchatservice.models.ChatUserKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): HUMAN = "Human" @@ -1143,6 +1247,23 @@ namespace azure.messaging.webpubsubchatservice.models def __init__(self, mapping: Mapping[str, Any]) -> None: ... + class azure.messaging.webpubsubchatservice.models.HumanChatUserCreate(ChatUserCreate, discriminator='Human'): + kind: Literal[ChatUserKind.HUMAN] + nickname: str + role_name: str + + @overload + def __init__( + self, + *, + nickname: str, + role_name: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + class azure.messaging.webpubsubchatservice.models.MessageContent(_Model): binary: Optional[bytes] text: Optional[str] @@ -1161,73 +1282,44 @@ namespace azure.messaging.webpubsubchatservice.models namespace azure.messaging.webpubsubchatservice.types - class azure.messaging.webpubsubchatservice.types.ChatMessage(TypedDict, total=False): - key "content": Required[MessageContent] - key "createdAt": Required[str] - key "createdBy": Required[str] - key "etag": Required[str] - key "id": Required[str] + class azure.messaging.webpubsubchatservice.types.ChatMessageUpdate(TypedDict, total=False): + key "content": ForwardRef('MessageContent', module='types') + key "createdBy": str content: MessageContent - createdAt: str createdBy: str - etag: str - id: str - class azure.messaging.webpubsubchatservice.types.ChatRole(TypedDict, total=False): - key "etag": Required[str] - key "name": Required[str] + class azure.messaging.webpubsubchatservice.types.ChatRoleCreate(TypedDict, total=False): key "permissions": Required[list[Union[str, ChatPermission]]] - etag: str - name: str permissions: list[Union[str, ChatPermission]] - class azure.messaging.webpubsubchatservice.types.ChatRoom(TypedDict, total=False): - key "defaultConversation": Required[str] - key "etag": Required[str] - key "id": Required[str] + class azure.messaging.webpubsubchatservice.types.ChatRoomCreate(TypedDict, total=False): key "title": Required[str] - defaultConversation: str - etag: str - id: str title: str - class azure.messaging.webpubsubchatservice.types.ChatRoomMember(TypedDict, total=False): - key "etag": Required[str] + class azure.messaging.webpubsubchatservice.types.ChatRoomMemberCreate(TypedDict, total=False): key "roleName": Required[str] - key "userId": Required[str] - etag: str roleName: str - userId: str - class azure.messaging.webpubsubchatservice.types.ChatTopic(TypedDict, total=False): - key "conversationId": Required[str] - key "createdAt": Required[str] - key "createdBy": Required[str] - key "etag": Required[str] - key "id": Required[str] - key "state": Required[Union[str, ChatTopicState]] + class azure.messaging.webpubsubchatservice.types.ChatTopicCreate(TypedDict, total=False): key "title": Required[str] - conversationId: str - createdAt: str - createdBy: str - etag: str - id: str + title: str + + + class azure.messaging.webpubsubchatservice.types.ChatTopicUpdate(TypedDict, total=False): + key "state": Union[str, ChatTopicState] + key "title": str state: Union[str, ChatTopicState] title: str - class azure.messaging.webpubsubchatservice.types.ChatUser(TypedDict, total=False): - key "etag": Required[str] - key "id": Required[str] + class azure.messaging.webpubsubchatservice.types.ChatUserCreate(TypedDict, total=False): key "kind": Required[Literal[ChatUserKind.HUMAN]] key "nickname": Required[str] key "roleName": Required[str] - etag: str - id: str kind: Literal[ChatUserKind.HUMAN] nickname: str roleName: str @@ -1237,14 +1329,10 @@ namespace azure.messaging.webpubsubchatservice.types HUMAN = "Human" - class azure.messaging.webpubsubchatservice.types.HumanChatUser(TypedDict, total=False): - key "etag": Required[str] - key "id": Required[str] + class azure.messaging.webpubsubchatservice.types.HumanChatUserCreate(TypedDict, total=False): key "kind": Required[Literal[ChatUserKind.HUMAN]] key "nickname": Required[str] key "roleName": Required[str] - etag: str - id: str kind: Literal[ChatUserKind.HUMAN] nickname: str roleName: str diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml index 59491ce85965..6f58c0deb25e 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml @@ -1,4 +1,4 @@ -apiMdSha256: 0c69f8dd9983b0c02f1a9926c54a0318c2235a3fde96dc5de5fce6ce63322092 +apiMdSha256: 9079dffe38f166d12378f9a5ed0227ddd99b73873158251ac51a32fd1904ca70 packageVersion: 1.0.0b2 parserVersion: 0.3.31 pythonVersion: 3.12.10 diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json b/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json index 8c50aca07375..ff161dcccf06 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json @@ -3,13 +3,21 @@ "CrossLanguageDefinitionId": { "azure.messaging.webpubsubchatservice.models.ChatConversation": "WebPubSubChat.ChatConversation", "azure.messaging.webpubsubchatservice.models.ChatMessage": "WebPubSubChat.ChatMessage", + "azure.messaging.webpubsubchatservice.models.ChatMessageUpdate": "WebPubSubChat.RequestModels.ChatMessageUpdate", "azure.messaging.webpubsubchatservice.models.ChatRole": "WebPubSubChat.ChatRole", + "azure.messaging.webpubsubchatservice.models.ChatRoleCreate": "WebPubSubChat.RequestModels.ChatRoleCreate", "azure.messaging.webpubsubchatservice.models.ChatRoom": "WebPubSubChat.ChatRoom", + "azure.messaging.webpubsubchatservice.models.ChatRoomCreate": "WebPubSubChat.RequestModels.ChatRoomCreate", "azure.messaging.webpubsubchatservice.models.ChatRoomMember": "WebPubSubChat.ChatRoomMember", + "azure.messaging.webpubsubchatservice.models.ChatRoomMemberCreate": "WebPubSubChat.RequestModels.ChatRoomMemberCreate", "azure.messaging.webpubsubchatservice.models.ChatTopic": "WebPubSubChat.ChatTopic", + "azure.messaging.webpubsubchatservice.models.ChatTopicCreate": "WebPubSubChat.RequestModels.ChatTopicCreate", + "azure.messaging.webpubsubchatservice.models.ChatTopicUpdate": "WebPubSubChat.RequestModels.ChatTopicUpdate", "azure.messaging.webpubsubchatservice.models.ChatUser": "WebPubSubChat.ChatUser", + "azure.messaging.webpubsubchatservice.models.ChatUserCreate": "WebPubSubChat.RequestModels.ChatUserCreate", "azure.messaging.webpubsubchatservice.models.ChatUserRoom": "WebPubSubChat.ChatUserRoom", "azure.messaging.webpubsubchatservice.models.HumanChatUser": "WebPubSubChat.HumanChatUser", + "azure.messaging.webpubsubchatservice.models.HumanChatUserCreate": "WebPubSubChat.RequestModels.HumanChatUserCreate", "azure.messaging.webpubsubchatservice.models.MessageContent": "WebPubSubChat.MessageContent", "azure.messaging.webpubsubchatservice.models.ChatPermission": "WebPubSubChat.ChatPermission", "azure.messaging.webpubsubchatservice.models.ChatTopicState": "WebPubSubChat.ChatTopicState", @@ -65,5 +73,5 @@ "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.list_rooms_for_user": "WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser", "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.list_rooms_for_user": "WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser" }, - "CrossLanguageVersion": "9db8b5aee1c7" + "CrossLanguageVersion": "37e519d01deb" } \ No newline at end of file diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_operations/_operations.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_operations/_operations.py index 58e50fb82ec7..e2abce07ff4c 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_operations/_operations.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_operations/_operations.py @@ -1238,7 +1238,7 @@ def update_message( self, conversation_id: str, message_id: str, - resource: _models.ChatMessage, + resource: _models.ChatMessageUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = None, @@ -1254,7 +1254,7 @@ def update_message( :param message_id: Message identifier. Required. :type message_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatMessage + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatMessageUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -1273,7 +1273,7 @@ def update_message( self, conversation_id: str, message_id: str, - resource: _types.ChatMessage, + resource: _types.ChatMessageUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = None, @@ -1289,7 +1289,7 @@ def update_message( :param message_id: Message identifier. Required. :type message_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatMessage + :type resource: ~azure.messaging.webpubsubchatservice.types.ChatMessageUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -1343,7 +1343,7 @@ def update_message( self, conversation_id: str, message_id: str, - resource: Union[_models.ChatMessage, _types.ChatMessage, IO[bytes]], + resource: Union[_models.ChatMessageUpdate, _types.ChatMessageUpdate, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -1357,10 +1357,10 @@ def update_message( :type conversation_id: str :param message_id: Message identifier. Required. :type message_id: str - :param resource: The resource instance. Is either a ChatMessage type or a IO[bytes] type. + :param resource: The resource instance. Is either a ChatMessageUpdate type or a IO[bytes] type. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatMessage or - ~azure.messaging.webpubsubchatservice.types.ChatMessage or IO[bytes] + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatMessageUpdate or + ~azure.messaging.webpubsubchatservice.types.ChatMessageUpdate or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. :paramtype etag: str @@ -1612,7 +1612,7 @@ def get_role(self, role_name: str, **kwargs: Any) -> _models.ChatRole: def create_or_replace_role( self, role_name: str, - resource: _models.ChatRole, + resource: _models.ChatRoleCreate, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -1626,7 +1626,7 @@ def create_or_replace_role( :param role_name: Role name. Must start with 'user.' or 'room.' prefix. Required. :type role_name: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRole + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoleCreate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1644,7 +1644,7 @@ def create_or_replace_role( def create_or_replace_role( self, role_name: str, - resource: _types.ChatRole, + resource: _types.ChatRoleCreate, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -1658,7 +1658,7 @@ def create_or_replace_role( :param role_name: Role name. Must start with 'user.' or 'room.' prefix. Required. :type role_name: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatRole + :type resource: ~azure.messaging.webpubsubchatservice.types.ChatRoleCreate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1708,7 +1708,7 @@ def create_or_replace_role( def create_or_replace_role( self, role_name: str, - resource: Union[_models.ChatRole, _types.ChatRole, IO[bytes]], + resource: Union[_models.ChatRoleCreate, _types.ChatRoleCreate, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -1720,10 +1720,10 @@ def create_or_replace_role( :param role_name: Role name. Must start with 'user.' or 'room.' prefix. Required. :type role_name: str - :param resource: The resource instance. Is either a ChatRole type or a IO[bytes] type. + :param resource: The resource instance. Is either a ChatRoleCreate type or a IO[bytes] type. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRole or - ~azure.messaging.webpubsubchatservice.types.ChatRole or IO[bytes] + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoleCreate or + ~azure.messaging.webpubsubchatservice.types.ChatRoleCreate or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. :paramtype etag: str @@ -1988,7 +1988,7 @@ def get_next(next_link=None): def create_or_replace_room( self, room_id: str, - resource: _models.ChatRoom, + resource: _models.ChatRoomCreate, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -2002,7 +2002,7 @@ def create_or_replace_room( :param room_id: Room identifier. Required. :type room_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoom + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomCreate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2020,7 +2020,7 @@ def create_or_replace_room( def create_or_replace_room( self, room_id: str, - resource: _types.ChatRoom, + resource: _types.ChatRoomCreate, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -2034,7 +2034,7 @@ def create_or_replace_room( :param room_id: Room identifier. Required. :type room_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatRoom + :type resource: ~azure.messaging.webpubsubchatservice.types.ChatRoomCreate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2084,7 +2084,7 @@ def create_or_replace_room( def create_or_replace_room( self, room_id: str, - resource: Union[_models.ChatRoom, _types.ChatRoom, IO[bytes]], + resource: Union[_models.ChatRoomCreate, _types.ChatRoomCreate, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -2096,10 +2096,10 @@ def create_or_replace_room( :param room_id: Room identifier. Required. :type room_id: str - :param resource: The resource instance. Is either a ChatRoom type or a IO[bytes] type. + :param resource: The resource instance. Is either a ChatRoomCreate type or a IO[bytes] type. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoom or - ~azure.messaging.webpubsubchatservice.types.ChatRoom or IO[bytes] + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomCreate or + ~azure.messaging.webpubsubchatservice.types.ChatRoomCreate or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. :paramtype etag: str @@ -2444,7 +2444,7 @@ def create_or_replace_topic( self, room_id: str, topic_id: str, - resource: _models.ChatTopic, + resource: _models.ChatTopicCreate, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -2460,7 +2460,7 @@ def create_or_replace_topic( :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopic + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopicCreate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2479,7 +2479,7 @@ def create_or_replace_topic( self, room_id: str, topic_id: str, - resource: _types.ChatTopic, + resource: _types.ChatTopicCreate, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -2495,7 +2495,7 @@ def create_or_replace_topic( :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatTopic + :type resource: ~azure.messaging.webpubsubchatservice.types.ChatTopicCreate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2565,7 +2565,7 @@ def create_or_replace_topic( self, room_id: str, topic_id: str, - resource: Union[_models.ChatTopic, _types.ChatTopic, IO[bytes]], + resource: Union[_models.ChatTopicCreate, _types.ChatTopicCreate, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -2579,10 +2579,10 @@ def create_or_replace_topic( :type room_id: str :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str - :param resource: The resource instance. Is either a ChatTopic type or a IO[bytes] type. + :param resource: The resource instance. Is either a ChatTopicCreate type or a IO[bytes] type. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopic or - ~azure.messaging.webpubsubchatservice.types.ChatTopic or IO[bytes] + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopicCreate or + ~azure.messaging.webpubsubchatservice.types.ChatTopicCreate or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. :paramtype etag: str @@ -2743,7 +2743,7 @@ def update_topic( self, room_id: str, topic_id: str, - resource: _models.ChatTopic, + resource: _models.ChatTopicUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = None, @@ -2759,7 +2759,7 @@ def update_topic( :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopic + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopicUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -2778,7 +2778,7 @@ def update_topic( self, room_id: str, topic_id: str, - resource: _types.ChatTopic, + resource: _types.ChatTopicUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = None, @@ -2794,7 +2794,7 @@ def update_topic( :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatTopic + :type resource: ~azure.messaging.webpubsubchatservice.types.ChatTopicUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -2864,7 +2864,7 @@ def update_topic( self, room_id: str, topic_id: str, - resource: Union[_models.ChatTopic, _types.ChatTopic, IO[bytes]], + resource: Union[_models.ChatTopicUpdate, _types.ChatTopicUpdate, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -2878,10 +2878,10 @@ def update_topic( :type room_id: str :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str - :param resource: The resource instance. Is either a ChatTopic type or a IO[bytes] type. + :param resource: The resource instance. Is either a ChatTopicUpdate type or a IO[bytes] type. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopic or - ~azure.messaging.webpubsubchatservice.types.ChatTopic or IO[bytes] + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopicUpdate or + ~azure.messaging.webpubsubchatservice.types.ChatTopicUpdate or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. :paramtype etag: str @@ -3161,7 +3161,7 @@ def create_or_replace_room_member( self, room_id: str, user_id: str, - resource: _models.ChatRoomMember, + resource: _models.ChatRoomMemberCreate, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -3177,7 +3177,7 @@ def create_or_replace_room_member( :param user_id: User ID of the member. Required. :type user_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomMember + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomMemberCreate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -3196,7 +3196,7 @@ def create_or_replace_room_member( self, room_id: str, user_id: str, - resource: _types.ChatRoomMember, + resource: _types.ChatRoomMemberCreate, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -3212,7 +3212,7 @@ def create_or_replace_room_member( :param user_id: User ID of the member. Required. :type user_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatRoomMember + :type resource: ~azure.messaging.webpubsubchatservice.types.ChatRoomMemberCreate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -3266,7 +3266,7 @@ def create_or_replace_room_member( self, room_id: str, user_id: str, - resource: Union[_models.ChatRoomMember, _types.ChatRoomMember, IO[bytes]], + resource: Union[_models.ChatRoomMemberCreate, _types.ChatRoomMemberCreate, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -3280,10 +3280,10 @@ def create_or_replace_room_member( :type room_id: str :param user_id: User ID of the member. Required. :type user_id: str - :param resource: The resource instance. Is either a ChatRoomMember type or a IO[bytes] type. - Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomMember or - ~azure.messaging.webpubsubchatservice.types.ChatRoomMember or IO[bytes] + :param resource: The resource instance. Is either a ChatRoomMemberCreate type or a IO[bytes] + type. Required. + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomMemberCreate or + ~azure.messaging.webpubsubchatservice.types.ChatRoomMemberCreate or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. :paramtype etag: str @@ -3618,7 +3618,7 @@ def get_user(self, user_id: str, **kwargs: Any) -> _models.ChatUser: def create_or_replace_user( self, user_id: str, - resource: _models.ChatUser, + resource: _models.ChatUserCreate, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -3633,7 +3633,7 @@ def create_or_replace_user( :param user_id: User identifier. Required. :type user_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatUser + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatUserCreate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -3651,7 +3651,7 @@ def create_or_replace_user( def create_or_replace_user( self, user_id: str, - resource: _types.ChatUser, + resource: _types.ChatUserCreate, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -3666,7 +3666,7 @@ def create_or_replace_user( :param user_id: User identifier. Required. :type user_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatUser + :type resource: ~azure.messaging.webpubsubchatservice.types.ChatUserCreate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -3717,7 +3717,7 @@ def create_or_replace_user( def create_or_replace_user( self, user_id: str, - resource: Union[_models.ChatUser, _types.ChatUser, IO[bytes]], + resource: Union[_models.ChatUserCreate, _types.ChatUserCreate, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -3730,10 +3730,10 @@ def create_or_replace_user( :param user_id: User identifier. Required. :type user_id: str - :param resource: The resource instance. Is either a ChatUser type or a IO[bytes] type. + :param resource: The resource instance. Is either a ChatUserCreate type or a IO[bytes] type. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatUser or - ~azure.messaging.webpubsubchatservice.types.ChatUser or IO[bytes] + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatUserCreate or + ~azure.messaging.webpubsubchatservice.types.ChatUserCreate or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. :paramtype etag: str diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_operations/_operations.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_operations/_operations.py index 0b8d1febae20..aac916b7349e 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_operations/_operations.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_operations/_operations.py @@ -331,7 +331,7 @@ async def update_message( self, conversation_id: str, message_id: str, - resource: _models.ChatMessage, + resource: _models.ChatMessageUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = None, @@ -347,7 +347,7 @@ async def update_message( :param message_id: Message identifier. Required. :type message_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatMessage + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatMessageUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -366,7 +366,7 @@ async def update_message( self, conversation_id: str, message_id: str, - resource: _types.ChatMessage, + resource: _types.ChatMessageUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = None, @@ -382,7 +382,7 @@ async def update_message( :param message_id: Message identifier. Required. :type message_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatMessage + :type resource: ~azure.messaging.webpubsubchatservice.types.ChatMessageUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -436,7 +436,7 @@ async def update_message( self, conversation_id: str, message_id: str, - resource: Union[_models.ChatMessage, _types.ChatMessage, IO[bytes]], + resource: Union[_models.ChatMessageUpdate, _types.ChatMessageUpdate, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -450,10 +450,10 @@ async def update_message( :type conversation_id: str :param message_id: Message identifier. Required. :type message_id: str - :param resource: The resource instance. Is either a ChatMessage type or a IO[bytes] type. + :param resource: The resource instance. Is either a ChatMessageUpdate type or a IO[bytes] type. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatMessage or - ~azure.messaging.webpubsubchatservice.types.ChatMessage or IO[bytes] + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatMessageUpdate or + ~azure.messaging.webpubsubchatservice.types.ChatMessageUpdate or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. :paramtype etag: str @@ -706,7 +706,7 @@ async def get_role(self, role_name: str, **kwargs: Any) -> _models.ChatRole: async def create_or_replace_role( self, role_name: str, - resource: _models.ChatRole, + resource: _models.ChatRoleCreate, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -720,7 +720,7 @@ async def create_or_replace_role( :param role_name: Role name. Must start with 'user.' or 'room.' prefix. Required. :type role_name: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRole + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoleCreate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -738,7 +738,7 @@ async def create_or_replace_role( async def create_or_replace_role( self, role_name: str, - resource: _types.ChatRole, + resource: _types.ChatRoleCreate, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -752,7 +752,7 @@ async def create_or_replace_role( :param role_name: Role name. Must start with 'user.' or 'room.' prefix. Required. :type role_name: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatRole + :type resource: ~azure.messaging.webpubsubchatservice.types.ChatRoleCreate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -802,7 +802,7 @@ async def create_or_replace_role( async def create_or_replace_role( self, role_name: str, - resource: Union[_models.ChatRole, _types.ChatRole, IO[bytes]], + resource: Union[_models.ChatRoleCreate, _types.ChatRoleCreate, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -814,10 +814,10 @@ async def create_or_replace_role( :param role_name: Role name. Must start with 'user.' or 'room.' prefix. Required. :type role_name: str - :param resource: The resource instance. Is either a ChatRole type or a IO[bytes] type. + :param resource: The resource instance. Is either a ChatRoleCreate type or a IO[bytes] type. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRole or - ~azure.messaging.webpubsubchatservice.types.ChatRole or IO[bytes] + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoleCreate or + ~azure.messaging.webpubsubchatservice.types.ChatRoleCreate or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. :paramtype etag: str @@ -1083,7 +1083,7 @@ async def get_next(next_link=None): async def create_or_replace_room( self, room_id: str, - resource: _models.ChatRoom, + resource: _models.ChatRoomCreate, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -1097,7 +1097,7 @@ async def create_or_replace_room( :param room_id: Room identifier. Required. :type room_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoom + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomCreate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1115,7 +1115,7 @@ async def create_or_replace_room( async def create_or_replace_room( self, room_id: str, - resource: _types.ChatRoom, + resource: _types.ChatRoomCreate, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -1129,7 +1129,7 @@ async def create_or_replace_room( :param room_id: Room identifier. Required. :type room_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatRoom + :type resource: ~azure.messaging.webpubsubchatservice.types.ChatRoomCreate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1179,7 +1179,7 @@ async def create_or_replace_room( async def create_or_replace_room( self, room_id: str, - resource: Union[_models.ChatRoom, _types.ChatRoom, IO[bytes]], + resource: Union[_models.ChatRoomCreate, _types.ChatRoomCreate, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -1191,10 +1191,10 @@ async def create_or_replace_room( :param room_id: Room identifier. Required. :type room_id: str - :param resource: The resource instance. Is either a ChatRoom type or a IO[bytes] type. + :param resource: The resource instance. Is either a ChatRoomCreate type or a IO[bytes] type. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoom or - ~azure.messaging.webpubsubchatservice.types.ChatRoom or IO[bytes] + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomCreate or + ~azure.messaging.webpubsubchatservice.types.ChatRoomCreate or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. :paramtype etag: str @@ -1540,7 +1540,7 @@ async def create_or_replace_topic( self, room_id: str, topic_id: str, - resource: _models.ChatTopic, + resource: _models.ChatTopicCreate, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -1556,7 +1556,7 @@ async def create_or_replace_topic( :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopic + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopicCreate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1575,7 +1575,7 @@ async def create_or_replace_topic( self, room_id: str, topic_id: str, - resource: _types.ChatTopic, + resource: _types.ChatTopicCreate, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -1591,7 +1591,7 @@ async def create_or_replace_topic( :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatTopic + :type resource: ~azure.messaging.webpubsubchatservice.types.ChatTopicCreate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1661,7 +1661,7 @@ async def create_or_replace_topic( self, room_id: str, topic_id: str, - resource: Union[_models.ChatTopic, _types.ChatTopic, IO[bytes]], + resource: Union[_models.ChatTopicCreate, _types.ChatTopicCreate, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -1675,10 +1675,10 @@ async def create_or_replace_topic( :type room_id: str :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str - :param resource: The resource instance. Is either a ChatTopic type or a IO[bytes] type. + :param resource: The resource instance. Is either a ChatTopicCreate type or a IO[bytes] type. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopic or - ~azure.messaging.webpubsubchatservice.types.ChatTopic or IO[bytes] + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopicCreate or + ~azure.messaging.webpubsubchatservice.types.ChatTopicCreate or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. :paramtype etag: str @@ -1839,7 +1839,7 @@ async def update_topic( self, room_id: str, topic_id: str, - resource: _models.ChatTopic, + resource: _models.ChatTopicUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = None, @@ -1855,7 +1855,7 @@ async def update_topic( :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopic + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopicUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -1874,7 +1874,7 @@ async def update_topic( self, room_id: str, topic_id: str, - resource: _types.ChatTopic, + resource: _types.ChatTopicUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = None, @@ -1890,7 +1890,7 @@ async def update_topic( :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatTopic + :type resource: ~azure.messaging.webpubsubchatservice.types.ChatTopicUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -1960,7 +1960,7 @@ async def update_topic( self, room_id: str, topic_id: str, - resource: Union[_models.ChatTopic, _types.ChatTopic, IO[bytes]], + resource: Union[_models.ChatTopicUpdate, _types.ChatTopicUpdate, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -1974,10 +1974,10 @@ async def update_topic( :type room_id: str :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str - :param resource: The resource instance. Is either a ChatTopic type or a IO[bytes] type. + :param resource: The resource instance. Is either a ChatTopicUpdate type or a IO[bytes] type. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopic or - ~azure.messaging.webpubsubchatservice.types.ChatTopic or IO[bytes] + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopicUpdate or + ~azure.messaging.webpubsubchatservice.types.ChatTopicUpdate or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. :paramtype etag: str @@ -2257,7 +2257,7 @@ async def create_or_replace_room_member( self, room_id: str, user_id: str, - resource: _models.ChatRoomMember, + resource: _models.ChatRoomMemberCreate, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -2273,7 +2273,7 @@ async def create_or_replace_room_member( :param user_id: User ID of the member. Required. :type user_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomMember + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomMemberCreate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2292,7 +2292,7 @@ async def create_or_replace_room_member( self, room_id: str, user_id: str, - resource: _types.ChatRoomMember, + resource: _types.ChatRoomMemberCreate, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -2308,7 +2308,7 @@ async def create_or_replace_room_member( :param user_id: User ID of the member. Required. :type user_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatRoomMember + :type resource: ~azure.messaging.webpubsubchatservice.types.ChatRoomMemberCreate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2362,7 +2362,7 @@ async def create_or_replace_room_member( self, room_id: str, user_id: str, - resource: Union[_models.ChatRoomMember, _types.ChatRoomMember, IO[bytes]], + resource: Union[_models.ChatRoomMemberCreate, _types.ChatRoomMemberCreate, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -2376,10 +2376,10 @@ async def create_or_replace_room_member( :type room_id: str :param user_id: User ID of the member. Required. :type user_id: str - :param resource: The resource instance. Is either a ChatRoomMember type or a IO[bytes] type. - Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomMember or - ~azure.messaging.webpubsubchatservice.types.ChatRoomMember or IO[bytes] + :param resource: The resource instance. Is either a ChatRoomMemberCreate type or a IO[bytes] + type. Required. + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomMemberCreate or + ~azure.messaging.webpubsubchatservice.types.ChatRoomMemberCreate or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. :paramtype etag: str @@ -2715,7 +2715,7 @@ async def get_user(self, user_id: str, **kwargs: Any) -> _models.ChatUser: async def create_or_replace_user( self, user_id: str, - resource: _models.ChatUser, + resource: _models.ChatUserCreate, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -2730,7 +2730,7 @@ async def create_or_replace_user( :param user_id: User identifier. Required. :type user_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatUser + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatUserCreate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2748,7 +2748,7 @@ async def create_or_replace_user( async def create_or_replace_user( self, user_id: str, - resource: _types.ChatUser, + resource: _types.ChatUserCreate, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -2763,7 +2763,7 @@ async def create_or_replace_user( :param user_id: User identifier. Required. :type user_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatUser + :type resource: ~azure.messaging.webpubsubchatservice.types.ChatUserCreate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2814,7 +2814,7 @@ async def create_or_replace_user( async def create_or_replace_user( self, user_id: str, - resource: Union[_models.ChatUser, _types.ChatUser, IO[bytes]], + resource: Union[_models.ChatUserCreate, _types.ChatUserCreate, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -2827,10 +2827,10 @@ async def create_or_replace_user( :param user_id: User identifier. Required. :type user_id: str - :param resource: The resource instance. Is either a ChatUser type or a IO[bytes] type. + :param resource: The resource instance. Is either a ChatUserCreate type or a IO[bytes] type. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatUser or - ~azure.messaging.webpubsubchatservice.types.ChatUser or IO[bytes] + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatUserCreate or + ~azure.messaging.webpubsubchatservice.types.ChatUserCreate or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. :paramtype etag: str diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/__init__.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/__init__.py index c0afafd66acc..7f275bbf418b 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/__init__.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/__init__.py @@ -16,13 +16,21 @@ from ._models import ( # type: ignore ChatConversation, ChatMessage, + ChatMessageUpdate, ChatRole, + ChatRoleCreate, ChatRoom, + ChatRoomCreate, ChatRoomMember, + ChatRoomMemberCreate, ChatTopic, + ChatTopicCreate, + ChatTopicUpdate, ChatUser, + ChatUserCreate, ChatUserRoom, HumanChatUser, + HumanChatUserCreate, MessageContent, ) @@ -38,13 +46,21 @@ __all__ = [ "ChatConversation", "ChatMessage", + "ChatMessageUpdate", "ChatRole", + "ChatRoleCreate", "ChatRoom", + "ChatRoomCreate", "ChatRoomMember", + "ChatRoomMemberCreate", "ChatTopic", + "ChatTopicCreate", + "ChatTopicUpdate", "ChatUser", + "ChatUserCreate", "ChatUserRoom", "HumanChatUser", + "HumanChatUserCreate", "MessageContent", "ChatPermission", "ChatTopicState", diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/_models.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/_models.py index 16971c33e2fa..f4b65ae712f0 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/_models.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/_models.py @@ -99,6 +99,39 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) +class ChatMessageUpdate(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Properties supplied when partially updating a message. + + :ivar created_by: User who created the message. + :vartype created_by: str + :ivar content: Message content. + :vartype content: ~azure.messaging.webpubsubchatservice.models.MessageContent + """ + + created_by: Optional[str] = rest_field(name="createdBy", visibility=["read", "create", "update", "delete", "query"]) + """User who created the message.""" + content: Optional["_models.MessageContent"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Message content.""" + + @overload + def __init__( + self, + *, + created_by: Optional[str] = None, + content: Optional["_models.MessageContent"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + class ChatRole(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only """Represents a chat role. A role name must start with 'user.' or 'room.' prefix. A role must contain either user permissions or room permissions, but not both. @@ -140,6 +173,38 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) +class ChatRoleCreate(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Properties supplied when creating a role. + + :ivar permissions: Permissions associated with the role. Do not mix user permissions and room + permissions in one role. Required. + :vartype permissions: list[str or ~azure.messaging.webpubsubchatservice.models.ChatPermission] + """ + + permissions: list[Union[str, "_models.ChatPermission"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Permissions associated with the role. Do not mix user permissions and room permissions in one + role. Required.""" + + @overload + def __init__( + self, + *, + permissions: list[Union[str, "_models.ChatPermission"]], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + class ChatRoom(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only """Represents a chat room. @@ -180,6 +245,34 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) +class ChatRoomCreate(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Properties supplied when creating a room. + + :ivar title: Room title. Required. + :vartype title: str + """ + + title: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Room title. Required.""" + + @overload + def __init__( + self, + *, + title: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + class ChatRoomMember(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only """Represents a room member. @@ -216,6 +309,34 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) +class ChatRoomMemberCreate(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Properties supplied when creating a room member. + + :ivar role_name: Room role assigned to the user within this room. Required. + :vartype role_name: str + """ + + role_name: str = rest_field(name="roleName", visibility=["read", "create", "update", "delete", "query"]) + """Room role assigned to the user within this room. Required.""" + + @overload + def __init__( + self, + *, + role_name: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + class ChatTopic(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only """Represents a chat topic in a room. @@ -271,6 +392,71 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) +class ChatTopicCreate(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Properties supplied when creating a topic. + + :ivar title: Topic title. Required. + :vartype title: str + """ + + title: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Topic title. Required.""" + + @overload + def __init__( + self, + *, + title: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ChatTopicUpdate(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Properties supplied when partially updating a topic. + + :ivar title: Topic title. + :vartype title: str + :ivar state: Current lifecycle state of the topic. Known values are: "Normal", "Archived", and + "SoftDeleted". + :vartype state: str or ~azure.messaging.webpubsubchatservice.models.ChatTopicState + """ + + title: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Topic title.""" + state: Optional[Union[str, "_models.ChatTopicState"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Current lifecycle state of the topic. Known values are: \"Normal\", \"Archived\", and + \"SoftDeleted\".""" + + @overload + def __init__( + self, + *, + title: Optional[str] = None, + state: Optional[Union[str, "_models.ChatTopicState"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + class ChatUser(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only """Represents a user profile in the chat system. This is a discriminated base type; concrete payloads are selected by the ``kind`` field (e.g. ``HumanChatUser``). @@ -317,6 +503,43 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) +class ChatUserCreate(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Properties supplied when creating a user. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + HumanChatUserCreate + + :ivar kind: The kind of user. Required. "Human" + :vartype kind: str or ~azure.messaging.webpubsubchatservice.models.ChatUserKind + :ivar nickname: User's display nickname. Required. + :vartype nickname: str + """ + + __mapping__: dict[str, _Model] = {} + kind: str = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) + """The kind of user. Required. \"Human\"""" + nickname: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """User's display nickname. Required.""" + + @overload + def __init__( + self, + *, + kind: str, + nickname: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + class ChatUserRoom(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only """Represents a read-only room projection used to list rooms associated with a user. This model enables the standard resource operation to derive the @@ -428,6 +651,44 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.kind = ChatUserKind.HUMAN # type: ignore +class HumanChatUserCreate( + ChatUserCreate, discriminator="Human" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """Properties supplied when creating a human user. + + :ivar kind: Required. A human end-user. + :vartype kind: str or ~azure.messaging.webpubsubchatservice.models.HUMAN + :ivar role_name: Global user role assigned to the user. Must start with ``user.``. Required. + :vartype role_name: str + :ivar nickname: User's display nickname. Required. + :vartype nickname: str + """ + + kind: Literal[ChatUserKind.HUMAN] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. A human end-user.""" + role_name: str = rest_field(name="roleName", visibility=["read", "create", "update", "delete", "query"]) + """Global user role assigned to the user. Must start with ``user.``. Required.""" + + @overload + def __init__( + self, + *, + role_name: str, + nickname: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.kind = ChatUserKind.HUMAN # type: ignore + + class MessageContent(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only """Message content body. diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py index 189375c7b7b2..716c6902af1d 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py @@ -15,159 +15,101 @@ from .models import ChatPermission, ChatTopicState -class ChatMessage(TypedDict, total=False): - """Represents a chat message. +class ChatMessageUpdate(TypedDict, total=False): + """Properties supplied when partially updating a message. - :ivar id: Message identifier. Required. - :vartype id: str - :ivar createdBy: User who created the message. Required. + :ivar createdBy: User who created the message. :vartype createdBy: str - :ivar content: Message content. Required. + :ivar content: Message content. :vartype content: "MessageContent" - :ivar createdAt: Timestamp when the message was created. Required. - :vartype createdAt: str - :ivar etag: The entity tag for this resource. Required. - :vartype etag: str """ - id: Required[str] - """Message identifier. Required.""" - createdBy: Required[str] - """User who created the message. Required.""" - content: Required["MessageContent"] - """Message content. Required.""" - createdAt: Required[str] - """Timestamp when the message was created. Required.""" - etag: Required[str] - """The entity tag for this resource. Required.""" + createdBy: str + """User who created the message.""" + content: "MessageContent" + """Message content.""" -class ChatRole(TypedDict, total=False): - """Represents a chat role. A role name must start with 'user.' or 'room.' prefix. A role must - contain either user permissions or room permissions, but not both. +class ChatRoleCreate(TypedDict, total=False): + """Properties supplied when creating a role. - :ivar name: Role name. Must start with 'user.' or 'room.' prefix. Required. - :vartype name: str :ivar permissions: Permissions associated with the role. Do not mix user permissions and room permissions in one role. Required. :vartype permissions: list[Union[str, "ChatPermission"]] - :ivar etag: The entity tag for this resource. Required. - :vartype etag: str """ - name: Required[str] - """Role name. Must start with 'user.' or 'room.' prefix. Required.""" permissions: Required[list[Union[str, "ChatPermission"]]] """Permissions associated with the role. Do not mix user permissions and room permissions in one role. Required.""" - etag: Required[str] - """The entity tag for this resource. Required.""" -class ChatRoom(TypedDict, total=False): - """Represents a chat room. +class ChatRoomCreate(TypedDict, total=False): + """Properties supplied when creating a room. - :ivar id: Room identifier. Required. - :vartype id: str :ivar title: Room title. Required. :vartype title: str - :ivar defaultConversation: Default conversation ID for this room. Required. - :vartype defaultConversation: str - :ivar etag: The entity tag for this resource. Required. - :vartype etag: str """ - id: Required[str] - """Room identifier. Required.""" title: Required[str] """Room title. Required.""" - defaultConversation: Required[str] - """Default conversation ID for this room. Required.""" - etag: Required[str] - """The entity tag for this resource. Required.""" -class ChatRoomMember(TypedDict, total=False): - """Represents a room member. +class ChatRoomMemberCreate(TypedDict, total=False): + """Properties supplied when creating a room member. - :ivar userId: User ID of the member. Required. - :vartype userId: str :ivar roleName: Room role assigned to the user within this room. Required. :vartype roleName: str - :ivar etag: The entity tag for this resource. Required. - :vartype etag: str """ - userId: Required[str] - """User ID of the member. Required.""" roleName: Required[str] """Room role assigned to the user within this room. Required.""" - etag: Required[str] - """The entity tag for this resource. Required.""" -class ChatTopic(TypedDict, total=False): - """Represents a chat topic in a room. +class ChatTopicCreate(TypedDict, total=False): + """Properties supplied when creating a topic. - :ivar id: Topic identifier unique within the room. Required. - :vartype id: str :ivar title: Topic title. Required. :vartype title: str - :ivar createdAt: Timestamp when the topic was created. Required. - :vartype createdAt: str - :ivar createdBy: User who created the topic. Required. - :vartype createdBy: str - :ivar state: Current lifecycle state of the topic. Required. Known values are: "Normal", - "Archived", and "SoftDeleted". - :vartype state: Union[str, "ChatTopicState"] - :ivar conversationId: Conversation associated with this topic. Required. - :vartype conversationId: str - :ivar etag: The entity tag for this resource. Required. - :vartype etag: str """ - id: Required[str] - """Topic identifier unique within the room. Required.""" title: Required[str] """Topic title. Required.""" - createdAt: Required[str] - """Timestamp when the topic was created. Required.""" - createdBy: Required[str] - """User who created the topic. Required.""" - state: Required[Union[str, "ChatTopicState"]] - """Current lifecycle state of the topic. Required. Known values are: \"Normal\", \"Archived\", and + + +class ChatTopicUpdate(TypedDict, total=False): + """Properties supplied when partially updating a topic. + + :ivar title: Topic title. + :vartype title: str + :ivar state: Current lifecycle state of the topic. Known values are: "Normal", "Archived", and + "SoftDeleted". + :vartype state: Union[str, "ChatTopicState"] + """ + + title: str + """Topic title.""" + state: Union[str, "ChatTopicState"] + """Current lifecycle state of the topic. Known values are: \"Normal\", \"Archived\", and \"SoftDeleted\".""" - conversationId: Required[str] - """Conversation associated with this topic. Required.""" - etag: Required[str] - """The entity tag for this resource. Required.""" -class HumanChatUser(TypedDict, total=False): - """A human end-user, identified by a user role. +class HumanChatUserCreate(TypedDict, total=False): + """Properties supplied when creating a human user. - :ivar id: User identifier. Required. - :vartype id: str - :ivar nickname: User's display nickname. Required. - :vartype nickname: str - :ivar etag: The entity tag for this resource. Required. - :vartype etag: str :ivar kind: Required. A human end-user. :vartype kind: Literal[ChatUserKind.HUMAN] :ivar roleName: Global user role assigned to the user. Must start with ``user.``. Required. :vartype roleName: str + :ivar nickname: User's display nickname. Required. + :vartype nickname: str """ - id: Required[str] - """User identifier. Required.""" - nickname: Required[str] - """User's display nickname. Required.""" - etag: Required[str] - """The entity tag for this resource. Required.""" kind: Required[Literal[ChatUserKind.HUMAN]] """Required. A human end-user.""" roleName: Required[str] """Global user role assigned to the user. Must start with ``user.``. Required.""" + nickname: Required[str] + """User's display nickname. Required.""" class MessageContent(TypedDict, total=False): @@ -185,4 +127,4 @@ class MessageContent(TypedDict, total=False): """Binary content (base64 encoded).""" -ChatUser = Union[HumanChatUser] +ChatUserCreate = Union[HumanChatUserCreate] diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service.py index 613f4617bda4..54880d9e5d24 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service.py @@ -53,13 +53,7 @@ def test_update_message(self, webpubsubchatservice_endpoint): response = client.update_message( conversation_id="str", message_id="str", - resource={ - "content": {"binary": bytes("bytes", encoding="utf-8"), "text": "str"}, - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "etag": "str", - "id": "str", - }, + resource={"content": {"binary": bytes("bytes", encoding="utf-8"), "text": "str"}, "createdBy": "str"}, ) # please add some check logic here by yourself @@ -91,7 +85,7 @@ def test_create_or_replace_role(self, webpubsubchatservice_endpoint): client = self.create_client(endpoint=webpubsubchatservice_endpoint) response = client.create_or_replace_role( role_name="str", - resource={"etag": "str", "name": "str", "permissions": ["str"]}, + resource={"permissions": ["str"]}, ) # please add some check logic here by yourself @@ -123,7 +117,7 @@ def test_create_or_replace_room(self, webpubsubchatservice_endpoint): client = self.create_client(endpoint=webpubsubchatservice_endpoint) response = client.create_or_replace_room( room_id="str", - resource={"defaultConversation": "str", "etag": "str", "id": "str", "title": "str"}, + resource={"title": "str"}, ) # please add some check logic here by yourself @@ -169,15 +163,7 @@ def test_create_or_replace_topic(self, webpubsubchatservice_endpoint): response = client.create_or_replace_topic( room_id="str", topic_id="str", - resource={ - "conversationId": "str", - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "etag": "str", - "id": "str", - "state": "str", - "title": "str", - }, + resource={"title": "str"}, ) # please add some check logic here by yourself @@ -202,15 +188,7 @@ def test_update_topic(self, webpubsubchatservice_endpoint): response = client.update_topic( room_id="str", topic_id="str", - resource={ - "conversationId": "str", - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "etag": "str", - "id": "str", - "state": "str", - "title": "str", - }, + resource={"state": "str", "title": "str"}, ) # please add some check logic here by yourself @@ -246,7 +224,7 @@ def test_create_or_replace_room_member(self, webpubsubchatservice_endpoint): response = client.create_or_replace_room_member( room_id="str", user_id="str", - resource={"etag": "str", "roleName": "str", "userId": "str"}, + resource={"roleName": "str"}, ) # please add some check logic here by yourself @@ -290,7 +268,7 @@ def test_create_or_replace_user(self, webpubsubchatservice_endpoint): client = self.create_client(endpoint=webpubsubchatservice_endpoint) response = client.create_or_replace_user( user_id="str", - resource={"etag": "str", "id": "str", "kind": "Human", "nickname": "str", "roleName": "str"}, + resource={"kind": "Human", "nickname": "str", "roleName": "str"}, ) # please add some check logic here by yourself diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service_async.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service_async.py index 9533e64c185b..c830c56a0d8a 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service_async.py @@ -54,13 +54,7 @@ async def test_update_message(self, webpubsubchatservice_endpoint): response = await client.update_message( conversation_id="str", message_id="str", - resource={ - "content": {"binary": bytes("bytes", encoding="utf-8"), "text": "str"}, - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "etag": "str", - "id": "str", - }, + resource={"content": {"binary": bytes("bytes", encoding="utf-8"), "text": "str"}, "createdBy": "str"}, ) # please add some check logic here by yourself @@ -92,7 +86,7 @@ async def test_create_or_replace_role(self, webpubsubchatservice_endpoint): client = self.create_async_client(endpoint=webpubsubchatservice_endpoint) response = await client.create_or_replace_role( role_name="str", - resource={"etag": "str", "name": "str", "permissions": ["str"]}, + resource={"permissions": ["str"]}, ) # please add some check logic here by yourself @@ -124,7 +118,7 @@ async def test_create_or_replace_room(self, webpubsubchatservice_endpoint): client = self.create_async_client(endpoint=webpubsubchatservice_endpoint) response = await client.create_or_replace_room( room_id="str", - resource={"defaultConversation": "str", "etag": "str", "id": "str", "title": "str"}, + resource={"title": "str"}, ) # please add some check logic here by yourself @@ -170,15 +164,7 @@ async def test_create_or_replace_topic(self, webpubsubchatservice_endpoint): response = await client.create_or_replace_topic( room_id="str", topic_id="str", - resource={ - "conversationId": "str", - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "etag": "str", - "id": "str", - "state": "str", - "title": "str", - }, + resource={"title": "str"}, ) # please add some check logic here by yourself @@ -203,15 +189,7 @@ async def test_update_topic(self, webpubsubchatservice_endpoint): response = await client.update_topic( room_id="str", topic_id="str", - resource={ - "conversationId": "str", - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "etag": "str", - "id": "str", - "state": "str", - "title": "str", - }, + resource={"state": "str", "title": "str"}, ) # please add some check logic here by yourself @@ -247,7 +225,7 @@ async def test_create_or_replace_room_member(self, webpubsubchatservice_endpoint response = await client.create_or_replace_room_member( room_id="str", user_id="str", - resource={"etag": "str", "roleName": "str", "userId": "str"}, + resource={"roleName": "str"}, ) # please add some check logic here by yourself @@ -291,7 +269,7 @@ async def test_create_or_replace_user(self, webpubsubchatservice_endpoint): client = self.create_async_client(endpoint=webpubsubchatservice_endpoint) response = await client.create_or_replace_user( user_id="str", - resource={"etag": "str", "id": "str", "kind": "Human", "nickname": "str", "roleName": "str"}, + resource={"kind": "Human", "nickname": "str", "roleName": "str"}, ) # please add some check logic here by yourself diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_message_management.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_message_management.py index 4755ee06d424..b6574cd274e1 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_message_management.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_message_management.py @@ -5,7 +5,7 @@ import os from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient -from azure.messaging.webpubsubchatservice.models import ChatMessage, MessageContent +from azure.messaging.webpubsubchatservice.models import ChatMessageUpdate, MessageContent def main(): @@ -13,7 +13,6 @@ def main(): "WPS_CHAT_CONNECTION_STRING", "WPS_CHAT_CONVERSATION_ID", "WPS_CHAT_MESSAGE_ID", - "WPS_CHAT_USER_ID", ) missing = [name for name in required if not os.environ.get(name)] if missing: @@ -29,8 +28,7 @@ def main(): client.update_message( conversation_id, message_id, - ChatMessage( - created_by=os.environ["WPS_CHAT_USER_ID"], + ChatMessageUpdate( content=MessageContent(text="Updated message"), ), ) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_readme_snippets.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_readme_snippets.py index 62811040c60e..4b7d30a29649 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_readme_snippets.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_readme_snippets.py @@ -16,11 +16,11 @@ def list_roles(client: WebPubSubChatServiceClient) -> None: def create_user(client: WebPubSubChatServiceClient) -> None: # [START create_user] - from azure.messaging.webpubsubchatservice.models import HumanChatUser + from azure.messaging.webpubsubchatservice.models import HumanChatUserCreate user = client.create_or_replace_user( "alice", - HumanChatUser(nickname="Alice", role_name="user.room_creator"), + HumanChatUserCreate(nickname="Alice", role_name="user.room_creator"), ) print(user.id, user.nickname) # [END create_user] @@ -28,21 +28,21 @@ def create_user(client: WebPubSubChatServiceClient) -> None: def create_room(client: WebPubSubChatServiceClient) -> None: # [START create_room] - from azure.messaging.webpubsubchatservice.models import ChatRoom + from azure.messaging.webpubsubchatservice.models import ChatRoomCreate - room = client.create_or_replace_room("general", ChatRoom(title="General")) + room = client.create_or_replace_room("general", ChatRoomCreate(title="General")) print(room.id, room.default_conversation) # [END create_room] def add_room_member(client: WebPubSubChatServiceClient) -> None: # [START add_room_member] - from azure.messaging.webpubsubchatservice.models import ChatRoomMember + from azure.messaging.webpubsubchatservice.models import ChatRoomMemberCreate member = client.create_or_replace_room_member( "general", "alice", - ChatRoomMember(role_name="room.contributor"), + ChatRoomMemberCreate(role_name="room.contributor"), ) print(member.user_id, member.role_name) # [END add_room_member] @@ -60,12 +60,12 @@ def list_messages(client: WebPubSubChatServiceClient) -> None: def create_topic(client: WebPubSubChatServiceClient) -> None: # [START create_topic] import os - from azure.messaging.webpubsubchatservice.models import ChatTopic + from azure.messaging.webpubsubchatservice.models import ChatTopicCreate topic = client.create_or_replace_topic( os.environ["WPS_CHAT_ROOM_ID"], os.environ["WPS_CHAT_TOPIC_ID"], - ChatTopic({"title": "Announcements"}), + ChatTopicCreate(title="Announcements"), ) print(topic.id, topic.etag) # [END create_topic] @@ -93,12 +93,12 @@ def archive_topic(client: WebPubSubChatServiceClient) -> None: # [START archive_topic] import os from azure.core import MatchConditions - from azure.messaging.webpubsubchatservice.models import ChatTopic, ChatTopicState + from azure.messaging.webpubsubchatservice.models import ChatTopicUpdate, ChatTopicState topic = client.update_topic( os.environ["WPS_CHAT_ROOM_ID"], os.environ["WPS_CHAT_TOPIC_ID"], - ChatTopic(title="Announcements", state=ChatTopicState.ARCHIVED), + ChatTopicUpdate(state=ChatTopicState.ARCHIVED), etag=os.environ["WPS_CHAT_TOPIC_ETAG"], match_condition=MatchConditions.IfNotModified, ) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions.py index 886e5589941d..1e9a18e75bcf 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions.py @@ -8,11 +8,11 @@ def create_role(client): # [START create_role] - from azure.messaging.webpubsubchatservice.models import ChatPermission, ChatRole + from azure.messaging.webpubsubchatservice.models import ChatPermission, ChatRoleCreate role = client.create_or_replace_role( os.environ.get("WPS_CHAT_ROLE_NAME", "user.python_sample"), - ChatRole(permissions=[ChatPermission.USER_CREATE_ROOM]), + ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM]), ) print(role.name, role.permissions) # [END create_role] diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions_async.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions_async.py index 03cdb4b8f22d..66fe3c206144 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions_async.py @@ -9,11 +9,11 @@ async def create_role(client): # [START create_role] - from azure.messaging.webpubsubchatservice.models import ChatPermission, ChatRole + from azure.messaging.webpubsubchatservice.models import ChatPermission, ChatRoleCreate role = await client.create_or_replace_role( os.environ.get("WPS_CHAT_ROLE_NAME", "user.python_sample"), - ChatRole(permissions=[ChatPermission.USER_CREATE_ROOM]), + ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM]), ) print(role.name, role.permissions) # [END create_role] diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview.py index 15f809471591..393bff912c70 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview.py @@ -17,7 +17,9 @@ from azure.messaging.webpubsubchatservice.models import ( ChatRoom, ChatTopic, + ChatTopicCreate, ChatTopicState, + ChatTopicUpdate, ChatUserRoom, HumanChatUser, ) @@ -125,16 +127,14 @@ def test_topic_serialization_lifecycle_and_etag(): "run", side_effect=[_response(TOPIC, 201), _response(TOPIC), _response(archived), _response({}, 204)], ) as run: - topic = client.create_or_replace_topic( - "room", "topic", ChatTopic({"title": TOPIC["title"], "id": TOPIC["id"], "etag": TOPIC["etag"]}) - ) + topic = client.create_or_replace_topic("room", "topic", ChatTopicCreate(title=TOPIC["title"])) assert topic.created_at == datetime.datetime(2026, 8, 1, tzinfo=datetime.timezone.utc) fetched = client.get_topic("room", "topic") assert fetched.state == ChatTopicState.NORMAL updated = client.update_topic( "room", "topic", - ChatTopic(title=topic.title, state=ChatTopicState.ARCHIVED), + ChatTopicUpdate(title=topic.title, state=ChatTopicState.ARCHIVED), etag=fetched.etag, match_condition=MatchConditions.IfNotModified, ) @@ -157,16 +157,14 @@ async def test_async_topic_serialization_lifecycle_and_etag(): new_callable=AsyncMock, side_effect=[_response(TOPIC, 201), _response(TOPIC), _response(archived), _response({}, 204)], ) as run: - topic = await client.create_or_replace_topic( - "room", "topic", ChatTopic({"title": TOPIC["title"], "id": TOPIC["id"], "etag": TOPIC["etag"]}) - ) + topic = await client.create_or_replace_topic("room", "topic", ChatTopicCreate(title=TOPIC["title"])) assert topic.created_at == datetime.datetime(2026, 8, 1, tzinfo=datetime.timezone.utc) fetched = await client.get_topic("room", "topic") assert fetched.state == ChatTopicState.NORMAL updated = await client.update_topic( "room", "topic", - ChatTopic(title=topic.title, state=ChatTopicState.ARCHIVED), + ChatTopicUpdate(title=topic.title, state=ChatTopicState.ARCHIVED), etag=fetched.etag, match_condition=MatchConditions.IfNotModified, ) @@ -192,7 +190,7 @@ def test_topic_stale_etag_surfaces_service_error(): client.update_topic( "room", "topic", - ChatTopic(title="Title", state=ChatTopicState.ARCHIVED), + ChatTopicUpdate(title="Title", state=ChatTopicState.ARCHIVED), etag='"stale"', match_condition=MatchConditions.IfNotModified, ) @@ -212,7 +210,7 @@ async def test_async_topic_stale_etag_surfaces_service_error(): await client.update_topic( "room", "topic", - ChatTopic(title="Title", state=ChatTopicState.ARCHIVED), + ChatTopicUpdate(title="Title", state=ChatTopicState.ARCHIVED), etag='"stale"', match_condition=MatchConditions.IfNotModified, ) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live.py index 03335b5e37cf..058efb2b83b1 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live.py @@ -9,12 +9,14 @@ from azure.core.exceptions import HttpResponseError from azure.messaging.webpubsubchatservice.models import ( ChatPermission, - ChatRole, - ChatRoom, - ChatRoomMember, - ChatTopic, + ChatRoleCreate, + ChatRoomCreate, + ChatRoomMemberCreate, + ChatTopicCreate, + ChatTopicUpdate, ChatTopicState, HumanChatUser, + HumanChatUserCreate, ) from testcase import WebPubSubChatPreparer, WebPubSubChatTest @@ -37,10 +39,10 @@ def test_topic_lifecycle_and_paging(self, wps_chat_endpoint): client = self.create_client(wps_chat_endpoint) room_id = "python-e2e-topics" try: - room = client.create_or_replace_room(room_id, ChatRoom(title="Topic E2E")) + room = client.create_or_replace_room(room_id, ChatRoomCreate(title="Topic E2E")) assert all(topic.conversation_id == room.default_conversation for topic in client.list_topics(room_id)) for topic_id in ("first", "second"): - topic = client.create_or_replace_topic(room_id, topic_id, ChatTopic({"title": topic_id})) + topic = client.create_or_replace_topic(room_id, topic_id, ChatTopicCreate(title=topic_id)) assert topic.id == topic_id assert topic.title == topic_id assert topic.state == ChatTopicState.NORMAL @@ -58,7 +60,7 @@ def test_topic_lifecycle_and_paging(self, wps_chat_endpoint): archived = client.update_topic( room_id, "first", - ChatTopic(title="Archived topic", state=ChatTopicState.ARCHIVED), + ChatTopicUpdate(title="Archived topic", state=ChatTopicState.ARCHIVED), etag=fetched.etag, match_condition=MatchConditions.IfNotModified, ) @@ -71,7 +73,7 @@ def test_topic_lifecycle_and_paging(self, wps_chat_endpoint): client.update_topic( room_id, "first", - ChatTopic(title="Stale update", state=ChatTopicState.NORMAL), + ChatTopicUpdate(title="Stale update", state=ChatTopicState.NORMAL), etag=fetched.etag, match_condition=MatchConditions.IfNotModified, ) @@ -90,14 +92,14 @@ def test_room_user_and_user_room_collections(self, wps_chat_endpoint): user_role = "user.python_e2e_collections" room_role = "room.python_e2e_collections" try: - client.create_or_replace_role(user_role, ChatRole(permissions=[ChatPermission.USER_CREATE_ROOM])) - client.create_or_replace_role(room_role, ChatRole(permissions=[ChatPermission.ROOM_PUBLISH_MESSAGE])) + client.create_or_replace_role(user_role, ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM])) + client.create_or_replace_role(room_role, ChatRoleCreate(permissions=[ChatPermission.ROOM_PUBLISH_MESSAGE])) for user_id in user_ids: - client.create_or_replace_user(user_id, HumanChatUser(nickname=user_id, role_name=user_role)) + client.create_or_replace_user(user_id, HumanChatUserCreate(nickname=user_id, role_name=user_role)) assert list(client.list_rooms_for_user(user_ids[0])) == [] for room_id in room_ids: - client.create_or_replace_room(room_id, ChatRoom(title=room_id)) - client.create_or_replace_room_member(room_id, user_ids[0], ChatRoomMember(role_name=room_role)) + client.create_or_replace_room(room_id, ChatRoomCreate(title=room_id)) + client.create_or_replace_room_member(room_id, user_ids[0], ChatRoomMemberCreate(role_name=room_role)) assert {room.id for room in client.list_rooms(max_page_size=1)}.issuperset(room_ids) users = list(client.list_users(max_page_size=1)) assert {user.id for user in users}.issuperset(user_ids) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live_async.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live_async.py index 8e7453935db8..52f76d57a893 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live_async.py @@ -9,12 +9,14 @@ from azure.core.exceptions import HttpResponseError from azure.messaging.webpubsubchatservice.models import ( ChatPermission, - ChatRole, - ChatRoom, - ChatRoomMember, - ChatTopic, + ChatRoleCreate, + ChatRoomCreate, + ChatRoomMemberCreate, + ChatTopicCreate, + ChatTopicUpdate, ChatTopicState, HumanChatUser, + HumanChatUserCreate, ) from testcase import WebPubSubChatPreparer, WebPubSubChatTest @@ -42,13 +44,13 @@ async def test_async_topic_lifecycle_and_paging(self, wps_chat_endpoint): client = self.create_async_client(wps_chat_endpoint) room_id = "python-async-e2e-topics" try: - room = await client.create_or_replace_room(room_id, ChatRoom(title="Async Topic E2E")) + room = await client.create_or_replace_room(room_id, ChatRoomCreate(title="Async Topic E2E")) assert all( topic.conversation_id == room.default_conversation for topic in await _collect(client.list_topics(room_id)) ) for topic_id in ("first", "second"): - topic = await client.create_or_replace_topic(room_id, topic_id, ChatTopic({"title": topic_id})) + topic = await client.create_or_replace_topic(room_id, topic_id, ChatTopicCreate(title=topic_id)) assert topic.id == topic_id assert topic.title == topic_id assert topic.state == ChatTopicState.NORMAL @@ -68,7 +70,7 @@ async def test_async_topic_lifecycle_and_paging(self, wps_chat_endpoint): archived = await client.update_topic( room_id, "first", - ChatTopic(title="Archived topic", state=ChatTopicState.ARCHIVED), + ChatTopicUpdate(title="Archived topic", state=ChatTopicState.ARCHIVED), etag=fetched.etag, match_condition=MatchConditions.IfNotModified, ) @@ -81,7 +83,7 @@ async def test_async_topic_lifecycle_and_paging(self, wps_chat_endpoint): await client.update_topic( room_id, "first", - ChatTopic(title="Stale update", state=ChatTopicState.NORMAL), + ChatTopicUpdate(title="Stale update", state=ChatTopicState.NORMAL), etag=fetched.etag, match_condition=MatchConditions.IfNotModified, ) @@ -103,14 +105,20 @@ async def test_async_room_user_and_user_room_collections(self, wps_chat_endpoint user_role = "user.python_async_e2e_collections" room_role = "room.python_async_e2e_collections" try: - await client.create_or_replace_role(user_role, ChatRole(permissions=[ChatPermission.USER_CREATE_ROOM])) - await client.create_or_replace_role(room_role, ChatRole(permissions=[ChatPermission.ROOM_PUBLISH_MESSAGE])) + await client.create_or_replace_role( + user_role, ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM]) + ) + await client.create_or_replace_role( + room_role, ChatRoleCreate(permissions=[ChatPermission.ROOM_PUBLISH_MESSAGE]) + ) for user_id in user_ids: - await client.create_or_replace_user(user_id, HumanChatUser(nickname=user_id, role_name=user_role)) + await client.create_or_replace_user(user_id, HumanChatUserCreate(nickname=user_id, role_name=user_role)) assert await _collect(client.list_rooms_for_user(user_ids[0])) == [] for room_id in room_ids: - await client.create_or_replace_room(room_id, ChatRoom(title=room_id)) - await client.create_or_replace_room_member(room_id, user_ids[0], ChatRoomMember(role_name=room_role)) + await client.create_or_replace_room(room_id, ChatRoomCreate(title=room_id)) + await client.create_or_replace_room_member( + room_id, user_ids[0], ChatRoomMemberCreate(role_name=room_role) + ) assert {room.id async for room in client.list_rooms(max_page_size=1)}.issuperset(room_ids) users = await _collect(client.list_users(max_page_size=1)) assert {user.id for user in users}.issuperset(user_ids) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live.py index bcadd81ac055..f4c8ffbde87d 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live.py @@ -8,12 +8,12 @@ from azure.core import MatchConditions from azure.core.exceptions import HttpResponseError from azure.messaging.webpubsubchatservice.models import ( - ChatMessage, + ChatMessageUpdate, ChatPermission, - ChatRole, - ChatRoom, - ChatRoomMember, - HumanChatUser, + ChatRoleCreate, + ChatRoomCreate, + ChatRoomMemberCreate, + HumanChatUserCreate, MessageContent, ) @@ -34,7 +34,7 @@ def test_role_lifecycle_and_paging(self, wps_chat_endpoint): for role_name in role_names: role = client.create_or_replace_role( role_name, - ChatRole(permissions=[ChatPermission.USER_CREATE_ROOM]), + ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM]), ) assert role.name == role_name assert client.get_role(role_name).permissions == [ChatPermission.USER_CREATE_ROOM] @@ -82,7 +82,7 @@ def test_create_role_only_when_missing(self, wps_chat_endpoint): try: created = client.create_or_replace_role( role_name, - ChatRole(permissions=[ChatPermission.USER_CREATE_ROOM]), + ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM]), match_condition=MatchConditions.IfMissing, ) assert created.name == role_name @@ -90,7 +90,7 @@ def test_create_role_only_when_missing(self, wps_chat_endpoint): with pytest.raises(HttpResponseError) as error: client.create_or_replace_role( role_name, - ChatRole(permissions=[ChatPermission.USER_FETCH_ALL_ROOMS]), + ChatRoleCreate(permissions=[ChatPermission.USER_FETCH_ALL_ROOMS]), match_condition=MatchConditions.IfMissing, ) assert error.value.status_code == 412 @@ -106,11 +106,11 @@ def test_rejects_stale_role_etag(self, wps_chat_endpoint): try: created = client.create_or_replace_role( role_name, - ChatRole(permissions=[ChatPermission.USER_CREATE_ROOM]), + ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM]), ) replaced = client.create_or_replace_role( role_name, - ChatRole( + ChatRoleCreate( permissions=[ ChatPermission.USER_CREATE_ROOM, ChatPermission.USER_FETCH_ALL_ROOMS, @@ -124,7 +124,7 @@ def test_rejects_stale_role_etag(self, wps_chat_endpoint): with pytest.raises(HttpResponseError) as error: client.create_or_replace_role( role_name, - ChatRole(permissions=[ChatPermission.USER_CREATE_ROOM]), + ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM]), etag=created.etag, match_condition=MatchConditions.IfNotModified, ) @@ -139,7 +139,7 @@ def test_room_conversation_and_empty_pages(self, wps_chat_endpoint): client = self.create_client(wps_chat_endpoint) room_id = "python-e2e-empty-room" try: - room = client.create_or_replace_room(room_id, ChatRoom(title="Python E2E Room")) + room = client.create_or_replace_room(room_id, ChatRoomCreate(title="Python E2E Room")) assert room.id == room_id fetched_room = client.get_room(room_id) assert fetched_room.id == room_id @@ -163,11 +163,11 @@ def test_user_and_room_member_lifecycle(self, wps_chat_endpoint): user_id = "python-e2e-user" room_id = "python-e2e-member-room" try: - client.create_or_replace_role(user_role, ChatRole(permissions=[ChatPermission.USER_CREATE_ROOM])) - client.create_or_replace_role(room_role, ChatRole(permissions=[ChatPermission.ROOM_PUBLISH_MESSAGE])) + client.create_or_replace_role(user_role, ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM])) + client.create_or_replace_role(room_role, ChatRoleCreate(permissions=[ChatPermission.ROOM_PUBLISH_MESSAGE])) user = client.create_or_replace_user( user_id, - HumanChatUser(nickname="Python User", role_name=user_role), + HumanChatUserCreate(nickname="Python User", role_name=user_role), ) assert user.id == user_id assert user.kind == "Human" @@ -175,11 +175,11 @@ def test_user_and_room_member_lifecycle(self, wps_chat_endpoint): assert fetched_user.id == user_id assert fetched_user.nickname == "Python User" - client.create_or_replace_room(room_id, ChatRoom(title="Member Room")) + client.create_or_replace_room(room_id, ChatRoomCreate(title="Member Room")) member = client.create_or_replace_room_member( room_id, user_id, - ChatRoomMember(role_name=room_role), + ChatRoomMemberCreate(role_name=room_role), ) assert member.user_id == user_id assert member.role_name == room_role @@ -206,10 +206,10 @@ def test_message_lifecycle(self, wps_chat_endpoint): updated_text = "Python E2E updated message" binary_content = bytes([0, 1, 2, 254, 255]) try: - client.create_or_replace_role(user_role, ChatRole(permissions=[ChatPermission.USER_CREATE_ROOM])) + client.create_or_replace_role(user_role, ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM])) client.create_or_replace_role( room_role, - ChatRole( + ChatRoleCreate( permissions=[ ChatPermission.ROOM_PUBLISH_MESSAGE, ChatPermission.ROOM_HISTORY, @@ -218,10 +218,10 @@ def test_message_lifecycle(self, wps_chat_endpoint): ) client.create_or_replace_user( user_id, - HumanChatUser(nickname="Python Message User", role_name=user_role), + HumanChatUserCreate(nickname="Python Message User", role_name=user_role), ) - room = client.create_or_replace_room(room_id, ChatRoom(title="Python Message Room")) - client.create_or_replace_room_member(room_id, user_id, ChatRoomMember(role_name=room_role)) + room = client.create_or_replace_room(room_id, ChatRoomCreate(title="Python Message Room")) + client.create_or_replace_room_member(room_id, user_id, ChatRoomMemberCreate(role_name=room_role)) self.seed_chat_message(client, user_id, room.default_conversation, message_text) message = next( @@ -232,13 +232,13 @@ def test_message_lifecycle(self, wps_chat_endpoint): updated = client.update_message( room.default_conversation, message.id, - ChatMessage(created_by=user_id, content=MessageContent(text=updated_text)), + ChatMessageUpdate(created_by=user_id, content=MessageContent(text=updated_text)), ) assert updated.content.text == updated_text binary_updated = client.update_message( room.default_conversation, message.id, - ChatMessage( + ChatMessageUpdate( created_by=user_id, content=MessageContent(binary=binary_content), ), diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live_async.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live_async.py index 90ecc39aad08..103d8532ea82 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live_async.py @@ -8,12 +8,12 @@ from azure.core import MatchConditions from azure.core.exceptions import HttpResponseError from azure.messaging.webpubsubchatservice.models import ( - ChatMessage, + ChatMessageUpdate, ChatPermission, - ChatRole, - ChatRoom, - ChatRoomMember, - HumanChatUser, + ChatRoleCreate, + ChatRoomCreate, + ChatRoomMemberCreate, + HumanChatUserCreate, MessageContent, ) @@ -39,7 +39,7 @@ async def test_async_role_lifecycle_and_paging(self, wps_chat_endpoint): for role_name in role_names: role = await client.create_or_replace_role( role_name, - ChatRole(permissions=[ChatPermission.USER_CREATE_ROOM]), + ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM]), ) assert role.name == role_name assert (await client.get_role(role_name)).permissions == [ChatPermission.USER_CREATE_ROOM] @@ -89,7 +89,7 @@ async def test_async_create_role_only_when_missing(self, wps_chat_endpoint): try: created = await client.create_or_replace_role( role_name, - ChatRole(permissions=[ChatPermission.USER_CREATE_ROOM]), + ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM]), match_condition=MatchConditions.IfMissing, ) assert created.name == role_name @@ -97,7 +97,7 @@ async def test_async_create_role_only_when_missing(self, wps_chat_endpoint): with pytest.raises(HttpResponseError) as error: await client.create_or_replace_role( role_name, - ChatRole(permissions=[ChatPermission.USER_FETCH_ALL_ROOMS]), + ChatRoleCreate(permissions=[ChatPermission.USER_FETCH_ALL_ROOMS]), match_condition=MatchConditions.IfMissing, ) assert error.value.status_code == 412 @@ -114,11 +114,11 @@ async def test_async_rejects_stale_role_etag(self, wps_chat_endpoint): try: created = await client.create_or_replace_role( role_name, - ChatRole(permissions=[ChatPermission.USER_CREATE_ROOM]), + ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM]), ) replaced = await client.create_or_replace_role( role_name, - ChatRole( + ChatRoleCreate( permissions=[ ChatPermission.USER_CREATE_ROOM, ChatPermission.USER_FETCH_ALL_ROOMS, @@ -132,7 +132,7 @@ async def test_async_rejects_stale_role_etag(self, wps_chat_endpoint): with pytest.raises(HttpResponseError) as error: await client.create_or_replace_role( role_name, - ChatRole(permissions=[ChatPermission.USER_CREATE_ROOM]), + ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM]), etag=created.etag, match_condition=MatchConditions.IfNotModified, ) @@ -148,7 +148,7 @@ async def test_async_room_conversation_and_empty_pages(self, wps_chat_endpoint): client = self.create_async_client(wps_chat_endpoint) room_id = "python-async-e2e-empty-room" try: - room = await client.create_or_replace_room(room_id, ChatRoom(title="Async Python E2E Room")) + room = await client.create_or_replace_room(room_id, ChatRoomCreate(title="Async Python E2E Room")) assert room.id == room_id fetched_room = await client.get_room(room_id) assert fetched_room.id == room_id @@ -173,23 +173,27 @@ async def test_async_user_and_room_member_lifecycle(self, wps_chat_endpoint): user_id = "python-async-e2e-user" room_id = "python-async-e2e-member-room" try: - await client.create_or_replace_role(user_role, ChatRole(permissions=[ChatPermission.USER_CREATE_ROOM])) - await client.create_or_replace_role(room_role, ChatRole(permissions=[ChatPermission.ROOM_PUBLISH_MESSAGE])) + await client.create_or_replace_role( + user_role, ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM]) + ) + await client.create_or_replace_role( + room_role, ChatRoleCreate(permissions=[ChatPermission.ROOM_PUBLISH_MESSAGE]) + ) user = await client.create_or_replace_user( user_id, - HumanChatUser(nickname="Async Python User", role_name=user_role), + HumanChatUserCreate(nickname="Async Python User", role_name=user_role), ) assert user.id == user_id assert user.kind == "Human" fetched_user = await client.get_user(user_id) assert fetched_user.id == user_id assert fetched_user.nickname == "Async Python User" - await client.create_or_replace_room(room_id, ChatRoom(title="Async Member Room")) + await client.create_or_replace_room(room_id, ChatRoomCreate(title="Async Member Room")) member = await client.create_or_replace_room_member( room_id, user_id, - ChatRoomMember(role_name=room_role), + ChatRoomMemberCreate(role_name=room_role), ) assert member.user_id == user_id assert member.role_name == room_role @@ -218,10 +222,12 @@ async def test_async_message_lifecycle(self, wps_chat_endpoint): updated_text = "Python async E2E updated message" binary_content = bytes([0, 1, 2, 254, 255]) try: - await client.create_or_replace_role(user_role, ChatRole(permissions=[ChatPermission.USER_CREATE_ROOM])) + await client.create_or_replace_role( + user_role, ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM]) + ) await client.create_or_replace_role( room_role, - ChatRole( + ChatRoleCreate( permissions=[ ChatPermission.ROOM_PUBLISH_MESSAGE, ChatPermission.ROOM_HISTORY, @@ -230,10 +236,10 @@ async def test_async_message_lifecycle(self, wps_chat_endpoint): ) await client.create_or_replace_user( user_id, - HumanChatUser(nickname="Async Message User", role_name=user_role), + HumanChatUserCreate(nickname="Async Message User", role_name=user_role), ) - room = await client.create_or_replace_room(room_id, ChatRoom(title="Async Message Room")) - await client.create_or_replace_room_member(room_id, user_id, ChatRoomMember(role_name=room_role)) + room = await client.create_or_replace_room(room_id, ChatRoomCreate(title="Async Message Room")) + await client.create_or_replace_room_member(room_id, user_id, ChatRoomMemberCreate(role_name=room_role)) await self.seed_chat_message_async(client, user_id, room.default_conversation, message_text) messages = await _collect(client.list_messages(room.default_conversation)) @@ -243,13 +249,13 @@ async def test_async_message_lifecycle(self, wps_chat_endpoint): updated = await client.update_message( room.default_conversation, message.id, - ChatMessage(created_by=user_id, content=MessageContent(text=updated_text)), + ChatMessageUpdate(created_by=user_id, content=MessageContent(text=updated_text)), ) assert updated.content.text == updated_text binary_updated = await client.update_message( room.default_conversation, message.id, - ChatMessage( + ChatMessageUpdate( created_by=user_id, content=MessageContent(binary=binary_content), ), diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_request_models.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_request_models.py new file mode 100644 index 000000000000..c1c0b594136c --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_request_models.py @@ -0,0 +1,154 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +import ast +import inspect +import json +from unittest.mock import AsyncMock, Mock, patch + +import pytest +from azure.core import MatchConditions +from azure.core.credentials import AzureKeyCredential + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient +from azure.messaging.webpubsubchatservice.aio import WebPubSubChatServiceClient as AsyncClient +from azure.messaging.webpubsubchatservice import models + +MODEL_SHAPES = [ + (models.ChatTopicCreate, {"title"}, {"title"}), + (models.ChatTopicUpdate, {"title", "state"}, set()), + (models.ChatMessageUpdate, {"created_by", "content"}, set()), + (models.ChatRoleCreate, {"permissions"}, {"permissions"}), + (models.ChatRoomCreate, {"title"}, {"title"}), + (models.ChatRoomMemberCreate, {"role_name"}, {"role_name"}), + (models.ChatUserCreate, {"kind", "nickname"}, {"kind", "nickname"}), + (models.HumanChatUserCreate, {"kind", "nickname", "role_name"}, {"nickname", "role_name"}), +] + +CASES = [ + ( + "create_or_replace_topic", + ("room", "topic"), + models.ChatTopicCreate(title="Title"), + models.ChatTopic, + {"title": "Title"}, + ), + ( + "update_topic", + ("room", "topic"), + models.ChatTopicUpdate(state=models.ChatTopicState.ARCHIVED), + models.ChatTopic, + {"state": "Archived"}, + ), + ( + "update_topic", + ("room", "topic"), + models.ChatTopicUpdate(title="New title"), + models.ChatTopic, + {"title": "New title"}, + ), + ( + "update_message", + ("conversation", "message"), + models.ChatMessageUpdate(content=models.MessageContent(text="Updated")), + models.ChatMessage, + {"content": {"text": "Updated"}}, + ), + ( + "update_message", + ("conversation", "message"), + models.ChatMessageUpdate(content=models.MessageContent(binary=b"\x00\xff")), + models.ChatMessage, + {"content": {"binary": "AP8="}}, + ), + ( + "create_or_replace_role", + ("user.role",), + models.ChatRoleCreate(permissions=[models.ChatPermission.USER_CREATE_ROOM]), + models.ChatRole, + {"permissions": ["user.create_room"]}, + ), + ("create_or_replace_room", ("room",), models.ChatRoomCreate(title="Room"), models.ChatRoom, {"title": "Room"}), + ( + "create_or_replace_room_member", + ("room", "user"), + models.ChatRoomMemberCreate(role_name="room.member"), + models.ChatRoomMember, + {"roleName": "room.member"}, + ), + ( + "create_or_replace_user", + ("user",), + models.HumanChatUserCreate(nickname="User", role_name="user.member"), + models.HumanChatUser, + {"kind": "Human", "nickname": "User", "roleName": "user.member"}, + ), +] + + +@pytest.mark.parametrize("model,fields,required", MODEL_SHAPES) +def test_request_model_constructor_shape(model, fields, required): + assert set(model({})._attr_to_rest_field) == fields + definition = ast.parse(inspect.getsource(model)).body[0] + constructor = next( + node for node in definition.body if isinstance(node, ast.FunctionDef) and node.name == "__init__" + ) + assert { + parameter.arg + for parameter, default in zip(constructor.args.kwonlyargs, constructor.args.kw_defaults) + if default is None + } == required + assert not {"id", "etag", "created_at", "default_conversation"} & fields + + +def _response(body): + payload = { + **body, + "id": "returned-id", + "etag": '"new"', + "createdAt": "2026-08-01T00:00:00Z", + "createdBy": "user", + "conversationId": "conversation", + "defaultConversation": "conversation", + } + response = Mock(status_code=200, headers={"content-type": "application/json"}, reason="OK") + response.json.return_value = payload + response.text.return_value = json.dumps(payload) + return Mock(http_response=response) + + +def _assert_request(run, method, body): + request = run.call_args.args[0] + assert json.loads(request.content) == body + assert request.method == ("PATCH" if method.startswith("update_") else "PUT") + assert request.headers["If-Match"] == '"old"' + if method.startswith("update_"): + assert request.headers["Content-Type"] == "application/merge-patch+json" + + +@pytest.mark.parametrize("method,args,resource,response_model,body", CASES) +def test_lifecycle_request_and_resource_response(method, args, resource, response_model, body): + with WebPubSubChatServiceClient( + "https://example.webpubsub.azure.com", "chat", AzureKeyCredential("test-key") + ) as client: + with patch.object(client._client._pipeline, "run", return_value=_response(body)) as run: + result = getattr(client, method)( + *args, resource, etag='"old"', match_condition=MatchConditions.IfNotModified + ) + assert isinstance(result, response_model) + assert result.etag == '"new"' + _assert_request(run, method, body) + + +@pytest.mark.asyncio +@pytest.mark.parametrize("method,args,resource,response_model,body", CASES) +async def test_async_lifecycle_request_and_resource_response(method, args, resource, response_model, body): + async with AsyncClient("https://example.webpubsub.azure.com", "chat", AzureKeyCredential("test-key")) as client: + with patch.object(client._client._pipeline, "run", new_callable=AsyncMock, return_value=_response(body)) as run: + result = await getattr(client, method)( + *args, resource, etag='"old"', match_condition=MatchConditions.IfNotModified + ) + assert isinstance(result, response_model) + assert result.etag == '"new"' + _assert_request(run, method, body) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml index e73da1923956..6278827459aa 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml @@ -1,5 +1,5 @@ directory: specification/webpubsub/data-plane/WebPubSubChat -commit: 44c2a4f48a4a2e4d77f9658749f990bcf9ab110f -repo: Azure/azure-rest-api-specs +commit: 7ee220e5e9f6e362989b326eb7c147633058a91a +repo: Y-Sindo/azure-rest-api-specs additionalDirectories: [] entrypointFile: client.tsp \ No newline at end of file From bae6c2d76003d02b8aea030273de139588d41e98 Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Wed, 14 Oct 2026 18:39:23 -0700 Subject: [PATCH 07/22] Fix next Pylint discovery and Chat test warnings Lint individual test files, including nested helpers, without assuming tests is a regular package. Add regression coverage and clean test imports, empty collection assertions, and unused test arguments. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- doc/dev/pylint_checking.md | 3 ++ eng/tools/azure-sdk-tools/azpysdk/pylint.py | 33 +++++++------------ .../azure-sdk-tools/tests/test_pylint.py | 30 ++++++++++++++++- .../tests/test_2026_08_01_preview.py | 2 +- .../tests/test_2026_08_01_preview_live.py | 6 ++-- .../test_2026_08_01_preview_live_async.py | 2 +- .../tests/test_client.py | 2 +- .../tests/test_client_async.py | 2 +- .../tests/test_live.py | 16 ++++----- .../tests/test_live_async.py | 12 +++---- .../tests/testcase.py | 13 ++++---- 11 files changed, 68 insertions(+), 53 deletions(-) diff --git a/doc/dev/pylint_checking.md b/doc/dev/pylint_checking.md index 7bee34e36590..bd21769a7657 100644 --- a/doc/dev/pylint_checking.md +++ b/doc/dev/pylint_checking.md @@ -61,6 +61,9 @@ This next-pylint check can also be run locally: azpysdk pylint --next=True +The next check includes every Python file under `tests/`, including nested helpers. +Test directories do not need an `__init__.py` file. + The errors generated by the `Run Pylint Next` step will not break your weekly test pipelines, but make sure to fix the warnings so that your client library is up to date for the next pylint release. # How to prepare your SDK for a new pylint update? diff --git a/eng/tools/azure-sdk-tools/azpysdk/pylint.py b/eng/tools/azure-sdk-tools/azpysdk/pylint.py index 92255ad263a7..1c1fcd0be5b5 100644 --- a/eng/tools/azure-sdk-tools/azpysdk/pylint.py +++ b/eng/tools/azure-sdk-tools/azpysdk/pylint.py @@ -53,6 +53,13 @@ def get_snippet_aware_sample_pylint_commands(executable: str, rcfile: str, sampl return commands +def get_test_pylint_command(executable: str, rcfile: str, tests_dir: str) -> List[str]: + test_files = sorted(str(path) for path in Path(tests_dir).rglob("*.py")) + if not test_files: + return [] + return [executable, "-m", "pylint", f"--rcfile={rcfile}", "--output-format=parseable", *test_files] + + class pylint(Check): def __init__(self) -> None: super().__init__() @@ -203,28 +210,10 @@ def run(self, args: argparse.Namespace) -> int: if os.path.exists(tests_dir): try: test_rcfile = os.path.join(REPO_ROOT, "eng/test_pylintrc") - logger.info( - [ - executable, - "-m", - "pylint", - "--rcfile={}".format(test_rcfile), - "--output-format=parseable", - tests_dir, - ] - ) - results.append( - check_call( - [ - executable, - "-m", - "pylint", - "--rcfile={}".format(test_rcfile), - "--output-format=parseable", - tests_dir, - ] - ) - ) + test_command = get_test_pylint_command(executable, test_rcfile, tests_dir) + if test_command: + logger.info(test_command) + results.append(check_call(test_command)) except CalledProcessError as e: logger.error( "{} tests exited with linting error {}. Please see this link for more information https://aka.ms/azsdk/python/pylint-guide".format( diff --git a/eng/tools/azure-sdk-tools/tests/test_pylint.py b/eng/tools/azure-sdk-tools/tests/test_pylint.py index 650fa56cee9e..548047e82cc7 100644 --- a/eng/tools/azure-sdk-tools/tests/test_pylint.py +++ b/eng/tools/azure-sdk-tools/tests/test_pylint.py @@ -1,6 +1,10 @@ from pathlib import Path -from azpysdk.pylint import SNIPPET_SAMPLE_IMPORT_DISABLES, get_snippet_aware_sample_pylint_commands +from azpysdk.pylint import ( + SNIPPET_SAMPLE_IMPORT_DISABLES, + get_snippet_aware_sample_pylint_commands, + get_test_pylint_command, +) def test_get_snippet_aware_sample_pylint_commands_separates_snippet_files(tmp_path): @@ -46,3 +50,27 @@ def test_get_snippet_aware_sample_pylint_commands_ignores_non_python_files(tmp_p Path(samples_dir / "README.md").write_text("# [START example]\n", encoding="utf-8") assert get_snippet_aware_sample_pylint_commands("python", "samples_pylintrc", str(samples_dir)) == [] + + +def test_get_test_pylint_command_supports_namespace_test_directories(tmp_path): + tests_dir = tmp_path / "tests" + nested_dir = tests_dir / "nested" + nested_dir.mkdir(parents=True) + test_file = tests_dir / "test_client.py" + helper = nested_dir / "helper.py" + for path in (test_file, helper): + path.write_text("pass\n", encoding="utf-8") + (tests_dir / "README.md").write_text("Test documentation\n", encoding="utf-8") + + assert get_test_pylint_command("python", "test_pylintrc", str(tests_dir)) == [ + "python", + "-m", + "pylint", + "--rcfile=test_pylintrc", + "--output-format=parseable", + *sorted([str(test_file), str(helper)]), + ] + + +def test_get_test_pylint_command_ignores_empty_directories(tmp_path): + assert get_test_pylint_command("python", "test_pylintrc", str(tmp_path)) == [] diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview.py index 393bff912c70..28aa2130e9cc 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview.py @@ -95,7 +95,7 @@ def test_collection_paging_and_continuation(operation, args, path, model, fields resumed = getattr(client, operation)(*args, **options).by_page(pages.continuation_token) second = list(next(resumed)) assert [item.id for item in first + second] == ["first", "second"] - assert list(resumed) == [] + assert not list(resumed) _assert_page_requests(run, path) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live.py index 058efb2b83b1..44069339021e 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live.py @@ -4,6 +4,7 @@ # -------------------------------------------------------------------------- from devtools_testutils import recorded_by_proxy import pytest +from testcase import WebPubSubChatPreparer, WebPubSubChatTest from azure.core import MatchConditions from azure.core.exceptions import HttpResponseError @@ -18,7 +19,6 @@ HumanChatUser, HumanChatUserCreate, ) -from testcase import WebPubSubChatPreparer, WebPubSubChatTest def _assert_resumable_pages(paged): @@ -52,7 +52,7 @@ def test_topic_lifecycle_and_paging(self, wps_chat_endpoint): conversation = client.get_conversation(topic.conversation_id) assert conversation.id == topic.conversation_id assert conversation.parent_room == room_id - assert list(client.list_messages(topic.conversation_id)) == [] + assert not list(client.list_messages(topic.conversation_id)) assert {topic.id for topic in client.list_topics(room_id, max_page_size=1)}.issuperset({"first", "second"}) _assert_resumable_pages(client.list_topics(room_id, max_page_size=1)) @@ -96,7 +96,7 @@ def test_room_user_and_user_room_collections(self, wps_chat_endpoint): client.create_or_replace_role(room_role, ChatRoleCreate(permissions=[ChatPermission.ROOM_PUBLISH_MESSAGE])) for user_id in user_ids: client.create_or_replace_user(user_id, HumanChatUserCreate(nickname=user_id, role_name=user_role)) - assert list(client.list_rooms_for_user(user_ids[0])) == [] + assert not list(client.list_rooms_for_user(user_ids[0])) for room_id in room_ids: client.create_or_replace_room(room_id, ChatRoomCreate(title=room_id)) client.create_or_replace_room_member(room_id, user_ids[0], ChatRoomMemberCreate(role_name=room_role)) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live_async.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live_async.py index 52f76d57a893..6651514d8a33 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live_async.py @@ -4,6 +4,7 @@ # -------------------------------------------------------------------------- import pytest from devtools_testutils.aio import recorded_by_proxy_async +from testcase import WebPubSubChatPreparer, WebPubSubChatTest from azure.core import MatchConditions from azure.core.exceptions import HttpResponseError @@ -18,7 +19,6 @@ HumanChatUser, HumanChatUserCreate, ) -from testcase import WebPubSubChatPreparer, WebPubSubChatTest async def _collect(paged): diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_client.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_client.py index 3ef6c68a4383..085ee43fe2b8 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_client.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_client.py @@ -54,7 +54,7 @@ def capture(pipeline_request): class FakeTokenCredential: - def get_token(self, *scopes, **kwargs): + def get_token(self, *_scopes, **_kwargs): return AccessToken("entra-token", int(time.time()) + 3600) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_client_async.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_client_async.py index e6a00a7e1cc9..32f156c93119 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_client_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_client_async.py @@ -25,7 +25,7 @@ class RequestCaptured(Exception): class FakeAsyncTokenCredential: - async def get_token(self, *scopes, **kwargs): + async def get_token(self, *_scopes, **_kwargs): return AccessToken("entra-token", int(time.time()) + 3600) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live.py index f4c8ffbde87d..c52054ff9515 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live.py @@ -4,6 +4,11 @@ # -------------------------------------------------------------------------- import pytest from devtools_testutils import recorded_by_proxy +from testcase import ( + WebPubSubChatAccessPreparer, + WebPubSubChatPreparer, + WebPubSubChatTest, +) from azure.core import MatchConditions from azure.core.exceptions import HttpResponseError @@ -17,12 +22,6 @@ MessageContent, ) -from testcase import ( - WebPubSubChatAccessPreparer, - WebPubSubChatPreparer, - WebPubSubChatTest, -) - class TestWebPubSubChatLive(WebPubSubChatTest): @WebPubSubChatPreparer() @@ -60,7 +59,6 @@ def test_role_lifecycle_and_paging(self, wps_chat_endpoint): @recorded_by_proxy def test_list_roles_using_connection_string( self, - wps_chat_endpoint, wps_chat_connection_string, wps_chat_disable_local_auth, ): @@ -148,8 +146,8 @@ def test_room_conversation_and_empty_pages(self, wps_chat_endpoint): conversation = client.get_conversation(room.default_conversation) assert conversation.id == room.default_conversation assert conversation.parent_room == room_id - assert list(client.list_messages(room.default_conversation)) == [] - assert list(client.list_room_members(room_id)) == [] + assert not list(client.list_messages(room.default_conversation)) + assert not list(client.list_room_members(room_id)) finally: self.cleanup(client.delete_room, room_id) client.close() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live_async.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live_async.py index 103d8532ea82..92e8fe6c1fb6 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live_async.py @@ -4,6 +4,11 @@ # -------------------------------------------------------------------------- import pytest from devtools_testutils.aio import recorded_by_proxy_async +from testcase import ( + WebPubSubChatAccessPreparer, + WebPubSubChatPreparer, + WebPubSubChatTest, +) from azure.core import MatchConditions from azure.core.exceptions import HttpResponseError @@ -17,12 +22,6 @@ MessageContent, ) -from testcase import ( - WebPubSubChatAccessPreparer, - WebPubSubChatPreparer, - WebPubSubChatTest, -) - async def _collect(paged): return [item async for item in paged] @@ -66,7 +65,6 @@ async def test_async_role_lifecycle_and_paging(self, wps_chat_endpoint): @pytest.mark.asyncio async def test_async_list_roles_using_connection_string( self, - wps_chat_endpoint, wps_chat_connection_string, wps_chat_disable_local_auth, ): diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/testcase.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/testcase.py index c75cc9019a1a..7cdae530cc20 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/testcase.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/testcase.py @@ -5,14 +5,7 @@ # -------------------------------------------------------------------------- import functools -from azure.core.exceptions import HttpResponseError from devtools_testutils import AzureRecordedTestCase, PowerShellPreparer - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient -from azure.messaging.webpubsubchatservice.aio import ( - WebPubSubChatServiceClient as AsyncWebPubSubChatServiceClient, -) - from chat_message_seed import ( create_chat_message, create_chat_message_async, @@ -20,6 +13,12 @@ verify_chat_connection_async, ) +from azure.core.exceptions import HttpResponseError +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient +from azure.messaging.webpubsubchatservice.aio import ( + WebPubSubChatServiceClient as AsyncWebPubSubChatServiceClient, +) + class WebPubSubChatTest(AzureRecordedTestCase): def create_client(self, endpoint, **kwargs): From c83bef565cebefac7682524eab5ce8e2962a461a Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Wed, 14 Oct 2026 18:45:24 -0700 Subject: [PATCH 08/22] Restrict Chat package discovery to the SDK namespace Retain build output exclusions and prevent local TypeSpec caches or stale wheel artifacts from being discovered as Python packages. Verified two successive wheel builds contain exactly the 27 SDK Python files. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../azure-messaging-webpubsubchatservice/pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/pyproject.toml b/sdk/webpubsub/azure-messaging-webpubsubchatservice/pyproject.toml index 5081602e9d19..ada9e51c31eb 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/pyproject.toml +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/pyproject.toml @@ -48,7 +48,9 @@ version = {attr = "azure.messaging.webpubsubchatservice._version.VERSION"} readme = {file = ["README.md", "CHANGELOG.md"], content-type = "text/markdown"} [tool.setuptools.packages.find] +include = ["azure.messaging.webpubsubchatservice*"] exclude = [ + "build*", "tests*", "generated_tests*", "samples*", From 34fe9b5ed00c441cde20d35a5ff5b6a89aae4610 Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Wed, 14 Oct 2026 18:54:37 -0700 Subject: [PATCH 09/22] Keep recursive test lint commands within Windows limits Let Pylint recursively discover namespace-directory tests inside its child process instead of expanding every file path into the command line. Cover nested helpers, empty directories, and a 620-file test tree. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- eng/tools/azure-sdk-tools/azpysdk/pylint.py | 5 ++-- .../azure-sdk-tools/tests/test_pylint.py | 23 ++++++++++++++++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/eng/tools/azure-sdk-tools/azpysdk/pylint.py b/eng/tools/azure-sdk-tools/azpysdk/pylint.py index 1c1fcd0be5b5..e7bf09532a55 100644 --- a/eng/tools/azure-sdk-tools/azpysdk/pylint.py +++ b/eng/tools/azure-sdk-tools/azpysdk/pylint.py @@ -54,10 +54,9 @@ def get_snippet_aware_sample_pylint_commands(executable: str, rcfile: str, sampl def get_test_pylint_command(executable: str, rcfile: str, tests_dir: str) -> List[str]: - test_files = sorted(str(path) for path in Path(tests_dir).rglob("*.py")) - if not test_files: + if not any(Path(tests_dir).rglob("*.py")): return [] - return [executable, "-m", "pylint", f"--rcfile={rcfile}", "--output-format=parseable", *test_files] + return [executable, "-m", "pylint", f"--rcfile={rcfile}", "--output-format=parseable", "--recursive=y", tests_dir] class pylint(Check): diff --git a/eng/tools/azure-sdk-tools/tests/test_pylint.py b/eng/tools/azure-sdk-tools/tests/test_pylint.py index 548047e82cc7..24b7960b08ce 100644 --- a/eng/tools/azure-sdk-tools/tests/test_pylint.py +++ b/eng/tools/azure-sdk-tools/tests/test_pylint.py @@ -68,9 +68,30 @@ def test_get_test_pylint_command_supports_namespace_test_directories(tmp_path): "pylint", "--rcfile=test_pylintrc", "--output-format=parseable", - *sorted([str(test_file), str(helper)]), + "--recursive=y", + str(tests_dir), ] def test_get_test_pylint_command_ignores_empty_directories(tmp_path): assert get_test_pylint_command("python", "test_pylintrc", str(tmp_path)) == [] + + +def test_get_test_pylint_command_keeps_large_directories_bounded(tmp_path): + tests_dir = tmp_path / "tests" + tests_dir.mkdir() + for index in range(620): + (tests_dir / f"test_client_with_a_long_file_name_{index:04}.py").write_text("pass\n", encoding="utf-8") + + command = get_test_pylint_command("python", "test_pylintrc", str(tests_dir)) + + assert command == [ + "python", + "-m", + "pylint", + "--rcfile=test_pylintrc", + "--output-format=parseable", + "--recursive=y", + str(tests_dir), + ] + assert len(" ".join(command)) < 32767 From e181e4c17b18a3df40dd30d80368e7f1dc234045 Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Thu, 15 Oct 2026 21:11:21 -0700 Subject: [PATCH 10/22] Revert out-of-scope Pylint tooling changes Restore engineering test-discovery behavior and its tests to the PR baseline. Keep the Web PubSub Chat SDK changes scoped to this package; the general tooling issue requires a separate PR. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- eng/tools/azure-sdk-tools/azpysdk/pylint.py | 32 ++++++++---- .../azure-sdk-tools/tests/test_pylint.py | 51 +------------------ 2 files changed, 23 insertions(+), 60 deletions(-) diff --git a/eng/tools/azure-sdk-tools/azpysdk/pylint.py b/eng/tools/azure-sdk-tools/azpysdk/pylint.py index e7bf09532a55..92255ad263a7 100644 --- a/eng/tools/azure-sdk-tools/azpysdk/pylint.py +++ b/eng/tools/azure-sdk-tools/azpysdk/pylint.py @@ -53,12 +53,6 @@ def get_snippet_aware_sample_pylint_commands(executable: str, rcfile: str, sampl return commands -def get_test_pylint_command(executable: str, rcfile: str, tests_dir: str) -> List[str]: - if not any(Path(tests_dir).rglob("*.py")): - return [] - return [executable, "-m", "pylint", f"--rcfile={rcfile}", "--output-format=parseable", "--recursive=y", tests_dir] - - class pylint(Check): def __init__(self) -> None: super().__init__() @@ -209,10 +203,28 @@ def run(self, args: argparse.Namespace) -> int: if os.path.exists(tests_dir): try: test_rcfile = os.path.join(REPO_ROOT, "eng/test_pylintrc") - test_command = get_test_pylint_command(executable, test_rcfile, tests_dir) - if test_command: - logger.info(test_command) - results.append(check_call(test_command)) + logger.info( + [ + executable, + "-m", + "pylint", + "--rcfile={}".format(test_rcfile), + "--output-format=parseable", + tests_dir, + ] + ) + results.append( + check_call( + [ + executable, + "-m", + "pylint", + "--rcfile={}".format(test_rcfile), + "--output-format=parseable", + tests_dir, + ] + ) + ) except CalledProcessError as e: logger.error( "{} tests exited with linting error {}. Please see this link for more information https://aka.ms/azsdk/python/pylint-guide".format( diff --git a/eng/tools/azure-sdk-tools/tests/test_pylint.py b/eng/tools/azure-sdk-tools/tests/test_pylint.py index 24b7960b08ce..650fa56cee9e 100644 --- a/eng/tools/azure-sdk-tools/tests/test_pylint.py +++ b/eng/tools/azure-sdk-tools/tests/test_pylint.py @@ -1,10 +1,6 @@ from pathlib import Path -from azpysdk.pylint import ( - SNIPPET_SAMPLE_IMPORT_DISABLES, - get_snippet_aware_sample_pylint_commands, - get_test_pylint_command, -) +from azpysdk.pylint import SNIPPET_SAMPLE_IMPORT_DISABLES, get_snippet_aware_sample_pylint_commands def test_get_snippet_aware_sample_pylint_commands_separates_snippet_files(tmp_path): @@ -50,48 +46,3 @@ def test_get_snippet_aware_sample_pylint_commands_ignores_non_python_files(tmp_p Path(samples_dir / "README.md").write_text("# [START example]\n", encoding="utf-8") assert get_snippet_aware_sample_pylint_commands("python", "samples_pylintrc", str(samples_dir)) == [] - - -def test_get_test_pylint_command_supports_namespace_test_directories(tmp_path): - tests_dir = tmp_path / "tests" - nested_dir = tests_dir / "nested" - nested_dir.mkdir(parents=True) - test_file = tests_dir / "test_client.py" - helper = nested_dir / "helper.py" - for path in (test_file, helper): - path.write_text("pass\n", encoding="utf-8") - (tests_dir / "README.md").write_text("Test documentation\n", encoding="utf-8") - - assert get_test_pylint_command("python", "test_pylintrc", str(tests_dir)) == [ - "python", - "-m", - "pylint", - "--rcfile=test_pylintrc", - "--output-format=parseable", - "--recursive=y", - str(tests_dir), - ] - - -def test_get_test_pylint_command_ignores_empty_directories(tmp_path): - assert get_test_pylint_command("python", "test_pylintrc", str(tmp_path)) == [] - - -def test_get_test_pylint_command_keeps_large_directories_bounded(tmp_path): - tests_dir = tmp_path / "tests" - tests_dir.mkdir() - for index in range(620): - (tests_dir / f"test_client_with_a_long_file_name_{index:04}.py").write_text("pass\n", encoding="utf-8") - - command = get_test_pylint_command("python", "test_pylintrc", str(tests_dir)) - - assert command == [ - "python", - "-m", - "pylint", - "--rcfile=test_pylintrc", - "--output-format=parseable", - "--recursive=y", - str(tests_dir), - ] - assert len(" ".join(command)) < 32767 From c9147b841ac1736e91e9f737514dd8a2887ed9e4 Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Thu, 15 Oct 2026 21:52:50 -0700 Subject: [PATCH 11/22] Rename Chat topic create-or-replace request model Generate ChatTopicCreateOrReplace from the pinned Python TypeSpec customization, update samples and API artifacts, and cover lifecycle request typing and partial updates. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../CHANGELOG.md | 2 +- .../README.md | 7 +-- .../api.md | 14 +++--- .../api.metadata.yml | 2 +- .../apiview-properties.json | 18 ++++---- .../_operations/_operations.py | 18 ++++---- .../aio/_operations/_operations.py | 18 ++++---- .../webpubsubchatservice/models/__init__.py | 4 +- .../webpubsubchatservice/models/_models.py | 4 +- .../messaging/webpubsubchatservice/types.py | 4 +- .../samples/sample_readme_snippets.py | 4 +- .../tests/test_2026_08_01_preview.py | 8 ++-- .../tests/test_2026_08_01_preview_live.py | 4 +- .../test_2026_08_01_preview_live_async.py | 6 ++- .../tests/test_request_models.py | 41 +++++++++++++++-- .../tests/typing/request_models.py | 44 +++++++++++++++++++ .../tsp-location.yaml | 2 +- 17 files changed, 142 insertions(+), 58 deletions(-) create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/typing/request_models.py diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md index 9288e50fb6d3..88fb3c3b9d5a 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md @@ -14,7 +14,7 @@ ### Breaking Changes - Create or replace operations now accept dedicated `ChatRoleCreate`, `ChatRoomCreate`, `ChatRoomMemberCreate`, and `ChatUserCreate` (including `HumanChatUserCreate`) request models instead of resource response models. - - Topic creation accepts `ChatTopicCreate`, which requires only `title`. Topic updates accept `ChatTopicUpdate`, whose fields are optional. + - Topic creation or replacement accepts `ChatTopicCreateOrReplace`, which requires only `title`. Topic updates accept `ChatTopicUpdate`, whose fields are optional. - Message updates accept `ChatMessageUpdate`, whose fields are optional, instead of `ChatMessage`. Resource response model names are unchanged. ## 1.0.0b1 (2026-10-08) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md index 23481b5ed2e0..109931f9792b 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md @@ -297,12 +297,12 @@ topic ID specified by `WPS_CHAT_TOPIC_ID`. ```python import os -from azure.messaging.webpubsubchatservice.models import ChatTopicCreate +from azure.messaging.webpubsubchatservice.models import ChatTopicCreateOrReplace topic = client.create_or_replace_topic( os.environ["WPS_CHAT_ROOM_ID"], os.environ["WPS_CHAT_TOPIC_ID"], - ChatTopicCreate(title="Announcements"), + ChatTopicCreateOrReplace(title="Announcements"), ) print(topic.id, topic.etag) ``` @@ -338,7 +338,8 @@ print(topic.id, topic.title, topic.state, topic.etag) #### Archive a topic Set `WPS_CHAT_TOPIC_ETAG` to the ETag returned by a previous create or get -operation. +operation. The update below changes only `state`; the existing title is left +unchanged. To change only the title, use `ChatTopicUpdate(title="New title")`. diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md index f8052807a1f1..b777d94cd6f6 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md @@ -145,7 +145,7 @@ namespace azure.messaging.webpubsubchatservice self, room_id: str, topic_id: str, - resource: ChatTopicCreate, + resource: ChatTopicCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -158,7 +158,7 @@ namespace azure.messaging.webpubsubchatservice self, room_id: str, topic_id: str, - resource: ChatTopicCreate, + resource: ChatTopicCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -624,7 +624,7 @@ namespace azure.messaging.webpubsubchatservice.aio self, room_id: str, topic_id: str, - resource: ChatTopicCreate, + resource: ChatTopicCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -637,7 +637,7 @@ namespace azure.messaging.webpubsubchatservice.aio self, room_id: str, topic_id: str, - resource: ChatTopicCreate, + resource: ChatTopicCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -1137,7 +1137,7 @@ namespace azure.messaging.webpubsubchatservice.models def __init__(self, mapping: Mapping[str, Any]) -> None: ... - class azure.messaging.webpubsubchatservice.models.ChatTopicCreate(_Model): + class azure.messaging.webpubsubchatservice.models.ChatTopicCreateOrReplace(_Model): title: str @overload @@ -1304,7 +1304,7 @@ namespace azure.messaging.webpubsubchatservice.types roleName: str - class azure.messaging.webpubsubchatservice.types.ChatTopicCreate(TypedDict, total=False): + class azure.messaging.webpubsubchatservice.types.ChatTopicCreateOrReplace(TypedDict, total=False): key "title": Required[str] title: str @@ -1345,4 +1345,4 @@ namespace azure.messaging.webpubsubchatservice.types text: str -``` \ No newline at end of file +``` diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml index 6f58c0deb25e..4d28569b017b 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml @@ -1,4 +1,4 @@ -apiMdSha256: 9079dffe38f166d12378f9a5ed0227ddd99b73873158251ac51a32fd1904ca70 +apiMdSha256: 579a81052926cd0807b5c1d43e7ed03ea068fea7762ec014c66e0f979d998358 packageVersion: 1.0.0b2 parserVersion: 0.3.31 pythonVersion: 3.12.10 diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json b/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json index ff161dcccf06..c1e3f995a661 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json @@ -3,21 +3,21 @@ "CrossLanguageDefinitionId": { "azure.messaging.webpubsubchatservice.models.ChatConversation": "WebPubSubChat.ChatConversation", "azure.messaging.webpubsubchatservice.models.ChatMessage": "WebPubSubChat.ChatMessage", - "azure.messaging.webpubsubchatservice.models.ChatMessageUpdate": "WebPubSubChat.RequestModels.ChatMessageUpdate", + "azure.messaging.webpubsubchatservice.models.ChatMessageUpdate": "WebPubSubChat.PythonCustomizations.ChatMessageUpdate", "azure.messaging.webpubsubchatservice.models.ChatRole": "WebPubSubChat.ChatRole", - "azure.messaging.webpubsubchatservice.models.ChatRoleCreate": "WebPubSubChat.RequestModels.ChatRoleCreate", + "azure.messaging.webpubsubchatservice.models.ChatRoleCreate": "WebPubSubChat.PythonCustomizations.ChatRoleCreate", "azure.messaging.webpubsubchatservice.models.ChatRoom": "WebPubSubChat.ChatRoom", - "azure.messaging.webpubsubchatservice.models.ChatRoomCreate": "WebPubSubChat.RequestModels.ChatRoomCreate", + "azure.messaging.webpubsubchatservice.models.ChatRoomCreate": "WebPubSubChat.PythonCustomizations.ChatRoomCreate", "azure.messaging.webpubsubchatservice.models.ChatRoomMember": "WebPubSubChat.ChatRoomMember", - "azure.messaging.webpubsubchatservice.models.ChatRoomMemberCreate": "WebPubSubChat.RequestModels.ChatRoomMemberCreate", + "azure.messaging.webpubsubchatservice.models.ChatRoomMemberCreate": "WebPubSubChat.PythonCustomizations.ChatRoomMemberCreate", "azure.messaging.webpubsubchatservice.models.ChatTopic": "WebPubSubChat.ChatTopic", - "azure.messaging.webpubsubchatservice.models.ChatTopicCreate": "WebPubSubChat.RequestModels.ChatTopicCreate", - "azure.messaging.webpubsubchatservice.models.ChatTopicUpdate": "WebPubSubChat.RequestModels.ChatTopicUpdate", + "azure.messaging.webpubsubchatservice.models.ChatTopicCreateOrReplace": "WebPubSubChat.PythonCustomizations.ChatTopicCreateOrReplace", + "azure.messaging.webpubsubchatservice.models.ChatTopicUpdate": "WebPubSubChat.PythonCustomizations.ChatTopicUpdate", "azure.messaging.webpubsubchatservice.models.ChatUser": "WebPubSubChat.ChatUser", - "azure.messaging.webpubsubchatservice.models.ChatUserCreate": "WebPubSubChat.RequestModels.ChatUserCreate", + "azure.messaging.webpubsubchatservice.models.ChatUserCreate": "WebPubSubChat.PythonCustomizations.ChatUserCreate", "azure.messaging.webpubsubchatservice.models.ChatUserRoom": "WebPubSubChat.ChatUserRoom", "azure.messaging.webpubsubchatservice.models.HumanChatUser": "WebPubSubChat.HumanChatUser", - "azure.messaging.webpubsubchatservice.models.HumanChatUserCreate": "WebPubSubChat.RequestModels.HumanChatUserCreate", + "azure.messaging.webpubsubchatservice.models.HumanChatUserCreate": "WebPubSubChat.PythonCustomizations.HumanChatUserCreate", "azure.messaging.webpubsubchatservice.models.MessageContent": "WebPubSubChat.MessageContent", "azure.messaging.webpubsubchatservice.models.ChatPermission": "WebPubSubChat.ChatPermission", "azure.messaging.webpubsubchatservice.models.ChatTopicState": "WebPubSubChat.ChatTopicState", @@ -73,5 +73,5 @@ "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.list_rooms_for_user": "WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser", "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.list_rooms_for_user": "WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser" }, - "CrossLanguageVersion": "37e519d01deb" + "CrossLanguageVersion": "99e41376e215" } \ No newline at end of file diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_operations/_operations.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_operations/_operations.py index e2abce07ff4c..140694b1e1f3 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_operations/_operations.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_operations/_operations.py @@ -2444,7 +2444,7 @@ def create_or_replace_topic( self, room_id: str, topic_id: str, - resource: _models.ChatTopicCreate, + resource: _models.ChatTopicCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -2460,7 +2460,7 @@ def create_or_replace_topic( :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopicCreate + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopicCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2479,7 +2479,7 @@ def create_or_replace_topic( self, room_id: str, topic_id: str, - resource: _types.ChatTopicCreate, + resource: _types.ChatTopicCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -2495,7 +2495,7 @@ def create_or_replace_topic( :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatTopicCreate + :type resource: ~azure.messaging.webpubsubchatservice.types.ChatTopicCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2565,7 +2565,7 @@ def create_or_replace_topic( self, room_id: str, topic_id: str, - resource: Union[_models.ChatTopicCreate, _types.ChatTopicCreate, IO[bytes]], + resource: Union[_models.ChatTopicCreateOrReplace, _types.ChatTopicCreateOrReplace, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -2579,10 +2579,10 @@ def create_or_replace_topic( :type room_id: str :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str - :param resource: The resource instance. Is either a ChatTopicCreate type or a IO[bytes] type. - Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopicCreate or - ~azure.messaging.webpubsubchatservice.types.ChatTopicCreate or IO[bytes] + :param resource: The resource instance. Is either a ChatTopicCreateOrReplace type or a + IO[bytes] type. Required. + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopicCreateOrReplace or + ~azure.messaging.webpubsubchatservice.types.ChatTopicCreateOrReplace or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. :paramtype etag: str diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_operations/_operations.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_operations/_operations.py index aac916b7349e..04d573fa59e6 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_operations/_operations.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_operations/_operations.py @@ -1540,7 +1540,7 @@ async def create_or_replace_topic( self, room_id: str, topic_id: str, - resource: _models.ChatTopicCreate, + resource: _models.ChatTopicCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -1556,7 +1556,7 @@ async def create_or_replace_topic( :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopicCreate + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopicCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1575,7 +1575,7 @@ async def create_or_replace_topic( self, room_id: str, topic_id: str, - resource: _types.ChatTopicCreate, + resource: _types.ChatTopicCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -1591,7 +1591,7 @@ async def create_or_replace_topic( :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatTopicCreate + :type resource: ~azure.messaging.webpubsubchatservice.types.ChatTopicCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1661,7 +1661,7 @@ async def create_or_replace_topic( self, room_id: str, topic_id: str, - resource: Union[_models.ChatTopicCreate, _types.ChatTopicCreate, IO[bytes]], + resource: Union[_models.ChatTopicCreateOrReplace, _types.ChatTopicCreateOrReplace, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -1675,10 +1675,10 @@ async def create_or_replace_topic( :type room_id: str :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str - :param resource: The resource instance. Is either a ChatTopicCreate type or a IO[bytes] type. - Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopicCreate or - ~azure.messaging.webpubsubchatservice.types.ChatTopicCreate or IO[bytes] + :param resource: The resource instance. Is either a ChatTopicCreateOrReplace type or a + IO[bytes] type. Required. + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopicCreateOrReplace or + ~azure.messaging.webpubsubchatservice.types.ChatTopicCreateOrReplace or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. :paramtype etag: str diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/__init__.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/__init__.py index 7f275bbf418b..e331d7586ea3 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/__init__.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/__init__.py @@ -24,7 +24,7 @@ ChatRoomMember, ChatRoomMemberCreate, ChatTopic, - ChatTopicCreate, + ChatTopicCreateOrReplace, ChatTopicUpdate, ChatUser, ChatUserCreate, @@ -54,7 +54,7 @@ "ChatRoomMember", "ChatRoomMemberCreate", "ChatTopic", - "ChatTopicCreate", + "ChatTopicCreateOrReplace", "ChatTopicUpdate", "ChatUser", "ChatUserCreate", diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/_models.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/_models.py index f4b65ae712f0..8ab0d756d0b7 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/_models.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/_models.py @@ -392,8 +392,8 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class ChatTopicCreate(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only - """Properties supplied when creating a topic. +class ChatTopicCreateOrReplace(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Properties supplied when creating or replacing a topic. :ivar title: Topic title. Required. :vartype title: str diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py index 716c6902af1d..09f42e14df91 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py @@ -65,8 +65,8 @@ class ChatRoomMemberCreate(TypedDict, total=False): """Room role assigned to the user within this room. Required.""" -class ChatTopicCreate(TypedDict, total=False): - """Properties supplied when creating a topic. +class ChatTopicCreateOrReplace(TypedDict, total=False): + """Properties supplied when creating or replacing a topic. :ivar title: Topic title. Required. :vartype title: str diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_readme_snippets.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_readme_snippets.py index 4b7d30a29649..513f2dbeabda 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_readme_snippets.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_readme_snippets.py @@ -60,12 +60,12 @@ def list_messages(client: WebPubSubChatServiceClient) -> None: def create_topic(client: WebPubSubChatServiceClient) -> None: # [START create_topic] import os - from azure.messaging.webpubsubchatservice.models import ChatTopicCreate + from azure.messaging.webpubsubchatservice.models import ChatTopicCreateOrReplace topic = client.create_or_replace_topic( os.environ["WPS_CHAT_ROOM_ID"], os.environ["WPS_CHAT_TOPIC_ID"], - ChatTopicCreate(title="Announcements"), + ChatTopicCreateOrReplace(title="Announcements"), ) print(topic.id, topic.etag) # [END create_topic] diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview.py index 28aa2130e9cc..f91f0b55d200 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview.py @@ -17,7 +17,7 @@ from azure.messaging.webpubsubchatservice.models import ( ChatRoom, ChatTopic, - ChatTopicCreate, + ChatTopicCreateOrReplace, ChatTopicState, ChatTopicUpdate, ChatUserRoom, @@ -127,7 +127,7 @@ def test_topic_serialization_lifecycle_and_etag(): "run", side_effect=[_response(TOPIC, 201), _response(TOPIC), _response(archived), _response({}, 204)], ) as run: - topic = client.create_or_replace_topic("room", "topic", ChatTopicCreate(title=TOPIC["title"])) + topic = client.create_or_replace_topic("room", "topic", ChatTopicCreateOrReplace(title=TOPIC["title"])) assert topic.created_at == datetime.datetime(2026, 8, 1, tzinfo=datetime.timezone.utc) fetched = client.get_topic("room", "topic") assert fetched.state == ChatTopicState.NORMAL @@ -157,7 +157,9 @@ async def test_async_topic_serialization_lifecycle_and_etag(): new_callable=AsyncMock, side_effect=[_response(TOPIC, 201), _response(TOPIC), _response(archived), _response({}, 204)], ) as run: - topic = await client.create_or_replace_topic("room", "topic", ChatTopicCreate(title=TOPIC["title"])) + topic = await client.create_or_replace_topic( + "room", "topic", ChatTopicCreateOrReplace(title=TOPIC["title"]) + ) assert topic.created_at == datetime.datetime(2026, 8, 1, tzinfo=datetime.timezone.utc) fetched = await client.get_topic("room", "topic") assert fetched.state == ChatTopicState.NORMAL diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live.py index 44069339021e..528dcaabed43 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live.py @@ -13,7 +13,7 @@ ChatRoleCreate, ChatRoomCreate, ChatRoomMemberCreate, - ChatTopicCreate, + ChatTopicCreateOrReplace, ChatTopicUpdate, ChatTopicState, HumanChatUser, @@ -42,7 +42,7 @@ def test_topic_lifecycle_and_paging(self, wps_chat_endpoint): room = client.create_or_replace_room(room_id, ChatRoomCreate(title="Topic E2E")) assert all(topic.conversation_id == room.default_conversation for topic in client.list_topics(room_id)) for topic_id in ("first", "second"): - topic = client.create_or_replace_topic(room_id, topic_id, ChatTopicCreate(title=topic_id)) + topic = client.create_or_replace_topic(room_id, topic_id, ChatTopicCreateOrReplace(title=topic_id)) assert topic.id == topic_id assert topic.title == topic_id assert topic.state == ChatTopicState.NORMAL diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live_async.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live_async.py index 6651514d8a33..8460a9ea6e46 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live_async.py @@ -13,7 +13,7 @@ ChatRoleCreate, ChatRoomCreate, ChatRoomMemberCreate, - ChatTopicCreate, + ChatTopicCreateOrReplace, ChatTopicUpdate, ChatTopicState, HumanChatUser, @@ -50,7 +50,9 @@ async def test_async_topic_lifecycle_and_paging(self, wps_chat_endpoint): for topic in await _collect(client.list_topics(room_id)) ) for topic_id in ("first", "second"): - topic = await client.create_or_replace_topic(room_id, topic_id, ChatTopicCreate(title=topic_id)) + topic = await client.create_or_replace_topic( + room_id, topic_id, ChatTopicCreateOrReplace(title=topic_id) + ) assert topic.id == topic_id assert topic.title == topic_id assert topic.state == ChatTopicState.NORMAL diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_request_models.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_request_models.py index c1c0b594136c..d71fd3a5c189 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_request_models.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_request_models.py @@ -13,10 +13,10 @@ from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient from azure.messaging.webpubsubchatservice.aio import WebPubSubChatServiceClient as AsyncClient -from azure.messaging.webpubsubchatservice import models +from azure.messaging.webpubsubchatservice import models, types MODEL_SHAPES = [ - (models.ChatTopicCreate, {"title"}, {"title"}), + (models.ChatTopicCreateOrReplace, {"title"}, {"title"}), (models.ChatTopicUpdate, {"title", "state"}, set()), (models.ChatMessageUpdate, {"created_by", "content"}, set()), (models.ChatRoleCreate, {"permissions"}, {"permissions"}), @@ -30,7 +30,7 @@ ( "create_or_replace_topic", ("room", "topic"), - models.ChatTopicCreate(title="Title"), + models.ChatTopicCreateOrReplace(title="Title"), models.ChatTopic, {"title": "Title"}, ), @@ -48,6 +48,41 @@ models.ChatTopic, {"title": "New title"}, ), + ( + "update_message", + ("conversation", "message"), + models.ChatMessageUpdate(created_by="Updated creator"), + models.ChatMessage, + {"createdBy": "Updated creator"}, + ), + ( + "update_topic", + ("room", "topic"), + types.ChatTopicUpdate(title="New title"), + models.ChatTopic, + {"title": "New title"}, + ), + ( + "update_topic", + ("room", "topic"), + types.ChatTopicUpdate(state=models.ChatTopicState.ARCHIVED), + models.ChatTopic, + {"state": "Archived"}, + ), + ( + "update_message", + ("conversation", "message"), + types.ChatMessageUpdate(createdBy="Updated creator"), + models.ChatMessage, + {"createdBy": "Updated creator"}, + ), + ( + "update_message", + ("conversation", "message"), + types.ChatMessageUpdate(content={"text": "Updated"}), + models.ChatMessage, + {"content": {"text": "Updated"}}, + ), ( "update_message", ("conversation", "message"), diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/typing/request_models.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/typing/request_models.py new file mode 100644 index 000000000000..e6c99ca9d56b --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/typing/request_models.py @@ -0,0 +1,44 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient, models, types +from azure.messaging.webpubsubchatservice.aio import WebPubSubChatServiceClient as AsyncClient + + +def check_request_types(client: WebPubSubChatServiceClient) -> None: + client.update_topic("room", "topic", models.ChatTopicUpdate(title="New title")) + client.update_topic("room", "topic", models.ChatTopicUpdate(state=models.ChatTopicState.ARCHIVED)) + client.update_topic("room", "topic", types.ChatTopicUpdate(title="New title")) + client.update_topic("room", "topic", types.ChatTopicUpdate(state=models.ChatTopicState.ARCHIVED)) + client.update_message("conversation", "message", models.ChatMessageUpdate(created_by="user")) + client.update_message( + "conversation", "message", models.ChatMessageUpdate(content=models.MessageContent(text="Updated")) + ) + client.update_message("conversation", "message", types.ChatMessageUpdate(createdBy="user")) + client.update_message("conversation", "message", types.ChatMessageUpdate(content={"text": "Updated"})) + client.create_or_replace_topic("room", "topic", models.ChatTopicCreateOrReplace(title="Title")) + models.ChatTopicUpdate(title=123) # type: ignore[call-overload] + models.ChatTopicUpdate(state=123) # type: ignore[call-overload] + models.ChatTopicUpdate(id="read-only") # type: ignore[call-overload] + models.ChatMessageUpdate(created_by=123) # type: ignore[call-overload] + models.ChatMessageUpdate(content=123) # type: ignore[call-overload] + models.ChatTopicCreateOrReplace() # type: ignore[call-overload] + models.ChatTopicCreateOrReplace(title="Title", state=models.ChatTopicState.ARCHIVED) # type: ignore[call-overload] + types.ChatTopicUpdate(title=123) # type: ignore[typeddict-item] + types.ChatTopicUpdate(id="read-only") # type: ignore[typeddict-unknown-key] + types.ChatMessageUpdate(content=123) # type: ignore[typeddict-item] + types.ChatTopicCreateOrReplace() # type: ignore[typeddict-item] + + +async def check_async_request_types(client: AsyncClient) -> None: + await client.update_topic("room", "topic", models.ChatTopicUpdate(title="New title")) + await client.update_topic("room", "topic", models.ChatTopicUpdate(state=models.ChatTopicState.ARCHIVED)) + await client.update_topic("room", "topic", types.ChatTopicUpdate(title="New title")) + await client.update_topic("room", "topic", types.ChatTopicUpdate(state=models.ChatTopicState.ARCHIVED)) + await client.update_message("conversation", "message", models.ChatMessageUpdate(created_by="user")) + await client.update_message( + "conversation", "message", models.ChatMessageUpdate(content=models.MessageContent(text="Updated")) + ) + await client.update_message("conversation", "message", types.ChatMessageUpdate(createdBy="user")) + await client.update_message("conversation", "message", types.ChatMessageUpdate(content={"text": "Updated"})) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml index 6278827459aa..9daa6f27eeb3 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml @@ -1,5 +1,5 @@ directory: specification/webpubsub/data-plane/WebPubSubChat -commit: 7ee220e5e9f6e362989b326eb7c147633058a91a +commit: a5644409aa48566153043c43be58327f9680d29b repo: Y-Sindo/azure-rest-api-specs additionalDirectories: [] entrypointFile: client.tsp \ No newline at end of file From 53c6d94debce21d049d2cfcae380bcdaa0955703 Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Mon, 19 Oct 2026 16:05:33 +1100 Subject: [PATCH 12/22] Clarify Chat concepts and sample request styles Document model and dictionary request bodies, automatic user discriminators, and all operation samples. Correct conversation terminology and remove stale Pylint discovery guarantees. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- doc/dev/pylint_checking.md | 3 - .../README.md | 34 +++++++- .../samples/README.md | 78 +++++++++++++++++++ 3 files changed, 108 insertions(+), 7 deletions(-) create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md diff --git a/doc/dev/pylint_checking.md b/doc/dev/pylint_checking.md index bd21769a7657..7bee34e36590 100644 --- a/doc/dev/pylint_checking.md +++ b/doc/dev/pylint_checking.md @@ -61,9 +61,6 @@ This next-pylint check can also be run locally: azpysdk pylint --next=True -The next check includes every Python file under `tests/`, including nested helpers. -Test directories do not need an `__init__.py` file. - The errors generated by the `Run Pylint Next` step will not break your weekly test pipelines, but make sure to fix the warnings so that your client library is up to date for the next pylint release. # How to prepare your SDK for a new pylint update? diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md index 109931f9792b..0027f7c2b4cc 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md @@ -117,7 +117,7 @@ The asynchronous client is available from the `azure.messaging.webpubsubchatserv ### 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. @@ -129,7 +129,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. In the service API, 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. In the service API, a user is identified by a user ID and assigned a user role. The SDK provides `HumanChatUserCreate` for creating human users with a nickname and a user role. Client access credentials associate WebSocket connections with a user ID. ### Room @@ -141,13 +141,13 @@ A room member represents a user added to a room. Membership controls which users ### 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. ### Topic -A topic is a named thread within a room with its own conversation. The service returns its +A topic represents a named conversation within a room. The service returns its ID, creation time, creator, conversation ID, and ETag in responses. Topic IDs are specified by the application in the request path. Topics have a lifecycle state of `Normal`, `Archived`, or `SoftDeleted`. Creating a topic requires a title; updating a topic can change its title @@ -156,6 +156,25 @@ and state. Deleting a topic is a soft delete. The default service API version is `2026-08-01-preview`, which adds topics and the room, user, and user-room collection operations. +### Request models and dictionaries + +Operations with JSON request bodies accept model instances from +`azure.messaging.webpubsubchatservice.models` or dictionaries described by the +`TypedDict` definitions in `azure.messaging.webpubsubchatservice.types`. +Model instances use Python property names, such as `role_name`, and provide +attribute access and JSON serialization. Dictionaries use JSON field names, +such as `roleName`. `TypedDict` provides static type checking for those +dictionaries; at runtime they are ordinary dictionaries, not model instances, +and do not perform runtime validation. + +Concrete user models automatically set the JSON discriminator field. +For example, `HumanChatUserCreate(nickname="Alice", role_name="user.normal")` +sets `kind` to `"Human"`; callers do not pass `kind` or `discriminator` to +this constructor. The `discriminator="Human"` in the generated class +declaration registers the subtype for deserialization, while `kind` is the +field sent in JSON. A dictionary request must include `"kind": "Human"` +explicitly. + ## Examples The following sections show common scenarios. Each operation snippet assumes an @@ -163,6 +182,13 @@ authenticated `client`, created as shown in Getting started. The async snippet uses a client from `azure.messaging.webpubsubchatservice.aio`. See the [package samples][samples] for complete synchronous and asynchronous programs. +The hand-written request-body examples use model instances. The +[generated operation samples][generated_samples] use dictionary literals +with JSON field names, rather than explicitly constructing `TypedDict` values. +Both request-body styles are supported. See the +[sample guide and complete operation index](samples/README.md) for links to +every operation and the available hand-written examples. + ### Generate client access credentials Generate credentials that a Chat WebSocket client can use to connect as a specific user: diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md new file mode 100644 index 000000000000..3a4211ef8f14 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md @@ -0,0 +1,78 @@ +# Azure Web PubSub Chat samples + +Use the [package README](../README.md) for installation, authentication, and +Chat hub prerequisites. + +## Sample styles + +The hand-written request-body examples in this directory use model classes from +`azure.messaging.webpubsubchatservice.models`. These classes use Python property +names such as `role_name`. The [generated samples](../generated_samples) use +ordinary dictionary literals with JSON field names such as `roleName`. +The `TypedDict` definitions in `azure.messaging.webpubsubchatservice.types` +describe those dictionary shapes for static type checking; they do not create +model instances or validate values at runtime. Both request-body styles are +accepted by the corresponding client operations. + +`HumanChatUserCreate` automatically supplies `"kind": "Human"` when serialized. +Dictionary requests must supply that field explicitly. See +[request models and dictionaries](../README.md#request-models-and-dictionaries) +for details. + +## Hand-written samples + +| Sample | Purpose | +| --- | --- | +| [Authentication](sample_authentication.py) | Connection string, access key, and Microsoft Entra ID authentication. | +| [Client access credentials](sample_client_access.py) / [async](sample_client_access_async.py) | Generate credentials for a Chat WebSocket client. | +| [Roles and permissions](sample_roles_and_permissions.py) / [async](sample_roles_and_permissions_async.py) | Create or replace a role using a model and permission enums. | +| [Message management](sample_message_management.py) | Update and delete persisted messages. | +| [Service errors](sample_errors.py) | Handle and re-raise an HTTP service error. | +| [Logging](sample_logging.py) | Enable SDK HTTP logging. | +| [README snippet sources](sample_readme_snippets.py) | Independent functions used by the README, not a standalone program. | + +For runnable hand-written samples, follow the environment-variable instructions +in each file and the [README run instructions](../README.md#run-the-samples). +Some samples create, replace, or delete resources; use sample-specific +identifiers and review each file before running it. + +## Complete operation index + +Each generated sample demonstrates one service operation using specification +examples. Replace placeholders and example resource identifiers, and configure +authentication as described in each file. Hand-written examples are linked +where available; README snippet functions require an authenticated client and +are not standalone programs. + +| Operation | Generated sample | Hand-written example | +| --- | --- | --- | +| `get_client_access_token` | Not generated; SDK convenience method. | [Sync](sample_client_access.py) / [async](sample_client_access_async.py) | +| `create_or_replace_role` | [Sample](../generated_samples/create_or_replace_role.py) | [Sync](sample_roles_and_permissions.py) / [async](sample_roles_and_permissions_async.py) | +| `get_role` | [Sample](../generated_samples/get_role.py) | [Service errors](sample_errors.py) | +| `list_roles` | [Sample](../generated_samples/list_roles.py) | [README snippets](sample_readme_snippets.py) | +| `delete_role` | [Sample](../generated_samples/delete_role.py) | - | +| `create_or_replace_room` | [Sample](../generated_samples/create_or_replace_room.py) | [README snippets](sample_readme_snippets.py) | +| `get_room` | [Sample](../generated_samples/get_room.py) | - | +| `list_rooms` | [Sample](../generated_samples/list_rooms.py) | [README snippets](sample_readme_snippets.py) | +| `delete_room` | [Sample](../generated_samples/delete_room.py) | - | +| `create_or_replace_room_member` | [Sample](../generated_samples/create_or_replace_room_member.py) | [README snippets](sample_readme_snippets.py) | +| `list_room_members` | [Sample](../generated_samples/list_room_members.py) | - | +| `delete_room_member` | [Sample](../generated_samples/delete_room_member.py) | - | +| `create_or_replace_user` | [Sample](../generated_samples/create_or_replace_user.py) | [README snippets](sample_readme_snippets.py) | +| `get_user` | [Sample](../generated_samples/get_user.py) | - | +| `list_users` | [Sample](../generated_samples/list_users.py) | [README snippets](sample_readme_snippets.py) | +| `delete_user` | [Sample](../generated_samples/delete_user.py) | - | +| `list_rooms_for_user` | [Sample](../generated_samples/list_rooms_for_user.py) | [README snippets](sample_readme_snippets.py) | +| `create_or_replace_topic` | [Sample](../generated_samples/create_or_replace_topic.py) | [README snippets](sample_readme_snippets.py) | +| `get_topic` | [Sample](../generated_samples/get_topic.py) | [README snippets](sample_readme_snippets.py) | +| `list_topics` | [Sample](../generated_samples/list_topics.py) | [README snippets](sample_readme_snippets.py) | +| `update_topic` | [Sample](../generated_samples/update_topic.py) | [README snippets](sample_readme_snippets.py) | +| `delete_topic` | [Sample](../generated_samples/delete_topic.py) | [README snippets](sample_readme_snippets.py) | +| `get_conversation` | [Sample](../generated_samples/get_conversation.py) | - | +| `list_messages` | [Sample](../generated_samples/list_messages.py) | [README snippets](sample_readme_snippets.py) | +| `update_message` | [Sample](../generated_samples/update_message.py) | [Message management](sample_message_management.py) | +| `delete_message` | [Sample](../generated_samples/delete_message.py) | [Message management](sample_message_management.py) | + +The synchronous and asynchronous clients expose the same service operations. +Await asynchronous non-paging calls, and use `async for` to iterate asynchronous +paged results. From b119b0bdf5cff52f416faaab57839ca919d0d7e3 Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Wed, 21 Oct 2026 15:03:06 +1100 Subject: [PATCH 13/22] Unify Chat create-or-replace request model names Regenerate role, room, membership and user request models with CreateOrReplace names matching their operations. Update docs, samples and tests, and cover sync/async model and TypedDict signatures. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../CHANGELOG.md | 2 +- .../README.md | 26 +++---- .../api.md | 52 +++++++------- .../api.metadata.yml | 2 +- .../apiview-properties.json | 12 ++-- .../_operations/_operations.py | 72 +++++++++---------- .../aio/_operations/_operations.py | 72 +++++++++---------- .../webpubsubchatservice/models/__init__.py | 20 +++--- .../webpubsubchatservice/models/_models.py | 24 +++---- .../messaging/webpubsubchatservice/types.py | 18 ++--- .../samples/README.md | 2 +- .../samples/sample_readme_snippets.py | 12 ++-- .../samples/sample_roles_and_permissions.py | 4 +- .../sample_roles_and_permissions_async.py | 4 +- .../tests/test_2026_08_01_preview_live.py | 28 +++++--- .../test_2026_08_01_preview_live_async.py | 22 +++--- .../tests/test_live.py | 48 +++++++------ .../tests/test_live_async.py | 44 ++++++------ .../tests/test_request_models.py | 24 ++++--- .../tests/typing/request_models.py | 28 ++++++++ .../tsp-location.yaml | 2 +- 21 files changed, 285 insertions(+), 233 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md index 88fb3c3b9d5a..7585cccef7dc 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md @@ -13,7 +13,7 @@ ### Breaking Changes - - Create or replace operations now accept dedicated `ChatRoleCreate`, `ChatRoomCreate`, `ChatRoomMemberCreate`, and `ChatUserCreate` (including `HumanChatUserCreate`) request models instead of resource response models. + - Create or replace operations now accept dedicated `ChatRoleCreateOrReplace`, `ChatRoomCreateOrReplace`, `ChatRoomMemberCreateOrReplace`, and `ChatUserCreateOrReplace` (including `HumanChatUserCreateOrReplace`) request models instead of resource response models. - Topic creation or replacement accepts `ChatTopicCreateOrReplace`, which requires only `title`. Topic updates accept `ChatTopicUpdate`, whose fields are optional. - Message updates accept `ChatMessageUpdate`, whose fields are optional, instead of `ChatMessage`. Resource response model names are unchanged. diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md index 0027f7c2b4cc..a5ff1c3088ee 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md @@ -129,7 +129,7 @@ User roles control operations such as creating rooms. Room roles control what a ### User -A user represents an identity participating in chat, such as a human end user or an application. In the service API, a user is identified by a user ID and assigned a user role. The SDK provides `HumanChatUserCreate` for creating human users with a nickname and a user role. 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. In the service API, a user is identified by a user ID and assigned a user role. The SDK provides `HumanChatUserCreateOrReplace` for creating human users with a nickname and a user role. Client access credentials associate WebSocket connections with a user ID. ### Room @@ -168,7 +168,7 @@ dictionaries; at runtime they are ordinary dictionaries, not model instances, and do not perform runtime validation. Concrete user models automatically set the JSON discriminator field. -For example, `HumanChatUserCreate(nickname="Alice", role_name="user.normal")` +For example, `HumanChatUserCreateOrReplace(nickname="Alice", role_name="user.normal")` sets `kind` to `"Human"`; callers do not pass `kind` or `discriminator` to this constructor. The `discriminator="Human"` in the generated class declaration registers the subtype for deserialization, while `kind` is the @@ -208,23 +208,23 @@ The returned URL contains an access token. Send it only to the intended client, ### Create a role -Create operations use dedicated request models such as `ChatRoleCreate` and -`ChatRoomCreate`. PATCH operations use `ChatTopicUpdate` and `ChatMessageUpdate`, +Create operations use dedicated request models such as `ChatRoleCreateOrReplace` and +`ChatRoomCreateOrReplace`. PATCH operations use `ChatTopicUpdate` and `ChatMessageUpdate`, whose fields can be omitted to leave existing values unchanged. The operations return resource models such as `ChatRole`, `ChatRoom`, and `ChatTopic`, which include service-assigned identifiers and ETags. -Use the `ChatRoleCreate` model and `ChatPermission` enum instead of a dictionary with +Use the `ChatRoleCreateOrReplace` model and `ChatPermission` enum instead of a dictionary with permission string literals. This example assumes `os` is imported. ```python -from azure.messaging.webpubsubchatservice.models import ChatPermission, ChatRoleCreate +from azure.messaging.webpubsubchatservice.models import ChatPermission, ChatRoleCreateOrReplace role = client.create_or_replace_role( os.environ.get("WPS_CHAT_ROLE_NAME", "user.python_sample"), - ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM]), + ChatRoleCreateOrReplace(permissions=[ChatPermission.USER_CREATE_ROOM]), ) print(role.name, role.permissions) ``` @@ -254,11 +254,11 @@ The user role `user.room_creator` must already exist. ```python -from azure.messaging.webpubsubchatservice.models import HumanChatUserCreate +from azure.messaging.webpubsubchatservice.models import HumanChatUserCreateOrReplace user = client.create_or_replace_user( "alice", - HumanChatUserCreate(nickname="Alice", role_name="user.room_creator"), + HumanChatUserCreateOrReplace(nickname="Alice", role_name="user.room_creator"), ) print(user.id, user.nickname) ``` @@ -270,9 +270,9 @@ print(user.id, user.nickname) ```python -from azure.messaging.webpubsubchatservice.models import ChatRoomCreate +from azure.messaging.webpubsubchatservice.models import ChatRoomCreateOrReplace -room = client.create_or_replace_room("general", ChatRoomCreate(title="General")) +room = client.create_or_replace_room("general", ChatRoomCreateOrReplace(title="General")) print(room.id, room.default_conversation) ``` @@ -285,12 +285,12 @@ The room `general`, user `alice`, and room role `room.contributor` must already ```python -from azure.messaging.webpubsubchatservice.models import ChatRoomMemberCreate +from azure.messaging.webpubsubchatservice.models import ChatRoomMemberCreateOrReplace member = client.create_or_replace_room_member( "general", "alice", - ChatRoomMemberCreate(role_name="room.contributor"), + ChatRoomMemberCreateOrReplace(role_name="room.contributor"), ) print(member.user_id, member.role_name) ``` diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md index b777d94cd6f6..3b51531c1da1 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md @@ -33,7 +33,7 @@ namespace azure.messaging.webpubsubchatservice def create_or_replace_role( self, role_name: str, - resource: ChatRoleCreate, + resource: ChatRoleCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -45,7 +45,7 @@ namespace azure.messaging.webpubsubchatservice def create_or_replace_role( self, role_name: str, - resource: ChatRoleCreate, + resource: ChatRoleCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -69,7 +69,7 @@ namespace azure.messaging.webpubsubchatservice def create_or_replace_room( self, room_id: str, - resource: ChatRoomCreate, + resource: ChatRoomCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -81,7 +81,7 @@ namespace azure.messaging.webpubsubchatservice def create_or_replace_room( self, room_id: str, - resource: ChatRoomCreate, + resource: ChatRoomCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -106,7 +106,7 @@ namespace azure.messaging.webpubsubchatservice self, room_id: str, user_id: str, - resource: ChatRoomMemberCreate, + resource: ChatRoomMemberCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -119,7 +119,7 @@ namespace azure.messaging.webpubsubchatservice self, room_id: str, user_id: str, - resource: ChatRoomMemberCreate, + resource: ChatRoomMemberCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -183,7 +183,7 @@ namespace azure.messaging.webpubsubchatservice def create_or_replace_user( self, user_id: str, - resource: ChatUserCreate, + resource: ChatUserCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -195,7 +195,7 @@ namespace azure.messaging.webpubsubchatservice def create_or_replace_user( self, user_id: str, - resource: ChatUserCreate, + resource: ChatUserCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -512,7 +512,7 @@ namespace azure.messaging.webpubsubchatservice.aio async def create_or_replace_role( self, role_name: str, - resource: ChatRoleCreate, + resource: ChatRoleCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -524,7 +524,7 @@ namespace azure.messaging.webpubsubchatservice.aio async def create_or_replace_role( self, role_name: str, - resource: ChatRoleCreate, + resource: ChatRoleCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -548,7 +548,7 @@ namespace azure.messaging.webpubsubchatservice.aio async def create_or_replace_room( self, room_id: str, - resource: ChatRoomCreate, + resource: ChatRoomCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -560,7 +560,7 @@ namespace azure.messaging.webpubsubchatservice.aio async def create_or_replace_room( self, room_id: str, - resource: ChatRoomCreate, + resource: ChatRoomCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -585,7 +585,7 @@ namespace azure.messaging.webpubsubchatservice.aio self, room_id: str, user_id: str, - resource: ChatRoomMemberCreate, + resource: ChatRoomMemberCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -598,7 +598,7 @@ namespace azure.messaging.webpubsubchatservice.aio self, room_id: str, user_id: str, - resource: ChatRoomMemberCreate, + resource: ChatRoomMemberCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -662,7 +662,7 @@ namespace azure.messaging.webpubsubchatservice.aio async def create_or_replace_user( self, user_id: str, - resource: ChatUserCreate, + resource: ChatUserCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -674,7 +674,7 @@ namespace azure.messaging.webpubsubchatservice.aio async def create_or_replace_user( self, user_id: str, - resource: ChatUserCreate, + resource: ChatUserCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -1041,7 +1041,7 @@ namespace azure.messaging.webpubsubchatservice.models def __init__(self, mapping: Mapping[str, Any]) -> None: ... - class azure.messaging.webpubsubchatservice.models.ChatRoleCreate(_Model): + class azure.messaging.webpubsubchatservice.models.ChatRoleCreateOrReplace(_Model): permissions: list[Union[str, ChatPermission]] @overload @@ -1072,7 +1072,7 @@ namespace azure.messaging.webpubsubchatservice.models def __init__(self, mapping: Mapping[str, Any]) -> None: ... - class azure.messaging.webpubsubchatservice.models.ChatRoomCreate(_Model): + class azure.messaging.webpubsubchatservice.models.ChatRoomCreateOrReplace(_Model): title: str @overload @@ -1102,7 +1102,7 @@ namespace azure.messaging.webpubsubchatservice.models def __init__(self, mapping: Mapping[str, Any]) -> None: ... - class azure.messaging.webpubsubchatservice.models.ChatRoomMemberCreate(_Model): + class azure.messaging.webpubsubchatservice.models.ChatRoomMemberCreateOrReplace(_Model): role_name: str @overload @@ -1191,7 +1191,7 @@ namespace azure.messaging.webpubsubchatservice.models def __init__(self, mapping: Mapping[str, Any]) -> None: ... - class azure.messaging.webpubsubchatservice.models.ChatUserCreate(_Model): + class azure.messaging.webpubsubchatservice.models.ChatUserCreateOrReplace(_Model): kind: str nickname: str @@ -1247,7 +1247,7 @@ namespace azure.messaging.webpubsubchatservice.models def __init__(self, mapping: Mapping[str, Any]) -> None: ... - class azure.messaging.webpubsubchatservice.models.HumanChatUserCreate(ChatUserCreate, discriminator='Human'): + class azure.messaging.webpubsubchatservice.models.HumanChatUserCreateOrReplace(ChatUserCreateOrReplace, discriminator='Human'): kind: Literal[ChatUserKind.HUMAN] nickname: str role_name: str @@ -1289,17 +1289,17 @@ namespace azure.messaging.webpubsubchatservice.types createdBy: str - class azure.messaging.webpubsubchatservice.types.ChatRoleCreate(TypedDict, total=False): + class azure.messaging.webpubsubchatservice.types.ChatRoleCreateOrReplace(TypedDict, total=False): key "permissions": Required[list[Union[str, ChatPermission]]] permissions: list[Union[str, ChatPermission]] - class azure.messaging.webpubsubchatservice.types.ChatRoomCreate(TypedDict, total=False): + class azure.messaging.webpubsubchatservice.types.ChatRoomCreateOrReplace(TypedDict, total=False): key "title": Required[str] title: str - class azure.messaging.webpubsubchatservice.types.ChatRoomMemberCreate(TypedDict, total=False): + class azure.messaging.webpubsubchatservice.types.ChatRoomMemberCreateOrReplace(TypedDict, total=False): key "roleName": Required[str] roleName: str @@ -1316,7 +1316,7 @@ namespace azure.messaging.webpubsubchatservice.types title: str - class azure.messaging.webpubsubchatservice.types.ChatUserCreate(TypedDict, total=False): + class azure.messaging.webpubsubchatservice.types.ChatUserCreateOrReplace(TypedDict, total=False): key "kind": Required[Literal[ChatUserKind.HUMAN]] key "nickname": Required[str] key "roleName": Required[str] @@ -1329,7 +1329,7 @@ namespace azure.messaging.webpubsubchatservice.types HUMAN = "Human" - class azure.messaging.webpubsubchatservice.types.HumanChatUserCreate(TypedDict, total=False): + class azure.messaging.webpubsubchatservice.types.HumanChatUserCreateOrReplace(TypedDict, total=False): key "kind": Required[Literal[ChatUserKind.HUMAN]] key "nickname": Required[str] key "roleName": Required[str] diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml index 4d28569b017b..02554ba13a19 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml @@ -1,4 +1,4 @@ -apiMdSha256: 579a81052926cd0807b5c1d43e7ed03ea068fea7762ec014c66e0f979d998358 +apiMdSha256: 528789bad38f0165f924016c0ebe7fc27feac738e5468b0147823c054bd475d7 packageVersion: 1.0.0b2 parserVersion: 0.3.31 pythonVersion: 3.12.10 diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json b/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json index c1e3f995a661..ed8b51e68cb1 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json @@ -5,19 +5,19 @@ "azure.messaging.webpubsubchatservice.models.ChatMessage": "WebPubSubChat.ChatMessage", "azure.messaging.webpubsubchatservice.models.ChatMessageUpdate": "WebPubSubChat.PythonCustomizations.ChatMessageUpdate", "azure.messaging.webpubsubchatservice.models.ChatRole": "WebPubSubChat.ChatRole", - "azure.messaging.webpubsubchatservice.models.ChatRoleCreate": "WebPubSubChat.PythonCustomizations.ChatRoleCreate", + "azure.messaging.webpubsubchatservice.models.ChatRoleCreateOrReplace": "WebPubSubChat.PythonCustomizations.ChatRoleCreateOrReplace", "azure.messaging.webpubsubchatservice.models.ChatRoom": "WebPubSubChat.ChatRoom", - "azure.messaging.webpubsubchatservice.models.ChatRoomCreate": "WebPubSubChat.PythonCustomizations.ChatRoomCreate", + "azure.messaging.webpubsubchatservice.models.ChatRoomCreateOrReplace": "WebPubSubChat.PythonCustomizations.ChatRoomCreateOrReplace", "azure.messaging.webpubsubchatservice.models.ChatRoomMember": "WebPubSubChat.ChatRoomMember", - "azure.messaging.webpubsubchatservice.models.ChatRoomMemberCreate": "WebPubSubChat.PythonCustomizations.ChatRoomMemberCreate", + "azure.messaging.webpubsubchatservice.models.ChatRoomMemberCreateOrReplace": "WebPubSubChat.PythonCustomizations.ChatRoomMemberCreateOrReplace", "azure.messaging.webpubsubchatservice.models.ChatTopic": "WebPubSubChat.ChatTopic", "azure.messaging.webpubsubchatservice.models.ChatTopicCreateOrReplace": "WebPubSubChat.PythonCustomizations.ChatTopicCreateOrReplace", "azure.messaging.webpubsubchatservice.models.ChatTopicUpdate": "WebPubSubChat.PythonCustomizations.ChatTopicUpdate", "azure.messaging.webpubsubchatservice.models.ChatUser": "WebPubSubChat.ChatUser", - "azure.messaging.webpubsubchatservice.models.ChatUserCreate": "WebPubSubChat.PythonCustomizations.ChatUserCreate", + "azure.messaging.webpubsubchatservice.models.ChatUserCreateOrReplace": "WebPubSubChat.PythonCustomizations.ChatUserCreateOrReplace", "azure.messaging.webpubsubchatservice.models.ChatUserRoom": "WebPubSubChat.ChatUserRoom", "azure.messaging.webpubsubchatservice.models.HumanChatUser": "WebPubSubChat.HumanChatUser", - "azure.messaging.webpubsubchatservice.models.HumanChatUserCreate": "WebPubSubChat.PythonCustomizations.HumanChatUserCreate", + "azure.messaging.webpubsubchatservice.models.HumanChatUserCreateOrReplace": "WebPubSubChat.PythonCustomizations.HumanChatUserCreateOrReplace", "azure.messaging.webpubsubchatservice.models.MessageContent": "WebPubSubChat.MessageContent", "azure.messaging.webpubsubchatservice.models.ChatPermission": "WebPubSubChat.ChatPermission", "azure.messaging.webpubsubchatservice.models.ChatTopicState": "WebPubSubChat.ChatTopicState", @@ -73,5 +73,5 @@ "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.list_rooms_for_user": "WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser", "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.list_rooms_for_user": "WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser" }, - "CrossLanguageVersion": "99e41376e215" + "CrossLanguageVersion": "584f70179c70" } \ No newline at end of file diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_operations/_operations.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_operations/_operations.py index 140694b1e1f3..42d86b965577 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_operations/_operations.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_operations/_operations.py @@ -1612,7 +1612,7 @@ def get_role(self, role_name: str, **kwargs: Any) -> _models.ChatRole: def create_or_replace_role( self, role_name: str, - resource: _models.ChatRoleCreate, + resource: _models.ChatRoleCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -1626,7 +1626,7 @@ def create_or_replace_role( :param role_name: Role name. Must start with 'user.' or 'room.' prefix. Required. :type role_name: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoleCreate + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoleCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1644,7 +1644,7 @@ def create_or_replace_role( def create_or_replace_role( self, role_name: str, - resource: _types.ChatRoleCreate, + resource: _types.ChatRoleCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -1658,7 +1658,7 @@ def create_or_replace_role( :param role_name: Role name. Must start with 'user.' or 'room.' prefix. Required. :type role_name: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatRoleCreate + :type resource: ~azure.messaging.webpubsubchatservice.types.ChatRoleCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1708,7 +1708,7 @@ def create_or_replace_role( def create_or_replace_role( self, role_name: str, - resource: Union[_models.ChatRoleCreate, _types.ChatRoleCreate, IO[bytes]], + resource: Union[_models.ChatRoleCreateOrReplace, _types.ChatRoleCreateOrReplace, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -1720,10 +1720,10 @@ def create_or_replace_role( :param role_name: Role name. Must start with 'user.' or 'room.' prefix. Required. :type role_name: str - :param resource: The resource instance. Is either a ChatRoleCreate type or a IO[bytes] type. - Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoleCreate or - ~azure.messaging.webpubsubchatservice.types.ChatRoleCreate or IO[bytes] + :param resource: The resource instance. Is either a ChatRoleCreateOrReplace type or a IO[bytes] + type. Required. + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoleCreateOrReplace or + ~azure.messaging.webpubsubchatservice.types.ChatRoleCreateOrReplace or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. :paramtype etag: str @@ -1988,7 +1988,7 @@ def get_next(next_link=None): def create_or_replace_room( self, room_id: str, - resource: _models.ChatRoomCreate, + resource: _models.ChatRoomCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -2002,7 +2002,7 @@ def create_or_replace_room( :param room_id: Room identifier. Required. :type room_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomCreate + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2020,7 +2020,7 @@ def create_or_replace_room( def create_or_replace_room( self, room_id: str, - resource: _types.ChatRoomCreate, + resource: _types.ChatRoomCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -2034,7 +2034,7 @@ def create_or_replace_room( :param room_id: Room identifier. Required. :type room_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatRoomCreate + :type resource: ~azure.messaging.webpubsubchatservice.types.ChatRoomCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2084,7 +2084,7 @@ def create_or_replace_room( def create_or_replace_room( self, room_id: str, - resource: Union[_models.ChatRoomCreate, _types.ChatRoomCreate, IO[bytes]], + resource: Union[_models.ChatRoomCreateOrReplace, _types.ChatRoomCreateOrReplace, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -2096,10 +2096,10 @@ def create_or_replace_room( :param room_id: Room identifier. Required. :type room_id: str - :param resource: The resource instance. Is either a ChatRoomCreate type or a IO[bytes] type. - Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomCreate or - ~azure.messaging.webpubsubchatservice.types.ChatRoomCreate or IO[bytes] + :param resource: The resource instance. Is either a ChatRoomCreateOrReplace type or a IO[bytes] + type. Required. + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomCreateOrReplace or + ~azure.messaging.webpubsubchatservice.types.ChatRoomCreateOrReplace or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. :paramtype etag: str @@ -3161,7 +3161,7 @@ def create_or_replace_room_member( self, room_id: str, user_id: str, - resource: _models.ChatRoomMemberCreate, + resource: _models.ChatRoomMemberCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -3177,7 +3177,7 @@ def create_or_replace_room_member( :param user_id: User ID of the member. Required. :type user_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomMemberCreate + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomMemberCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -3196,7 +3196,7 @@ def create_or_replace_room_member( self, room_id: str, user_id: str, - resource: _types.ChatRoomMemberCreate, + resource: _types.ChatRoomMemberCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -3212,7 +3212,7 @@ def create_or_replace_room_member( :param user_id: User ID of the member. Required. :type user_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatRoomMemberCreate + :type resource: ~azure.messaging.webpubsubchatservice.types.ChatRoomMemberCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -3266,7 +3266,7 @@ def create_or_replace_room_member( self, room_id: str, user_id: str, - resource: Union[_models.ChatRoomMemberCreate, _types.ChatRoomMemberCreate, IO[bytes]], + resource: Union[_models.ChatRoomMemberCreateOrReplace, _types.ChatRoomMemberCreateOrReplace, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -3280,10 +3280,10 @@ def create_or_replace_room_member( :type room_id: str :param user_id: User ID of the member. Required. :type user_id: str - :param resource: The resource instance. Is either a ChatRoomMemberCreate type or a IO[bytes] - type. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomMemberCreate or - ~azure.messaging.webpubsubchatservice.types.ChatRoomMemberCreate or IO[bytes] + :param resource: The resource instance. Is either a ChatRoomMemberCreateOrReplace type or a + IO[bytes] type. Required. + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomMemberCreateOrReplace or + ~azure.messaging.webpubsubchatservice.types.ChatRoomMemberCreateOrReplace or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. :paramtype etag: str @@ -3618,7 +3618,7 @@ def get_user(self, user_id: str, **kwargs: Any) -> _models.ChatUser: def create_or_replace_user( self, user_id: str, - resource: _models.ChatUserCreate, + resource: _models.ChatUserCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -3633,7 +3633,7 @@ def create_or_replace_user( :param user_id: User identifier. Required. :type user_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatUserCreate + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatUserCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -3651,7 +3651,7 @@ def create_or_replace_user( def create_or_replace_user( self, user_id: str, - resource: _types.ChatUserCreate, + resource: _types.ChatUserCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -3666,7 +3666,7 @@ def create_or_replace_user( :param user_id: User identifier. Required. :type user_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatUserCreate + :type resource: ~azure.messaging.webpubsubchatservice.types.ChatUserCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -3717,7 +3717,7 @@ def create_or_replace_user( def create_or_replace_user( self, user_id: str, - resource: Union[_models.ChatUserCreate, _types.ChatUserCreate, IO[bytes]], + resource: Union[_models.ChatUserCreateOrReplace, _types.ChatUserCreateOrReplace, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -3730,10 +3730,10 @@ def create_or_replace_user( :param user_id: User identifier. Required. :type user_id: str - :param resource: The resource instance. Is either a ChatUserCreate type or a IO[bytes] type. - Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatUserCreate or - ~azure.messaging.webpubsubchatservice.types.ChatUserCreate or IO[bytes] + :param resource: The resource instance. Is either a ChatUserCreateOrReplace type or a IO[bytes] + type. Required. + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatUserCreateOrReplace or + ~azure.messaging.webpubsubchatservice.types.ChatUserCreateOrReplace or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. :paramtype etag: str diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_operations/_operations.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_operations/_operations.py index 04d573fa59e6..45a08e76a659 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_operations/_operations.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_operations/_operations.py @@ -706,7 +706,7 @@ async def get_role(self, role_name: str, **kwargs: Any) -> _models.ChatRole: async def create_or_replace_role( self, role_name: str, - resource: _models.ChatRoleCreate, + resource: _models.ChatRoleCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -720,7 +720,7 @@ async def create_or_replace_role( :param role_name: Role name. Must start with 'user.' or 'room.' prefix. Required. :type role_name: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoleCreate + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoleCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -738,7 +738,7 @@ async def create_or_replace_role( async def create_or_replace_role( self, role_name: str, - resource: _types.ChatRoleCreate, + resource: _types.ChatRoleCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -752,7 +752,7 @@ async def create_or_replace_role( :param role_name: Role name. Must start with 'user.' or 'room.' prefix. Required. :type role_name: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatRoleCreate + :type resource: ~azure.messaging.webpubsubchatservice.types.ChatRoleCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -802,7 +802,7 @@ async def create_or_replace_role( async def create_or_replace_role( self, role_name: str, - resource: Union[_models.ChatRoleCreate, _types.ChatRoleCreate, IO[bytes]], + resource: Union[_models.ChatRoleCreateOrReplace, _types.ChatRoleCreateOrReplace, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -814,10 +814,10 @@ async def create_or_replace_role( :param role_name: Role name. Must start with 'user.' or 'room.' prefix. Required. :type role_name: str - :param resource: The resource instance. Is either a ChatRoleCreate type or a IO[bytes] type. - Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoleCreate or - ~azure.messaging.webpubsubchatservice.types.ChatRoleCreate or IO[bytes] + :param resource: The resource instance. Is either a ChatRoleCreateOrReplace type or a IO[bytes] + type. Required. + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoleCreateOrReplace or + ~azure.messaging.webpubsubchatservice.types.ChatRoleCreateOrReplace or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. :paramtype etag: str @@ -1083,7 +1083,7 @@ async def get_next(next_link=None): async def create_or_replace_room( self, room_id: str, - resource: _models.ChatRoomCreate, + resource: _models.ChatRoomCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -1097,7 +1097,7 @@ async def create_or_replace_room( :param room_id: Room identifier. Required. :type room_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomCreate + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1115,7 +1115,7 @@ async def create_or_replace_room( async def create_or_replace_room( self, room_id: str, - resource: _types.ChatRoomCreate, + resource: _types.ChatRoomCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -1129,7 +1129,7 @@ async def create_or_replace_room( :param room_id: Room identifier. Required. :type room_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatRoomCreate + :type resource: ~azure.messaging.webpubsubchatservice.types.ChatRoomCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1179,7 +1179,7 @@ async def create_or_replace_room( async def create_or_replace_room( self, room_id: str, - resource: Union[_models.ChatRoomCreate, _types.ChatRoomCreate, IO[bytes]], + resource: Union[_models.ChatRoomCreateOrReplace, _types.ChatRoomCreateOrReplace, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -1191,10 +1191,10 @@ async def create_or_replace_room( :param room_id: Room identifier. Required. :type room_id: str - :param resource: The resource instance. Is either a ChatRoomCreate type or a IO[bytes] type. - Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomCreate or - ~azure.messaging.webpubsubchatservice.types.ChatRoomCreate or IO[bytes] + :param resource: The resource instance. Is either a ChatRoomCreateOrReplace type or a IO[bytes] + type. Required. + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomCreateOrReplace or + ~azure.messaging.webpubsubchatservice.types.ChatRoomCreateOrReplace or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. :paramtype etag: str @@ -2257,7 +2257,7 @@ async def create_or_replace_room_member( self, room_id: str, user_id: str, - resource: _models.ChatRoomMemberCreate, + resource: _models.ChatRoomMemberCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -2273,7 +2273,7 @@ async def create_or_replace_room_member( :param user_id: User ID of the member. Required. :type user_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomMemberCreate + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomMemberCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2292,7 +2292,7 @@ async def create_or_replace_room_member( self, room_id: str, user_id: str, - resource: _types.ChatRoomMemberCreate, + resource: _types.ChatRoomMemberCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -2308,7 +2308,7 @@ async def create_or_replace_room_member( :param user_id: User ID of the member. Required. :type user_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatRoomMemberCreate + :type resource: ~azure.messaging.webpubsubchatservice.types.ChatRoomMemberCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2362,7 +2362,7 @@ async def create_or_replace_room_member( self, room_id: str, user_id: str, - resource: Union[_models.ChatRoomMemberCreate, _types.ChatRoomMemberCreate, IO[bytes]], + resource: Union[_models.ChatRoomMemberCreateOrReplace, _types.ChatRoomMemberCreateOrReplace, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -2376,10 +2376,10 @@ async def create_or_replace_room_member( :type room_id: str :param user_id: User ID of the member. Required. :type user_id: str - :param resource: The resource instance. Is either a ChatRoomMemberCreate type or a IO[bytes] - type. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomMemberCreate or - ~azure.messaging.webpubsubchatservice.types.ChatRoomMemberCreate or IO[bytes] + :param resource: The resource instance. Is either a ChatRoomMemberCreateOrReplace type or a + IO[bytes] type. Required. + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomMemberCreateOrReplace or + ~azure.messaging.webpubsubchatservice.types.ChatRoomMemberCreateOrReplace or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. :paramtype etag: str @@ -2715,7 +2715,7 @@ async def get_user(self, user_id: str, **kwargs: Any) -> _models.ChatUser: async def create_or_replace_user( self, user_id: str, - resource: _models.ChatUserCreate, + resource: _models.ChatUserCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -2730,7 +2730,7 @@ async def create_or_replace_user( :param user_id: User identifier. Required. :type user_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatUserCreate + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatUserCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2748,7 +2748,7 @@ async def create_or_replace_user( async def create_or_replace_user( self, user_id: str, - resource: _types.ChatUserCreate, + resource: _types.ChatUserCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -2763,7 +2763,7 @@ async def create_or_replace_user( :param user_id: User identifier. Required. :type user_id: str :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatUserCreate + :type resource: ~azure.messaging.webpubsubchatservice.types.ChatUserCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2814,7 +2814,7 @@ async def create_or_replace_user( async def create_or_replace_user( self, user_id: str, - resource: Union[_models.ChatUserCreate, _types.ChatUserCreate, IO[bytes]], + resource: Union[_models.ChatUserCreateOrReplace, _types.ChatUserCreateOrReplace, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -2827,10 +2827,10 @@ async def create_or_replace_user( :param user_id: User identifier. Required. :type user_id: str - :param resource: The resource instance. Is either a ChatUserCreate type or a IO[bytes] type. - Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatUserCreate or - ~azure.messaging.webpubsubchatservice.types.ChatUserCreate or IO[bytes] + :param resource: The resource instance. Is either a ChatUserCreateOrReplace type or a IO[bytes] + type. Required. + :type resource: ~azure.messaging.webpubsubchatservice.models.ChatUserCreateOrReplace or + ~azure.messaging.webpubsubchatservice.types.ChatUserCreateOrReplace or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. :paramtype etag: str diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/__init__.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/__init__.py index e331d7586ea3..ea91b356fa91 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/__init__.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/__init__.py @@ -18,19 +18,19 @@ ChatMessage, ChatMessageUpdate, ChatRole, - ChatRoleCreate, + ChatRoleCreateOrReplace, ChatRoom, - ChatRoomCreate, + ChatRoomCreateOrReplace, ChatRoomMember, - ChatRoomMemberCreate, + ChatRoomMemberCreateOrReplace, ChatTopic, ChatTopicCreateOrReplace, ChatTopicUpdate, ChatUser, - ChatUserCreate, + ChatUserCreateOrReplace, ChatUserRoom, HumanChatUser, - HumanChatUserCreate, + HumanChatUserCreateOrReplace, MessageContent, ) @@ -48,19 +48,19 @@ "ChatMessage", "ChatMessageUpdate", "ChatRole", - "ChatRoleCreate", + "ChatRoleCreateOrReplace", "ChatRoom", - "ChatRoomCreate", + "ChatRoomCreateOrReplace", "ChatRoomMember", - "ChatRoomMemberCreate", + "ChatRoomMemberCreateOrReplace", "ChatTopic", "ChatTopicCreateOrReplace", "ChatTopicUpdate", "ChatUser", - "ChatUserCreate", + "ChatUserCreateOrReplace", "ChatUserRoom", "HumanChatUser", - "HumanChatUserCreate", + "HumanChatUserCreateOrReplace", "MessageContent", "ChatPermission", "ChatTopicState", diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/_models.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/_models.py index 8ab0d756d0b7..232ce47e5432 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/_models.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/_models.py @@ -173,8 +173,8 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class ChatRoleCreate(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only - """Properties supplied when creating a role. +class ChatRoleCreateOrReplace(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Properties supplied when creating or replacing a role. :ivar permissions: Permissions associated with the role. Do not mix user permissions and room permissions in one role. Required. @@ -245,8 +245,8 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class ChatRoomCreate(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only - """Properties supplied when creating a room. +class ChatRoomCreateOrReplace(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Properties supplied when creating or replacing a room. :ivar title: Room title. Required. :vartype title: str @@ -309,8 +309,8 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class ChatRoomMemberCreate(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only - """Properties supplied when creating a room member. +class ChatRoomMemberCreateOrReplace(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Properties supplied when creating or replacing a room member. :ivar role_name: Room role assigned to the user within this room. Required. :vartype role_name: str @@ -503,11 +503,11 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class ChatUserCreate(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only - """Properties supplied when creating a user. +class ChatUserCreateOrReplace(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Properties supplied when creating or replacing a user. You probably want to use the sub-classes and not this class directly. Known sub-classes are: - HumanChatUserCreate + HumanChatUserCreateOrReplace :ivar kind: The kind of user. Required. "Human" :vartype kind: str or ~azure.messaging.webpubsubchatservice.models.ChatUserKind @@ -651,10 +651,10 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.kind = ChatUserKind.HUMAN # type: ignore -class HumanChatUserCreate( - ChatUserCreate, discriminator="Human" +class HumanChatUserCreateOrReplace( + ChatUserCreateOrReplace, discriminator="Human" ): # pylint: disable=docstring-keyword-should-match-keyword-only - """Properties supplied when creating a human user. + """Properties supplied when creating or replacing a human user. :ivar kind: Required. A human end-user. :vartype kind: str or ~azure.messaging.webpubsubchatservice.models.HUMAN diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py index 09f42e14df91..21cc25cc2be6 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py @@ -30,8 +30,8 @@ class ChatMessageUpdate(TypedDict, total=False): """Message content.""" -class ChatRoleCreate(TypedDict, total=False): - """Properties supplied when creating a role. +class ChatRoleCreateOrReplace(TypedDict, total=False): + """Properties supplied when creating or replacing a role. :ivar permissions: Permissions associated with the role. Do not mix user permissions and room permissions in one role. Required. @@ -43,8 +43,8 @@ class ChatRoleCreate(TypedDict, total=False): role. Required.""" -class ChatRoomCreate(TypedDict, total=False): - """Properties supplied when creating a room. +class ChatRoomCreateOrReplace(TypedDict, total=False): + """Properties supplied when creating or replacing a room. :ivar title: Room title. Required. :vartype title: str @@ -54,8 +54,8 @@ class ChatRoomCreate(TypedDict, total=False): """Room title. Required.""" -class ChatRoomMemberCreate(TypedDict, total=False): - """Properties supplied when creating a room member. +class ChatRoomMemberCreateOrReplace(TypedDict, total=False): + """Properties supplied when creating or replacing a room member. :ivar roleName: Room role assigned to the user within this room. Required. :vartype roleName: str @@ -93,8 +93,8 @@ class ChatTopicUpdate(TypedDict, total=False): \"SoftDeleted\".""" -class HumanChatUserCreate(TypedDict, total=False): - """Properties supplied when creating a human user. +class HumanChatUserCreateOrReplace(TypedDict, total=False): + """Properties supplied when creating or replacing a human user. :ivar kind: Required. A human end-user. :vartype kind: Literal[ChatUserKind.HUMAN] @@ -127,4 +127,4 @@ class MessageContent(TypedDict, total=False): """Binary content (base64 encoded).""" -ChatUserCreate = Union[HumanChatUserCreate] +ChatUserCreateOrReplace = Union[HumanChatUserCreateOrReplace] diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md index 3a4211ef8f14..44152ce69694 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md @@ -14,7 +14,7 @@ describe those dictionary shapes for static type checking; they do not create model instances or validate values at runtime. Both request-body styles are accepted by the corresponding client operations. -`HumanChatUserCreate` automatically supplies `"kind": "Human"` when serialized. +`HumanChatUserCreateOrReplace` automatically supplies `"kind": "Human"` when serialized. Dictionary requests must supply that field explicitly. See [request models and dictionaries](../README.md#request-models-and-dictionaries) for details. diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_readme_snippets.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_readme_snippets.py index 513f2dbeabda..632d100536e5 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_readme_snippets.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_readme_snippets.py @@ -16,11 +16,11 @@ def list_roles(client: WebPubSubChatServiceClient) -> None: def create_user(client: WebPubSubChatServiceClient) -> None: # [START create_user] - from azure.messaging.webpubsubchatservice.models import HumanChatUserCreate + from azure.messaging.webpubsubchatservice.models import HumanChatUserCreateOrReplace user = client.create_or_replace_user( "alice", - HumanChatUserCreate(nickname="Alice", role_name="user.room_creator"), + HumanChatUserCreateOrReplace(nickname="Alice", role_name="user.room_creator"), ) print(user.id, user.nickname) # [END create_user] @@ -28,21 +28,21 @@ def create_user(client: WebPubSubChatServiceClient) -> None: def create_room(client: WebPubSubChatServiceClient) -> None: # [START create_room] - from azure.messaging.webpubsubchatservice.models import ChatRoomCreate + from azure.messaging.webpubsubchatservice.models import ChatRoomCreateOrReplace - room = client.create_or_replace_room("general", ChatRoomCreate(title="General")) + room = client.create_or_replace_room("general", ChatRoomCreateOrReplace(title="General")) print(room.id, room.default_conversation) # [END create_room] def add_room_member(client: WebPubSubChatServiceClient) -> None: # [START add_room_member] - from azure.messaging.webpubsubchatservice.models import ChatRoomMemberCreate + from azure.messaging.webpubsubchatservice.models import ChatRoomMemberCreateOrReplace member = client.create_or_replace_room_member( "general", "alice", - ChatRoomMemberCreate(role_name="room.contributor"), + ChatRoomMemberCreateOrReplace(role_name="room.contributor"), ) print(member.user_id, member.role_name) # [END add_room_member] diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions.py index 1e9a18e75bcf..eede3c81e9c3 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions.py @@ -8,11 +8,11 @@ def create_role(client): # [START create_role] - from azure.messaging.webpubsubchatservice.models import ChatPermission, ChatRoleCreate + from azure.messaging.webpubsubchatservice.models import ChatPermission, ChatRoleCreateOrReplace role = client.create_or_replace_role( os.environ.get("WPS_CHAT_ROLE_NAME", "user.python_sample"), - ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM]), + ChatRoleCreateOrReplace(permissions=[ChatPermission.USER_CREATE_ROOM]), ) print(role.name, role.permissions) # [END create_role] diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions_async.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions_async.py index 66fe3c206144..6f8906012343 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions_async.py @@ -9,11 +9,11 @@ async def create_role(client): # [START create_role] - from azure.messaging.webpubsubchatservice.models import ChatPermission, ChatRoleCreate + from azure.messaging.webpubsubchatservice.models import ChatPermission, ChatRoleCreateOrReplace role = await client.create_or_replace_role( os.environ.get("WPS_CHAT_ROLE_NAME", "user.python_sample"), - ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM]), + ChatRoleCreateOrReplace(permissions=[ChatPermission.USER_CREATE_ROOM]), ) print(role.name, role.permissions) # [END create_role] diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live.py index 528dcaabed43..8f06c2fb54c6 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live.py @@ -10,14 +10,14 @@ from azure.core.exceptions import HttpResponseError from azure.messaging.webpubsubchatservice.models import ( ChatPermission, - ChatRoleCreate, - ChatRoomCreate, - ChatRoomMemberCreate, + ChatRoleCreateOrReplace, + ChatRoomCreateOrReplace, + ChatRoomMemberCreateOrReplace, ChatTopicCreateOrReplace, ChatTopicUpdate, ChatTopicState, HumanChatUser, - HumanChatUserCreate, + HumanChatUserCreateOrReplace, ) @@ -39,7 +39,7 @@ def test_topic_lifecycle_and_paging(self, wps_chat_endpoint): client = self.create_client(wps_chat_endpoint) room_id = "python-e2e-topics" try: - room = client.create_or_replace_room(room_id, ChatRoomCreate(title="Topic E2E")) + room = client.create_or_replace_room(room_id, ChatRoomCreateOrReplace(title="Topic E2E")) assert all(topic.conversation_id == room.default_conversation for topic in client.list_topics(room_id)) for topic_id in ("first", "second"): topic = client.create_or_replace_topic(room_id, topic_id, ChatTopicCreateOrReplace(title=topic_id)) @@ -92,14 +92,22 @@ def test_room_user_and_user_room_collections(self, wps_chat_endpoint): user_role = "user.python_e2e_collections" room_role = "room.python_e2e_collections" try: - client.create_or_replace_role(user_role, ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM])) - client.create_or_replace_role(room_role, ChatRoleCreate(permissions=[ChatPermission.ROOM_PUBLISH_MESSAGE])) + client.create_or_replace_role( + user_role, ChatRoleCreateOrReplace(permissions=[ChatPermission.USER_CREATE_ROOM]) + ) + client.create_or_replace_role( + room_role, ChatRoleCreateOrReplace(permissions=[ChatPermission.ROOM_PUBLISH_MESSAGE]) + ) for user_id in user_ids: - client.create_or_replace_user(user_id, HumanChatUserCreate(nickname=user_id, role_name=user_role)) + client.create_or_replace_user( + user_id, HumanChatUserCreateOrReplace(nickname=user_id, role_name=user_role) + ) assert not list(client.list_rooms_for_user(user_ids[0])) for room_id in room_ids: - client.create_or_replace_room(room_id, ChatRoomCreate(title=room_id)) - client.create_or_replace_room_member(room_id, user_ids[0], ChatRoomMemberCreate(role_name=room_role)) + client.create_or_replace_room(room_id, ChatRoomCreateOrReplace(title=room_id)) + client.create_or_replace_room_member( + room_id, user_ids[0], ChatRoomMemberCreateOrReplace(role_name=room_role) + ) assert {room.id for room in client.list_rooms(max_page_size=1)}.issuperset(room_ids) users = list(client.list_users(max_page_size=1)) assert {user.id for user in users}.issuperset(user_ids) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live_async.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live_async.py index 8460a9ea6e46..4f7b9e5d68f7 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live_async.py @@ -10,14 +10,14 @@ from azure.core.exceptions import HttpResponseError from azure.messaging.webpubsubchatservice.models import ( ChatPermission, - ChatRoleCreate, - ChatRoomCreate, - ChatRoomMemberCreate, + ChatRoleCreateOrReplace, + ChatRoomCreateOrReplace, + ChatRoomMemberCreateOrReplace, ChatTopicCreateOrReplace, ChatTopicUpdate, ChatTopicState, HumanChatUser, - HumanChatUserCreate, + HumanChatUserCreateOrReplace, ) @@ -44,7 +44,7 @@ async def test_async_topic_lifecycle_and_paging(self, wps_chat_endpoint): client = self.create_async_client(wps_chat_endpoint) room_id = "python-async-e2e-topics" try: - room = await client.create_or_replace_room(room_id, ChatRoomCreate(title="Async Topic E2E")) + room = await client.create_or_replace_room(room_id, ChatRoomCreateOrReplace(title="Async Topic E2E")) assert all( topic.conversation_id == room.default_conversation for topic in await _collect(client.list_topics(room_id)) @@ -108,18 +108,20 @@ async def test_async_room_user_and_user_room_collections(self, wps_chat_endpoint room_role = "room.python_async_e2e_collections" try: await client.create_or_replace_role( - user_role, ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM]) + user_role, ChatRoleCreateOrReplace(permissions=[ChatPermission.USER_CREATE_ROOM]) ) await client.create_or_replace_role( - room_role, ChatRoleCreate(permissions=[ChatPermission.ROOM_PUBLISH_MESSAGE]) + room_role, ChatRoleCreateOrReplace(permissions=[ChatPermission.ROOM_PUBLISH_MESSAGE]) ) for user_id in user_ids: - await client.create_or_replace_user(user_id, HumanChatUserCreate(nickname=user_id, role_name=user_role)) + await client.create_or_replace_user( + user_id, HumanChatUserCreateOrReplace(nickname=user_id, role_name=user_role) + ) assert await _collect(client.list_rooms_for_user(user_ids[0])) == [] for room_id in room_ids: - await client.create_or_replace_room(room_id, ChatRoomCreate(title=room_id)) + await client.create_or_replace_room(room_id, ChatRoomCreateOrReplace(title=room_id)) await client.create_or_replace_room_member( - room_id, user_ids[0], ChatRoomMemberCreate(role_name=room_role) + room_id, user_ids[0], ChatRoomMemberCreateOrReplace(role_name=room_role) ) assert {room.id async for room in client.list_rooms(max_page_size=1)}.issuperset(room_ids) users = await _collect(client.list_users(max_page_size=1)) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live.py index c52054ff9515..06713c609e28 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live.py @@ -15,10 +15,10 @@ from azure.messaging.webpubsubchatservice.models import ( ChatMessageUpdate, ChatPermission, - ChatRoleCreate, - ChatRoomCreate, - ChatRoomMemberCreate, - HumanChatUserCreate, + ChatRoleCreateOrReplace, + ChatRoomCreateOrReplace, + ChatRoomMemberCreateOrReplace, + HumanChatUserCreateOrReplace, MessageContent, ) @@ -33,7 +33,7 @@ def test_role_lifecycle_and_paging(self, wps_chat_endpoint): for role_name in role_names: role = client.create_or_replace_role( role_name, - ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM]), + ChatRoleCreateOrReplace(permissions=[ChatPermission.USER_CREATE_ROOM]), ) assert role.name == role_name assert client.get_role(role_name).permissions == [ChatPermission.USER_CREATE_ROOM] @@ -80,7 +80,7 @@ def test_create_role_only_when_missing(self, wps_chat_endpoint): try: created = client.create_or_replace_role( role_name, - ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM]), + ChatRoleCreateOrReplace(permissions=[ChatPermission.USER_CREATE_ROOM]), match_condition=MatchConditions.IfMissing, ) assert created.name == role_name @@ -88,7 +88,7 @@ def test_create_role_only_when_missing(self, wps_chat_endpoint): with pytest.raises(HttpResponseError) as error: client.create_or_replace_role( role_name, - ChatRoleCreate(permissions=[ChatPermission.USER_FETCH_ALL_ROOMS]), + ChatRoleCreateOrReplace(permissions=[ChatPermission.USER_FETCH_ALL_ROOMS]), match_condition=MatchConditions.IfMissing, ) assert error.value.status_code == 412 @@ -104,11 +104,11 @@ def test_rejects_stale_role_etag(self, wps_chat_endpoint): try: created = client.create_or_replace_role( role_name, - ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM]), + ChatRoleCreateOrReplace(permissions=[ChatPermission.USER_CREATE_ROOM]), ) replaced = client.create_or_replace_role( role_name, - ChatRoleCreate( + ChatRoleCreateOrReplace( permissions=[ ChatPermission.USER_CREATE_ROOM, ChatPermission.USER_FETCH_ALL_ROOMS, @@ -122,7 +122,7 @@ def test_rejects_stale_role_etag(self, wps_chat_endpoint): with pytest.raises(HttpResponseError) as error: client.create_or_replace_role( role_name, - ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM]), + ChatRoleCreateOrReplace(permissions=[ChatPermission.USER_CREATE_ROOM]), etag=created.etag, match_condition=MatchConditions.IfNotModified, ) @@ -137,7 +137,7 @@ def test_room_conversation_and_empty_pages(self, wps_chat_endpoint): client = self.create_client(wps_chat_endpoint) room_id = "python-e2e-empty-room" try: - room = client.create_or_replace_room(room_id, ChatRoomCreate(title="Python E2E Room")) + room = client.create_or_replace_room(room_id, ChatRoomCreateOrReplace(title="Python E2E Room")) assert room.id == room_id fetched_room = client.get_room(room_id) assert fetched_room.id == room_id @@ -161,11 +161,15 @@ def test_user_and_room_member_lifecycle(self, wps_chat_endpoint): user_id = "python-e2e-user" room_id = "python-e2e-member-room" try: - client.create_or_replace_role(user_role, ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM])) - client.create_or_replace_role(room_role, ChatRoleCreate(permissions=[ChatPermission.ROOM_PUBLISH_MESSAGE])) + client.create_or_replace_role( + user_role, ChatRoleCreateOrReplace(permissions=[ChatPermission.USER_CREATE_ROOM]) + ) + client.create_or_replace_role( + room_role, ChatRoleCreateOrReplace(permissions=[ChatPermission.ROOM_PUBLISH_MESSAGE]) + ) user = client.create_or_replace_user( user_id, - HumanChatUserCreate(nickname="Python User", role_name=user_role), + HumanChatUserCreateOrReplace(nickname="Python User", role_name=user_role), ) assert user.id == user_id assert user.kind == "Human" @@ -173,11 +177,11 @@ def test_user_and_room_member_lifecycle(self, wps_chat_endpoint): assert fetched_user.id == user_id assert fetched_user.nickname == "Python User" - client.create_or_replace_room(room_id, ChatRoomCreate(title="Member Room")) + client.create_or_replace_room(room_id, ChatRoomCreateOrReplace(title="Member Room")) member = client.create_or_replace_room_member( room_id, user_id, - ChatRoomMemberCreate(role_name=room_role), + ChatRoomMemberCreateOrReplace(role_name=room_role), ) assert member.user_id == user_id assert member.role_name == room_role @@ -204,10 +208,12 @@ def test_message_lifecycle(self, wps_chat_endpoint): updated_text = "Python E2E updated message" binary_content = bytes([0, 1, 2, 254, 255]) try: - client.create_or_replace_role(user_role, ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM])) + client.create_or_replace_role( + user_role, ChatRoleCreateOrReplace(permissions=[ChatPermission.USER_CREATE_ROOM]) + ) client.create_or_replace_role( room_role, - ChatRoleCreate( + ChatRoleCreateOrReplace( permissions=[ ChatPermission.ROOM_PUBLISH_MESSAGE, ChatPermission.ROOM_HISTORY, @@ -216,10 +222,10 @@ def test_message_lifecycle(self, wps_chat_endpoint): ) client.create_or_replace_user( user_id, - HumanChatUserCreate(nickname="Python Message User", role_name=user_role), + HumanChatUserCreateOrReplace(nickname="Python Message User", role_name=user_role), ) - room = client.create_or_replace_room(room_id, ChatRoomCreate(title="Python Message Room")) - client.create_or_replace_room_member(room_id, user_id, ChatRoomMemberCreate(role_name=room_role)) + room = client.create_or_replace_room(room_id, ChatRoomCreateOrReplace(title="Python Message Room")) + client.create_or_replace_room_member(room_id, user_id, ChatRoomMemberCreateOrReplace(role_name=room_role)) self.seed_chat_message(client, user_id, room.default_conversation, message_text) message = next( diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live_async.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live_async.py index 92e8fe6c1fb6..06541c5632c0 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live_async.py @@ -15,10 +15,10 @@ from azure.messaging.webpubsubchatservice.models import ( ChatMessageUpdate, ChatPermission, - ChatRoleCreate, - ChatRoomCreate, - ChatRoomMemberCreate, - HumanChatUserCreate, + ChatRoleCreateOrReplace, + ChatRoomCreateOrReplace, + ChatRoomMemberCreateOrReplace, + HumanChatUserCreateOrReplace, MessageContent, ) @@ -38,7 +38,7 @@ async def test_async_role_lifecycle_and_paging(self, wps_chat_endpoint): for role_name in role_names: role = await client.create_or_replace_role( role_name, - ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM]), + ChatRoleCreateOrReplace(permissions=[ChatPermission.USER_CREATE_ROOM]), ) assert role.name == role_name assert (await client.get_role(role_name)).permissions == [ChatPermission.USER_CREATE_ROOM] @@ -87,7 +87,7 @@ async def test_async_create_role_only_when_missing(self, wps_chat_endpoint): try: created = await client.create_or_replace_role( role_name, - ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM]), + ChatRoleCreateOrReplace(permissions=[ChatPermission.USER_CREATE_ROOM]), match_condition=MatchConditions.IfMissing, ) assert created.name == role_name @@ -95,7 +95,7 @@ async def test_async_create_role_only_when_missing(self, wps_chat_endpoint): with pytest.raises(HttpResponseError) as error: await client.create_or_replace_role( role_name, - ChatRoleCreate(permissions=[ChatPermission.USER_FETCH_ALL_ROOMS]), + ChatRoleCreateOrReplace(permissions=[ChatPermission.USER_FETCH_ALL_ROOMS]), match_condition=MatchConditions.IfMissing, ) assert error.value.status_code == 412 @@ -112,11 +112,11 @@ async def test_async_rejects_stale_role_etag(self, wps_chat_endpoint): try: created = await client.create_or_replace_role( role_name, - ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM]), + ChatRoleCreateOrReplace(permissions=[ChatPermission.USER_CREATE_ROOM]), ) replaced = await client.create_or_replace_role( role_name, - ChatRoleCreate( + ChatRoleCreateOrReplace( permissions=[ ChatPermission.USER_CREATE_ROOM, ChatPermission.USER_FETCH_ALL_ROOMS, @@ -130,7 +130,7 @@ async def test_async_rejects_stale_role_etag(self, wps_chat_endpoint): with pytest.raises(HttpResponseError) as error: await client.create_or_replace_role( role_name, - ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM]), + ChatRoleCreateOrReplace(permissions=[ChatPermission.USER_CREATE_ROOM]), etag=created.etag, match_condition=MatchConditions.IfNotModified, ) @@ -146,7 +146,7 @@ async def test_async_room_conversation_and_empty_pages(self, wps_chat_endpoint): client = self.create_async_client(wps_chat_endpoint) room_id = "python-async-e2e-empty-room" try: - room = await client.create_or_replace_room(room_id, ChatRoomCreate(title="Async Python E2E Room")) + room = await client.create_or_replace_room(room_id, ChatRoomCreateOrReplace(title="Async Python E2E Room")) assert room.id == room_id fetched_room = await client.get_room(room_id) assert fetched_room.id == room_id @@ -172,26 +172,26 @@ async def test_async_user_and_room_member_lifecycle(self, wps_chat_endpoint): room_id = "python-async-e2e-member-room" try: await client.create_or_replace_role( - user_role, ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM]) + user_role, ChatRoleCreateOrReplace(permissions=[ChatPermission.USER_CREATE_ROOM]) ) await client.create_or_replace_role( - room_role, ChatRoleCreate(permissions=[ChatPermission.ROOM_PUBLISH_MESSAGE]) + room_role, ChatRoleCreateOrReplace(permissions=[ChatPermission.ROOM_PUBLISH_MESSAGE]) ) user = await client.create_or_replace_user( user_id, - HumanChatUserCreate(nickname="Async Python User", role_name=user_role), + HumanChatUserCreateOrReplace(nickname="Async Python User", role_name=user_role), ) assert user.id == user_id assert user.kind == "Human" fetched_user = await client.get_user(user_id) assert fetched_user.id == user_id assert fetched_user.nickname == "Async Python User" - await client.create_or_replace_room(room_id, ChatRoomCreate(title="Async Member Room")) + await client.create_or_replace_room(room_id, ChatRoomCreateOrReplace(title="Async Member Room")) member = await client.create_or_replace_room_member( room_id, user_id, - ChatRoomMemberCreate(role_name=room_role), + ChatRoomMemberCreateOrReplace(role_name=room_role), ) assert member.user_id == user_id assert member.role_name == room_role @@ -221,11 +221,11 @@ async def test_async_message_lifecycle(self, wps_chat_endpoint): binary_content = bytes([0, 1, 2, 254, 255]) try: await client.create_or_replace_role( - user_role, ChatRoleCreate(permissions=[ChatPermission.USER_CREATE_ROOM]) + user_role, ChatRoleCreateOrReplace(permissions=[ChatPermission.USER_CREATE_ROOM]) ) await client.create_or_replace_role( room_role, - ChatRoleCreate( + ChatRoleCreateOrReplace( permissions=[ ChatPermission.ROOM_PUBLISH_MESSAGE, ChatPermission.ROOM_HISTORY, @@ -234,10 +234,12 @@ async def test_async_message_lifecycle(self, wps_chat_endpoint): ) await client.create_or_replace_user( user_id, - HumanChatUserCreate(nickname="Async Message User", role_name=user_role), + HumanChatUserCreateOrReplace(nickname="Async Message User", role_name=user_role), + ) + room = await client.create_or_replace_room(room_id, ChatRoomCreateOrReplace(title="Async Message Room")) + await client.create_or_replace_room_member( + room_id, user_id, ChatRoomMemberCreateOrReplace(role_name=room_role) ) - room = await client.create_or_replace_room(room_id, ChatRoomCreate(title="Async Message Room")) - await client.create_or_replace_room_member(room_id, user_id, ChatRoomMemberCreate(role_name=room_role)) await self.seed_chat_message_async(client, user_id, room.default_conversation, message_text) messages = await _collect(client.list_messages(room.default_conversation)) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_request_models.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_request_models.py index d71fd3a5c189..c12a9f29db4c 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_request_models.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_request_models.py @@ -19,11 +19,11 @@ (models.ChatTopicCreateOrReplace, {"title"}, {"title"}), (models.ChatTopicUpdate, {"title", "state"}, set()), (models.ChatMessageUpdate, {"created_by", "content"}, set()), - (models.ChatRoleCreate, {"permissions"}, {"permissions"}), - (models.ChatRoomCreate, {"title"}, {"title"}), - (models.ChatRoomMemberCreate, {"role_name"}, {"role_name"}), - (models.ChatUserCreate, {"kind", "nickname"}, {"kind", "nickname"}), - (models.HumanChatUserCreate, {"kind", "nickname", "role_name"}, {"nickname", "role_name"}), + (models.ChatRoleCreateOrReplace, {"permissions"}, {"permissions"}), + (models.ChatRoomCreateOrReplace, {"title"}, {"title"}), + (models.ChatRoomMemberCreateOrReplace, {"role_name"}, {"role_name"}), + (models.ChatUserCreateOrReplace, {"kind", "nickname"}, {"kind", "nickname"}), + (models.HumanChatUserCreateOrReplace, {"kind", "nickname", "role_name"}, {"nickname", "role_name"}), ] CASES = [ @@ -100,22 +100,28 @@ ( "create_or_replace_role", ("user.role",), - models.ChatRoleCreate(permissions=[models.ChatPermission.USER_CREATE_ROOM]), + models.ChatRoleCreateOrReplace(permissions=[models.ChatPermission.USER_CREATE_ROOM]), models.ChatRole, {"permissions": ["user.create_room"]}, ), - ("create_or_replace_room", ("room",), models.ChatRoomCreate(title="Room"), models.ChatRoom, {"title": "Room"}), + ( + "create_or_replace_room", + ("room",), + models.ChatRoomCreateOrReplace(title="Room"), + models.ChatRoom, + {"title": "Room"}, + ), ( "create_or_replace_room_member", ("room", "user"), - models.ChatRoomMemberCreate(role_name="room.member"), + models.ChatRoomMemberCreateOrReplace(role_name="room.member"), models.ChatRoomMember, {"roleName": "room.member"}, ), ( "create_or_replace_user", ("user",), - models.HumanChatUserCreate(nickname="User", role_name="user.member"), + models.HumanChatUserCreateOrReplace(nickname="User", role_name="user.member"), models.HumanChatUser, {"kind": "Human", "nickname": "User", "roleName": "user.member"}, ), diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/typing/request_models.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/typing/request_models.py index e6c99ca9d56b..147554c5c21b 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/typing/request_models.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/typing/request_models.py @@ -18,6 +18,18 @@ def check_request_types(client: WebPubSubChatServiceClient) -> None: client.update_message("conversation", "message", types.ChatMessageUpdate(createdBy="user")) client.update_message("conversation", "message", types.ChatMessageUpdate(content={"text": "Updated"})) client.create_or_replace_topic("room", "topic", models.ChatTopicCreateOrReplace(title="Title")) + client.create_or_replace_role("user.role", models.ChatRoleCreateOrReplace(permissions=["user.create_room"])) + client.create_or_replace_role("user.role", types.ChatRoleCreateOrReplace(permissions=["user.create_room"])) + client.create_or_replace_room("room", models.ChatRoomCreateOrReplace(title="Room")) + client.create_or_replace_room("room", types.ChatRoomCreateOrReplace(title="Room")) + client.create_or_replace_room_member("room", "user", models.ChatRoomMemberCreateOrReplace(role_name="room.member")) + client.create_or_replace_room_member("room", "user", types.ChatRoomMemberCreateOrReplace(roleName="room.member")) + user: models.ChatUserCreateOrReplace = models.HumanChatUserCreateOrReplace(nickname="User", role_name="user.member") + user_dict: types.ChatUserCreateOrReplace = types.HumanChatUserCreateOrReplace( + kind=models.ChatUserKind.HUMAN, nickname="User", roleName="user.member" + ) + client.create_or_replace_user("user", user) + client.create_or_replace_user("user", user_dict) models.ChatTopicUpdate(title=123) # type: ignore[call-overload] models.ChatTopicUpdate(state=123) # type: ignore[call-overload] models.ChatTopicUpdate(id="read-only") # type: ignore[call-overload] @@ -32,6 +44,22 @@ def check_request_types(client: WebPubSubChatServiceClient) -> None: async def check_async_request_types(client: AsyncClient) -> None: + await client.create_or_replace_role("user.role", models.ChatRoleCreateOrReplace(permissions=["user.create_room"])) + await client.create_or_replace_role("user.role", types.ChatRoleCreateOrReplace(permissions=["user.create_room"])) + await client.create_or_replace_room("room", models.ChatRoomCreateOrReplace(title="Room")) + await client.create_or_replace_room("room", types.ChatRoomCreateOrReplace(title="Room")) + await client.create_or_replace_room_member( + "room", "user", models.ChatRoomMemberCreateOrReplace(role_name="room.member") + ) + await client.create_or_replace_room_member( + "room", "user", types.ChatRoomMemberCreateOrReplace(roleName="room.member") + ) + user: models.ChatUserCreateOrReplace = models.HumanChatUserCreateOrReplace(nickname="User", role_name="user.member") + user_dict: types.ChatUserCreateOrReplace = types.HumanChatUserCreateOrReplace( + kind=models.ChatUserKind.HUMAN, nickname="User", roleName="user.member" + ) + await client.create_or_replace_user("user", user) + await client.create_or_replace_user("user", user_dict) await client.update_topic("room", "topic", models.ChatTopicUpdate(title="New title")) await client.update_topic("room", "topic", models.ChatTopicUpdate(state=models.ChatTopicState.ARCHIVED)) await client.update_topic("room", "topic", types.ChatTopicUpdate(title="New title")) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml index 9daa6f27eeb3..3b676eb805e3 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml @@ -1,5 +1,5 @@ directory: specification/webpubsub/data-plane/WebPubSubChat -commit: a5644409aa48566153043c43be58327f9680d29b +commit: 9749691ba43fcab0e9f1a954f104bf753ee90387 repo: Y-Sindo/azure-rest-api-specs additionalDirectories: [] entrypointFile: client.tsp \ No newline at end of file From 72de31797e7d723e32b9b317bc1cb362e840b35f Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Wed, 21 Oct 2026 16:03:44 +1100 Subject: [PATCH 14/22] Add model-based Chat operation samples and address review feedback Pair all 25 generated operation examples with runnable model-based samples and regression coverage. Simplify the README, regenerate the corrected topic example, and fix documentation links and spelling checks without engineering-tool changes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../CHANGELOG.md | 3 +- .../README.md | 39 ++-- .../create_or_replace_topic.py | 2 +- .../pyproject.toml | 2 +- .../samples/README.md | 128 +++++++----- .../samples/_shared.py | 23 +++ .../samples/sample_create_or_replace_role.py | 23 +++ .../samples/sample_create_or_replace_room.py | 20 ++ .../sample_create_or_replace_room_member.py | 24 +++ .../samples/sample_create_or_replace_topic.py | 24 +++ .../samples/sample_create_or_replace_user.py | 23 +++ .../samples/sample_delete_message.py | 18 ++ .../samples/sample_delete_role.py | 18 ++ .../samples/sample_delete_room.py | 18 ++ .../samples/sample_delete_room_member.py | 18 ++ .../samples/sample_delete_topic.py | 24 +++ .../samples/sample_delete_user.py | 18 ++ .../samples/sample_get_conversation.py | 19 ++ .../samples/sample_get_role.py | 19 ++ .../samples/sample_get_room.py | 19 ++ .../samples/sample_get_topic.py | 19 ++ .../samples/sample_get_user.py | 19 ++ .../samples/sample_list_messages.py | 19 ++ .../samples/sample_list_roles.py | 17 ++ .../samples/sample_list_room_members.py | 19 ++ .../samples/sample_list_rooms.py | 17 ++ .../samples/sample_list_rooms_for_user.py | 19 ++ .../samples/sample_list_topics.py | 19 ++ .../samples/sample_list_users.py | 17 ++ .../samples/sample_update_message.py | 24 +++ .../samples/sample_update_topic.py | 27 +++ .../tests/test_operation_samples.py | 183 ++++++++++++++++++ .../tests/test_request_models.py | 1 + .../tsp-location.yaml | 4 +- 34 files changed, 803 insertions(+), 83 deletions(-) create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/_shared.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_role.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_room.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_room_member.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_topic.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_user.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_message.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_role.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_room.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_room_member.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_topic.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_user.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_conversation.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_role.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_room.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_topic.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_user.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_messages.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_roles.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_room_members.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_rooms.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_rooms_for_user.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_topics.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_users.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_update_message.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_update_topic.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_operation_samples.py diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md index 7585cccef7dc..8625a8673793 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md @@ -4,7 +4,7 @@ ### Features Added - - Added topic lifecycle operations (create or replace, list, get, update, and soft delete) + - Added topic lifecycle operations (create or replace, list, get, update, and soft delete). Creation or replacement accepts `ChatTopicCreateOrReplace`, which requires only `title`; updates accept `ChatTopicUpdate`, whose fields are optional. - Added room, user, and user-room collection operations ### Other Changes @@ -14,7 +14,6 @@ ### Breaking Changes - Create or replace operations now accept dedicated `ChatRoleCreateOrReplace`, `ChatRoomCreateOrReplace`, `ChatRoomMemberCreateOrReplace`, and `ChatUserCreateOrReplace` (including `HumanChatUserCreateOrReplace`) request models instead of resource response models. - - Topic creation or replacement accepts `ChatTopicCreateOrReplace`, which requires only `title`. Topic updates accept `ChatTopicUpdate`, whose fields are optional. - Message updates accept `ChatMessageUpdate`, whose fields are optional, instead of `ChatMessage`. Resource response model names are unchanged. ## 1.0.0b1 (2026-10-08) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md index a5ff1c3088ee..8cb6ae461fd3 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md @@ -17,8 +17,8 @@ Use this client library in an application server to: | [Package (PyPI)][package] | [API reference documentation][api_reference] | [Product documentation][product_docs] -| [Samples][samples] -| [Generated samples][generated_samples] +| [Model-based samples][samples] +| [Dictionary-based samples][generated_samples] | [Changelog][changelog] ## Getting started @@ -129,7 +129,7 @@ User roles control operations such as creating rooms. Room roles control what a ### User -A user represents an identity participating in chat, such as a human end user or an application. In the service API, a user is identified by a user ID and assigned a user role. The SDK provides `HumanChatUserCreateOrReplace` for creating human users with a nickname and a user role. 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 @@ -147,14 +147,8 @@ Messages sent to a conversation are delivered in real time to the room's connect ### Topic -A topic represents a named conversation within a room. The service returns its -ID, creation time, creator, conversation ID, and ETag in responses. Topic IDs are specified -by the application in the request path. Topics have a lifecycle state of `Normal`, `Archived`, -or `SoftDeleted`. Creating a topic requires a title; updating a topic can change its title -and state. Deleting a topic is a soft delete. - -The default service API version is `2026-08-01-preview`, which adds topics and the -room, user, and user-room collection operations. +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. ### Request models and dictionaries @@ -167,14 +161,6 @@ such as `roleName`. `TypedDict` provides static type checking for those dictionaries; at runtime they are ordinary dictionaries, not model instances, and do not perform runtime validation. -Concrete user models automatically set the JSON discriminator field. -For example, `HumanChatUserCreateOrReplace(nickname="Alice", role_name="user.normal")` -sets `kind` to `"Human"`; callers do not pass `kind` or `discriminator` to -this constructor. The `discriminator="Human"` in the generated class -declaration registers the subtype for deserialization, while `kind` is the -field sent in JSON. A dictionary request must include `"kind": "Human"` -explicitly. - ## Examples The following sections show common scenarios. Each operation snippet assumes an @@ -182,12 +168,11 @@ authenticated `client`, created as shown in Getting started. The async snippet uses a client from `azure.messaging.webpubsubchatservice.aio`. See the [package samples][samples] for complete synchronous and asynchronous programs. -The hand-written request-body examples use model instances. The -[generated operation samples][generated_samples] use dictionary literals -with JSON field names, rather than explicitly constructing `TypedDict` values. -Both request-body styles are supported. See the -[sample guide and complete operation index](samples/README.md) for links to -every operation and the available hand-written examples. +The [model-based samples][samples] use model instances for request bodies. +The [dictionary-based samples][generated_samples] use dictionary literals with +JSON field names. Both call the same client methods. See the +[sample guide and complete operation index](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md) +for a corresponding model-based example of every service operation. ### Generate client access credentials @@ -575,13 +560,13 @@ Explore the [README snippet sources](https://github.com/Azure/azure-sdk-for-pyth - Manage topic lifecycles and iterate over room and user collections. - Use synchronous and asynchronous clients. -See also the [generated operation samples][generated_samples], produced from the +See also the [dictionary-based operation samples][generated_samples], produced from the specification's examples. Each file demonstrates one operation. Replace `ENDPOINT`, `HUB`, and any example resource identifiers before running them, and configure authentication as described in each file. These generated files are refreshed during SDK generation. The README snippet source contains independent functions, not a combined workflow or a standalone program. -The runnable hand-written samples demonstrate model and permission-enum usage, +The runnable model-based samples demonstrate model and permission-enum usage, authentication, client access credentials, errors, and logging. ## Additional resources diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_topic.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_topic.py index 94f745112aaf..80fffd44b6fc 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_topic.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_topic.py @@ -34,7 +34,7 @@ def main(): response = client.create_or_replace_topic( room_id="general", topic_id="product-updates", - resource={"state": "Normal", "title": "Product updates"}, + resource={"title": "Product updates"}, ) print(response) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/pyproject.toml b/sdk/webpubsub/azure-messaging-webpubsubchatservice/pyproject.toml index ada9e51c31eb..ccf1ee1e2406 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/pyproject.toml +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/pyproject.toml @@ -50,12 +50,12 @@ readme = {file = ["README.md", "CHANGELOG.md"], content-type = "text/markdown"} [tool.setuptools.packages.find] include = ["azure.messaging.webpubsubchatservice*"] exclude = [ - "build*", "tests*", "generated_tests*", "samples*", "generated_samples*", "doc*", + "build*", "azure", "azure.messaging", ] diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md index 44152ce69694..b8e1c9233a04 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md @@ -1,77 +1,105 @@ # Azure Web PubSub Chat samples -Use the [package README](../README.md) for installation, authentication, and +Use the [package README](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md) for installation, authentication, and Chat hub prerequisites. ## Sample styles -The hand-written request-body examples in this directory use model classes from +The model-based examples in this directory use model classes from `azure.messaging.webpubsubchatservice.models`. These classes use Python property -names such as `role_name`. The [generated samples](../generated_samples) use +names such as `role_name`. The [generated samples](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples) use ordinary dictionary literals with JSON field names such as `roleName`. The `TypedDict` definitions in `azure.messaging.webpubsubchatservice.types` describe those dictionary shapes for static type checking; they do not create model instances or validate values at runtime. Both request-body styles are accepted by the corresponding client operations. -`HumanChatUserCreateOrReplace` automatically supplies `"kind": "Human"` when serialized. -Dictionary requests must supply that field explicitly. See -[request models and dictionaries](../README.md#request-models-and-dictionaries) -for details. +Both styles call the same client methods; these are not separate convenience +and protocol method APIs. -## Hand-written samples +## Scenario samples | Sample | Purpose | | --- | --- | -| [Authentication](sample_authentication.py) | Connection string, access key, and Microsoft Entra ID authentication. | -| [Client access credentials](sample_client_access.py) / [async](sample_client_access_async.py) | Generate credentials for a Chat WebSocket client. | -| [Roles and permissions](sample_roles_and_permissions.py) / [async](sample_roles_and_permissions_async.py) | Create or replace a role using a model and permission enums. | -| [Message management](sample_message_management.py) | Update and delete persisted messages. | -| [Service errors](sample_errors.py) | Handle and re-raise an HTTP service error. | -| [Logging](sample_logging.py) | Enable SDK HTTP logging. | -| [README snippet sources](sample_readme_snippets.py) | Independent functions used by the README, not a standalone program. | - -For runnable hand-written samples, follow the environment-variable instructions -in each file and the [README run instructions](../README.md#run-the-samples). +| [Authentication](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_authentication.py) | Connection string, access key, and Microsoft Entra ID authentication. | +| [Client access credentials](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_client_access.py) / [async](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_client_access_async.py) | Generate credentials for a Chat WebSocket client. | +| [Roles and permissions](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions.py) / [async](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions_async.py) | Create or replace a role using a model and permission enums. | +| [Message management](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_message_management.py) | Update and delete persisted messages. | +| [Service errors](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_errors.py) | Handle and re-raise an HTTP service error. | +| [Logging](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_logging.py) | Enable SDK HTTP logging. | +| [README snippet sources](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_readme_snippets.py) | Independent functions used by the README, not a standalone program. | + +For runnable scenario samples, follow the environment-variable instructions +in each file and the [README run instructions](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md#run-the-samples). Some samples create, replace, or delete resources; use sample-specific identifiers and review each file before running it. ## Complete operation index -Each generated sample demonstrates one service operation using specification -examples. Replace placeholders and example resource identifiers, and configure -authentication as described in each file. Hand-written examples are linked -where available; README snippet functions require an authenticated client and -are not standalone programs. +Each operation has a runnable model-based sample and a dictionary-based sample +generated from specification examples. For operations without request bodies, +both styles use the same parameter types. + +Run model-based samples from the package directory, for example: + +```bash +python samples/sample_list_rooms.py +python samples/sample_create_or_replace_topic.py +``` + +Set `WPS_CHAT_CONNECTION_STRING` and optionally `WPS_CHAT_HUB` (default: +`test_hub`). Each sample reports any additional missing variables without +contacting the service. Identifiers must refer to existing resources for get, +list, update, membership, and delete operations. + +| Variable | Used for | +| --- | --- | +| `WPS_CHAT_ROLE_NAME` | Role operations. Use a `room.` name when running the role creation sample. | +| `WPS_CHAT_ROOM_ID` | Room, room member, and topic operations. | +| `WPS_CHAT_USER_ID` | User, membership, and user-room operations. | +| `WPS_CHAT_USER_ROLE_NAME` | Existing `user.` role for user creation. | +| `WPS_CHAT_ROOM_ROLE_NAME` | Existing `room.` role for adding a member. | +| `WPS_CHAT_TOPIC_ID` | Topic operations. | +| `WPS_CHAT_TOPIC_ETAG` | Current ETag from get/create for conditional topic update and delete. Refresh it after an update. | +| `WPS_CHAT_CONVERSATION_ID` | Conversation and message operations. Obtain it from a room or topic. | +| `WPS_CHAT_MESSAGE_ID` | Existing persisted message to update or delete. | + +Create/replace operations can overwrite existing resources; delete operations +remove the specified resource (topic deletion is a soft delete). Use isolated +sample resources and review each operation before running it. The samples do +not create unrelated prerequisites or send WebSocket messages. + +Dictionary-based samples use placeholder endpoints and example identifiers; +replace them and configure authentication as described in each file. -| Operation | Generated sample | Hand-written example | +| Operation | Dictionary-based sample | Model-based sample | | --- | --- | --- | -| `get_client_access_token` | Not generated; SDK convenience method. | [Sync](sample_client_access.py) / [async](sample_client_access_async.py) | -| `create_or_replace_role` | [Sample](../generated_samples/create_or_replace_role.py) | [Sync](sample_roles_and_permissions.py) / [async](sample_roles_and_permissions_async.py) | -| `get_role` | [Sample](../generated_samples/get_role.py) | [Service errors](sample_errors.py) | -| `list_roles` | [Sample](../generated_samples/list_roles.py) | [README snippets](sample_readme_snippets.py) | -| `delete_role` | [Sample](../generated_samples/delete_role.py) | - | -| `create_or_replace_room` | [Sample](../generated_samples/create_or_replace_room.py) | [README snippets](sample_readme_snippets.py) | -| `get_room` | [Sample](../generated_samples/get_room.py) | - | -| `list_rooms` | [Sample](../generated_samples/list_rooms.py) | [README snippets](sample_readme_snippets.py) | -| `delete_room` | [Sample](../generated_samples/delete_room.py) | - | -| `create_or_replace_room_member` | [Sample](../generated_samples/create_or_replace_room_member.py) | [README snippets](sample_readme_snippets.py) | -| `list_room_members` | [Sample](../generated_samples/list_room_members.py) | - | -| `delete_room_member` | [Sample](../generated_samples/delete_room_member.py) | - | -| `create_or_replace_user` | [Sample](../generated_samples/create_or_replace_user.py) | [README snippets](sample_readme_snippets.py) | -| `get_user` | [Sample](../generated_samples/get_user.py) | - | -| `list_users` | [Sample](../generated_samples/list_users.py) | [README snippets](sample_readme_snippets.py) | -| `delete_user` | [Sample](../generated_samples/delete_user.py) | - | -| `list_rooms_for_user` | [Sample](../generated_samples/list_rooms_for_user.py) | [README snippets](sample_readme_snippets.py) | -| `create_or_replace_topic` | [Sample](../generated_samples/create_or_replace_topic.py) | [README snippets](sample_readme_snippets.py) | -| `get_topic` | [Sample](../generated_samples/get_topic.py) | [README snippets](sample_readme_snippets.py) | -| `list_topics` | [Sample](../generated_samples/list_topics.py) | [README snippets](sample_readme_snippets.py) | -| `update_topic` | [Sample](../generated_samples/update_topic.py) | [README snippets](sample_readme_snippets.py) | -| `delete_topic` | [Sample](../generated_samples/delete_topic.py) | [README snippets](sample_readme_snippets.py) | -| `get_conversation` | [Sample](../generated_samples/get_conversation.py) | - | -| `list_messages` | [Sample](../generated_samples/list_messages.py) | [README snippets](sample_readme_snippets.py) | -| `update_message` | [Sample](../generated_samples/update_message.py) | [Message management](sample_message_management.py) | -| `delete_message` | [Sample](../generated_samples/delete_message.py) | [Message management](sample_message_management.py) | +| `get_client_access_token` | SDK convenience method; no generated sample. | [Sync](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_client_access.py) / [async](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_client_access_async.py) | +| `create_or_replace_role` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_role.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_role.py) | +| `get_role` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_role.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_role.py) | +| `list_roles` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_roles.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_roles.py) | +| `delete_role` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_role.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_role.py) | +| `create_or_replace_room` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_room.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_room.py) | +| `get_room` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_room.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_room.py) | +| `list_rooms` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_rooms.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_rooms.py) | +| `delete_room` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_room.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_room.py) | +| `create_or_replace_room_member` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_room_member.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_room_member.py) | +| `list_room_members` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_room_members.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_room_members.py) | +| `delete_room_member` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_room_member.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_room_member.py) | +| `create_or_replace_user` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_user.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_user.py) | +| `get_user` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_user.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_user.py) | +| `list_users` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_users.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_users.py) | +| `delete_user` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_user.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_user.py) | +| `list_rooms_for_user` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_rooms_for_user.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_rooms_for_user.py) | +| `create_or_replace_topic` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_topic.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_topic.py) | +| `get_topic` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_topic.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_topic.py) | +| `list_topics` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_topics.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_topics.py) | +| `update_topic` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/update_topic.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_update_topic.py) | +| `delete_topic` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_topic.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_topic.py) | +| `get_conversation` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_conversation.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_conversation.py) | +| `list_messages` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_messages.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_messages.py) | +| `update_message` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/update_message.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_update_message.py) | +| `delete_message` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_message.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_message.py) | The synchronous and asynchronous clients expose the same service operations. Await asynchronous non-paging calls, and use `async for` to iterate asynchronous diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/_shared.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/_shared.py new file mode 100644 index 000000000000..d2b8c5861f01 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/_shared.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Configuration and client lifetime for the operation samples.""" + +import os +from typing import Callable + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient + + +def run_sample(sample: Callable[[WebPubSubChatServiceClient], None], required: tuple[str, ...] = ()) -> None: + missing = [name for name in ("WPS_CHAT_CONNECTION_STRING", *required) if not os.environ.get(name)] + if missing: + print(f"Set {', '.join(missing)} to run this sample.") + return + + with WebPubSubChatServiceClient.from_connection_string( + os.environ["WPS_CHAT_CONNECTION_STRING"], + os.environ.get("WPS_CHAT_HUB", "test_hub"), + ) as client: + sample(client) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_role.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_role.py new file mode 100644 index 000000000000..f1cd954c8bd2 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_role.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Create or replace a sample-specific room role. Existing permissions are replaced.""" + +import os + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient +from azure.messaging.webpubsubchatservice.models import ChatPermission, ChatRoleCreateOrReplace +from _shared import run_sample + + +def sample(client: WebPubSubChatServiceClient) -> None: + role = client.create_or_replace_role( + os.environ["WPS_CHAT_ROLE_NAME"], + ChatRoleCreateOrReplace(permissions=[ChatPermission.ROOM_HISTORY, ChatPermission.ROOM_PUBLISH_MESSAGE]), + ) + print(role.name, role.permissions) + + +if __name__ == "__main__": + run_sample(sample, ("WPS_CHAT_ROLE_NAME",)) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_room.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_room.py new file mode 100644 index 000000000000..3b651bcb7a12 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_room.py @@ -0,0 +1,20 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Create or replace a sample-specific room.""" + +import os + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient +from azure.messaging.webpubsubchatservice.models import ChatRoomCreateOrReplace +from _shared import run_sample + + +def sample(client: WebPubSubChatServiceClient) -> None: + room = client.create_or_replace_room(os.environ["WPS_CHAT_ROOM_ID"], ChatRoomCreateOrReplace(title="Sample room")) + print(room.id, room.title, room.default_conversation) + + +if __name__ == "__main__": + run_sample(sample, ("WPS_CHAT_ROOM_ID",)) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_room_member.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_room_member.py new file mode 100644 index 000000000000..cbf1cf73d44e --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_room_member.py @@ -0,0 +1,24 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Add an existing user to a room, or replace their room role.""" + +import os + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient +from azure.messaging.webpubsubchatservice.models import ChatRoomMemberCreateOrReplace +from _shared import run_sample + + +def sample(client: WebPubSubChatServiceClient) -> None: + member = client.create_or_replace_room_member( + os.environ["WPS_CHAT_ROOM_ID"], + os.environ["WPS_CHAT_USER_ID"], + ChatRoomMemberCreateOrReplace(role_name=os.environ["WPS_CHAT_ROOM_ROLE_NAME"]), + ) + print(member.user_id, member.role_name) + + +if __name__ == "__main__": + run_sample(sample, ("WPS_CHAT_ROOM_ID", "WPS_CHAT_USER_ID", "WPS_CHAT_ROOM_ROLE_NAME")) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_topic.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_topic.py new file mode 100644 index 000000000000..30d5d752172d --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_topic.py @@ -0,0 +1,24 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Create or replace a sample-specific topic in an existing room.""" + +import os + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient +from azure.messaging.webpubsubchatservice.models import ChatTopicCreateOrReplace +from _shared import run_sample + + +def sample(client: WebPubSubChatServiceClient) -> None: + topic = client.create_or_replace_topic( + os.environ["WPS_CHAT_ROOM_ID"], + os.environ["WPS_CHAT_TOPIC_ID"], + ChatTopicCreateOrReplace(title="Sample topic"), + ) + print(topic.id, topic.conversation_id, topic.etag) + + +if __name__ == "__main__": + run_sample(sample, ("WPS_CHAT_ROOM_ID", "WPS_CHAT_TOPIC_ID")) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_user.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_user.py new file mode 100644 index 000000000000..54f44f90842d --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_user.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Create or replace a sample-specific human user with an existing user role.""" + +import os + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient +from azure.messaging.webpubsubchatservice.models import HumanChatUserCreateOrReplace +from _shared import run_sample + + +def sample(client: WebPubSubChatServiceClient) -> None: + user = client.create_or_replace_user( + os.environ["WPS_CHAT_USER_ID"], + HumanChatUserCreateOrReplace(nickname="Sample user", role_name=os.environ["WPS_CHAT_USER_ROLE_NAME"]), + ) + print(user.id, user.kind) + + +if __name__ == "__main__": + run_sample(sample, ("WPS_CHAT_USER_ID", "WPS_CHAT_USER_ROLE_NAME")) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_message.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_message.py new file mode 100644 index 000000000000..d2c01e3c3e57 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_message.py @@ -0,0 +1,18 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Delete a sample-specific persisted message.""" + +import os + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient +from _shared import run_sample + + +def sample(client: WebPubSubChatServiceClient) -> None: + client.delete_message(os.environ["WPS_CHAT_CONVERSATION_ID"], os.environ["WPS_CHAT_MESSAGE_ID"]) + + +if __name__ == "__main__": + run_sample(sample, ("WPS_CHAT_CONVERSATION_ID", "WPS_CHAT_MESSAGE_ID")) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_role.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_role.py new file mode 100644 index 000000000000..4e79e6966db6 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_role.py @@ -0,0 +1,18 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Delete a sample-specific role. Do not target a role used by your application.""" + +import os + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient +from _shared import run_sample + + +def sample(client: WebPubSubChatServiceClient) -> None: + client.delete_role(os.environ["WPS_CHAT_ROLE_NAME"]) + + +if __name__ == "__main__": + run_sample(sample, ("WPS_CHAT_ROLE_NAME",)) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_room.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_room.py new file mode 100644 index 000000000000..1b03f68d3ffa --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_room.py @@ -0,0 +1,18 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Delete a sample-specific room. Review the target room before running.""" + +import os + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient +from _shared import run_sample + + +def sample(client: WebPubSubChatServiceClient) -> None: + client.delete_room(os.environ["WPS_CHAT_ROOM_ID"]) + + +if __name__ == "__main__": + run_sample(sample, ("WPS_CHAT_ROOM_ID",)) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_room_member.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_room_member.py new file mode 100644 index 000000000000..102dbf9ab4dc --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_room_member.py @@ -0,0 +1,18 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Remove an existing user from a sample-specific room.""" + +import os + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient +from _shared import run_sample + + +def sample(client: WebPubSubChatServiceClient) -> None: + client.delete_room_member(os.environ["WPS_CHAT_ROOM_ID"], os.environ["WPS_CHAT_USER_ID"]) + + +if __name__ == "__main__": + run_sample(sample, ("WPS_CHAT_ROOM_ID", "WPS_CHAT_USER_ID")) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_topic.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_topic.py new file mode 100644 index 000000000000..6c714524d3d9 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_topic.py @@ -0,0 +1,24 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Soft delete a topic only if the supplied ETag still matches.""" + +import os + +from azure.core import MatchConditions +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient +from _shared import run_sample + + +def sample(client: WebPubSubChatServiceClient) -> None: + client.delete_topic( + os.environ["WPS_CHAT_ROOM_ID"], + os.environ["WPS_CHAT_TOPIC_ID"], + etag=os.environ["WPS_CHAT_TOPIC_ETAG"], + match_condition=MatchConditions.IfNotModified, + ) + + +if __name__ == "__main__": + run_sample(sample, ("WPS_CHAT_ROOM_ID", "WPS_CHAT_TOPIC_ID", "WPS_CHAT_TOPIC_ETAG")) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_user.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_user.py new file mode 100644 index 000000000000..9bcb750834a2 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_user.py @@ -0,0 +1,18 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Delete a sample-specific user. Do not target an active application user.""" + +import os + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient +from _shared import run_sample + + +def sample(client: WebPubSubChatServiceClient) -> None: + client.delete_user(os.environ["WPS_CHAT_USER_ID"]) + + +if __name__ == "__main__": + run_sample(sample, ("WPS_CHAT_USER_ID",)) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_conversation.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_conversation.py new file mode 100644 index 000000000000..4f39b27041af --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_conversation.py @@ -0,0 +1,19 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Read a room's default conversation or a topic's conversation.""" + +import os + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient +from _shared import run_sample + + +def sample(client: WebPubSubChatServiceClient) -> None: + conversation = client.get_conversation(os.environ["WPS_CHAT_CONVERSATION_ID"]) + print(conversation.id, conversation.parent_room) + + +if __name__ == "__main__": + run_sample(sample, ("WPS_CHAT_CONVERSATION_ID",)) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_role.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_role.py new file mode 100644 index 000000000000..8bdbb1e39da5 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_role.py @@ -0,0 +1,19 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Read an existing role.""" + +import os + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient +from _shared import run_sample + + +def sample(client: WebPubSubChatServiceClient) -> None: + role = client.get_role(os.environ["WPS_CHAT_ROLE_NAME"]) + print(role.name, role.permissions) + + +if __name__ == "__main__": + run_sample(sample, ("WPS_CHAT_ROLE_NAME",)) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_room.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_room.py new file mode 100644 index 000000000000..49c4629c01f6 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_room.py @@ -0,0 +1,19 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Read an existing room and its default conversation ID.""" + +import os + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient +from _shared import run_sample + + +def sample(client: WebPubSubChatServiceClient) -> None: + room = client.get_room(os.environ["WPS_CHAT_ROOM_ID"]) + print(room.id, room.title, room.default_conversation) + + +if __name__ == "__main__": + run_sample(sample, ("WPS_CHAT_ROOM_ID",)) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_topic.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_topic.py new file mode 100644 index 000000000000..d2fe0fa9b379 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_topic.py @@ -0,0 +1,19 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Read a topic and the ETag used for a conditional update or delete.""" + +import os + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient +from _shared import run_sample + + +def sample(client: WebPubSubChatServiceClient) -> None: + topic = client.get_topic(os.environ["WPS_CHAT_ROOM_ID"], os.environ["WPS_CHAT_TOPIC_ID"]) + print(topic.id, topic.title, topic.state, topic.etag) + + +if __name__ == "__main__": + run_sample(sample, ("WPS_CHAT_ROOM_ID", "WPS_CHAT_TOPIC_ID")) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_user.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_user.py new file mode 100644 index 000000000000..ae2e802c7c6b --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_user.py @@ -0,0 +1,19 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Read an existing user.""" + +import os + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient +from _shared import run_sample + + +def sample(client: WebPubSubChatServiceClient) -> None: + user = client.get_user(os.environ["WPS_CHAT_USER_ID"]) + print(user.id, user.kind) + + +if __name__ == "__main__": + run_sample(sample, ("WPS_CHAT_USER_ID",)) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_messages.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_messages.py new file mode 100644 index 000000000000..172006071270 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_messages.py @@ -0,0 +1,19 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Iterate persisted messages from an existing conversation.""" + +import os + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient +from _shared import run_sample + + +def sample(client: WebPubSubChatServiceClient) -> None: + for message in client.list_messages(os.environ["WPS_CHAT_CONVERSATION_ID"]): + print(message.id, message.created_by, message.content) + + +if __name__ == "__main__": + run_sample(sample, ("WPS_CHAT_CONVERSATION_ID",)) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_roles.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_roles.py new file mode 100644 index 000000000000..c94007b91039 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_roles.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Iterate roles, allowing the SDK to fetch subsequent pages.""" + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient +from _shared import run_sample + + +def sample(client: WebPubSubChatServiceClient) -> None: + for role in client.list_roles(): + print(role.name, role.permissions) + + +if __name__ == "__main__": + run_sample(sample) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_room_members.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_room_members.py new file mode 100644 index 000000000000..2344525f35a7 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_room_members.py @@ -0,0 +1,19 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Iterate the members of an existing room.""" + +import os + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient +from _shared import run_sample + + +def sample(client: WebPubSubChatServiceClient) -> None: + for member in client.list_room_members(os.environ["WPS_CHAT_ROOM_ID"]): + print(member.user_id, member.role_name) + + +if __name__ == "__main__": + run_sample(sample, ("WPS_CHAT_ROOM_ID",)) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_rooms.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_rooms.py new file mode 100644 index 000000000000..6173f611e15c --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_rooms.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Iterate rooms with a requested page size.""" + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient +from _shared import run_sample + + +def sample(client: WebPubSubChatServiceClient) -> None: + for room in client.list_rooms(max_page_size=10): + print(room.id, room.title) + + +if __name__ == "__main__": + run_sample(sample) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_rooms_for_user.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_rooms_for_user.py new file mode 100644 index 000000000000..aa36d7c13413 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_rooms_for_user.py @@ -0,0 +1,19 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Iterate rooms associated with an existing user.""" + +import os + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient +from _shared import run_sample + + +def sample(client: WebPubSubChatServiceClient) -> None: + for room in client.list_rooms_for_user(os.environ["WPS_CHAT_USER_ID"]): + print(room.id, room.title) + + +if __name__ == "__main__": + run_sample(sample, ("WPS_CHAT_USER_ID",)) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_topics.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_topics.py new file mode 100644 index 000000000000..84d9f088455c --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_topics.py @@ -0,0 +1,19 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Iterate the topics in an existing room.""" + +import os + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient +from _shared import run_sample + + +def sample(client: WebPubSubChatServiceClient) -> None: + for topic in client.list_topics(os.environ["WPS_CHAT_ROOM_ID"], max_page_size=10): + print(topic.id, topic.title, topic.conversation_id) + + +if __name__ == "__main__": + run_sample(sample, ("WPS_CHAT_ROOM_ID",)) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_users.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_users.py new file mode 100644 index 000000000000..329ef54c1529 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_users.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Iterate users with a requested page size.""" + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient +from _shared import run_sample + + +def sample(client: WebPubSubChatServiceClient) -> None: + for user in client.list_users(max_page_size=10): + print(user.id, user.kind) + + +if __name__ == "__main__": + run_sample(sample) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_update_message.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_update_message.py new file mode 100644 index 000000000000..9608a72997f8 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_update_message.py @@ -0,0 +1,24 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Update the content of a sample-specific persisted message.""" + +import os + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient +from azure.messaging.webpubsubchatservice.models import ChatMessageUpdate, MessageContent +from _shared import run_sample + + +def sample(client: WebPubSubChatServiceClient) -> None: + message = client.update_message( + os.environ["WPS_CHAT_CONVERSATION_ID"], + os.environ["WPS_CHAT_MESSAGE_ID"], + ChatMessageUpdate(content=MessageContent(text="Updated sample message")), + ) + print(message.id, message.content) + + +if __name__ == "__main__": + run_sample(sample, ("WPS_CHAT_CONVERSATION_ID", "WPS_CHAT_MESSAGE_ID")) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_update_topic.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_update_topic.py new file mode 100644 index 000000000000..185efd2641dd --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_update_topic.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Archive a topic only if the supplied ETag still matches; leave its title unchanged.""" + +import os + +from azure.core import MatchConditions +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient +from azure.messaging.webpubsubchatservice.models import ChatTopicState, ChatTopicUpdate +from _shared import run_sample + + +def sample(client: WebPubSubChatServiceClient) -> None: + topic = client.update_topic( + os.environ["WPS_CHAT_ROOM_ID"], + os.environ["WPS_CHAT_TOPIC_ID"], + ChatTopicUpdate(state=ChatTopicState.ARCHIVED), + etag=os.environ["WPS_CHAT_TOPIC_ETAG"], + match_condition=MatchConditions.IfNotModified, + ) + print(topic.id, topic.state, topic.etag) + + +if __name__ == "__main__": + run_sample(sample, ("WPS_CHAT_ROOM_ID", "WPS_CHAT_TOPIC_ID", "WPS_CHAT_TOPIC_ETAG")) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_operation_samples.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_operation_samples.py new file mode 100644 index 000000000000..a1013d2c6e40 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_operation_samples.py @@ -0,0 +1,183 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +import ast +import importlib.util +import os +from pathlib import Path +import runpy +from types import SimpleNamespace +from unittest.mock import Mock + +import pytest + +from azure.core import MatchConditions +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient, models + + +PACKAGE = Path(__file__).resolve().parents[1] +SAMPLES = PACKAGE / "samples" +OPERATIONS = sorted(path.stem for path in (PACKAGE / "generated_samples").glob("*.py")) +ENVIRONMENT = { + "WPS_CHAT_ROLE_NAME": "room.sample", + "WPS_CHAT_ROOM_ID": "sample-room", + "WPS_CHAT_USER_ID": "sample-user", + "WPS_CHAT_USER_ROLE_NAME": "user.member", + "WPS_CHAT_ROOM_ROLE_NAME": "room.member", + "WPS_CHAT_TOPIC_ID": "sample-topic", + "WPS_CHAT_TOPIC_ETAG": '"sample-etag"', + "WPS_CHAT_CONVERSATION_ID": "c.sample-room.sample-topic", + "WPS_CHAT_MESSAGE_ID": "sample-message", +} +IDENTIFIERS = { + "role": ("room.sample",), + "room": ("sample-room",), + "room_member": ("sample-room", "sample-user"), + "user": ("sample-user",), + "topic": ("sample-room", "sample-topic"), + "conversation": ("c.sample-room.sample-topic",), + "message": ("c.sample-room.sample-topic", "sample-message"), +} +REQUESTS = { + "create_or_replace_role": ( + models.ChatRoleCreateOrReplace, + {"permissions": ["room.history", "room.publish_message"]}, + ), + "create_or_replace_room": (models.ChatRoomCreateOrReplace, {"title": "Sample room"}), + "create_or_replace_room_member": (models.ChatRoomMemberCreateOrReplace, {"roleName": "room.member"}), + "create_or_replace_user": ( + models.HumanChatUserCreateOrReplace, + {"kind": "Human", "nickname": "Sample user", "roleName": "user.member"}, + ), + "create_or_replace_topic": (models.ChatTopicCreateOrReplace, {"title": "Sample topic"}), + "update_topic": (models.ChatTopicUpdate, {"state": "Archived"}), + "update_message": (models.ChatMessageUpdate, {"content": {"text": "Updated sample message"}}), +} + + +@pytest.fixture +def sample_imports(monkeypatch): + monkeypatch.syspath_prepend(str(SAMPLES)) + + +@pytest.mark.parametrize("operation", OPERATIONS) +def test_operation_sample_uses_matching_method_and_models(operation, monkeypatch, sample_imports): + for name, value in ENVIRONMENT.items(): + monkeypatch.setenv(name, value) + path = SAMPLES / f"sample_{operation}.py" + spec = importlib.util.spec_from_file_location(f"operation_sample_{operation}", path) + assert spec and spec.loader + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + + client = Mock(spec=WebPubSubChatServiceClient) + response = SimpleNamespace( + id="result", + name="room.sample", + permissions=[], + title="Title", + default_conversation="conversation", + user_id="sample-user", + role_name="room.member", + kind="Human", + conversation_id="conversation", + etag='"etag"', + state="Archived", + parent_room="sample-room", + created_by="sample-user", + content=None, + ) + method = getattr(client, operation) + method.return_value = [response] if operation.startswith("list_") else response + module.sample(client) + assert len(client.method_calls) == 1 + method.assert_called_once() + args = method.call_args.args + if operation == "list_rooms_for_user": + assert args == ("sample-user",) + elif operation == "list_room_members": + assert args == ("sample-room",) + elif operation in ("list_topics", "list_messages"): + assert args == (ENVIRONMENT["WPS_CHAT_ROOM_ID" if operation == "list_topics" else "WPS_CHAT_CONVERSATION_ID"],) + elif operation.startswith("list_"): + assert args == () + else: + entity = ( + operation.removeprefix("create_or_replace_") + .removeprefix("get_") + .removeprefix("delete_") + .removeprefix("update_") + ) + expected_ids = IDENTIFIERS[entity] + assert args[: len(expected_ids)] == expected_ids + if operation in REQUESTS: + request_type, expected_json = REQUESTS[operation] + assert isinstance(args[-1], request_type) + assert args[-1].as_dict() == expected_json + if operation in ("update_topic", "delete_topic"): + assert method.call_args.kwargs == { + "etag": '"sample-etag"', + "match_condition": MatchConditions.IfNotModified, + } + + +@pytest.mark.parametrize("operation", OPERATIONS) +def test_operation_sample_skips_without_configuration(operation, monkeypatch, sample_imports, capsys): + for name in list(os.environ): + if name.startswith("WPS_CHAT_"): + monkeypatch.delenv(name) + create = Mock(side_effect=AssertionError("Samples without configuration must not create a client")) + monkeypatch.setattr(WebPubSubChatServiceClient, "from_connection_string", create) + runpy.run_path(str(SAMPLES / f"sample_{operation}.py"), run_name="__main__") + create.assert_not_called() + assert "WPS_CHAT_CONNECTION_STRING" in capsys.readouterr().out + + +def test_operation_sample_coverage(): + assert len(OPERATIONS) == 25 + assert all((SAMPLES / f"sample_{operation}.py").is_file() for operation in OPERATIONS) + + +def test_sample_runner_validates_resource_ids(monkeypatch, sample_imports, capsys): + from _shared import run_sample + + monkeypatch.setenv("WPS_CHAT_CONNECTION_STRING", "not-used") + monkeypatch.delenv("WPS_CHAT_ROOM_ID", raising=False) + create = Mock(side_effect=AssertionError("Missing identifiers must not create a client")) + monkeypatch.setattr(WebPubSubChatServiceClient, "from_connection_string", create) + run_sample(Mock(), ("WPS_CHAT_ROOM_ID",)) + create.assert_not_called() + assert "WPS_CHAT_ROOM_ID" in capsys.readouterr().out + + +def test_sample_runner_closes_client_and_propagates_errors(monkeypatch, sample_imports): + from _shared import run_sample + + monkeypatch.setenv("WPS_CHAT_CONNECTION_STRING", "not-a-real-connection-string") + monkeypatch.delenv("WPS_CHAT_HUB", raising=False) + manager = Mock() + manager.__enter__ = Mock(return_value=Mock(spec=WebPubSubChatServiceClient)) + manager.__exit__ = Mock(return_value=False) + create = Mock(return_value=manager) + monkeypatch.setattr(WebPubSubChatServiceClient, "from_connection_string", create) + callback = Mock(side_effect=ValueError("Sample error")) + with pytest.raises(ValueError, match="Sample error"): + run_sample(callback) + create.assert_called_once_with("not-a-real-connection-string", "test_hub") + callback.assert_called_once_with(manager.__enter__.return_value) + manager.__exit__.assert_called_once() + + +def test_generated_topic_create_example_contains_only_title(): + tree = ast.parse((PACKAGE / "generated_samples" / "create_or_replace_topic.py").read_text()) + calls = [ + node + for node in ast.walk(tree) + if isinstance(node, ast.Call) + and isinstance(node.func, ast.Attribute) + and node.func.attr == "create_or_replace_topic" + ] + assert len(calls) == 1 + body = next(keyword.value for keyword in calls[0].keywords if keyword.arg == "resource") + assert ast.literal_eval(body) == {"title": "Product updates"} diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_request_models.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_request_models.py index c12a9f29db4c..d948d0240f10 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_request_models.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_request_models.py @@ -2,6 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------- +# cspell:ignore kwonlyargs import ast import inspect import json diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml index 3b676eb805e3..d2d71e474191 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml @@ -1,5 +1,5 @@ directory: specification/webpubsub/data-plane/WebPubSubChat -commit: 9749691ba43fcab0e9f1a954f104bf753ee90387 -repo: Y-Sindo/azure-rest-api-specs +commit: 5d511288c9acb00cdc6c5eb76615327798004d03 +repo: Y-Sindo/azure-rest-api-specs # cspell:ignore Sindo additionalDirectories: [] entrypointFile: client.tsp \ No newline at end of file From ef2fc05ceea360168ac33539631bc037764cbd13 Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Thu, 22 Oct 2026 15:46:55 +1100 Subject: [PATCH 15/22] Preserve replace-visible Chat topic state in PUT requests Regenerate from CreateOrUpdate projections and keep topic state optional on the combined request. Restore the original JSON example and test lifecycle visibility, requiredness, and sync/async model and dictionary serialization rather than fixed API field snapshots. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../CHANGELOG.md | 2 +- .../README.md | 6 ++ .../api.md | 4 + .../api.metadata.yml | 2 +- .../apiview-properties.json | 2 +- .../webpubsubchatservice/models/_models.py | 9 +++ .../messaging/webpubsubchatservice/types.py | 6 ++ .../create_or_replace_topic.py | 2 +- .../test_web_pub_sub_chat_service.py | 2 +- .../test_web_pub_sub_chat_service_async.py | 2 +- .../tests/test_operation_samples.py | 6 +- .../tests/test_request_models.py | 79 +++++++++++++++---- .../tests/typing/request_models.py | 17 +++- .../tsp-location.yaml | 2 +- 14 files changed, 116 insertions(+), 25 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md index 8625a8673793..1acf0c28874d 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md @@ -4,7 +4,7 @@ ### Features Added - - Added topic lifecycle operations (create or replace, list, get, update, and soft delete). Creation or replacement accepts `ChatTopicCreateOrReplace`, which requires only `title`; updates accept `ChatTopicUpdate`, whose fields are optional. + - Added topic lifecycle operations (create or replace, list, get, update, and soft delete). Creation or replacement accepts `ChatTopicCreateOrReplace`, which requires `title` and accepts optional `state` for replacement; updates accept `ChatTopicUpdate`, whose fields are optional. - Added room, user, and user-room collection operations ### Other Changes diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md index 8cb6ae461fd3..f42512d349b7 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md @@ -304,6 +304,12 @@ topic ID specified by `WPS_CHAT_TOPIC_ID`. #### Create a topic +`ChatTopicCreateOrReplace` requires a title. When replacing an existing topic, +you can also supply `state`, for example +`ChatTopicCreateOrReplace(title="Announcements", state=ChatTopicState.ARCHIVED)`. +Import `ChatTopicState` from `azure.messaging.webpubsubchatservice.models`. +Omit `state` when creating a topic. + ```python diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md index 3b51531c1da1..f8b44e6bf4f6 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md @@ -1138,12 +1138,14 @@ namespace azure.messaging.webpubsubchatservice.models class azure.messaging.webpubsubchatservice.models.ChatTopicCreateOrReplace(_Model): + state: Optional[Union[str, ChatTopicState]] title: str @overload def __init__( self, *, + state: Optional[Union[str, ChatTopicState]] = ..., title: str ) -> None: ... @@ -1305,7 +1307,9 @@ namespace azure.messaging.webpubsubchatservice.types class azure.messaging.webpubsubchatservice.types.ChatTopicCreateOrReplace(TypedDict, total=False): + key "state": Union[str, ChatTopicState] key "title": Required[str] + state: Union[str, ChatTopicState] title: str diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml index 02554ba13a19..c64c6252f87c 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml @@ -1,4 +1,4 @@ -apiMdSha256: 528789bad38f0165f924016c0ebe7fc27feac738e5468b0147823c054bd475d7 +apiMdSha256: f9e69641a04546543d07880f46f0686197a829554e669f6b4f285043b773e939 packageVersion: 1.0.0b2 parserVersion: 0.3.31 pythonVersion: 3.12.10 diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json b/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json index ed8b51e68cb1..b5c6f3cbaa22 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json @@ -73,5 +73,5 @@ "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.list_rooms_for_user": "WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser", "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.list_rooms_for_user": "WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser" }, - "CrossLanguageVersion": "584f70179c70" + "CrossLanguageVersion": "e41a201baeb5" } \ No newline at end of file diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/_models.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/_models.py index 232ce47e5432..1bf1a96641aa 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/_models.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/_models.py @@ -397,16 +397,25 @@ class ChatTopicCreateOrReplace(_Model): # pylint: disable=docstring-keyword-sho :ivar title: Topic title. Required. :vartype title: str + :ivar state: Current lifecycle state of the topic. Known values are: "Normal", "Archived", and + "SoftDeleted". + :vartype state: str or ~azure.messaging.webpubsubchatservice.models.ChatTopicState """ title: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Topic title. Required.""" + state: Optional[Union[str, "_models.ChatTopicState"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Current lifecycle state of the topic. Known values are: \"Normal\", \"Archived\", and + \"SoftDeleted\".""" @overload def __init__( self, *, title: str, + state: Optional[Union[str, "_models.ChatTopicState"]] = None, ) -> None: ... @overload diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py index 21cc25cc2be6..14755098e183 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py @@ -70,10 +70,16 @@ class ChatTopicCreateOrReplace(TypedDict, total=False): :ivar title: Topic title. Required. :vartype title: str + :ivar state: Current lifecycle state of the topic. Known values are: "Normal", "Archived", and + "SoftDeleted". + :vartype state: Union[str, "ChatTopicState"] """ title: Required[str] """Topic title. Required.""" + state: Union[str, "ChatTopicState"] + """Current lifecycle state of the topic. Known values are: \"Normal\", \"Archived\", and + \"SoftDeleted\".""" class ChatTopicUpdate(TypedDict, total=False): diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_topic.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_topic.py index 80fffd44b6fc..94f745112aaf 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_topic.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_topic.py @@ -34,7 +34,7 @@ def main(): response = client.create_or_replace_topic( room_id="general", topic_id="product-updates", - resource={"title": "Product updates"}, + resource={"state": "Normal", "title": "Product updates"}, ) print(response) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service.py index 54880d9e5d24..bb6731b0f563 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service.py @@ -163,7 +163,7 @@ def test_create_or_replace_topic(self, webpubsubchatservice_endpoint): response = client.create_or_replace_topic( room_id="str", topic_id="str", - resource={"title": "str"}, + resource={"title": "str", "state": "str"}, ) # please add some check logic here by yourself diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service_async.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service_async.py index c830c56a0d8a..a3c10505e531 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service_async.py @@ -164,7 +164,7 @@ async def test_create_or_replace_topic(self, webpubsubchatservice_endpoint): response = await client.create_or_replace_topic( room_id="str", topic_id="str", - resource={"title": "str"}, + resource={"title": "str", "state": "str"}, ) # please add some check logic here by yourself diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_operation_samples.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_operation_samples.py index a1013d2c6e40..fac9b80f9560 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_operation_samples.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_operation_samples.py @@ -169,7 +169,7 @@ def test_sample_runner_closes_client_and_propagates_errors(monkeypatch, sample_i manager.__exit__.assert_called_once() -def test_generated_topic_create_example_contains_only_title(): +def test_generated_topic_put_example_serializes_replace_state(): tree = ast.parse((PACKAGE / "generated_samples" / "create_or_replace_topic.py").read_text()) calls = [ node @@ -180,4 +180,6 @@ def test_generated_topic_create_example_contains_only_title(): ] assert len(calls) == 1 body = next(keyword.value for keyword in calls[0].keywords if keyword.arg == "resource") - assert ast.literal_eval(body) == {"title": "Product updates"} + request = ast.literal_eval(body) + assert request["state"] == models.ChatTopicState.NORMAL + assert models.ChatTopicCreateOrReplace(request).as_dict() == request diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_request_models.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_request_models.py index d948d0240f10..117fc54566a9 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_request_models.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_request_models.py @@ -6,6 +6,7 @@ import ast import inspect import json +from typing import get_args from unittest.mock import AsyncMock, Mock, patch import pytest @@ -16,15 +17,15 @@ from azure.messaging.webpubsubchatservice.aio import WebPubSubChatServiceClient as AsyncClient from azure.messaging.webpubsubchatservice import models, types -MODEL_SHAPES = [ - (models.ChatTopicCreateOrReplace, {"title"}, {"title"}), - (models.ChatTopicUpdate, {"title", "state"}, set()), - (models.ChatMessageUpdate, {"created_by", "content"}, set()), - (models.ChatRoleCreateOrReplace, {"permissions"}, {"permissions"}), - (models.ChatRoomCreateOrReplace, {"title"}, {"title"}), - (models.ChatRoomMemberCreateOrReplace, {"role_name"}, {"role_name"}), - (models.ChatUserCreateOrReplace, {"kind", "nickname"}, {"kind", "nickname"}), - (models.HumanChatUserCreateOrReplace, {"kind", "nickname", "role_name"}, {"nickname", "role_name"}), +REQUEST_PROJECTIONS = [ + (models.ChatTopicCreateOrReplace, models.ChatTopic, {"create", "update"}), + (models.ChatTopicUpdate, models.ChatTopic, {"update"}), + (models.ChatMessageUpdate, models.ChatMessage, {"update"}), + (models.ChatRoleCreateOrReplace, models.ChatRole, {"create", "update"}), + (models.ChatRoomCreateOrReplace, models.ChatRoom, {"create", "update"}), + (models.ChatRoomMemberCreateOrReplace, models.ChatRoomMember, {"create", "update"}), + (models.ChatUserCreateOrReplace, models.ChatUser, {"create", "update"}), + (models.HumanChatUserCreateOrReplace, models.HumanChatUser, {"create", "update"}), ] CASES = [ @@ -35,6 +36,27 @@ models.ChatTopic, {"title": "Title"}, ), + ( + "create_or_replace_topic", + ("room", "topic"), + types.ChatTopicCreateOrReplace(title="Title"), + models.ChatTopic, + {"title": "Title"}, + ), + ( + "create_or_replace_topic", + ("room", "topic"), + models.ChatTopicCreateOrReplace(title="Title", state=models.ChatTopicState.ARCHIVED), + models.ChatTopic, + {"title": "Title", "state": "Archived"}, + ), + ( + "create_or_replace_topic", + ("room", "topic"), + types.ChatTopicCreateOrReplace(title="Title", state=models.ChatTopicState.ARCHIVED), + models.ChatTopic, + {"title": "Title", "state": "Archived"}, + ), ( "update_topic", ("room", "topic"), @@ -129,19 +151,46 @@ ] -@pytest.mark.parametrize("model,fields,required", MODEL_SHAPES) -def test_request_model_constructor_shape(model, fields, required): - assert set(model({})._attr_to_rest_field) == fields +def _required_constructor_fields(model): definition = ast.parse(inspect.getsource(model)).body[0] constructor = next( node for node in definition.body if isinstance(node, ast.FunctionDef) and node.name == "__init__" ) - assert { + return { parameter.arg for parameter, default in zip(constructor.args.kwonlyargs, constructor.args.kw_defaults) if default is None - } == required - assert not {"id", "etag", "created_at", "default_conversation"} & fields + } + + +@pytest.mark.parametrize("request_model,resource_model,lifecycle", REQUEST_PROJECTIONS) +def test_request_fields_follow_resource_lifecycle_visibility(request_model, resource_model, lifecycle): + resource_fields = resource_model({})._attr_to_rest_field + request_fields = request_model({})._attr_to_rest_field + writable_fields = {name for name, field in resource_fields.items() if lifecycle.intersection(field._visibility)} + assert set(request_fields) == writable_fields + for name, field in request_fields.items(): + assert field._rest_name == resource_fields[name]._rest_name + assert lifecycle.intersection(field._visibility) + + required = _required_constructor_fields(resource_model) + if lifecycle == {"update"}: + required = set() + else: + required = {name for name in required & writable_fields if "create" in resource_fields[name]._visibility} + assert _required_constructor_fields(request_model) == required + dictionary_projection = getattr(types, request_model.__name__) + # Discriminated dictionary requests are unions of their concrete subtypes. + for dictionary_type in get_args(dictionary_projection) or (dictionary_projection,): + concrete_request = getattr(models, dictionary_type.__name__) + concrete_fields = concrete_request({})._attr_to_rest_field + assert set(dictionary_type.__annotations__) == {field._rest_name for field in concrete_fields.values()} + required_dictionary_fields = _required_constructor_fields(concrete_request) | { + name for name, field in concrete_fields.items() if field._is_discriminator + } + assert dictionary_type.__required_keys__ == { + concrete_fields[name]._rest_name for name in required_dictionary_fields + } def _response(body): diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/typing/request_models.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/typing/request_models.py index 147554c5c21b..3be4fd105bdd 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/typing/request_models.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/typing/request_models.py @@ -18,6 +18,13 @@ def check_request_types(client: WebPubSubChatServiceClient) -> None: client.update_message("conversation", "message", types.ChatMessageUpdate(createdBy="user")) client.update_message("conversation", "message", types.ChatMessageUpdate(content={"text": "Updated"})) client.create_or_replace_topic("room", "topic", models.ChatTopicCreateOrReplace(title="Title")) + client.create_or_replace_topic( + "room", "topic", models.ChatTopicCreateOrReplace(title="Title", state=models.ChatTopicState.ARCHIVED) + ) + client.create_or_replace_topic("room", "topic", types.ChatTopicCreateOrReplace(title="Title")) + client.create_or_replace_topic( + "room", "topic", types.ChatTopicCreateOrReplace(title="Title", state=models.ChatTopicState.ARCHIVED) + ) client.create_or_replace_role("user.role", models.ChatRoleCreateOrReplace(permissions=["user.create_room"])) client.create_or_replace_role("user.role", types.ChatRoleCreateOrReplace(permissions=["user.create_room"])) client.create_or_replace_room("room", models.ChatRoomCreateOrReplace(title="Room")) @@ -36,7 +43,7 @@ def check_request_types(client: WebPubSubChatServiceClient) -> None: models.ChatMessageUpdate(created_by=123) # type: ignore[call-overload] models.ChatMessageUpdate(content=123) # type: ignore[call-overload] models.ChatTopicCreateOrReplace() # type: ignore[call-overload] - models.ChatTopicCreateOrReplace(title="Title", state=models.ChatTopicState.ARCHIVED) # type: ignore[call-overload] + models.ChatTopicCreateOrReplace(title="Title", state=123) # type: ignore[call-overload] types.ChatTopicUpdate(title=123) # type: ignore[typeddict-item] types.ChatTopicUpdate(id="read-only") # type: ignore[typeddict-unknown-key] types.ChatMessageUpdate(content=123) # type: ignore[typeddict-item] @@ -44,6 +51,14 @@ def check_request_types(client: WebPubSubChatServiceClient) -> None: async def check_async_request_types(client: AsyncClient) -> None: + await client.create_or_replace_topic("room", "topic", models.ChatTopicCreateOrReplace(title="Title")) + await client.create_or_replace_topic( + "room", "topic", models.ChatTopicCreateOrReplace(title="Title", state=models.ChatTopicState.ARCHIVED) + ) + await client.create_or_replace_topic("room", "topic", types.ChatTopicCreateOrReplace(title="Title")) + await client.create_or_replace_topic( + "room", "topic", types.ChatTopicCreateOrReplace(title="Title", state=models.ChatTopicState.ARCHIVED) + ) await client.create_or_replace_role("user.role", models.ChatRoleCreateOrReplace(permissions=["user.create_room"])) await client.create_or_replace_role("user.role", types.ChatRoleCreateOrReplace(permissions=["user.create_room"])) await client.create_or_replace_room("room", models.ChatRoomCreateOrReplace(title="Room")) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml index d2d71e474191..69b798ebbf0a 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml @@ -1,5 +1,5 @@ directory: specification/webpubsub/data-plane/WebPubSubChat -commit: 5d511288c9acb00cdc6c5eb76615327798004d03 +commit: 59d709b28e3808cbcec119f0ceaeb5f228a42a63 repo: Y-Sindo/azure-rest-api-specs # cspell:ignore Sindo additionalDirectories: [] entrypointFile: client.tsp \ No newline at end of file From e6104523cd674b1d29afca1d8ac5aa188823e07c Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Thu, 22 Oct 2026 16:36:46 +1100 Subject: [PATCH 16/22] Simplify Chat samples and explain JSON request body styles Recommend model-based usage in the package README and describe all three input styles in the sample guide. Remove duplicate bodyless operation examples and their environment-variable runner, add a three-style comparison, and retain focused sample and lifecycle tests. Clarify runtime versus static tests and strip generated API whitespace without changing its normalized content. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../README.md | 31 +- .../api.md | 1010 ++++++++--------- .../samples/README.md | 120 +- .../samples/_shared.py | 23 - .../samples/sample_create_or_replace_role.py | 9 +- .../samples/sample_create_or_replace_room.py | 9 +- .../sample_create_or_replace_room_member.py | 13 +- .../samples/sample_create_or_replace_topic.py | 11 +- .../samples/sample_create_or_replace_user.py | 11 +- .../samples/sample_delete_message.py | 18 - .../samples/sample_delete_role.py | 18 - .../samples/sample_delete_room.py | 18 - .../samples/sample_delete_room_member.py | 18 - .../samples/sample_delete_topic.py | 24 - .../samples/sample_delete_user.py | 18 - .../samples/sample_get_conversation.py | 19 - .../samples/sample_get_role.py | 19 - .../samples/sample_get_room.py | 19 - .../samples/sample_get_topic.py | 19 - .../samples/sample_get_user.py | 19 - .../samples/sample_list_messages.py | 19 - .../samples/sample_list_roles.py | 17 - .../samples/sample_list_room_members.py | 19 - .../samples/sample_list_rooms.py | 17 - .../samples/sample_list_rooms_for_user.py | 19 - .../samples/sample_list_topics.py | 19 - .../samples/sample_list_users.py | 17 - .../samples/sample_request_body_styles.py | 31 + .../samples/sample_update_message.py | 11 +- .../samples/sample_update_topic.py | 16 +- .../tests/test_operation_samples.py | 149 +-- .../tests/test_request_models.py | 5 + .../tests/typing/request_models.py | 9 + 33 files changed, 699 insertions(+), 1095 deletions(-) delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/_shared.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_message.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_role.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_room.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_room_member.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_topic.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_user.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_conversation.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_role.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_room.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_topic.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_user.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_messages.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_roles.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_room_members.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_rooms.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_rooms_for_user.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_topics.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_users.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_request_body_styles.py diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md index f42512d349b7..fa5fda00d284 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md @@ -152,14 +152,20 @@ renamed, archived, and soft deleted independently of the room's default conversa ### Request models and dictionaries -Operations with JSON request bodies accept model instances from -`azure.messaging.webpubsubchatservice.models` or dictionaries described by the -`TypedDict` definitions in `azure.messaging.webpubsubchatservice.types`. -Model instances use Python property names, such as `role_name`, and provide -attribute access and JSON serialization. Dictionaries use JSON field names, -such as `roleName`. `TypedDict` provides static type checking for those -dictionaries; at runtime they are ordinary dictionaries, not model instances, -and do not perform runtime validation. +You can supply a JSON request body in three ways: + +- **Model-based:** use classes from `azure.messaging.webpubsubchatservice.models` + with Python-style attributes and SDK-managed serialization. +- **Typed dictionary:** use the `TypedDict` definitions from + `azure.messaging.webpubsubchatservice.types` for static checking of JSON-shaped dictionaries. +- **Plain dictionary:** pass a dictionary using JSON field names. + +Model-based usage is recommended for getting started and is used throughout the +examples below. Dictionaries are useful when your application already works with +JSON-shaped data. All three styles call the same client methods; typed dictionaries +are ordinary dictionaries at runtime. See the +[sample guide](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md#request-body-styles) +for a comparison and examples of each style. ## Examples @@ -168,11 +174,9 @@ authenticated `client`, created as shown in Getting started. The async snippet uses a client from `azure.messaging.webpubsubchatservice.aio`. See the [package samples][samples] for complete synchronous and asynchronous programs. -The [model-based samples][samples] use model instances for request bodies. -The [dictionary-based samples][generated_samples] use dictionary literals with -JSON field names. Both call the same client methods. See the +The examples below use model instances for request bodies. See the [sample guide and complete operation index](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md) -for a corresponding model-based example of every service operation. +for more request-body styles and examples of every service operation. ### Generate client access credentials @@ -572,7 +576,8 @@ specification's examples. Each file demonstrates one operation. Replace and configure authentication as described in each file. These generated files are refreshed during SDK generation. The README snippet source contains independent functions, not a combined workflow or a standalone program. -The runnable model-based samples demonstrate model and permission-enum usage, +The model-based operation examples accept an authenticated client and use example +resource identifiers that you can adapt. The scenario samples demonstrate authentication, client access credentials, errors, and logging. ## Additional resources diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md index f8b44e6bf4f6..0ba29e8e48a1 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md @@ -7,23 +7,23 @@ namespace azure.messaging.webpubsubchatservice USER_NORMAL = user.normal - class azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient(WebPubSubChatServiceClientGenerated): implements ContextManager + class azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient(WebPubSubChatServiceClientGenerated): implements ContextManager def __init__( - self, - endpoint: str, - hub: str, - credential: Union[TokenCredential, AzureKeyCredential], - *, - api_version: Optional[str] = ..., + self, + endpoint: str, + hub: str, + credential: Union[TokenCredential, AzureKeyCredential], + *, + api_version: Optional[str] = ..., **kwargs: Any ) -> None: ... @classmethod def from_connection_string( - cls, - conn_str: str, - hub: str, + cls, + conn_str: str, + hub: str, **kwargs: Any ) -> WebPubSubChatServiceClient: ... @@ -31,478 +31,478 @@ namespace azure.messaging.webpubsubchatservice @overload def create_or_replace_role( - self, - role_name: str, + self, + role_name: str, resource: ChatRoleCreateOrReplace, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRole: ... @overload def create_or_replace_role( - self, - role_name: str, + self, + role_name: str, resource: ChatRoleCreateOrReplace, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRole: ... @overload def create_or_replace_role( - self, - role_name: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + role_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRole: ... @overload def create_or_replace_room( - self, - room_id: str, + self, + room_id: str, resource: ChatRoomCreateOrReplace, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRoom: ... @overload def create_or_replace_room( - self, - room_id: str, + self, + room_id: str, resource: ChatRoomCreateOrReplace, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRoom: ... @overload def create_or_replace_room( - self, - room_id: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + room_id: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRoom: ... @overload def create_or_replace_room_member( - self, - room_id: str, - user_id: str, + self, + room_id: str, + user_id: str, resource: ChatRoomMemberCreateOrReplace, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRoomMember: ... @overload def create_or_replace_room_member( - self, - room_id: str, - user_id: str, + self, + room_id: str, + user_id: str, resource: ChatRoomMemberCreateOrReplace, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRoomMember: ... @overload def create_or_replace_room_member( - self, - room_id: str, - user_id: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + room_id: str, + user_id: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRoomMember: ... @overload def create_or_replace_topic( - self, - room_id: str, - topic_id: str, + self, + room_id: str, + topic_id: str, resource: ChatTopicCreateOrReplace, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatTopic: ... @overload def create_or_replace_topic( - self, - room_id: str, - topic_id: str, + self, + room_id: str, + topic_id: str, resource: ChatTopicCreateOrReplace, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatTopic: ... @overload def create_or_replace_topic( - self, - room_id: str, - topic_id: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + room_id: str, + topic_id: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatTopic: ... @overload def create_or_replace_user( - self, - user_id: str, + self, + user_id: str, resource: ChatUserCreateOrReplace, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatUser: ... @overload def create_or_replace_user( - self, - user_id: str, + self, + user_id: str, resource: ChatUserCreateOrReplace, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatUser: ... @overload def create_or_replace_user( - self, - user_id: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + user_id: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatUser: ... @distributed_trace def delete_message( - self, - conversation_id: str, - message_id: str, - *, - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + conversation_id: str, + message_id: str, + *, + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> None: ... @distributed_trace def delete_role( - self, - role_name: str, - *, - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + role_name: str, + *, + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> None: ... @distributed_trace def delete_room( - self, - room_id: str, - *, - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + room_id: str, + *, + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> None: ... @distributed_trace def delete_room_member( - self, - room_id: str, - user_id: str, - *, - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + room_id: str, + user_id: str, + *, + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> None: ... @distributed_trace @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'room_id', 'topic_id', 'etag', 'match_condition']}, api_versions_list=['2026-08-01-preview']) def delete_topic( - self, - room_id: str, - topic_id: str, - *, - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + room_id: str, + topic_id: str, + *, + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> None: ... @distributed_trace def delete_user( - self, - user_id: str, - *, - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + user_id: str, + *, + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> None: ... @distributed_trace def get_client_access_token( - self, - *, - minutes_to_expire: int = 60, - user_id: Optional[str] = ..., + self, + *, + minutes_to_expire: int = 60, + user_id: Optional[str] = ..., **kwargs: Any ) -> Dict[str, Any]: ... @distributed_trace def get_conversation( - self, - conversation_id: str, + self, + conversation_id: str, **kwargs: Any ) -> ChatConversation: ... @distributed_trace def get_role( - self, - role_name: str, + self, + role_name: str, **kwargs: Any ) -> ChatRole: ... @distributed_trace def get_room( - self, - room_id: str, + self, + room_id: str, **kwargs: Any ) -> ChatRoom: ... @distributed_trace @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'room_id', 'topic_id', 'accept']}, api_versions_list=['2026-08-01-preview']) def get_topic( - self, - room_id: str, - topic_id: str, + self, + room_id: str, + topic_id: str, **kwargs: Any ) -> ChatTopic: ... @distributed_trace def get_user( - self, - user_id: str, + self, + user_id: str, **kwargs: Any ) -> ChatUser: ... @distributed_trace def list_messages( - self, - conversation_id: str, - *, - earliest_message_id: Optional[str] = ..., - latest_message_id: Optional[str] = ..., - max_page_size: Optional[int] = ..., + self, + conversation_id: str, + *, + earliest_message_id: Optional[str] = ..., + latest_message_id: Optional[str] = ..., + max_page_size: Optional[int] = ..., **kwargs: Any ) -> ItemPaged[ChatMessage]: ... @distributed_trace def list_roles( - self, - *, - continuation_token_parameter: Optional[str] = ..., - max_page_size: Optional[int] = ..., + self, + *, + continuation_token_parameter: Optional[str] = ..., + max_page_size: Optional[int] = ..., **kwargs: Any ) -> ItemPaged[ChatRole]: ... @distributed_trace def list_room_members( - self, - room_id: str, - *, - continuation_token_parameter: Optional[str] = ..., - max_page_size: Optional[int] = ..., + self, + room_id: str, + *, + continuation_token_parameter: Optional[str] = ..., + max_page_size: Optional[int] = ..., **kwargs: Any ) -> ItemPaged[ChatRoomMember]: ... @distributed_trace @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'max_page_size', 'continuation_token_parameter', 'accept']}, api_versions_list=['2026-08-01-preview']) def list_rooms( - self, - *, - continuation_token_parameter: Optional[str] = ..., - max_page_size: Optional[int] = ..., + self, + *, + continuation_token_parameter: Optional[str] = ..., + max_page_size: Optional[int] = ..., **kwargs: Any ) -> ItemPaged[ChatRoom]: ... @distributed_trace @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'user_id', 'max_page_size', 'continuation_token_parameter', 'accept']}, api_versions_list=['2026-08-01-preview']) def list_rooms_for_user( - self, - user_id: str, - *, - continuation_token_parameter: Optional[str] = ..., - max_page_size: Optional[int] = ..., + self, + user_id: str, + *, + continuation_token_parameter: Optional[str] = ..., + max_page_size: Optional[int] = ..., **kwargs: Any ) -> ItemPaged[ChatUserRoom]: ... @distributed_trace @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'room_id', 'max_page_size', 'continuation_token_parameter', 'accept']}, api_versions_list=['2026-08-01-preview']) def list_topics( - self, - room_id: str, - *, - continuation_token_parameter: Optional[str] = ..., - max_page_size: Optional[int] = ..., + self, + room_id: str, + *, + continuation_token_parameter: Optional[str] = ..., + max_page_size: Optional[int] = ..., **kwargs: Any ) -> ItemPaged[ChatTopic]: ... @distributed_trace @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'max_page_size', 'continuation_token_parameter', 'accept']}, api_versions_list=['2026-08-01-preview']) def list_users( - self, - *, - continuation_token_parameter: Optional[str] = ..., - max_page_size: Optional[int] = ..., + self, + *, + continuation_token_parameter: Optional[str] = ..., + max_page_size: Optional[int] = ..., **kwargs: Any ) -> ItemPaged[ChatUser]: ... def send_request( - self, - request: HttpRequest, - *, - stream: bool = False, + self, + request: HttpRequest, + *, + stream: bool = False, **kwargs: Any ) -> HttpResponse: ... @overload def update_message( - self, - conversation_id: str, - message_id: str, + self, + conversation_id: str, + message_id: str, resource: ChatMessageUpdate, - *, - content_type: str = "application/merge-patch+json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + *, + content_type: str = "application/merge-patch+json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatMessage: ... @overload def update_message( - self, - conversation_id: str, - message_id: str, + self, + conversation_id: str, + message_id: str, resource: ChatMessageUpdate, - *, - content_type: str = "application/merge-patch+json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + *, + content_type: str = "application/merge-patch+json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatMessage: ... @overload def update_message( - self, - conversation_id: str, - message_id: str, - resource: IO[bytes], - *, - content_type: str = "application/merge-patch+json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + conversation_id: str, + message_id: str, + resource: IO[bytes], + *, + content_type: str = "application/merge-patch+json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatMessage: ... @overload def update_topic( - self, - room_id: str, - topic_id: str, + self, + room_id: str, + topic_id: str, resource: ChatTopicUpdate, - *, - content_type: str = "application/merge-patch+json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + *, + content_type: str = "application/merge-patch+json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatTopic: ... @overload def update_topic( - self, - room_id: str, - topic_id: str, + self, + room_id: str, + topic_id: str, resource: ChatTopicUpdate, - *, - content_type: str = "application/merge-patch+json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + *, + content_type: str = "application/merge-patch+json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatTopic: ... @overload def update_topic( - self, - room_id: str, - topic_id: str, - resource: IO[bytes], - *, - content_type: str = "application/merge-patch+json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + room_id: str, + topic_id: str, + resource: IO[bytes], + *, + content_type: str = "application/merge-patch+json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatTopic: ... namespace azure.messaging.webpubsubchatservice.aio - class azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient(WebPubSubChatServiceClientGenerated): implements AsyncContextManager + class azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient(WebPubSubChatServiceClientGenerated): implements AsyncContextManager def __init__( - self, - endpoint: str, - hub: str, - credential: Union[AsyncTokenCredential, AzureKeyCredential], - *, - api_version: Optional[str] = ..., + self, + endpoint: str, + hub: str, + credential: Union[AsyncTokenCredential, AzureKeyCredential], + *, + api_version: Optional[str] = ..., **kwargs: Any ) -> None: ... @classmethod def from_connection_string( - cls, - conn_str: str, - hub: str, + cls, + conn_str: str, + hub: str, **kwargs: Any ) -> WebPubSubChatServiceClient: ... @@ -510,455 +510,455 @@ namespace azure.messaging.webpubsubchatservice.aio @overload async def create_or_replace_role( - self, - role_name: str, + self, + role_name: str, resource: ChatRoleCreateOrReplace, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRole: ... @overload async def create_or_replace_role( - self, - role_name: str, + self, + role_name: str, resource: ChatRoleCreateOrReplace, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRole: ... @overload async def create_or_replace_role( - self, - role_name: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + role_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRole: ... @overload async def create_or_replace_room( - self, - room_id: str, + self, + room_id: str, resource: ChatRoomCreateOrReplace, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRoom: ... @overload async def create_or_replace_room( - self, - room_id: str, + self, + room_id: str, resource: ChatRoomCreateOrReplace, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRoom: ... @overload async def create_or_replace_room( - self, - room_id: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + room_id: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRoom: ... @overload async def create_or_replace_room_member( - self, - room_id: str, - user_id: str, + self, + room_id: str, + user_id: str, resource: ChatRoomMemberCreateOrReplace, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRoomMember: ... @overload async def create_or_replace_room_member( - self, - room_id: str, - user_id: str, + self, + room_id: str, + user_id: str, resource: ChatRoomMemberCreateOrReplace, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRoomMember: ... @overload async def create_or_replace_room_member( - self, - room_id: str, - user_id: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + room_id: str, + user_id: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatRoomMember: ... @overload async def create_or_replace_topic( - self, - room_id: str, - topic_id: str, + self, + room_id: str, + topic_id: str, resource: ChatTopicCreateOrReplace, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatTopic: ... @overload async def create_or_replace_topic( - self, - room_id: str, - topic_id: str, + self, + room_id: str, + topic_id: str, resource: ChatTopicCreateOrReplace, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatTopic: ... @overload async def create_or_replace_topic( - self, - room_id: str, - topic_id: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + room_id: str, + topic_id: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatTopic: ... @overload async def create_or_replace_user( - self, - user_id: str, + self, + user_id: str, resource: ChatUserCreateOrReplace, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatUser: ... @overload async def create_or_replace_user( - self, - user_id: str, + self, + user_id: str, resource: ChatUserCreateOrReplace, - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatUser: ... @overload async def create_or_replace_user( - self, - user_id: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + user_id: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatUser: ... @distributed_trace_async async def delete_message( - self, - conversation_id: str, - message_id: str, - *, - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + conversation_id: str, + message_id: str, + *, + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> None: ... @distributed_trace_async async def delete_role( - self, - role_name: str, - *, - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + role_name: str, + *, + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> None: ... @distributed_trace_async async def delete_room( - self, - room_id: str, - *, - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + room_id: str, + *, + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> None: ... @distributed_trace_async async def delete_room_member( - self, - room_id: str, - user_id: str, - *, - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + room_id: str, + user_id: str, + *, + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> None: ... @distributed_trace_async @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'room_id', 'topic_id', 'etag', 'match_condition']}, api_versions_list=['2026-08-01-preview']) async def delete_topic( - self, - room_id: str, - topic_id: str, - *, - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + room_id: str, + topic_id: str, + *, + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> None: ... @distributed_trace_async async def delete_user( - self, - user_id: str, - *, - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + user_id: str, + *, + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> None: ... @distributed_trace_async async def get_client_access_token( - self, - *, - minutes_to_expire: int = 60, - user_id: Optional[str] = ..., + self, + *, + minutes_to_expire: int = 60, + user_id: Optional[str] = ..., **kwargs: Any ) -> Dict[str, Any]: ... @distributed_trace_async async def get_conversation( - self, - conversation_id: str, + self, + conversation_id: str, **kwargs: Any ) -> ChatConversation: ... @distributed_trace_async async def get_role( - self, - role_name: str, + self, + role_name: str, **kwargs: Any ) -> ChatRole: ... @distributed_trace_async async def get_room( - self, - room_id: str, + self, + room_id: str, **kwargs: Any ) -> ChatRoom: ... @distributed_trace_async @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'room_id', 'topic_id', 'accept']}, api_versions_list=['2026-08-01-preview']) async def get_topic( - self, - room_id: str, - topic_id: str, + self, + room_id: str, + topic_id: str, **kwargs: Any ) -> ChatTopic: ... @distributed_trace_async async def get_user( - self, - user_id: str, + self, + user_id: str, **kwargs: Any ) -> ChatUser: ... @distributed_trace def list_messages( - self, - conversation_id: str, - *, - earliest_message_id: Optional[str] = ..., - latest_message_id: Optional[str] = ..., - max_page_size: Optional[int] = ..., + self, + conversation_id: str, + *, + earliest_message_id: Optional[str] = ..., + latest_message_id: Optional[str] = ..., + max_page_size: Optional[int] = ..., **kwargs: Any ) -> AsyncItemPaged[ChatMessage]: ... @distributed_trace def list_roles( - self, - *, - continuation_token_parameter: Optional[str] = ..., - max_page_size: Optional[int] = ..., + self, + *, + continuation_token_parameter: Optional[str] = ..., + max_page_size: Optional[int] = ..., **kwargs: Any ) -> AsyncItemPaged[ChatRole]: ... @distributed_trace def list_room_members( - self, - room_id: str, - *, - continuation_token_parameter: Optional[str] = ..., - max_page_size: Optional[int] = ..., + self, + room_id: str, + *, + continuation_token_parameter: Optional[str] = ..., + max_page_size: Optional[int] = ..., **kwargs: Any ) -> AsyncItemPaged[ChatRoomMember]: ... @distributed_trace @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'max_page_size', 'continuation_token_parameter', 'accept']}, api_versions_list=['2026-08-01-preview']) def list_rooms( - self, - *, - continuation_token_parameter: Optional[str] = ..., - max_page_size: Optional[int] = ..., + self, + *, + continuation_token_parameter: Optional[str] = ..., + max_page_size: Optional[int] = ..., **kwargs: Any ) -> AsyncItemPaged[ChatRoom]: ... @distributed_trace @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'user_id', 'max_page_size', 'continuation_token_parameter', 'accept']}, api_versions_list=['2026-08-01-preview']) def list_rooms_for_user( - self, - user_id: str, - *, - continuation_token_parameter: Optional[str] = ..., - max_page_size: Optional[int] = ..., + self, + user_id: str, + *, + continuation_token_parameter: Optional[str] = ..., + max_page_size: Optional[int] = ..., **kwargs: Any ) -> AsyncItemPaged[ChatUserRoom]: ... @distributed_trace @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'room_id', 'max_page_size', 'continuation_token_parameter', 'accept']}, api_versions_list=['2026-08-01-preview']) def list_topics( - self, - room_id: str, - *, - continuation_token_parameter: Optional[str] = ..., - max_page_size: Optional[int] = ..., + self, + room_id: str, + *, + continuation_token_parameter: Optional[str] = ..., + max_page_size: Optional[int] = ..., **kwargs: Any ) -> AsyncItemPaged[ChatTopic]: ... @distributed_trace @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'max_page_size', 'continuation_token_parameter', 'accept']}, api_versions_list=['2026-08-01-preview']) def list_users( - self, - *, - continuation_token_parameter: Optional[str] = ..., - max_page_size: Optional[int] = ..., + self, + *, + continuation_token_parameter: Optional[str] = ..., + max_page_size: Optional[int] = ..., **kwargs: Any ) -> AsyncItemPaged[ChatUser]: ... def send_request( - self, - request: HttpRequest, - *, - stream: bool = False, + self, + request: HttpRequest, + *, + stream: bool = False, **kwargs: Any ) -> Awaitable[AsyncHttpResponse]: ... @overload async def update_message( - self, - conversation_id: str, - message_id: str, + self, + conversation_id: str, + message_id: str, resource: ChatMessageUpdate, - *, - content_type: str = "application/merge-patch+json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + *, + content_type: str = "application/merge-patch+json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatMessage: ... @overload async def update_message( - self, - conversation_id: str, - message_id: str, + self, + conversation_id: str, + message_id: str, resource: ChatMessageUpdate, - *, - content_type: str = "application/merge-patch+json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + *, + content_type: str = "application/merge-patch+json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatMessage: ... @overload async def update_message( - self, - conversation_id: str, - message_id: str, - resource: IO[bytes], - *, - content_type: str = "application/merge-patch+json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + conversation_id: str, + message_id: str, + resource: IO[bytes], + *, + content_type: str = "application/merge-patch+json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatMessage: ... @overload async def update_topic( - self, - room_id: str, - topic_id: str, + self, + room_id: str, + topic_id: str, resource: ChatTopicUpdate, - *, - content_type: str = "application/merge-patch+json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + *, + content_type: str = "application/merge-patch+json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatTopic: ... @overload async def update_topic( - self, - room_id: str, - topic_id: str, + self, + room_id: str, + topic_id: str, resource: ChatTopicUpdate, - *, - content_type: str = "application/merge-patch+json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + *, + content_type: str = "application/merge-patch+json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatTopic: ... @overload async def update_topic( - self, - room_id: str, - topic_id: str, - resource: IO[bytes], - *, - content_type: str = "application/merge-patch+json", - etag: Optional[str] = ..., - match_condition: Optional[MatchConditions] = ..., + self, + room_id: str, + topic_id: str, + resource: IO[bytes], + *, + content_type: str = "application/merge-patch+json", + etag: Optional[str] = ..., + match_condition: Optional[MatchConditions] = ..., **kwargs: Any ) -> ChatTopic: ... @@ -972,8 +972,8 @@ namespace azure.messaging.webpubsubchatservice.models @overload def __init__( - self, - *, + self, + *, parent_room: str ) -> None: ... @@ -990,9 +990,9 @@ namespace azure.messaging.webpubsubchatservice.models @overload def __init__( - self, - *, - content: MessageContent, + self, + *, + content: MessageContent, created_by: str ) -> None: ... @@ -1032,8 +1032,8 @@ namespace azure.messaging.webpubsubchatservice.models @overload def __init__( - self, - *, + self, + *, permissions: list[Union[str, ChatPermission]] ) -> None: ... @@ -1063,8 +1063,8 @@ namespace azure.messaging.webpubsubchatservice.models @overload def __init__( - self, - *, + self, + *, title: str ) -> None: ... @@ -1093,8 +1093,8 @@ namespace azure.messaging.webpubsubchatservice.models @overload def __init__( - self, - *, + self, + *, role_name: str ) -> None: ... @@ -1127,9 +1127,9 @@ namespace azure.messaging.webpubsubchatservice.models @overload def __init__( - self, - *, - state: Union[str, ChatTopicState], + self, + *, + state: Union[str, ChatTopicState], title: str ) -> None: ... @@ -1183,9 +1183,9 @@ namespace azure.messaging.webpubsubchatservice.models @overload def __init__( - self, - *, - kind: str, + self, + *, + kind: str, nickname: str ) -> None: ... @@ -1221,8 +1221,8 @@ namespace azure.messaging.webpubsubchatservice.models @overload def __init__( - self, - *, + self, + *, title: str ) -> None: ... @@ -1239,9 +1239,9 @@ namespace azure.messaging.webpubsubchatservice.models @overload def __init__( - self, - *, - nickname: str, + self, + *, + nickname: str, role_name: str ) -> None: ... @@ -1272,9 +1272,9 @@ namespace azure.messaging.webpubsubchatservice.models @overload def __init__( - self, - *, - binary: Optional[bytes] = ..., + self, + *, + binary: Optional[bytes] = ..., text: Optional[str] = ... ) -> None: ... diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md index b8e1c9233a04..61ae99aac615 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md @@ -3,19 +3,42 @@ Use the [package README](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md) for installation, authentication, and Chat hub prerequisites. -## Sample styles +## Request-body styles + +Operations with a JSON request body support three styles: + +- **Model-based (recommended for getting started):** construct a class from + `azure.messaging.webpubsubchatservice.models`, using Python names such as + `role_name`. Models provide attribute access, type hints, and SDK-managed + serialization. See the model-based operation examples below and `model_based` + in the [three-style comparison](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_request_body_styles.py). +- **Typed dictionary:** annotate a dictionary with a `TypedDict` from + `azure.messaging.webpubsubchatservice.types`, using JSON names such as + `roleName`. A type checker can check its keys and value types. See + `typed_dictionary` in the [three-style comparison](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_request_body_styles.py). +- **Plain dictionary:** pass a JSON-shaped dictionary directly, without an + explicit `TypedDict` annotation. See `plain_dictionary` in the + [three-style comparison](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_request_body_styles.py) + and the [generated operation examples](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples). + +For example, these request bodies express the same room membership: + +```python +from azure.messaging.webpubsubchatservice import models, types + +model = models.ChatRoomMemberCreateOrReplace(role_name="room.member") +typed: types.ChatRoomMemberCreateOrReplace = {"roleName": "room.member"} +plain = {"roleName": "room.member"} +``` -The model-based examples in this directory use model classes from -`azure.messaging.webpubsubchatservice.models`. These classes use Python property -names such as `role_name`. The [generated samples](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples) use -ordinary dictionary literals with JSON field names such as `roleName`. -The `TypedDict` definitions in `azure.messaging.webpubsubchatservice.types` -describe those dictionary shapes for static type checking; they do not create -model instances or validate values at runtime. Both request-body styles are -accepted by the corresponding client operations. +All three styles call the same client methods. A typed dictionary is an ordinary +dictionary at runtime; its annotation does not add runtime validation. These +examples use "JSON" to mean a dictionary of JSON fields, not a JSON-encoded string. +Dictionary literals can also be checked against the method's type hints. -Both styles call the same client methods; these are not separate convenience -and protocol method APIs. +GET, LIST, and DELETE operations in this client have no JSON request body, so +there is no request-body style to choose. GET and LIST still return model +instances or paged models; their examples are not duplicated by input style. ## Scenario samples @@ -36,70 +59,53 @@ identifiers and review each file before running it. ## Complete operation index -Each operation has a runnable model-based sample and a dictionary-based sample -generated from specification examples. For operations without request bodies, -both styles use the same parameter types. - -Run model-based samples from the package directory, for example: - -```bash -python samples/sample_list_rooms.py -python samples/sample_create_or_replace_topic.py -``` - -Set `WPS_CHAT_CONNECTION_STRING` and optionally `WPS_CHAT_HUB` (default: -`test_hub`). Each sample reports any additional missing variables without -contacting the service. Identifiers must refer to existing resources for get, -list, update, membership, and delete operations. +The model-based operation examples expose a `sample(client)` function. Supply an +authenticated client as shown in the [authentication sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_authentication.py) +and replace the example identifiers with your own. These functions illustrate +API usage; they are not standalone command-line programs. -| Variable | Used for | -| --- | --- | -| `WPS_CHAT_ROLE_NAME` | Role operations. Use a `room.` name when running the role creation sample. | -| `WPS_CHAT_ROOM_ID` | Room, room member, and topic operations. | -| `WPS_CHAT_USER_ID` | User, membership, and user-room operations. | -| `WPS_CHAT_USER_ROLE_NAME` | Existing `user.` role for user creation. | -| `WPS_CHAT_ROOM_ROLE_NAME` | Existing `room.` role for adding a member. | -| `WPS_CHAT_TOPIC_ID` | Topic operations. | -| `WPS_CHAT_TOPIC_ETAG` | Current ETag from get/create for conditional topic update and delete. Refresh it after an update. | -| `WPS_CHAT_CONVERSATION_ID` | Conversation and message operations. Obtain it from a room or topic. | -| `WPS_CHAT_MESSAGE_ID` | Existing persisted message to update or delete. | +Membership examples assume an existing room, user, and `room.member` role. User +creation assumes an existing `user.member` role. Topic examples assume an +existing room; update examples assume an existing topic or persisted message. +The topic update example reads the current ETag before issuing a conditional +update. No extra resource environment variables or shared runner are needed. Create/replace operations can overwrite existing resources; delete operations remove the specified resource (topic deletion is a soft delete). Use isolated sample resources and review each operation before running it. The samples do not create unrelated prerequisites or send WebSocket messages. -Dictionary-based samples use placeholder endpoints and example identifiers; +Generated examples use placeholder endpoints and example identifiers; replace them and configure authentication as described in each file. -| Operation | Dictionary-based sample | Model-based sample | +| Operation | Generated example | Model-based request-body example | | --- | --- | --- | | `get_client_access_token` | SDK convenience method; no generated sample. | [Sync](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_client_access.py) / [async](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_client_access_async.py) | | `create_or_replace_role` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_role.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_role.py) | -| `get_role` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_role.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_role.py) | -| `list_roles` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_roles.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_roles.py) | -| `delete_role` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_role.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_role.py) | +| `get_role` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_role.py) | No request body | +| `list_roles` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_roles.py) | No request body | +| `delete_role` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_role.py) | No request body | | `create_or_replace_room` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_room.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_room.py) | -| `get_room` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_room.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_room.py) | -| `list_rooms` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_rooms.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_rooms.py) | -| `delete_room` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_room.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_room.py) | +| `get_room` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_room.py) | No request body | +| `list_rooms` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_rooms.py) | No request body | +| `delete_room` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_room.py) | No request body | | `create_or_replace_room_member` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_room_member.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_room_member.py) | -| `list_room_members` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_room_members.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_room_members.py) | -| `delete_room_member` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_room_member.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_room_member.py) | +| `list_room_members` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_room_members.py) | No request body | +| `delete_room_member` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_room_member.py) | No request body | | `create_or_replace_user` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_user.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_user.py) | -| `get_user` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_user.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_user.py) | -| `list_users` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_users.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_users.py) | -| `delete_user` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_user.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_user.py) | -| `list_rooms_for_user` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_rooms_for_user.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_rooms_for_user.py) | +| `get_user` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_user.py) | No request body | +| `list_users` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_users.py) | No request body | +| `delete_user` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_user.py) | No request body | +| `list_rooms_for_user` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_rooms_for_user.py) | No request body | | `create_or_replace_topic` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_topic.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_topic.py) | -| `get_topic` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_topic.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_topic.py) | -| `list_topics` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_topics.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_topics.py) | +| `get_topic` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_topic.py) | No request body | +| `list_topics` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_topics.py) | No request body | | `update_topic` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/update_topic.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_update_topic.py) | -| `delete_topic` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_topic.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_topic.py) | -| `get_conversation` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_conversation.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_conversation.py) | -| `list_messages` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_messages.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_messages.py) | +| `delete_topic` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_topic.py) | No request body | +| `get_conversation` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_conversation.py) | No request body | +| `list_messages` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_messages.py) | No request body | | `update_message` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/update_message.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_update_message.py) | -| `delete_message` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_message.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_message.py) | +| `delete_message` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_message.py) | No request body | The synchronous and asynchronous clients expose the same service operations. Await asynchronous non-paging calls, and use `async for` to iterate asynchronous diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/_shared.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/_shared.py deleted file mode 100644 index d2b8c5861f01..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/_shared.py +++ /dev/null @@ -1,23 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------- -"""Configuration and client lifetime for the operation samples.""" - -import os -from typing import Callable - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient - - -def run_sample(sample: Callable[[WebPubSubChatServiceClient], None], required: tuple[str, ...] = ()) -> None: - missing = [name for name in ("WPS_CHAT_CONNECTION_STRING", *required) if not os.environ.get(name)] - if missing: - print(f"Set {', '.join(missing)} to run this sample.") - return - - with WebPubSubChatServiceClient.from_connection_string( - os.environ["WPS_CHAT_CONNECTION_STRING"], - os.environ.get("WPS_CHAT_HUB", "test_hub"), - ) as client: - sample(client) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_role.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_role.py index f1cd954c8bd2..f583cd2f7dba 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_role.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_role.py @@ -4,20 +4,13 @@ # -------------------------------------------------------------------------- """Create or replace a sample-specific room role. Existing permissions are replaced.""" -import os - from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient from azure.messaging.webpubsubchatservice.models import ChatPermission, ChatRoleCreateOrReplace -from _shared import run_sample def sample(client: WebPubSubChatServiceClient) -> None: role = client.create_or_replace_role( - os.environ["WPS_CHAT_ROLE_NAME"], + "room.sample", ChatRoleCreateOrReplace(permissions=[ChatPermission.ROOM_HISTORY, ChatPermission.ROOM_PUBLISH_MESSAGE]), ) print(role.name, role.permissions) - - -if __name__ == "__main__": - run_sample(sample, ("WPS_CHAT_ROLE_NAME",)) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_room.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_room.py index 3b651bcb7a12..110ba2d7dc7a 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_room.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_room.py @@ -4,17 +4,10 @@ # -------------------------------------------------------------------------- """Create or replace a sample-specific room.""" -import os - from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient from azure.messaging.webpubsubchatservice.models import ChatRoomCreateOrReplace -from _shared import run_sample def sample(client: WebPubSubChatServiceClient) -> None: - room = client.create_or_replace_room(os.environ["WPS_CHAT_ROOM_ID"], ChatRoomCreateOrReplace(title="Sample room")) + room = client.create_or_replace_room("sample-room", ChatRoomCreateOrReplace(title="Sample room")) print(room.id, room.title, room.default_conversation) - - -if __name__ == "__main__": - run_sample(sample, ("WPS_CHAT_ROOM_ID",)) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_room_member.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_room_member.py index cbf1cf73d44e..02a7a0eed05d 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_room_member.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_room_member.py @@ -4,21 +4,14 @@ # -------------------------------------------------------------------------- """Add an existing user to a room, or replace their room role.""" -import os - from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient from azure.messaging.webpubsubchatservice.models import ChatRoomMemberCreateOrReplace -from _shared import run_sample def sample(client: WebPubSubChatServiceClient) -> None: member = client.create_or_replace_room_member( - os.environ["WPS_CHAT_ROOM_ID"], - os.environ["WPS_CHAT_USER_ID"], - ChatRoomMemberCreateOrReplace(role_name=os.environ["WPS_CHAT_ROOM_ROLE_NAME"]), + "sample-room", + "sample-user", + ChatRoomMemberCreateOrReplace(role_name="room.member"), ) print(member.user_id, member.role_name) - - -if __name__ == "__main__": - run_sample(sample, ("WPS_CHAT_ROOM_ID", "WPS_CHAT_USER_ID", "WPS_CHAT_ROOM_ROLE_NAME")) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_topic.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_topic.py index 30d5d752172d..494718e7de3c 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_topic.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_topic.py @@ -4,21 +4,14 @@ # -------------------------------------------------------------------------- """Create or replace a sample-specific topic in an existing room.""" -import os - from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient from azure.messaging.webpubsubchatservice.models import ChatTopicCreateOrReplace -from _shared import run_sample def sample(client: WebPubSubChatServiceClient) -> None: topic = client.create_or_replace_topic( - os.environ["WPS_CHAT_ROOM_ID"], - os.environ["WPS_CHAT_TOPIC_ID"], + "sample-room", + "sample-topic", ChatTopicCreateOrReplace(title="Sample topic"), ) print(topic.id, topic.conversation_id, topic.etag) - - -if __name__ == "__main__": - run_sample(sample, ("WPS_CHAT_ROOM_ID", "WPS_CHAT_TOPIC_ID")) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_user.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_user.py index 54f44f90842d..1e2ab499c80e 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_user.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_user.py @@ -4,20 +4,13 @@ # -------------------------------------------------------------------------- """Create or replace a sample-specific human user with an existing user role.""" -import os - from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient from azure.messaging.webpubsubchatservice.models import HumanChatUserCreateOrReplace -from _shared import run_sample def sample(client: WebPubSubChatServiceClient) -> None: user = client.create_or_replace_user( - os.environ["WPS_CHAT_USER_ID"], - HumanChatUserCreateOrReplace(nickname="Sample user", role_name=os.environ["WPS_CHAT_USER_ROLE_NAME"]), + "sample-user", + HumanChatUserCreateOrReplace(nickname="Sample user", role_name="user.member"), ) print(user.id, user.kind) - - -if __name__ == "__main__": - run_sample(sample, ("WPS_CHAT_USER_ID", "WPS_CHAT_USER_ROLE_NAME")) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_message.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_message.py deleted file mode 100644 index d2c01e3c3e57..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_message.py +++ /dev/null @@ -1,18 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------- -"""Delete a sample-specific persisted message.""" - -import os - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient -from _shared import run_sample - - -def sample(client: WebPubSubChatServiceClient) -> None: - client.delete_message(os.environ["WPS_CHAT_CONVERSATION_ID"], os.environ["WPS_CHAT_MESSAGE_ID"]) - - -if __name__ == "__main__": - run_sample(sample, ("WPS_CHAT_CONVERSATION_ID", "WPS_CHAT_MESSAGE_ID")) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_role.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_role.py deleted file mode 100644 index 4e79e6966db6..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_role.py +++ /dev/null @@ -1,18 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------- -"""Delete a sample-specific role. Do not target a role used by your application.""" - -import os - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient -from _shared import run_sample - - -def sample(client: WebPubSubChatServiceClient) -> None: - client.delete_role(os.environ["WPS_CHAT_ROLE_NAME"]) - - -if __name__ == "__main__": - run_sample(sample, ("WPS_CHAT_ROLE_NAME",)) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_room.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_room.py deleted file mode 100644 index 1b03f68d3ffa..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_room.py +++ /dev/null @@ -1,18 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------- -"""Delete a sample-specific room. Review the target room before running.""" - -import os - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient -from _shared import run_sample - - -def sample(client: WebPubSubChatServiceClient) -> None: - client.delete_room(os.environ["WPS_CHAT_ROOM_ID"]) - - -if __name__ == "__main__": - run_sample(sample, ("WPS_CHAT_ROOM_ID",)) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_room_member.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_room_member.py deleted file mode 100644 index 102dbf9ab4dc..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_room_member.py +++ /dev/null @@ -1,18 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------- -"""Remove an existing user from a sample-specific room.""" - -import os - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient -from _shared import run_sample - - -def sample(client: WebPubSubChatServiceClient) -> None: - client.delete_room_member(os.environ["WPS_CHAT_ROOM_ID"], os.environ["WPS_CHAT_USER_ID"]) - - -if __name__ == "__main__": - run_sample(sample, ("WPS_CHAT_ROOM_ID", "WPS_CHAT_USER_ID")) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_topic.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_topic.py deleted file mode 100644 index 6c714524d3d9..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_topic.py +++ /dev/null @@ -1,24 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------- -"""Soft delete a topic only if the supplied ETag still matches.""" - -import os - -from azure.core import MatchConditions -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient -from _shared import run_sample - - -def sample(client: WebPubSubChatServiceClient) -> None: - client.delete_topic( - os.environ["WPS_CHAT_ROOM_ID"], - os.environ["WPS_CHAT_TOPIC_ID"], - etag=os.environ["WPS_CHAT_TOPIC_ETAG"], - match_condition=MatchConditions.IfNotModified, - ) - - -if __name__ == "__main__": - run_sample(sample, ("WPS_CHAT_ROOM_ID", "WPS_CHAT_TOPIC_ID", "WPS_CHAT_TOPIC_ETAG")) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_user.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_user.py deleted file mode 100644 index 9bcb750834a2..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_user.py +++ /dev/null @@ -1,18 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------- -"""Delete a sample-specific user. Do not target an active application user.""" - -import os - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient -from _shared import run_sample - - -def sample(client: WebPubSubChatServiceClient) -> None: - client.delete_user(os.environ["WPS_CHAT_USER_ID"]) - - -if __name__ == "__main__": - run_sample(sample, ("WPS_CHAT_USER_ID",)) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_conversation.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_conversation.py deleted file mode 100644 index 4f39b27041af..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_conversation.py +++ /dev/null @@ -1,19 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------- -"""Read a room's default conversation or a topic's conversation.""" - -import os - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient -from _shared import run_sample - - -def sample(client: WebPubSubChatServiceClient) -> None: - conversation = client.get_conversation(os.environ["WPS_CHAT_CONVERSATION_ID"]) - print(conversation.id, conversation.parent_room) - - -if __name__ == "__main__": - run_sample(sample, ("WPS_CHAT_CONVERSATION_ID",)) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_role.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_role.py deleted file mode 100644 index 8bdbb1e39da5..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_role.py +++ /dev/null @@ -1,19 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------- -"""Read an existing role.""" - -import os - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient -from _shared import run_sample - - -def sample(client: WebPubSubChatServiceClient) -> None: - role = client.get_role(os.environ["WPS_CHAT_ROLE_NAME"]) - print(role.name, role.permissions) - - -if __name__ == "__main__": - run_sample(sample, ("WPS_CHAT_ROLE_NAME",)) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_room.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_room.py deleted file mode 100644 index 49c4629c01f6..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_room.py +++ /dev/null @@ -1,19 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------- -"""Read an existing room and its default conversation ID.""" - -import os - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient -from _shared import run_sample - - -def sample(client: WebPubSubChatServiceClient) -> None: - room = client.get_room(os.environ["WPS_CHAT_ROOM_ID"]) - print(room.id, room.title, room.default_conversation) - - -if __name__ == "__main__": - run_sample(sample, ("WPS_CHAT_ROOM_ID",)) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_topic.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_topic.py deleted file mode 100644 index d2fe0fa9b379..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_topic.py +++ /dev/null @@ -1,19 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------- -"""Read a topic and the ETag used for a conditional update or delete.""" - -import os - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient -from _shared import run_sample - - -def sample(client: WebPubSubChatServiceClient) -> None: - topic = client.get_topic(os.environ["WPS_CHAT_ROOM_ID"], os.environ["WPS_CHAT_TOPIC_ID"]) - print(topic.id, topic.title, topic.state, topic.etag) - - -if __name__ == "__main__": - run_sample(sample, ("WPS_CHAT_ROOM_ID", "WPS_CHAT_TOPIC_ID")) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_user.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_user.py deleted file mode 100644 index ae2e802c7c6b..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_get_user.py +++ /dev/null @@ -1,19 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------- -"""Read an existing user.""" - -import os - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient -from _shared import run_sample - - -def sample(client: WebPubSubChatServiceClient) -> None: - user = client.get_user(os.environ["WPS_CHAT_USER_ID"]) - print(user.id, user.kind) - - -if __name__ == "__main__": - run_sample(sample, ("WPS_CHAT_USER_ID",)) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_messages.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_messages.py deleted file mode 100644 index 172006071270..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_messages.py +++ /dev/null @@ -1,19 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------- -"""Iterate persisted messages from an existing conversation.""" - -import os - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient -from _shared import run_sample - - -def sample(client: WebPubSubChatServiceClient) -> None: - for message in client.list_messages(os.environ["WPS_CHAT_CONVERSATION_ID"]): - print(message.id, message.created_by, message.content) - - -if __name__ == "__main__": - run_sample(sample, ("WPS_CHAT_CONVERSATION_ID",)) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_roles.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_roles.py deleted file mode 100644 index c94007b91039..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_roles.py +++ /dev/null @@ -1,17 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------- -"""Iterate roles, allowing the SDK to fetch subsequent pages.""" - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient -from _shared import run_sample - - -def sample(client: WebPubSubChatServiceClient) -> None: - for role in client.list_roles(): - print(role.name, role.permissions) - - -if __name__ == "__main__": - run_sample(sample) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_room_members.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_room_members.py deleted file mode 100644 index 2344525f35a7..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_room_members.py +++ /dev/null @@ -1,19 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------- -"""Iterate the members of an existing room.""" - -import os - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient -from _shared import run_sample - - -def sample(client: WebPubSubChatServiceClient) -> None: - for member in client.list_room_members(os.environ["WPS_CHAT_ROOM_ID"]): - print(member.user_id, member.role_name) - - -if __name__ == "__main__": - run_sample(sample, ("WPS_CHAT_ROOM_ID",)) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_rooms.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_rooms.py deleted file mode 100644 index 6173f611e15c..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_rooms.py +++ /dev/null @@ -1,17 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------- -"""Iterate rooms with a requested page size.""" - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient -from _shared import run_sample - - -def sample(client: WebPubSubChatServiceClient) -> None: - for room in client.list_rooms(max_page_size=10): - print(room.id, room.title) - - -if __name__ == "__main__": - run_sample(sample) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_rooms_for_user.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_rooms_for_user.py deleted file mode 100644 index aa36d7c13413..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_rooms_for_user.py +++ /dev/null @@ -1,19 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------- -"""Iterate rooms associated with an existing user.""" - -import os - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient -from _shared import run_sample - - -def sample(client: WebPubSubChatServiceClient) -> None: - for room in client.list_rooms_for_user(os.environ["WPS_CHAT_USER_ID"]): - print(room.id, room.title) - - -if __name__ == "__main__": - run_sample(sample, ("WPS_CHAT_USER_ID",)) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_topics.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_topics.py deleted file mode 100644 index 84d9f088455c..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_topics.py +++ /dev/null @@ -1,19 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------- -"""Iterate the topics in an existing room.""" - -import os - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient -from _shared import run_sample - - -def sample(client: WebPubSubChatServiceClient) -> None: - for topic in client.list_topics(os.environ["WPS_CHAT_ROOM_ID"], max_page_size=10): - print(topic.id, topic.title, topic.conversation_id) - - -if __name__ == "__main__": - run_sample(sample, ("WPS_CHAT_ROOM_ID",)) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_users.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_users.py deleted file mode 100644 index 329ef54c1529..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_list_users.py +++ /dev/null @@ -1,17 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------- -"""Iterate users with a requested page size.""" - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient -from _shared import run_sample - - -def sample(client: WebPubSubChatServiceClient) -> None: - for user in client.list_users(max_page_size=10): - print(user.id, user.kind) - - -if __name__ == "__main__": - run_sample(sample) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_request_body_styles.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_request_body_styles.py new file mode 100644 index 000000000000..545db992c146 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_request_body_styles.py @@ -0,0 +1,31 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Three equivalent ways to add an existing user to a room with an existing room role. + +Each function accepts an authenticated client. Adapt the example identifiers +before calling one of the functions; all three create or replace the same membership. +""" + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient, models, types + + +def model_based(client: WebPubSubChatServiceClient) -> None: + member = client.create_or_replace_room_member( + "sample-room", + "sample-user", + models.ChatRoomMemberCreateOrReplace(role_name="room.member"), + ) + print(member.user_id, member.role_name) + + +def typed_dictionary(client: WebPubSubChatServiceClient) -> None: + resource: types.ChatRoomMemberCreateOrReplace = {"roleName": "room.member"} + member = client.create_or_replace_room_member("sample-room", "sample-user", resource) + print(member.user_id, member.role_name) + + +def plain_dictionary(client: WebPubSubChatServiceClient) -> None: + member = client.create_or_replace_room_member("sample-room", "sample-user", {"roleName": "room.member"}) + print(member.user_id, member.role_name) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_update_message.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_update_message.py index 9608a72997f8..035ee1afbdde 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_update_message.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_update_message.py @@ -4,21 +4,14 @@ # -------------------------------------------------------------------------- """Update the content of a sample-specific persisted message.""" -import os - from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient from azure.messaging.webpubsubchatservice.models import ChatMessageUpdate, MessageContent -from _shared import run_sample def sample(client: WebPubSubChatServiceClient) -> None: message = client.update_message( - os.environ["WPS_CHAT_CONVERSATION_ID"], - os.environ["WPS_CHAT_MESSAGE_ID"], + "c.sample-room.sample-topic", + "123456789", ChatMessageUpdate(content=MessageContent(text="Updated sample message")), ) print(message.id, message.content) - - -if __name__ == "__main__": - run_sample(sample, ("WPS_CHAT_CONVERSATION_ID", "WPS_CHAT_MESSAGE_ID")) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_update_topic.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_update_topic.py index 185efd2641dd..7b5a2bf5adaf 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_update_topic.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_update_topic.py @@ -2,26 +2,20 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------- -"""Archive a topic only if the supplied ETag still matches; leave its title unchanged.""" - -import os +"""Archive an existing topic only if it has not changed since it was read.""" from azure.core import MatchConditions from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient from azure.messaging.webpubsubchatservice.models import ChatTopicState, ChatTopicUpdate -from _shared import run_sample def sample(client: WebPubSubChatServiceClient) -> None: + current = client.get_topic("sample-room", "sample-topic") topic = client.update_topic( - os.environ["WPS_CHAT_ROOM_ID"], - os.environ["WPS_CHAT_TOPIC_ID"], + "sample-room", + "sample-topic", ChatTopicUpdate(state=ChatTopicState.ARCHIVED), - etag=os.environ["WPS_CHAT_TOPIC_ETAG"], + etag=current.etag, match_condition=MatchConditions.IfNotModified, ) print(topic.id, topic.state, topic.etag) - - -if __name__ == "__main__": - run_sample(sample, ("WPS_CHAT_ROOM_ID", "WPS_CHAT_TOPIC_ID", "WPS_CHAT_TOPIC_ETAG")) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_operation_samples.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_operation_samples.py index fac9b80f9560..5b815e5675a6 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_operation_samples.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_operation_samples.py @@ -4,9 +4,7 @@ # -------------------------------------------------------------------------- import ast import importlib.util -import os from pathlib import Path -import runpy from types import SimpleNamespace from unittest.mock import Mock @@ -18,26 +16,13 @@ PACKAGE = Path(__file__).resolve().parents[1] SAMPLES = PACKAGE / "samples" -OPERATIONS = sorted(path.stem for path in (PACKAGE / "generated_samples").glob("*.py")) -ENVIRONMENT = { - "WPS_CHAT_ROLE_NAME": "room.sample", - "WPS_CHAT_ROOM_ID": "sample-room", - "WPS_CHAT_USER_ID": "sample-user", - "WPS_CHAT_USER_ROLE_NAME": "user.member", - "WPS_CHAT_ROOM_ROLE_NAME": "room.member", - "WPS_CHAT_TOPIC_ID": "sample-topic", - "WPS_CHAT_TOPIC_ETAG": '"sample-etag"', - "WPS_CHAT_CONVERSATION_ID": "c.sample-room.sample-topic", - "WPS_CHAT_MESSAGE_ID": "sample-message", -} IDENTIFIERS = { "role": ("room.sample",), "room": ("sample-room",), "room_member": ("sample-room", "sample-user"), "user": ("sample-user",), "topic": ("sample-room", "sample-topic"), - "conversation": ("c.sample-room.sample-topic",), - "message": ("c.sample-room.sample-topic", "sample-message"), + "message": ("c.sample-room.sample-topic", "123456789"), } REQUESTS = { "create_or_replace_role": ( @@ -56,21 +41,17 @@ } -@pytest.fixture -def sample_imports(monkeypatch): - monkeypatch.syspath_prepend(str(SAMPLES)) - - -@pytest.mark.parametrize("operation", OPERATIONS) -def test_operation_sample_uses_matching_method_and_models(operation, monkeypatch, sample_imports): - for name, value in ENVIRONMENT.items(): - monkeypatch.setenv(name, value) - path = SAMPLES / f"sample_{operation}.py" - spec = importlib.util.spec_from_file_location(f"operation_sample_{operation}", path) +def _load_sample(name): + path = SAMPLES / f"{name}.py" + spec = importlib.util.spec_from_file_location(name, path) assert spec and spec.loader module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) + return module + + +def _client(): client = Mock(spec=WebPubSubChatServiceClient) response = SimpleNamespace( id="result", @@ -82,91 +63,65 @@ def test_operation_sample_uses_matching_method_and_models(operation, monkeypatch role_name="room.member", kind="Human", conversation_id="conversation", - etag='"etag"', + etag='"sample-etag"', state="Archived", parent_room="sample-room", created_by="sample-user", content=None, ) - method = getattr(client, operation) - method.return_value = [response] if operation.startswith("list_") else response + for operation in (*REQUESTS, "get_topic"): + getattr(client, operation).return_value = response + return client + + +@pytest.mark.parametrize("operation", REQUESTS) +def test_operation_sample_uses_matching_method_and_models(operation): + module = _load_sample(f"sample_{operation}") + client = _client() module.sample(client) - assert len(client.method_calls) == 1 + expected_calls = ["get_topic", operation] if operation == "update_topic" else [operation] + assert [call[0] for call in client.method_calls] == expected_calls + method = getattr(client, operation) method.assert_called_once() args = method.call_args.args - if operation == "list_rooms_for_user": - assert args == ("sample-user",) - elif operation == "list_room_members": - assert args == ("sample-room",) - elif operation in ("list_topics", "list_messages"): - assert args == (ENVIRONMENT["WPS_CHAT_ROOM_ID" if operation == "list_topics" else "WPS_CHAT_CONVERSATION_ID"],) - elif operation.startswith("list_"): - assert args == () - else: - entity = ( - operation.removeprefix("create_or_replace_") - .removeprefix("get_") - .removeprefix("delete_") - .removeprefix("update_") - ) - expected_ids = IDENTIFIERS[entity] - assert args[: len(expected_ids)] == expected_ids - if operation in REQUESTS: - request_type, expected_json = REQUESTS[operation] - assert isinstance(args[-1], request_type) - assert args[-1].as_dict() == expected_json - if operation in ("update_topic", "delete_topic"): + entity = operation.removeprefix("create_or_replace_").removeprefix("update_") + expected_ids = IDENTIFIERS[entity] + assert args[: len(expected_ids)] == expected_ids + request_type, expected_json = REQUESTS[operation] + assert isinstance(args[-1], request_type) + assert args[-1].as_dict() == expected_json + if operation == "update_topic": + client.get_topic.assert_called_once_with(*expected_ids) assert method.call_args.kwargs == { "etag": '"sample-etag"', "match_condition": MatchConditions.IfNotModified, } -@pytest.mark.parametrize("operation", OPERATIONS) -def test_operation_sample_skips_without_configuration(operation, monkeypatch, sample_imports, capsys): - for name in list(os.environ): - if name.startswith("WPS_CHAT_"): - monkeypatch.delenv(name) - create = Mock(side_effect=AssertionError("Samples without configuration must not create a client")) - monkeypatch.setattr(WebPubSubChatServiceClient, "from_connection_string", create) - runpy.run_path(str(SAMPLES / f"sample_{operation}.py"), run_name="__main__") - create.assert_not_called() - assert "WPS_CHAT_CONNECTION_STRING" in capsys.readouterr().out - - def test_operation_sample_coverage(): - assert len(OPERATIONS) == 25 - assert all((SAMPLES / f"sample_{operation}.py").is_file() for operation in OPERATIONS) - - -def test_sample_runner_validates_resource_ids(monkeypatch, sample_imports, capsys): - from _shared import run_sample - - monkeypatch.setenv("WPS_CHAT_CONNECTION_STRING", "not-used") - monkeypatch.delenv("WPS_CHAT_ROOM_ID", raising=False) - create = Mock(side_effect=AssertionError("Missing identifiers must not create a client")) - monkeypatch.setattr(WebPubSubChatServiceClient, "from_connection_string", create) - run_sample(Mock(), ("WPS_CHAT_ROOM_ID",)) - create.assert_not_called() - assert "WPS_CHAT_ROOM_ID" in capsys.readouterr().out - - -def test_sample_runner_closes_client_and_propagates_errors(monkeypatch, sample_imports): - from _shared import run_sample - - monkeypatch.setenv("WPS_CHAT_CONNECTION_STRING", "not-a-real-connection-string") - monkeypatch.delenv("WPS_CHAT_HUB", raising=False) - manager = Mock() - manager.__enter__ = Mock(return_value=Mock(spec=WebPubSubChatServiceClient)) - manager.__exit__ = Mock(return_value=False) - create = Mock(return_value=manager) - monkeypatch.setattr(WebPubSubChatServiceClient, "from_connection_string", create) - callback = Mock(side_effect=ValueError("Sample error")) - with pytest.raises(ValueError, match="Sample error"): - run_sample(callback) - create.assert_called_once_with("not-a-real-connection-string", "test_hub") - callback.assert_called_once_with(manager.__enter__.return_value) - manager.__exit__.assert_called_once() + body_operations = { + path.stem + for path in (PACKAGE / "generated_samples").glob("*.py") + if path.stem.startswith(("create_or_replace_", "update_")) + } + assert set(REQUESTS) == body_operations + assert all((SAMPLES / f"sample_{operation}.py").is_file() for operation in body_operations) + + +@pytest.mark.parametrize("style", ["model_based", "typed_dictionary", "plain_dictionary"]) +def test_request_body_styles_are_equivalent(style): + module = _load_sample("sample_request_body_styles") + client = _client() + getattr(module, style)(client) + client.create_or_replace_room_member.assert_called_once() + room_id, user_id, body = client.create_or_replace_room_member.call_args.args + assert (room_id, user_id) == ("sample-room", "sample-user") + if style == "model_based": + assert isinstance(body, models.ChatRoomMemberCreateOrReplace) + body = body.as_dict() + else: + assert isinstance(body, dict) + assert body == {"roleName": "room.member"} def test_generated_topic_put_example_serializes_replace_state(): diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_request_models.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_request_models.py index 117fc54566a9..4377cdf9655e 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_request_models.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_request_models.py @@ -2,6 +2,11 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------- +"""Runtime tests for lifecycle visibility and serialized HTTP requests. + +Static overload and invalid-input checks live in typing/request_models.py. +""" + # cspell:ignore kwonlyargs import ast import inspect diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/typing/request_models.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/typing/request_models.py index 3be4fd105bdd..5c22a9b21654 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/typing/request_models.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/typing/request_models.py @@ -2,6 +2,15 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------- +"""Static type-checking fixture, not an executable test or customer sample. + +From the package directory, run: +python -m mypy --python-version 3.10 --ignore-missing-imports --warn-unused-ignores tests/typing/request_models.py + +The negative cases must remain type errors; warn-unused-ignores detects them +becoming incorrectly accepted. Runtime request tests live in test_request_models.py. +""" + from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient, models, types from azure.messaging.webpubsubchatservice.aio import WebPubSubChatServiceClient as AsyncClient From acff5e7372c00d27e3ddc77eba96a00478fb9f69 Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Thu, 22 Oct 2026 17:27:29 +1100 Subject: [PATCH 17/22] Clarify Chat README examples and use resource placeholders Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../README.md | 145 +++++++----------- .../samples/README.md | 4 +- .../samples/sample_errors.py | 3 +- .../samples/sample_message_management.py | 14 +- .../samples/sample_readme_snippets.py | 35 ++--- .../samples/sample_roles_and_permissions.py | 2 +- .../sample_roles_and_permissions_async.py | 2 +- 7 files changed, 78 insertions(+), 127 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md index fa5fda00d284..d0288b2cf7be 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md @@ -17,8 +17,7 @@ Use this client library in an application server to: | [Package (PyPI)][package] | [API reference documentation][api_reference] | [Product documentation][product_docs] -| [Model-based samples][samples] -| [Dictionary-based samples][generated_samples] +| [Examples](#examples) | [Changelog][changelog] ## Getting started @@ -109,12 +108,6 @@ For more information, see [Authenticate Azure-hosted Python applications][azure_ ## 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. The client can be used as a context manager and is safe to reuse for multiple operations. - -The asynchronous client is available from the `azure.messaging.webpubsubchatservice.aio` namespace. - ### Hub A hub is a logical collection of WebSocket connections. A chat hub adds built-in rooms, member management, message persistence, and chat-specific APIs. @@ -150,33 +143,38 @@ Messages sent to a conversation are delivered in real time to the room's connect 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. -### Request models and dictionaries +## Examples + +The async snippet +uses a client from `azure.messaging.webpubsubchatservice.aio`. +Replace placeholders such as `` with your application's resource identifiers. + +### Request-body styles You can supply a JSON request body in three ways: - **Model-based:** use classes from `azure.messaging.webpubsubchatservice.models` with Python-style attributes and SDK-managed serialization. - **Typed dictionary:** use the `TypedDict` definitions from - `azure.messaging.webpubsubchatservice.types` for static checking of JSON-shaped dictionaries. + `azure.messaging.webpubsubchatservice.types` for static checking of dictionaries + that use JSON field names. - **Plain dictionary:** pass a dictionary using JSON field names. Model-based usage is recommended for getting started and is used throughout the examples below. Dictionaries are useful when your application already works with JSON-shaped data. All three styles call the same client methods; typed dictionaries -are ordinary dictionaries at runtime. See the -[sample guide](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md#request-body-styles) +are ordinary dictionaries at runtime and do not add runtime validation. See the +[examples guide](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md#request-body-styles) for a comparison and examples of each style. -## Examples - -The following sections show common scenarios. Each operation snippet assumes an -authenticated `client`, created as shown in Getting started. The async snippet -uses a client from `azure.messaging.webpubsubchatservice.aio`. -See the [package samples][samples] for complete synchronous and asynchronous programs. +Explore the examples: -The examples below use model instances for request bodies. See the -[sample guide and complete operation index](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md) -for more request-body styles and examples of every service operation. +- [Model-based and scenario examples][examples], including complete synchronous and + asynchronous programs. +- [Dictionary-based operation examples][generated_examples], generated from the + specification's examples. +- [Complete operation index](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md#complete-operation-index), + linking to model-based and generated examples for each service operation. ### Generate client access credentials @@ -204,7 +202,7 @@ return resource models such as `ChatRole`, `ChatRoom`, and `ChatTopic`, which include service-assigned identifiers and ETags. Use the `ChatRoleCreateOrReplace` model and `ChatPermission` enum instead of a dictionary with -permission string literals. This example assumes `os` is imported. +permission string literals. @@ -212,7 +210,7 @@ permission string literals. This example assumes `os` is imported. from azure.messaging.webpubsubchatservice.models import ChatPermission, ChatRoleCreateOrReplace role = client.create_or_replace_role( - os.environ.get("WPS_CHAT_ROLE_NAME", "user.python_sample"), + "user.example", ChatRoleCreateOrReplace(permissions=[ChatPermission.USER_CREATE_ROOM]), ) print(role.name, role.permissions) @@ -220,10 +218,10 @@ print(role.name, role.permissions) -See [sample_roles_and_permissions.py](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions.py) -and [sample_roles_and_permissions_async.py](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions_async.py) +See the [synchronous role example](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions.py) +and [asynchronous role example](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions_async.py) for runnable model-and-enum examples. The selected role is created or replaced -and remains in the hub; these samples do not create users or rooms. +and remains in the hub; these examples do not create users or rooms. ### List roles @@ -288,14 +286,12 @@ print(member.user_id, member.role_name) ### List persisted messages -Set `WPS_CHAT_CONVERSATION_ID` to an existing conversation ID. +Replace `` with an existing conversation ID. ```python -import os - -for message in client.list_messages(os.environ["WPS_CHAT_CONVERSATION_ID"]): +for message in client.list_messages(""): print(message.id, message.created_by, message.content.text) ``` @@ -303,8 +299,7 @@ for message in client.list_messages(os.environ["WPS_CHAT_CONVERSATION_ID"]): ### Manage room topics -These examples use an existing room identified by `WPS_CHAT_ROOM_ID` and a -topic ID specified by `WPS_CHAT_TOPIC_ID`. +Replace `` with an existing room ID and `` with the topic ID. #### Create a topic @@ -317,12 +312,11 @@ Omit `state` when creating a topic. ```python -import os from azure.messaging.webpubsubchatservice.models import ChatTopicCreateOrReplace topic = client.create_or_replace_topic( - os.environ["WPS_CHAT_ROOM_ID"], - os.environ["WPS_CHAT_TOPIC_ID"], + "", + "", ChatTopicCreateOrReplace(title="Announcements"), ) print(topic.id, topic.etag) @@ -335,9 +329,7 @@ print(topic.id, topic.etag) ```python -import os - -for topic in client.list_topics(os.environ["WPS_CHAT_ROOM_ID"], max_page_size=10): +for topic in client.list_topics("", max_page_size=10): print(topic.id, topic.title, topic.conversation_id) ``` @@ -348,9 +340,7 @@ for topic in client.list_topics(os.environ["WPS_CHAT_ROOM_ID"], max_page_size=10 ```python -import os - -topic = client.get_topic(os.environ["WPS_CHAT_ROOM_ID"], os.environ["WPS_CHAT_TOPIC_ID"]) +topic = client.get_topic("", "") print(topic.id, topic.title, topic.state, topic.etag) ``` @@ -358,22 +348,21 @@ print(topic.id, topic.title, topic.state, topic.etag) #### Archive a topic -Set `WPS_CHAT_TOPIC_ETAG` to the ETag returned by a previous create or get -operation. The update below changes only `state`; the existing title is left +Replace `` with the ETag returned by a previous create or get +operation, preserving its quotes. The update below changes only `state`; the existing title is left unchanged. To change only the title, use `ChatTopicUpdate(title="New title")`. ```python -import os from azure.core import MatchConditions from azure.messaging.webpubsubchatservice.models import ChatTopicUpdate, ChatTopicState topic = client.update_topic( - os.environ["WPS_CHAT_ROOM_ID"], - os.environ["WPS_CHAT_TOPIC_ID"], + "", + "", ChatTopicUpdate(state=ChatTopicState.ARCHIVED), - etag=os.environ["WPS_CHAT_TOPIC_ETAG"], + etag='""', match_condition=MatchConditions.IfNotModified, ) print(topic.id, topic.state, topic.etag) @@ -383,18 +372,17 @@ print(topic.id, topic.state, topic.etag) #### Soft delete a topic -Set `WPS_CHAT_TOPIC_ETAG` to the current ETag, including any change from an update. +Replace `` with the current ETag, including any change from an update. ```python -import os from azure.core import MatchConditions client.delete_topic( - os.environ["WPS_CHAT_ROOM_ID"], - os.environ["WPS_CHAT_TOPIC_ID"], - etag=os.environ["WPS_CHAT_TOPIC_ETAG"], + "", + "", + etag='""', match_condition=MatchConditions.IfNotModified, ) ``` @@ -407,7 +395,7 @@ For conditional updates and deletes, pass the current ETag with `MatchConditions.IfNotModified`. A stale ETag prevents overwriting a topic that another caller has changed. Deleting a topic is a soft delete. -For individual API calls, see the generated samples for +For individual API calls, see the generated examples for [create or replace](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_topic.py), [list](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_topics.py), [get](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_topic.py), [update](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/update_topic.py), and @@ -439,14 +427,12 @@ for user in client.list_users(max_page_size=10): #### List rooms for a user -Set `WPS_CHAT_USER_ID` to an existing user ID. +Replace `` with an existing user ID. ```python -import os - -for room in client.list_rooms_for_user(os.environ["WPS_CHAT_USER_ID"]): +for room in client.list_rooms_for_user(""): print(room.id, room.title) ``` @@ -462,7 +448,7 @@ Collection iterators automatically fetch subsequent pages. ### Use the asynchronous client Run this snippet inside an async function with an authenticated async `client`; see -[sample_client_access_async.py](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_client_access_async.py) +[the asynchronous client access example](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_client_access_async.py) for the complete program. @@ -476,12 +462,12 @@ print(access["baseUrl"]) -### Run the samples +### Run the examples Set `WPS_CHAT_CONNECTION_STRING` and optionally `WPS_CHAT_HUB` (default: `test_hub`). -The role samples accept `WPS_CHAT_ROLE_NAME` (default: `user.python_sample`). -Use a role name reserved for the sample: an existing role with that name is -replaced. Install `aiohttp` to run async samples. +The role examples use `user.example`; replace it with a role name reserved for +the example. An existing role with that name is replaced. +Install `aiohttp` to run async examples. From the package directory, run, for example: @@ -496,18 +482,17 @@ python samples/sample_roles_and_permissions_async.py Service operations raise `HttpResponseError` or a more specific subclass when a request fails: -The [sample_errors.py](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_errors.py) example reads an existing role, -prints the status on failure, and re-raises the error. Set `WPS_CHAT_ROLE_NAME` -to the role to read (default: `user.python_sample`). +The [service error example](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_errors.py) reads an existing role, +prints the status on failure, and re-raises the error. Replace `user.example` +with the role name to read. ```python -import os from azure.core.exceptions import HttpResponseError try: - role = client.get_role(os.environ.get("WPS_CHAT_ROLE_NAME", "user.python_sample")) + role = client.get_role("user.example") print(role.name, role.permissions) except HttpResponseError as error: print(f"Chat service request failed with status {error.status_code}") @@ -548,20 +533,10 @@ with DefaultAzureCredential() as credential: HTTP logs can contain sensitive information. Do not enable detailed logging in production without reviewing how logs are collected and protected. For more information, see [Configure logging in the Azure SDK for Python][azure_sdk_logging]. -### 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. - -### Message history - -If a newly sent message does not appear immediately, confirm that the sending user is a room member with publish permission and that message history is enabled for the member's room role. - ## Next steps Explore the [README snippet sources](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_readme_snippets.py) and -[complete package samples][samples] to learn how to: +[complete package examples][examples] to learn how to: - Authenticate with a connection string, access key, or Microsoft Entra ID. - Manage roles, permissions, users, rooms, and room members. @@ -570,15 +545,7 @@ Explore the [README snippet sources](https://github.com/Azure/azure-sdk-for-pyth - Manage topic lifecycles and iterate over room and user collections. - Use synchronous and asynchronous clients. -See also the [dictionary-based operation samples][generated_samples], produced from the -specification's examples. Each file demonstrates one operation. Replace -`ENDPOINT`, `HUB`, and any example resource identifiers before running them, -and configure authentication as described in each file. These generated files -are refreshed during SDK generation. The README snippet source contains -independent functions, not a combined workflow or a standalone program. -The model-based operation examples accept an authenticated client and use example -resource identifiers that you can adapt. The scenario samples demonstrate -authentication, client access credentials, errors, and logging. +See also the [dictionary-based operation examples][generated_examples]. ## Additional resources @@ -598,8 +565,8 @@ This project has adopted the [Microsoft Open Source Code of Conduct][code_of_con [package]: https://pypi.org/project/azure-messaging-webpubsubchatservice/ [api_reference]: https://learn.microsoft.com/python/api/overview/azure/messaging-webpubsubchatservice-readme?view=azure-python-preview [product_docs]: https://learn.microsoft.com/azure/azure-web-pubsub/chat-overview -[samples]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples -[generated_samples]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples +[examples]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples +[generated_examples]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples [changelog]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md [azure_sub]: https://azure.microsoft.com/free/ [webpubsub_docs]: https://learn.microsoft.com/azure/azure-web-pubsub/ diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md index 61ae99aac615..6d0f6ea0a006 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md @@ -53,7 +53,9 @@ instances or paged models; their examples are not duplicated by input style. | [README snippet sources](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_readme_snippets.py) | Independent functions used by the README, not a standalone program. | For runnable scenario samples, follow the environment-variable instructions -in each file and the [README run instructions](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md#run-the-samples). +in each file and the [README run instructions](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md#run-the-examples). +Replace resource ID placeholders such as `` and `` +with existing resource identifiers before running the examples. Some samples create, replace, or delete resources; use sample-specific identifiers and review each file before running it. diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_errors.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_errors.py index c87592a687b1..aea4f59ea7d3 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_errors.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_errors.py @@ -9,11 +9,10 @@ def handle_service_errors(client): # [START handle_service_errors] - import os from azure.core.exceptions import HttpResponseError try: - role = client.get_role(os.environ.get("WPS_CHAT_ROLE_NAME", "user.python_sample")) + role = client.get_role("user.example") print(role.name, role.permissions) except HttpResponseError as error: print(f"Chat service request failed with status {error.status_code}") diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_message_management.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_message_management.py index b6574cd274e1..451fcb2ac1a9 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_message_management.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_message_management.py @@ -9,22 +9,16 @@ def main(): - required = ( - "WPS_CHAT_CONNECTION_STRING", - "WPS_CHAT_CONVERSATION_ID", - "WPS_CHAT_MESSAGE_ID", - ) - missing = [name for name in required if not os.environ.get(name)] - if missing: - print(f"Set {', '.join(missing)} to run this sample.") + if not os.environ.get("WPS_CHAT_CONNECTION_STRING"): + print("Set WPS_CHAT_CONNECTION_STRING to run this example.") return with WebPubSubChatServiceClient.from_connection_string( os.environ["WPS_CHAT_CONNECTION_STRING"], os.environ.get("WPS_CHAT_HUB", "test_hub"), ) as client: - conversation_id = os.environ["WPS_CHAT_CONVERSATION_ID"] - message_id = os.environ["WPS_CHAT_MESSAGE_ID"] + conversation_id = "" + message_id = "" client.update_message( conversation_id, message_id, diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_readme_snippets.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_readme_snippets.py index 632d100536e5..f794f31ad937 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_readme_snippets.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_readme_snippets.py @@ -50,21 +50,18 @@ def add_room_member(client: WebPubSubChatServiceClient) -> None: def list_messages(client: WebPubSubChatServiceClient) -> None: # [START list_messages] - import os - - for message in client.list_messages(os.environ["WPS_CHAT_CONVERSATION_ID"]): + for message in client.list_messages(""): print(message.id, message.created_by, message.content.text) # [END list_messages] def create_topic(client: WebPubSubChatServiceClient) -> None: # [START create_topic] - import os from azure.messaging.webpubsubchatservice.models import ChatTopicCreateOrReplace topic = client.create_or_replace_topic( - os.environ["WPS_CHAT_ROOM_ID"], - os.environ["WPS_CHAT_TOPIC_ID"], + "", + "", ChatTopicCreateOrReplace(title="Announcements"), ) print(topic.id, topic.etag) @@ -73,33 +70,28 @@ def create_topic(client: WebPubSubChatServiceClient) -> None: def list_topics(client: WebPubSubChatServiceClient) -> None: # [START list_topics] - import os - - for topic in client.list_topics(os.environ["WPS_CHAT_ROOM_ID"], max_page_size=10): + for topic in client.list_topics("", max_page_size=10): print(topic.id, topic.title, topic.conversation_id) # [END list_topics] def get_topic(client: WebPubSubChatServiceClient) -> None: # [START get_topic] - import os - - topic = client.get_topic(os.environ["WPS_CHAT_ROOM_ID"], os.environ["WPS_CHAT_TOPIC_ID"]) + topic = client.get_topic("", "") print(topic.id, topic.title, topic.state, topic.etag) # [END get_topic] def archive_topic(client: WebPubSubChatServiceClient) -> None: # [START archive_topic] - import os from azure.core import MatchConditions from azure.messaging.webpubsubchatservice.models import ChatTopicUpdate, ChatTopicState topic = client.update_topic( - os.environ["WPS_CHAT_ROOM_ID"], - os.environ["WPS_CHAT_TOPIC_ID"], + "", + "", ChatTopicUpdate(state=ChatTopicState.ARCHIVED), - etag=os.environ["WPS_CHAT_TOPIC_ETAG"], + etag='""', match_condition=MatchConditions.IfNotModified, ) print(topic.id, topic.state, topic.etag) @@ -108,13 +100,12 @@ def archive_topic(client: WebPubSubChatServiceClient) -> None: def delete_topic(client: WebPubSubChatServiceClient) -> None: # [START delete_topic] - import os from azure.core import MatchConditions client.delete_topic( - os.environ["WPS_CHAT_ROOM_ID"], - os.environ["WPS_CHAT_TOPIC_ID"], - etag=os.environ["WPS_CHAT_TOPIC_ETAG"], + "", + "", + etag='""', match_condition=MatchConditions.IfNotModified, ) # [END delete_topic] @@ -136,9 +127,7 @@ def list_users(client: WebPubSubChatServiceClient) -> None: def list_rooms_for_user(client: WebPubSubChatServiceClient) -> None: # [START list_rooms_for_user] - import os - - for room in client.list_rooms_for_user(os.environ["WPS_CHAT_USER_ID"]): + for room in client.list_rooms_for_user(""): print(room.id, room.title) # [END list_rooms_for_user] diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions.py index eede3c81e9c3..7c688baa8c10 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions.py @@ -11,7 +11,7 @@ def create_role(client): from azure.messaging.webpubsubchatservice.models import ChatPermission, ChatRoleCreateOrReplace role = client.create_or_replace_role( - os.environ.get("WPS_CHAT_ROLE_NAME", "user.python_sample"), + "user.example", ChatRoleCreateOrReplace(permissions=[ChatPermission.USER_CREATE_ROOM]), ) print(role.name, role.permissions) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions_async.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions_async.py index 6f8906012343..b846520977c7 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions_async.py @@ -12,7 +12,7 @@ async def create_role(client): from azure.messaging.webpubsubchatservice.models import ChatPermission, ChatRoleCreateOrReplace role = await client.create_or_replace_role( - os.environ.get("WPS_CHAT_ROLE_NAME", "user.python_sample"), + "user.example", ChatRoleCreateOrReplace(permissions=[ChatPermission.USER_CREATE_ROOM]), ) print(role.name, role.permissions) From 3e0a2afd0e58af83379ea694e3a5e40ab5c9af29 Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Tue, 27 Oct 2026 14:12:15 +1100 Subject: [PATCH 18/22] Hide initial continuation tokens from Chat listing APIs Regenerate sync and async listing methods from TypeSpec customizations while preserving next-link paging and by_page resume support. Update API snapshots and paging regression tests, and pin the rebased specification including its shared customization module rename. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../CHANGELOG.md | 1 + .../api.md | 28 +--- .../api.metadata.yml | 2 +- .../apiview-properties.json | 2 +- .../_operations/_operations.py | 138 ++---------------- .../aio/_operations/_operations.py | 87 ++--------- .../tests/test_2026_08_01_preview.py | 105 +++++++++---- .../tsp-location.yaml | 2 +- 8 files changed, 116 insertions(+), 249 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md index 1acf0c28874d..a6bcf6d53d5f 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md @@ -13,6 +13,7 @@ ### Breaking Changes + - Removed the `continuation_token_parameter` argument from listing operations. Resume paging with `by_page(continuation_token=...)` on the returned `ItemPaged` or `AsyncItemPaged` instead. - Create or replace operations now accept dedicated `ChatRoleCreateOrReplace`, `ChatRoomCreateOrReplace`, `ChatRoomMemberCreateOrReplace`, and `ChatUserCreateOrReplace` (including `HumanChatUserCreateOrReplace`) request models instead of resource response models. - Message updates accept `ChatMessageUpdate`, whose fields are optional, instead of `ChatMessage`. Resource response model names are unchanged. diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md index 0ba29e8e48a1..2eed03d88047 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md @@ -340,7 +340,6 @@ namespace azure.messaging.webpubsubchatservice def list_roles( self, *, - continuation_token_parameter: Optional[str] = ..., max_page_size: Optional[int] = ..., **kwargs: Any ) -> ItemPaged[ChatRole]: ... @@ -350,49 +349,44 @@ namespace azure.messaging.webpubsubchatservice self, room_id: str, *, - continuation_token_parameter: Optional[str] = ..., max_page_size: Optional[int] = ..., **kwargs: Any ) -> ItemPaged[ChatRoomMember]: ... @distributed_trace - @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'max_page_size', 'continuation_token_parameter', 'accept']}, api_versions_list=['2026-08-01-preview']) + @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'max_page_size', 'accept']}, api_versions_list=['2026-08-01-preview']) def list_rooms( self, *, - continuation_token_parameter: Optional[str] = ..., max_page_size: Optional[int] = ..., **kwargs: Any ) -> ItemPaged[ChatRoom]: ... @distributed_trace - @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'user_id', 'max_page_size', 'continuation_token_parameter', 'accept']}, api_versions_list=['2026-08-01-preview']) + @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'user_id', 'max_page_size', 'accept']}, api_versions_list=['2026-08-01-preview']) def list_rooms_for_user( self, user_id: str, *, - continuation_token_parameter: Optional[str] = ..., max_page_size: Optional[int] = ..., **kwargs: Any ) -> ItemPaged[ChatUserRoom]: ... @distributed_trace - @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'room_id', 'max_page_size', 'continuation_token_parameter', 'accept']}, api_versions_list=['2026-08-01-preview']) + @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'room_id', 'max_page_size', 'accept']}, api_versions_list=['2026-08-01-preview']) def list_topics( self, room_id: str, *, - continuation_token_parameter: Optional[str] = ..., max_page_size: Optional[int] = ..., **kwargs: Any ) -> ItemPaged[ChatTopic]: ... @distributed_trace - @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'max_page_size', 'continuation_token_parameter', 'accept']}, api_versions_list=['2026-08-01-preview']) + @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'max_page_size', 'accept']}, api_versions_list=['2026-08-01-preview']) def list_users( self, *, - continuation_token_parameter: Optional[str] = ..., max_page_size: Optional[int] = ..., **kwargs: Any ) -> ItemPaged[ChatUser]: ... @@ -819,7 +813,6 @@ namespace azure.messaging.webpubsubchatservice.aio def list_roles( self, *, - continuation_token_parameter: Optional[str] = ..., max_page_size: Optional[int] = ..., **kwargs: Any ) -> AsyncItemPaged[ChatRole]: ... @@ -829,49 +822,44 @@ namespace azure.messaging.webpubsubchatservice.aio self, room_id: str, *, - continuation_token_parameter: Optional[str] = ..., max_page_size: Optional[int] = ..., **kwargs: Any ) -> AsyncItemPaged[ChatRoomMember]: ... @distributed_trace - @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'max_page_size', 'continuation_token_parameter', 'accept']}, api_versions_list=['2026-08-01-preview']) + @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'max_page_size', 'accept']}, api_versions_list=['2026-08-01-preview']) def list_rooms( self, *, - continuation_token_parameter: Optional[str] = ..., max_page_size: Optional[int] = ..., **kwargs: Any ) -> AsyncItemPaged[ChatRoom]: ... @distributed_trace - @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'user_id', 'max_page_size', 'continuation_token_parameter', 'accept']}, api_versions_list=['2026-08-01-preview']) + @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'user_id', 'max_page_size', 'accept']}, api_versions_list=['2026-08-01-preview']) def list_rooms_for_user( self, user_id: str, *, - continuation_token_parameter: Optional[str] = ..., max_page_size: Optional[int] = ..., **kwargs: Any ) -> AsyncItemPaged[ChatUserRoom]: ... @distributed_trace - @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'room_id', 'max_page_size', 'continuation_token_parameter', 'accept']}, api_versions_list=['2026-08-01-preview']) + @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'room_id', 'max_page_size', 'accept']}, api_versions_list=['2026-08-01-preview']) def list_topics( self, room_id: str, *, - continuation_token_parameter: Optional[str] = ..., max_page_size: Optional[int] = ..., **kwargs: Any ) -> AsyncItemPaged[ChatTopic]: ... @distributed_trace - @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'max_page_size', 'continuation_token_parameter', 'accept']}, api_versions_list=['2026-08-01-preview']) + @api_version_validation(method_added_on='2026-08-01-preview', params_added_on={'2026-08-01-preview': ['api_version', 'hub', 'max_page_size', 'accept']}, api_versions_list=['2026-08-01-preview']) def list_users( self, *, - continuation_token_parameter: Optional[str] = ..., max_page_size: Optional[int] = ..., **kwargs: Any ) -> AsyncItemPaged[ChatUser]: ... diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml index c64c6252f87c..f5ffb298528d 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml @@ -1,4 +1,4 @@ -apiMdSha256: f9e69641a04546543d07880f46f0686197a829554e669f6b4f285043b773e939 +apiMdSha256: de70ea75cfa4d03247454217b82c8f8e4b1bd9426cabcafc0b148c377528a184 packageVersion: 1.0.0b2 parserVersion: 0.3.31 pythonVersion: 3.12.10 diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json b/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json index b5c6f3cbaa22..45500121523b 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json @@ -73,5 +73,5 @@ "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.list_rooms_for_user": "WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser", "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.list_rooms_for_user": "WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser" }, - "CrossLanguageVersion": "e41a201baeb5" + "CrossLanguageVersion": "c8facae70120" } \ No newline at end of file diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_operations/_operations.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_operations/_operations.py index 42d86b965577..c53c94ff1b3b 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_operations/_operations.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_operations/_operations.py @@ -191,7 +191,7 @@ def build_web_pub_sub_chat_service_update_message_request( # pylint: disable=na def build_web_pub_sub_chat_service_list_roles_request( # pylint: disable=name-too-long - hub: str, *, max_page_size: Optional[int] = None, continuation_token_parameter: Optional[str] = None, **kwargs: Any + hub: str, *, max_page_size: Optional[int] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -211,10 +211,6 @@ def build_web_pub_sub_chat_service_list_roles_request( # pylint: disable=name-t _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if max_page_size is not None: _params["maxpagesize"] = _SERIALIZER.query("max_page_size", max_page_size, "int") - if continuation_token_parameter is not None: - _params["continuationToken"] = _SERIALIZER.query( - "continuation_token_parameter", continuation_token_parameter, "str" - ) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -326,7 +322,7 @@ def build_web_pub_sub_chat_service_delete_role_request( # pylint: disable=name- def build_web_pub_sub_chat_service_list_rooms_request( # pylint: disable=name-too-long - hub: str, *, max_page_size: Optional[int] = None, continuation_token_parameter: Optional[str] = None, **kwargs: Any + hub: str, *, max_page_size: Optional[int] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -346,10 +342,6 @@ def build_web_pub_sub_chat_service_list_rooms_request( # pylint: disable=name-t _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if max_page_size is not None: _params["maxpagesize"] = _SERIALIZER.query("max_page_size", max_page_size, "int") - if continuation_token_parameter is not None: - _params["continuationToken"] = _SERIALIZER.query( - "continuation_token_parameter", continuation_token_parameter, "str" - ) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -461,12 +453,7 @@ def build_web_pub_sub_chat_service_delete_room_request( # pylint: disable=name- def build_web_pub_sub_chat_service_list_topics_request( # pylint: disable=name-too-long - room_id: str, - hub: str, - *, - max_page_size: Optional[int] = None, - continuation_token_parameter: Optional[str] = None, - **kwargs: Any + room_id: str, hub: str, *, max_page_size: Optional[int] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -487,10 +474,6 @@ def build_web_pub_sub_chat_service_list_topics_request( # pylint: disable=name- _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if max_page_size is not None: _params["maxpagesize"] = _SERIALIZER.query("max_page_size", max_page_size, "int") - if continuation_token_parameter is not None: - _params["continuationToken"] = _SERIALIZER.query( - "continuation_token_parameter", continuation_token_parameter, "str" - ) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -650,12 +633,7 @@ def build_web_pub_sub_chat_service_delete_topic_request( # pylint: disable=name def build_web_pub_sub_chat_service_list_room_members_request( # pylint: disable=name-too-long - room_id: str, - hub: str, - *, - max_page_size: Optional[int] = None, - continuation_token_parameter: Optional[str] = None, - **kwargs: Any + room_id: str, hub: str, *, max_page_size: Optional[int] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -676,10 +654,6 @@ def build_web_pub_sub_chat_service_list_room_members_request( # pylint: disable _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if max_page_size is not None: _params["maxpagesize"] = _SERIALIZER.query("max_page_size", max_page_size, "int") - if continuation_token_parameter is not None: - _params["continuationToken"] = _SERIALIZER.query( - "continuation_token_parameter", continuation_token_parameter, "str" - ) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -768,7 +742,7 @@ def build_web_pub_sub_chat_service_delete_room_member_request( # pylint: disabl def build_web_pub_sub_chat_service_list_users_request( # pylint: disable=name-too-long - hub: str, *, max_page_size: Optional[int] = None, continuation_token_parameter: Optional[str] = None, **kwargs: Any + hub: str, *, max_page_size: Optional[int] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -788,10 +762,6 @@ def build_web_pub_sub_chat_service_list_users_request( # pylint: disable=name-t _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if max_page_size is not None: _params["maxpagesize"] = _SERIALIZER.query("max_page_size", max_page_size, "int") - if continuation_token_parameter is not None: - _params["continuationToken"] = _SERIALIZER.query( - "continuation_token_parameter", continuation_token_parameter, "str" - ) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -903,12 +873,7 @@ def build_web_pub_sub_chat_service_delete_user_request( # pylint: disable=name- def build_web_pub_sub_chat_service_list_rooms_for_user_request( # pylint: disable=name-too-long - user_id: str, - hub: str, - *, - max_page_size: Optional[int] = None, - continuation_token_parameter: Optional[str] = None, - **kwargs: Any + user_id: str, hub: str, *, max_page_size: Optional[int] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -929,10 +894,6 @@ def build_web_pub_sub_chat_service_list_rooms_for_user_request( # pylint: disab _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if max_page_size is not None: _params["maxpagesize"] = _SERIALIZER.query("max_page_size", max_page_size, "int") - if continuation_token_parameter is not None: - _params["continuationToken"] = _SERIALIZER.query( - "continuation_token_parameter", continuation_token_parameter, "str" - ) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1445,18 +1406,13 @@ def update_message( return deserialized # type: ignore @distributed_trace - def list_roles( - self, *, max_page_size: Optional[int] = None, continuation_token_parameter: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.ChatRole"]: + def list_roles(self, *, max_page_size: Optional[int] = None, **kwargs: Any) -> ItemPaged["_models.ChatRole"]: """Query roles in a hub. Query roles in a hub. :keyword max_page_size: The maximum number of result items per page. Default value is None. :paramtype max_page_size: int - :keyword continuation_token_parameter: Continuation token for pagination. Default value is - None. - :paramtype continuation_token_parameter: str :return: An iterator like instance of ChatRole :rtype: ~azure.core.paging.ItemPaged[~azure.messaging.webpubsubchatservice.models.ChatRole] :raises ~azure.core.exceptions.HttpResponseError: @@ -1480,7 +1436,6 @@ def prepare_request(next_link=None): _request = build_web_pub_sub_chat_service_list_roles_request( hub=self._config.hub, max_page_size=max_page_size, - continuation_token_parameter=continuation_token_parameter, api_version=self._config.api_version, headers=_headers, params=_params, @@ -1880,23 +1835,16 @@ def delete_role( # pylint: disable=inconsistent-return-statements @distributed_trace @api_version_validation( method_added_on="2026-08-01-preview", - params_added_on={ - "2026-08-01-preview": ["api_version", "hub", "max_page_size", "continuation_token_parameter", "accept"] - }, + params_added_on={"2026-08-01-preview": ["api_version", "hub", "max_page_size", "accept"]}, api_versions_list=["2026-08-01-preview"], ) - def list_rooms( - self, *, max_page_size: Optional[int] = None, continuation_token_parameter: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.ChatRoom"]: + def list_rooms(self, *, max_page_size: Optional[int] = None, **kwargs: Any) -> ItemPaged["_models.ChatRoom"]: """List rooms with pagination. List rooms with pagination. :keyword max_page_size: The maximum number of result items per page. Default value is None. :paramtype max_page_size: int - :keyword continuation_token_parameter: Continuation token for pagination. Default value is - None. - :paramtype continuation_token_parameter: str :return: An iterator like instance of ChatRoom :rtype: ~azure.core.paging.ItemPaged[~azure.messaging.webpubsubchatservice.models.ChatRoom] :raises ~azure.core.exceptions.HttpResponseError: @@ -1920,7 +1868,6 @@ def prepare_request(next_link=None): _request = build_web_pub_sub_chat_service_list_rooms_request( hub=self._config.hub, max_page_size=max_page_size, - continuation_token_parameter=continuation_token_parameter, api_version=self._config.api_version, headers=_headers, params=_params, @@ -2320,25 +2267,11 @@ def delete_room( # pylint: disable=inconsistent-return-statements @distributed_trace @api_version_validation( method_added_on="2026-08-01-preview", - params_added_on={ - "2026-08-01-preview": [ - "api_version", - "hub", - "room_id", - "max_page_size", - "continuation_token_parameter", - "accept", - ] - }, + params_added_on={"2026-08-01-preview": ["api_version", "hub", "room_id", "max_page_size", "accept"]}, api_versions_list=["2026-08-01-preview"], ) def list_topics( - self, - room_id: str, - *, - max_page_size: Optional[int] = None, - continuation_token_parameter: Optional[str] = None, - **kwargs: Any + self, room_id: str, *, max_page_size: Optional[int] = None, **kwargs: Any ) -> ItemPaged["_models.ChatTopic"]: """List topics in a room with pagination. @@ -2348,9 +2281,6 @@ def list_topics( :type room_id: str :keyword max_page_size: The maximum number of result items per page. Default value is None. :paramtype max_page_size: int - :keyword continuation_token_parameter: Continuation token for pagination. Default value is - None. - :paramtype continuation_token_parameter: str :return: An iterator like instance of ChatTopic :rtype: ~azure.core.paging.ItemPaged[~azure.messaging.webpubsubchatservice.models.ChatTopic] :raises ~azure.core.exceptions.HttpResponseError: @@ -2375,7 +2305,6 @@ def prepare_request(next_link=None): room_id=room_id, hub=self._config.hub, max_page_size=max_page_size, - continuation_token_parameter=continuation_token_parameter, api_version=self._config.api_version, headers=_headers, params=_params, @@ -3049,12 +2978,7 @@ def delete_topic( # pylint: disable=inconsistent-return-statements @distributed_trace def list_room_members( - self, - room_id: str, - *, - max_page_size: Optional[int] = None, - continuation_token_parameter: Optional[str] = None, - **kwargs: Any + self, room_id: str, *, max_page_size: Optional[int] = None, **kwargs: Any ) -> ItemPaged["_models.ChatRoomMember"]: """Get room members. @@ -3064,9 +2988,6 @@ def list_room_members( :type room_id: str :keyword max_page_size: The maximum number of result items per page. Default value is None. :paramtype max_page_size: int - :keyword continuation_token_parameter: Continuation token for pagination. Default value is - None. - :paramtype continuation_token_parameter: str :return: An iterator like instance of ChatRoomMember :rtype: ~azure.core.paging.ItemPaged[~azure.messaging.webpubsubchatservice.models.ChatRoomMember] @@ -3092,7 +3013,6 @@ def prepare_request(next_link=None): room_id=room_id, hub=self._config.hub, max_page_size=max_page_size, - continuation_token_parameter=continuation_token_parameter, api_version=self._config.api_version, headers=_headers, params=_params, @@ -3445,23 +3365,16 @@ def delete_room_member( # pylint: disable=inconsistent-return-statements @distributed_trace @api_version_validation( method_added_on="2026-08-01-preview", - params_added_on={ - "2026-08-01-preview": ["api_version", "hub", "max_page_size", "continuation_token_parameter", "accept"] - }, + params_added_on={"2026-08-01-preview": ["api_version", "hub", "max_page_size", "accept"]}, api_versions_list=["2026-08-01-preview"], ) - def list_users( - self, *, max_page_size: Optional[int] = None, continuation_token_parameter: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.ChatUser"]: + def list_users(self, *, max_page_size: Optional[int] = None, **kwargs: Any) -> ItemPaged["_models.ChatUser"]: """List all users with pagination. List all users with pagination. :keyword max_page_size: The maximum number of result items per page. Default value is None. :paramtype max_page_size: int - :keyword continuation_token_parameter: Continuation token for pagination. Default value is - None. - :paramtype continuation_token_parameter: str :return: An iterator like instance of ChatUser :rtype: ~azure.core.paging.ItemPaged[~azure.messaging.webpubsubchatservice.models.ChatUser] :raises ~azure.core.exceptions.HttpResponseError: @@ -3485,7 +3398,6 @@ def prepare_request(next_link=None): _request = build_web_pub_sub_chat_service_list_users_request( hub=self._config.hub, max_page_size=max_page_size, - continuation_token_parameter=continuation_token_parameter, api_version=self._config.api_version, headers=_headers, params=_params, @@ -3890,25 +3802,11 @@ def delete_user( # pylint: disable=inconsistent-return-statements @distributed_trace @api_version_validation( method_added_on="2026-08-01-preview", - params_added_on={ - "2026-08-01-preview": [ - "api_version", - "hub", - "user_id", - "max_page_size", - "continuation_token_parameter", - "accept", - ] - }, + params_added_on={"2026-08-01-preview": ["api_version", "hub", "user_id", "max_page_size", "accept"]}, api_versions_list=["2026-08-01-preview"], ) def list_rooms_for_user( - self, - user_id: str, - *, - max_page_size: Optional[int] = None, - continuation_token_parameter: Optional[str] = None, - **kwargs: Any + self, user_id: str, *, max_page_size: Optional[int] = None, **kwargs: Any ) -> ItemPaged["_models.ChatUserRoom"]: """List rooms for a user with pagination. @@ -3918,9 +3816,6 @@ def list_rooms_for_user( :type user_id: str :keyword max_page_size: The maximum number of result items per page. Default value is None. :paramtype max_page_size: int - :keyword continuation_token_parameter: Continuation token for pagination. Default value is - None. - :paramtype continuation_token_parameter: str :return: An iterator like instance of ChatUserRoom :rtype: ~azure.core.paging.ItemPaged[~azure.messaging.webpubsubchatservice.models.ChatUserRoom] :raises ~azure.core.exceptions.HttpResponseError: @@ -3945,7 +3840,6 @@ def prepare_request(next_link=None): user_id=user_id, hub=self._config.hub, max_page_size=max_page_size, - continuation_token_parameter=continuation_token_parameter, api_version=self._config.api_version, headers=_headers, params=_params, diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_operations/_operations.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_operations/_operations.py index 45a08e76a659..23031867f1bc 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_operations/_operations.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_operations/_operations.py @@ -538,18 +538,13 @@ async def update_message( return deserialized # type: ignore @distributed_trace - def list_roles( - self, *, max_page_size: Optional[int] = None, continuation_token_parameter: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.ChatRole"]: + def list_roles(self, *, max_page_size: Optional[int] = None, **kwargs: Any) -> AsyncItemPaged["_models.ChatRole"]: """Query roles in a hub. Query roles in a hub. :keyword max_page_size: The maximum number of result items per page. Default value is None. :paramtype max_page_size: int - :keyword continuation_token_parameter: Continuation token for pagination. Default value is - None. - :paramtype continuation_token_parameter: str :return: An iterator like instance of ChatRole :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.messaging.webpubsubchatservice.models.ChatRole] @@ -574,7 +569,6 @@ def prepare_request(next_link=None): _request = build_web_pub_sub_chat_service_list_roles_request( hub=self._config.hub, max_page_size=max_page_size, - continuation_token_parameter=continuation_token_parameter, api_version=self._config.api_version, headers=_headers, params=_params, @@ -974,23 +968,16 @@ async def delete_role( @distributed_trace @api_version_validation( method_added_on="2026-08-01-preview", - params_added_on={ - "2026-08-01-preview": ["api_version", "hub", "max_page_size", "continuation_token_parameter", "accept"] - }, + params_added_on={"2026-08-01-preview": ["api_version", "hub", "max_page_size", "accept"]}, api_versions_list=["2026-08-01-preview"], ) - def list_rooms( - self, *, max_page_size: Optional[int] = None, continuation_token_parameter: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.ChatRoom"]: + def list_rooms(self, *, max_page_size: Optional[int] = None, **kwargs: Any) -> AsyncItemPaged["_models.ChatRoom"]: """List rooms with pagination. List rooms with pagination. :keyword max_page_size: The maximum number of result items per page. Default value is None. :paramtype max_page_size: int - :keyword continuation_token_parameter: Continuation token for pagination. Default value is - None. - :paramtype continuation_token_parameter: str :return: An iterator like instance of ChatRoom :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.messaging.webpubsubchatservice.models.ChatRoom] @@ -1015,7 +1002,6 @@ def prepare_request(next_link=None): _request = build_web_pub_sub_chat_service_list_rooms_request( hub=self._config.hub, max_page_size=max_page_size, - continuation_token_parameter=continuation_token_parameter, api_version=self._config.api_version, headers=_headers, params=_params, @@ -1415,25 +1401,11 @@ async def delete_room( @distributed_trace @api_version_validation( method_added_on="2026-08-01-preview", - params_added_on={ - "2026-08-01-preview": [ - "api_version", - "hub", - "room_id", - "max_page_size", - "continuation_token_parameter", - "accept", - ] - }, + params_added_on={"2026-08-01-preview": ["api_version", "hub", "room_id", "max_page_size", "accept"]}, api_versions_list=["2026-08-01-preview"], ) def list_topics( - self, - room_id: str, - *, - max_page_size: Optional[int] = None, - continuation_token_parameter: Optional[str] = None, - **kwargs: Any + self, room_id: str, *, max_page_size: Optional[int] = None, **kwargs: Any ) -> AsyncItemPaged["_models.ChatTopic"]: """List topics in a room with pagination. @@ -1443,9 +1415,6 @@ def list_topics( :type room_id: str :keyword max_page_size: The maximum number of result items per page. Default value is None. :paramtype max_page_size: int - :keyword continuation_token_parameter: Continuation token for pagination. Default value is - None. - :paramtype continuation_token_parameter: str :return: An iterator like instance of ChatTopic :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.messaging.webpubsubchatservice.models.ChatTopic] @@ -1471,7 +1440,6 @@ def prepare_request(next_link=None): room_id=room_id, hub=self._config.hub, max_page_size=max_page_size, - continuation_token_parameter=continuation_token_parameter, api_version=self._config.api_version, headers=_headers, params=_params, @@ -2145,12 +2113,7 @@ async def delete_topic( @distributed_trace def list_room_members( - self, - room_id: str, - *, - max_page_size: Optional[int] = None, - continuation_token_parameter: Optional[str] = None, - **kwargs: Any + self, room_id: str, *, max_page_size: Optional[int] = None, **kwargs: Any ) -> AsyncItemPaged["_models.ChatRoomMember"]: """Get room members. @@ -2160,9 +2123,6 @@ def list_room_members( :type room_id: str :keyword max_page_size: The maximum number of result items per page. Default value is None. :paramtype max_page_size: int - :keyword continuation_token_parameter: Continuation token for pagination. Default value is - None. - :paramtype continuation_token_parameter: str :return: An iterator like instance of ChatRoomMember :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.messaging.webpubsubchatservice.models.ChatRoomMember] @@ -2188,7 +2148,6 @@ def prepare_request(next_link=None): room_id=room_id, hub=self._config.hub, max_page_size=max_page_size, - continuation_token_parameter=continuation_token_parameter, api_version=self._config.api_version, headers=_headers, params=_params, @@ -2541,23 +2500,16 @@ async def delete_room_member( @distributed_trace @api_version_validation( method_added_on="2026-08-01-preview", - params_added_on={ - "2026-08-01-preview": ["api_version", "hub", "max_page_size", "continuation_token_parameter", "accept"] - }, + params_added_on={"2026-08-01-preview": ["api_version", "hub", "max_page_size", "accept"]}, api_versions_list=["2026-08-01-preview"], ) - def list_users( - self, *, max_page_size: Optional[int] = None, continuation_token_parameter: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.ChatUser"]: + def list_users(self, *, max_page_size: Optional[int] = None, **kwargs: Any) -> AsyncItemPaged["_models.ChatUser"]: """List all users with pagination. List all users with pagination. :keyword max_page_size: The maximum number of result items per page. Default value is None. :paramtype max_page_size: int - :keyword continuation_token_parameter: Continuation token for pagination. Default value is - None. - :paramtype continuation_token_parameter: str :return: An iterator like instance of ChatUser :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.messaging.webpubsubchatservice.models.ChatUser] @@ -2582,7 +2534,6 @@ def prepare_request(next_link=None): _request = build_web_pub_sub_chat_service_list_users_request( hub=self._config.hub, max_page_size=max_page_size, - continuation_token_parameter=continuation_token_parameter, api_version=self._config.api_version, headers=_headers, params=_params, @@ -2987,25 +2938,11 @@ async def delete_user( @distributed_trace @api_version_validation( method_added_on="2026-08-01-preview", - params_added_on={ - "2026-08-01-preview": [ - "api_version", - "hub", - "user_id", - "max_page_size", - "continuation_token_parameter", - "accept", - ] - }, + params_added_on={"2026-08-01-preview": ["api_version", "hub", "user_id", "max_page_size", "accept"]}, api_versions_list=["2026-08-01-preview"], ) def list_rooms_for_user( - self, - user_id: str, - *, - max_page_size: Optional[int] = None, - continuation_token_parameter: Optional[str] = None, - **kwargs: Any + self, user_id: str, *, max_page_size: Optional[int] = None, **kwargs: Any ) -> AsyncItemPaged["_models.ChatUserRoom"]: """List rooms for a user with pagination. @@ -3015,9 +2952,6 @@ def list_rooms_for_user( :type user_id: str :keyword max_page_size: The maximum number of result items per page. Default value is None. :paramtype max_page_size: int - :keyword continuation_token_parameter: Continuation token for pagination. Default value is - None. - :paramtype continuation_token_parameter: str :return: An iterator like instance of ChatUserRoom :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.messaging.webpubsubchatservice.models.ChatUserRoom] @@ -3043,7 +2977,6 @@ def prepare_request(next_link=None): user_id=user_id, hub=self._config.hub, max_page_size=max_page_size, - continuation_token_parameter=continuation_token_parameter, api_version=self._config.api_version, headers=_headers, params=_params, diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview.py index f91f0b55d200..78dc892df302 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview.py @@ -3,9 +3,10 @@ # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------- import datetime +import inspect import json from unittest.mock import AsyncMock, Mock, patch -from urllib.parse import parse_qs, urlparse +from urllib.parse import parse_qs, urlencode, urlparse import pytest from azure.core import MatchConditions @@ -15,7 +16,10 @@ from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient from azure.messaging.webpubsubchatservice.aio import WebPubSubChatServiceClient as AsyncClient from azure.messaging.webpubsubchatservice.models import ( + ChatMessage, + ChatRole, ChatRoom, + ChatRoomMember, ChatTopic, ChatTopicCreateOrReplace, ChatTopicState, @@ -35,10 +39,27 @@ "etag": '"first"', } COLLECTIONS = [ - ("list_rooms", (), "rooms", ChatRoom, {"title": "Room", "defaultConversation": "c.room.default"}), - ("list_users", (), "users", HumanChatUser, {"kind": "Human", "nickname": "User", "roleName": "user.member"}), - ("list_topics", ("room",), "rooms/room/topics", ChatTopic, TOPIC), - ("list_rooms_for_user", ("user",), "users/user/rooms", ChatUserRoom, {"title": "Room"}), + ( + "list_messages", + ("conversation",), + "conversations/conversation/messages", + ChatMessage, + {"createdBy": "user", "content": {}, "createdAt": "2026-08-01T00:00:00Z", "etag": '"message"'}, + "id", + ), + ("list_roles", (), "roles", ChatRole, {"permissions": [], "etag": '"role"'}, "name"), + ( + "list_room_members", + ("room",), + "rooms/room/members", + ChatRoomMember, + {"roleName": "room.member", "etag": '"member"'}, + "userId", + ), + ("list_rooms", (), "rooms", ChatRoom, {"title": "Room", "defaultConversation": "c.room.default"}, "id"), + ("list_users", (), "users", HumanChatUser, {"kind": "Human", "nickname": "User", "roleName": "user.member"}, "id"), + ("list_topics", ("room",), "rooms/room/topics", ChatTopic, TOPIC, "id"), + ("list_rooms_for_user", ("user",), "users/user/rooms", ChatUserRoom, {"title": "Room"}, "id"), ] @@ -49,11 +70,12 @@ def _response(payload, status=200): return Mock(http_response=response) -def _paging_responses(path, fields): - next_link = f"{ENDPOINT}/api/hubs/chat/chat/{path}?api-version=2026-08-01-preview&continuationToken=next" +def _paging_responses(path, fields, identity): + query = urlencode({"api-version": "2026-08-01-preview", "continuationToken": "next+/=token"}) + next_link = f"{ENDPOINT}/api/hubs/chat/chat/{path}?{query}" return [ - _response({"value": [{**fields, "id": "first"}], "nextLink": next_link}), - _response({"value": [{**fields, "id": "second"}]}), + _response({"value": [{**fields, identity: "first"}], "nextLink": next_link}), + _response({"value": [{**fields, identity: "second"}]}), ] @@ -62,9 +84,10 @@ def _assert_page_requests(run, path): assert first.method == second.method == "GET" assert urlparse(first.url).path == f"/api/hubs/chat/chat/{path}" assert parse_qs(urlparse(first.url).query)["maxpagesize"] == ["1"] - assert parse_qs(urlparse(first.url).query)["continuationToken"] == ["initial+/=token"] + assert "continuationToken" not in parse_qs(urlparse(first.url).query) assert parse_qs(urlparse(first.url).query)["api-version"] == ["2026-08-01-preview"] - assert parse_qs(urlparse(second.url).query)["continuationToken"] == ["next"] + assert urlparse(second.url).path == f"/api/hubs/chat/chat/{path}" + assert parse_qs(urlparse(second.url).query)["continuationToken"] == ["next+/=token"] assert parse_qs(urlparse(second.url).query)["api-version"] == ["2026-08-01-preview"] @@ -82,40 +105,68 @@ def _assert_topic_requests(run): assert delete.headers["If-Match"] == '"second"' -@pytest.mark.parametrize("operation,args,path,model,fields", COLLECTIONS) -def test_collection_paging_and_continuation(operation, args, path, model, fields): +@pytest.mark.parametrize("client_type", [WebPubSubChatServiceClient, AsyncClient]) +def test_listing_api_surface(client_type): + operations = {name for name in dir(client_type) if name.startswith("list_")} + assert operations == {collection[0] for collection in COLLECTIONS} + for name in operations: + method = getattr(client_type, name) + assert not any("continuation_token" in parameter for parameter in inspect.signature(method).parameters) + assert ":keyword continuation_token" not in method.__doc__ + assert ":paramtype continuation_token" not in method.__doc__ + + +@pytest.mark.parametrize("resume", [False, True]) +@pytest.mark.parametrize("operation,args,path,model,fields,identity", COLLECTIONS) +def test_collection_paging_and_continuation(operation, args, path, model, fields, identity, resume): with WebPubSubChatServiceClient(ENDPOINT, "chat", AzureKeyCredential("test-key")) as client: - with patch.object(client._client._pipeline, "run", side_effect=_paging_responses(path, fields)) as run: - options = {"max_page_size": 1, "continuation_token_parameter": "initial+/=token"} + with patch.object( + client._client._pipeline, "run", side_effect=_paging_responses(path, fields, identity) + ) as run: + options = {"max_page_size": 1} pages = getattr(client, operation)(*args, **options).by_page() first = list(next(pages)) assert len(first) == 1 assert isinstance(first[0], model) assert pages.continuation_token - resumed = getattr(client, operation)(*args, **options).by_page(pages.continuation_token) - second = list(next(resumed)) - assert [item.id for item in first + second] == ["first", "second"] - assert not list(resumed) + remaining = ( + getattr(client, operation)(*args, **options).by_page(continuation_token=pages.continuation_token) + if resume + else pages + ) + second = list(next(remaining)) + assert isinstance(second[0], model) + assert [item[identity] for item in first + second] == ["first", "second"] + assert not list(remaining) _assert_page_requests(run, path) @pytest.mark.asyncio -@pytest.mark.parametrize("operation,args,path,model,fields", COLLECTIONS) -async def test_async_collection_paging_and_continuation(operation, args, path, model, fields): +@pytest.mark.parametrize("resume", [False, True]) +@pytest.mark.parametrize("operation,args,path,model,fields,identity", COLLECTIONS) +async def test_async_collection_paging_and_continuation(operation, args, path, model, fields, identity, resume): async with AsyncClient(ENDPOINT, "chat", AzureKeyCredential("test-key")) as client: with patch.object( - client._client._pipeline, "run", new_callable=AsyncMock, side_effect=_paging_responses(path, fields) + client._client._pipeline, + "run", + new_callable=AsyncMock, + side_effect=_paging_responses(path, fields, identity), ) as run: - options = {"max_page_size": 1, "continuation_token_parameter": "initial+/=token"} + options = {"max_page_size": 1} pages = getattr(client, operation)(*args, **options).by_page() first = [item async for item in await anext(pages)] assert len(first) == 1 assert isinstance(first[0], model) assert pages.continuation_token - resumed = getattr(client, operation)(*args, **options).by_page(pages.continuation_token) - second = [item async for item in await anext(resumed)] - assert [item.id for item in first + second] == ["first", "second"] - assert [page async for page in resumed] == [] + remaining = ( + getattr(client, operation)(*args, **options).by_page(continuation_token=pages.continuation_token) + if resume + else pages + ) + second = [item async for item in await anext(remaining)] + assert isinstance(second[0], model) + assert [item[identity] for item in first + second] == ["first", "second"] + assert [page async for page in remaining] == [] _assert_page_requests(run, path) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml index 69b798ebbf0a..bd4401843ea2 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml @@ -1,5 +1,5 @@ directory: specification/webpubsub/data-plane/WebPubSubChat -commit: 59d709b28e3808cbcec119f0ceaeb5f228a42a63 +commit: 2d9fd4ac7fa10dce72c79e35ec144c04ed2e269f repo: Y-Sindo/azure-rest-api-specs # cspell:ignore Sindo additionalDirectories: [] entrypointFile: client.tsp \ No newline at end of file From b59c6690f7eb68183bfcbbabeca5271a6ea0baf6 Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Fri, 30 Oct 2026 01:22:23 +1100 Subject: [PATCH 19/22] Sync Chat SDK request names and retain handwritten samples Regenerate from the published TypeSpec configuration, preserve resource-specific request parameters and room_id, and replace standalone generated samples with validated handwritten examples. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../CHANGELOG.md | 4 + .../README.md | 26 +-- .../api.md | 90 ++++---- .../api.metadata.yml | 2 +- .../apiview-properties.json | 18 +- .../_operations/_operations.py | 215 +++++++++--------- .../aio/_operations/_operations.py | 215 +++++++++--------- .../webpubsubchatservice/models/_models.py | 8 +- .../create_or_replace_role.py | 43 ---- .../create_or_replace_room.py | 43 ---- .../create_or_replace_room_member.py | 44 ---- .../create_or_replace_topic.py | 44 ---- .../create_or_replace_user.py | 43 ---- .../generated_samples/delete_message.py | 42 ---- .../generated_samples/delete_role.py | 41 ---- .../generated_samples/delete_room.py | 41 ---- .../generated_samples/delete_room_member.py | 42 ---- .../generated_samples/delete_topic.py | 42 ---- .../generated_samples/delete_user.py | 41 ---- .../generated_samples/get_conversation.py | 42 ---- .../generated_samples/get_role.py | 42 ---- .../generated_samples/get_room.py | 42 ---- .../generated_samples/get_topic.py | 43 ---- .../generated_samples/get_user.py | 42 ---- .../generated_samples/list_messages.py | 43 ---- .../generated_samples/list_roles.py | 41 ---- .../generated_samples/list_room_members.py | 43 ---- .../generated_samples/list_rooms.py | 41 ---- .../generated_samples/list_rooms_for_user.py | 43 ---- .../generated_samples/list_topics.py | 43 ---- .../generated_samples/list_users.py | 41 ---- .../generated_samples/update_message.py | 44 ---- .../generated_samples/update_topic.py | 44 ---- .../test_web_pub_sub_chat_service.py | 14 +- .../test_web_pub_sub_chat_service_async.py | 14 +- .../samples/README.md | 50 ++-- .../samples/sample_delete_operations.py | 31 +++ .../samples/sample_read_operations.py | 67 ++++++ .../samples/sample_request_body_styles.py | 7 + .../tests/test_2026_08_01_preview.py | 8 +- .../tests/test_2026_08_01_preview_live.py | 2 +- .../test_2026_08_01_preview_live_async.py | 2 +- .../tests/test_live.py | 2 +- .../tests/test_live_async.py | 2 +- .../tests/test_operation_samples.py | 96 ++++++-- .../tests/test_request_models.py | 73 +++++- .../tests/typing/request_models.py | 32 +-- .../tsp-location.yaml | 2 +- 48 files changed, 601 insertions(+), 1439 deletions(-) delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_role.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_room.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_room_member.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_topic.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_user.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_message.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_role.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_room.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_room_member.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_topic.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_user.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_conversation.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_role.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_room.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_topic.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_user.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_messages.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_roles.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_room_members.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_rooms.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_rooms_for_user.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_topics.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_users.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/update_message.py delete mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/update_topic.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_operations.py create mode 100644 sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_read_operations.py diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md index a6bcf6d53d5f..f5368cc25b43 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md @@ -10,9 +10,13 @@ ### Other Changes - Changed the default service API version from `2026-02-01-preview` to `2026-08-01-preview` for both existing and newly added Chat operations + - Clarified that message IDs are pagination cursors for `list_messages`. The pager follows the service's `nextLink`; resume with `by_page(continuation_token=...)`. + - Replaced standalone generated samples with handwritten operation examples and Model/TypedDict request-body examples. ### Breaking Changes + - Renamed request-body parameters from `resource` to `role`, `room`, `member`, `user`, `topic`, or `message`, matching the operation's resource. Positional calls are unchanged. + - Renamed `ChatConversation.parent_room` to `room_id`. The JSON field remains `parentRoom`. - Removed the `continuation_token_parameter` argument from listing operations. Resume paging with `by_page(continuation_token=...)` on the returned `ItemPaged` or `AsyncItemPaged` instead. - Create or replace operations now accept dedicated `ChatRoleCreateOrReplace`, `ChatRoomCreateOrReplace`, `ChatRoomMemberCreateOrReplace`, and `ChatUserCreateOrReplace` (including `HumanChatUserCreateOrReplace`) request models instead of resource response models. - Message updates accept `ChatMessageUpdate`, whose fields are optional, instead of `ChatMessage`. Resource response model names are unchanged. diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md index d0288b2cf7be..e9d91fd5a7c5 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md @@ -138,6 +138,12 @@ A conversation is an ordered message stream within a room. Every room has a defa 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. +`ChatConversation.room_id` identifies the room containing the conversation. +`list_messages` returns messages from latest to earliest, using message IDs as +pagination cursors. The returned pager follows the service's `nextLink` +automatically. To resume a page iteration, pass its continuation token to +`by_page(continuation_token=...)`, not to `list_messages` itself. + ### Topic A topic represents a named conversation within a room. Topics can be created, @@ -171,10 +177,9 @@ Explore the examples: - [Model-based and scenario examples][examples], including complete synchronous and asynchronous programs. -- [Dictionary-based operation examples][generated_examples], generated from the - specification's examples. +- [Model, typed-dictionary, and plain-dictionary comparison](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_request_body_styles.py). - [Complete operation index](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md#complete-operation-index), - linking to model-based and generated examples for each service operation. + linking to handwritten examples for each service operation. ### Generate client access credentials @@ -395,11 +400,8 @@ For conditional updates and deletes, pass the current ETag with `MatchConditions.IfNotModified`. A stale ETag prevents overwriting a topic that another caller has changed. Deleting a topic is a soft delete. -For individual API calls, see the generated examples for -[create or replace](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_topic.py), -[list](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_topics.py), [get](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_topic.py), -[update](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/update_topic.py), and -[delete](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_topic.py). +For individual API calls, see the +[operation examples](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md#complete-operation-index). ### List rooms and users @@ -438,9 +440,8 @@ for room in client.list_rooms_for_user(""): -For basic list calls, see [list_rooms.py](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_rooms.py), -[list_users.py](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_users.py), and -[list_rooms_for_user.py](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_rooms_for_user.py). +For basic list calls, see the functions in +[the README snippet sources](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_readme_snippets.py). Listing rooms for a user requires an existing user ID. Collection iterators automatically fetch subsequent pages. @@ -545,7 +546,7 @@ Explore the [README snippet sources](https://github.com/Azure/azure-sdk-for-pyth - Manage topic lifecycles and iterate over room and user collections. - Use synchronous and asynchronous clients. -See also the [dictionary-based operation examples][generated_examples]. +See also the [request-body style comparison](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_request_body_styles.py). ## Additional resources @@ -566,7 +567,6 @@ This project has adopted the [Microsoft Open Source Code of Conduct][code_of_con [api_reference]: https://learn.microsoft.com/python/api/overview/azure/messaging-webpubsubchatservice-readme?view=azure-python-preview [product_docs]: https://learn.microsoft.com/azure/azure-web-pubsub/chat-overview [examples]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples -[generated_examples]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples [changelog]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md [azure_sub]: https://azure.microsoft.com/free/ [webpubsub_docs]: https://learn.microsoft.com/azure/azure-web-pubsub/ diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md index 2eed03d88047..16ea26a56873 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md @@ -33,7 +33,7 @@ namespace azure.messaging.webpubsubchatservice def create_or_replace_role( self, role_name: str, - resource: ChatRoleCreateOrReplace, + role: ChatRoleCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -45,7 +45,7 @@ namespace azure.messaging.webpubsubchatservice def create_or_replace_role( self, role_name: str, - resource: ChatRoleCreateOrReplace, + role: ChatRoleCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -57,7 +57,7 @@ namespace azure.messaging.webpubsubchatservice def create_or_replace_role( self, role_name: str, - resource: IO[bytes], + role: IO[bytes], *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -69,7 +69,7 @@ namespace azure.messaging.webpubsubchatservice def create_or_replace_room( self, room_id: str, - resource: ChatRoomCreateOrReplace, + room: ChatRoomCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -81,7 +81,7 @@ namespace azure.messaging.webpubsubchatservice def create_or_replace_room( self, room_id: str, - resource: ChatRoomCreateOrReplace, + room: ChatRoomCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -93,7 +93,7 @@ namespace azure.messaging.webpubsubchatservice def create_or_replace_room( self, room_id: str, - resource: IO[bytes], + room: IO[bytes], *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -106,7 +106,7 @@ namespace azure.messaging.webpubsubchatservice self, room_id: str, user_id: str, - resource: ChatRoomMemberCreateOrReplace, + member: ChatRoomMemberCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -119,7 +119,7 @@ namespace azure.messaging.webpubsubchatservice self, room_id: str, user_id: str, - resource: ChatRoomMemberCreateOrReplace, + member: ChatRoomMemberCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -132,7 +132,7 @@ namespace azure.messaging.webpubsubchatservice self, room_id: str, user_id: str, - resource: IO[bytes], + member: IO[bytes], *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -145,7 +145,7 @@ namespace azure.messaging.webpubsubchatservice self, room_id: str, topic_id: str, - resource: ChatTopicCreateOrReplace, + topic: ChatTopicCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -158,7 +158,7 @@ namespace azure.messaging.webpubsubchatservice self, room_id: str, topic_id: str, - resource: ChatTopicCreateOrReplace, + topic: ChatTopicCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -171,7 +171,7 @@ namespace azure.messaging.webpubsubchatservice self, room_id: str, topic_id: str, - resource: IO[bytes], + topic: IO[bytes], *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -183,7 +183,7 @@ namespace azure.messaging.webpubsubchatservice def create_or_replace_user( self, user_id: str, - resource: ChatUserCreateOrReplace, + user: ChatUserCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -195,7 +195,7 @@ namespace azure.messaging.webpubsubchatservice def create_or_replace_user( self, user_id: str, - resource: ChatUserCreateOrReplace, + user: ChatUserCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -207,7 +207,7 @@ namespace azure.messaging.webpubsubchatservice def create_or_replace_user( self, user_id: str, - resource: IO[bytes], + user: IO[bytes], *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -404,7 +404,7 @@ namespace azure.messaging.webpubsubchatservice self, conversation_id: str, message_id: str, - resource: ChatMessageUpdate, + message: ChatMessageUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = ..., @@ -417,7 +417,7 @@ namespace azure.messaging.webpubsubchatservice self, conversation_id: str, message_id: str, - resource: ChatMessageUpdate, + message: ChatMessageUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = ..., @@ -430,7 +430,7 @@ namespace azure.messaging.webpubsubchatservice self, conversation_id: str, message_id: str, - resource: IO[bytes], + message: IO[bytes], *, content_type: str = "application/merge-patch+json", etag: Optional[str] = ..., @@ -443,7 +443,7 @@ namespace azure.messaging.webpubsubchatservice self, room_id: str, topic_id: str, - resource: ChatTopicUpdate, + topic: ChatTopicUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = ..., @@ -456,7 +456,7 @@ namespace azure.messaging.webpubsubchatservice self, room_id: str, topic_id: str, - resource: ChatTopicUpdate, + topic: ChatTopicUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = ..., @@ -469,7 +469,7 @@ namespace azure.messaging.webpubsubchatservice self, room_id: str, topic_id: str, - resource: IO[bytes], + topic: IO[bytes], *, content_type: str = "application/merge-patch+json", etag: Optional[str] = ..., @@ -506,7 +506,7 @@ namespace azure.messaging.webpubsubchatservice.aio async def create_or_replace_role( self, role_name: str, - resource: ChatRoleCreateOrReplace, + role: ChatRoleCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -518,7 +518,7 @@ namespace azure.messaging.webpubsubchatservice.aio async def create_or_replace_role( self, role_name: str, - resource: ChatRoleCreateOrReplace, + role: ChatRoleCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -530,7 +530,7 @@ namespace azure.messaging.webpubsubchatservice.aio async def create_or_replace_role( self, role_name: str, - resource: IO[bytes], + role: IO[bytes], *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -542,7 +542,7 @@ namespace azure.messaging.webpubsubchatservice.aio async def create_or_replace_room( self, room_id: str, - resource: ChatRoomCreateOrReplace, + room: ChatRoomCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -554,7 +554,7 @@ namespace azure.messaging.webpubsubchatservice.aio async def create_or_replace_room( self, room_id: str, - resource: ChatRoomCreateOrReplace, + room: ChatRoomCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -566,7 +566,7 @@ namespace azure.messaging.webpubsubchatservice.aio async def create_or_replace_room( self, room_id: str, - resource: IO[bytes], + room: IO[bytes], *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -579,7 +579,7 @@ namespace azure.messaging.webpubsubchatservice.aio self, room_id: str, user_id: str, - resource: ChatRoomMemberCreateOrReplace, + member: ChatRoomMemberCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -592,7 +592,7 @@ namespace azure.messaging.webpubsubchatservice.aio self, room_id: str, user_id: str, - resource: ChatRoomMemberCreateOrReplace, + member: ChatRoomMemberCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -605,7 +605,7 @@ namespace azure.messaging.webpubsubchatservice.aio self, room_id: str, user_id: str, - resource: IO[bytes], + member: IO[bytes], *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -618,7 +618,7 @@ namespace azure.messaging.webpubsubchatservice.aio self, room_id: str, topic_id: str, - resource: ChatTopicCreateOrReplace, + topic: ChatTopicCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -631,7 +631,7 @@ namespace azure.messaging.webpubsubchatservice.aio self, room_id: str, topic_id: str, - resource: ChatTopicCreateOrReplace, + topic: ChatTopicCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -644,7 +644,7 @@ namespace azure.messaging.webpubsubchatservice.aio self, room_id: str, topic_id: str, - resource: IO[bytes], + topic: IO[bytes], *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -656,7 +656,7 @@ namespace azure.messaging.webpubsubchatservice.aio async def create_or_replace_user( self, user_id: str, - resource: ChatUserCreateOrReplace, + user: ChatUserCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -668,7 +668,7 @@ namespace azure.messaging.webpubsubchatservice.aio async def create_or_replace_user( self, user_id: str, - resource: ChatUserCreateOrReplace, + user: ChatUserCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -680,7 +680,7 @@ namespace azure.messaging.webpubsubchatservice.aio async def create_or_replace_user( self, user_id: str, - resource: IO[bytes], + user: IO[bytes], *, content_type: str = "application/json", etag: Optional[str] = ..., @@ -877,7 +877,7 @@ namespace azure.messaging.webpubsubchatservice.aio self, conversation_id: str, message_id: str, - resource: ChatMessageUpdate, + message: ChatMessageUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = ..., @@ -890,7 +890,7 @@ namespace azure.messaging.webpubsubchatservice.aio self, conversation_id: str, message_id: str, - resource: ChatMessageUpdate, + message: ChatMessageUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = ..., @@ -903,7 +903,7 @@ namespace azure.messaging.webpubsubchatservice.aio self, conversation_id: str, message_id: str, - resource: IO[bytes], + message: IO[bytes], *, content_type: str = "application/merge-patch+json", etag: Optional[str] = ..., @@ -916,7 +916,7 @@ namespace azure.messaging.webpubsubchatservice.aio self, room_id: str, topic_id: str, - resource: ChatTopicUpdate, + topic: ChatTopicUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = ..., @@ -929,7 +929,7 @@ namespace azure.messaging.webpubsubchatservice.aio self, room_id: str, topic_id: str, - resource: ChatTopicUpdate, + topic: ChatTopicUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = ..., @@ -942,7 +942,7 @@ namespace azure.messaging.webpubsubchatservice.aio self, room_id: str, topic_id: str, - resource: IO[bytes], + topic: IO[bytes], *, content_type: str = "application/merge-patch+json", etag: Optional[str] = ..., @@ -956,13 +956,13 @@ namespace azure.messaging.webpubsubchatservice.models class azure.messaging.webpubsubchatservice.models.ChatConversation(_Model): etag: str id: str - parent_room: str + room_id: str @overload def __init__( self, *, - parent_room: str + room_id: str ) -> None: ... @overload @@ -1337,4 +1337,4 @@ namespace azure.messaging.webpubsubchatservice.types text: str -``` +``` \ No newline at end of file diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml index f5ffb298528d..6de17fb462c2 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml @@ -1,4 +1,4 @@ -apiMdSha256: de70ea75cfa4d03247454217b82c8f8e4b1bd9426cabcafc0b148c377528a184 +apiMdSha256: bc6ec089811cdbda7c3ae09f1d6b38e2a1ab37b5d0f31b69258b7832bd31527f packageVersion: 1.0.0b2 parserVersion: 0.3.31 pythonVersion: 3.12.10 diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json b/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json index 45500121523b..698aad3e427d 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json @@ -3,21 +3,21 @@ "CrossLanguageDefinitionId": { "azure.messaging.webpubsubchatservice.models.ChatConversation": "WebPubSubChat.ChatConversation", "azure.messaging.webpubsubchatservice.models.ChatMessage": "WebPubSubChat.ChatMessage", - "azure.messaging.webpubsubchatservice.models.ChatMessageUpdate": "WebPubSubChat.PythonCustomizations.ChatMessageUpdate", + "azure.messaging.webpubsubchatservice.models.ChatMessageUpdate": "ClientCustomizations.ChatMessageUpdate", "azure.messaging.webpubsubchatservice.models.ChatRole": "WebPubSubChat.ChatRole", - "azure.messaging.webpubsubchatservice.models.ChatRoleCreateOrReplace": "WebPubSubChat.PythonCustomizations.ChatRoleCreateOrReplace", + "azure.messaging.webpubsubchatservice.models.ChatRoleCreateOrReplace": "ClientCustomizations.ChatRoleCreateOrReplace", "azure.messaging.webpubsubchatservice.models.ChatRoom": "WebPubSubChat.ChatRoom", - "azure.messaging.webpubsubchatservice.models.ChatRoomCreateOrReplace": "WebPubSubChat.PythonCustomizations.ChatRoomCreateOrReplace", + "azure.messaging.webpubsubchatservice.models.ChatRoomCreateOrReplace": "ClientCustomizations.ChatRoomCreateOrReplace", "azure.messaging.webpubsubchatservice.models.ChatRoomMember": "WebPubSubChat.ChatRoomMember", - "azure.messaging.webpubsubchatservice.models.ChatRoomMemberCreateOrReplace": "WebPubSubChat.PythonCustomizations.ChatRoomMemberCreateOrReplace", + "azure.messaging.webpubsubchatservice.models.ChatRoomMemberCreateOrReplace": "ClientCustomizations.ChatRoomMemberCreateOrReplace", "azure.messaging.webpubsubchatservice.models.ChatTopic": "WebPubSubChat.ChatTopic", - "azure.messaging.webpubsubchatservice.models.ChatTopicCreateOrReplace": "WebPubSubChat.PythonCustomizations.ChatTopicCreateOrReplace", - "azure.messaging.webpubsubchatservice.models.ChatTopicUpdate": "WebPubSubChat.PythonCustomizations.ChatTopicUpdate", + "azure.messaging.webpubsubchatservice.models.ChatTopicCreateOrReplace": "ClientCustomizations.ChatTopicCreateOrReplace", + "azure.messaging.webpubsubchatservice.models.ChatTopicUpdate": "ClientCustomizations.ChatTopicUpdate", "azure.messaging.webpubsubchatservice.models.ChatUser": "WebPubSubChat.ChatUser", - "azure.messaging.webpubsubchatservice.models.ChatUserCreateOrReplace": "WebPubSubChat.PythonCustomizations.ChatUserCreateOrReplace", + "azure.messaging.webpubsubchatservice.models.ChatUserCreateOrReplace": "ClientCustomizations.ChatUserCreateOrReplace", "azure.messaging.webpubsubchatservice.models.ChatUserRoom": "WebPubSubChat.ChatUserRoom", "azure.messaging.webpubsubchatservice.models.HumanChatUser": "WebPubSubChat.HumanChatUser", - "azure.messaging.webpubsubchatservice.models.HumanChatUserCreateOrReplace": "WebPubSubChat.PythonCustomizations.HumanChatUserCreateOrReplace", + "azure.messaging.webpubsubchatservice.models.HumanChatUserCreateOrReplace": "ClientCustomizations.HumanChatUserCreateOrReplace", "azure.messaging.webpubsubchatservice.models.MessageContent": "WebPubSubChat.MessageContent", "azure.messaging.webpubsubchatservice.models.ChatPermission": "WebPubSubChat.ChatPermission", "azure.messaging.webpubsubchatservice.models.ChatTopicState": "WebPubSubChat.ChatTopicState", @@ -73,5 +73,5 @@ "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.list_rooms_for_user": "WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser", "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.list_rooms_for_user": "WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser" }, - "CrossLanguageVersion": "c8facae70120" + "CrossLanguageVersion": "c47dbe5e13af" } \ No newline at end of file diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_operations/_operations.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_operations/_operations.py index c53c94ff1b3b..45bd811f0b82 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_operations/_operations.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_operations/_operations.py @@ -1018,7 +1018,8 @@ def list_messages( ) -> ItemPaged["_models.ChatMessage"]: """Query messages in a conversation from latest to earliest. - Query messages in a conversation from latest to earliest. + Message IDs are used as pagination cursors. Follow the response nextLink, which contains the + message ID cursor, to retrieve the next page. :param conversation_id: Conversation identifier. Required. :type conversation_id: str @@ -1199,7 +1200,7 @@ def update_message( self, conversation_id: str, message_id: str, - resource: _models.ChatMessageUpdate, + message: _models.ChatMessageUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = None, @@ -1214,8 +1215,8 @@ def update_message( :type conversation_id: str :param message_id: Message identifier. Required. :type message_id: str - :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatMessageUpdate + :param message: The resource instance. Required. + :type message: ~azure.messaging.webpubsubchatservice.models.ChatMessageUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -1234,7 +1235,7 @@ def update_message( self, conversation_id: str, message_id: str, - resource: _types.ChatMessageUpdate, + message: _types.ChatMessageUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = None, @@ -1249,8 +1250,8 @@ def update_message( :type conversation_id: str :param message_id: Message identifier. Required. :type message_id: str - :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatMessageUpdate + :param message: The resource instance. Required. + :type message: ~azure.messaging.webpubsubchatservice.types.ChatMessageUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -1269,7 +1270,7 @@ def update_message( self, conversation_id: str, message_id: str, - resource: IO[bytes], + message: IO[bytes], *, content_type: str = "application/merge-patch+json", etag: Optional[str] = None, @@ -1284,8 +1285,8 @@ def update_message( :type conversation_id: str :param message_id: Message identifier. Required. :type message_id: str - :param resource: The resource instance. Required. - :type resource: IO[bytes] + :param message: The resource instance. Required. + :type message: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -1304,7 +1305,7 @@ def update_message( self, conversation_id: str, message_id: str, - resource: Union[_models.ChatMessageUpdate, _types.ChatMessageUpdate, IO[bytes]], + message: Union[_models.ChatMessageUpdate, _types.ChatMessageUpdate, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -1318,9 +1319,9 @@ def update_message( :type conversation_id: str :param message_id: Message identifier. Required. :type message_id: str - :param resource: The resource instance. Is either a ChatMessageUpdate type or a IO[bytes] type. + :param message: The resource instance. Is either a ChatMessageUpdate type or a IO[bytes] type. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatMessageUpdate or + :type message: ~azure.messaging.webpubsubchatservice.models.ChatMessageUpdate or ~azure.messaging.webpubsubchatservice.types.ChatMessageUpdate or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. @@ -1353,10 +1354,10 @@ def update_message( content_type = content_type or "application/merge-patch+json" _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource + if isinstance(message, (IOBase, bytes)): + _content = message else: - _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(message, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_web_pub_sub_chat_service_update_message_request( conversation_id=conversation_id, @@ -1567,7 +1568,7 @@ def get_role(self, role_name: str, **kwargs: Any) -> _models.ChatRole: def create_or_replace_role( self, role_name: str, - resource: _models.ChatRoleCreateOrReplace, + role: _models.ChatRoleCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -1580,8 +1581,8 @@ def create_or_replace_role( :param role_name: Role name. Must start with 'user.' or 'room.' prefix. Required. :type role_name: str - :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoleCreateOrReplace + :param role: The resource instance. Required. + :type role: ~azure.messaging.webpubsubchatservice.models.ChatRoleCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1599,7 +1600,7 @@ def create_or_replace_role( def create_or_replace_role( self, role_name: str, - resource: _types.ChatRoleCreateOrReplace, + role: _types.ChatRoleCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -1612,8 +1613,8 @@ def create_or_replace_role( :param role_name: Role name. Must start with 'user.' or 'room.' prefix. Required. :type role_name: str - :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatRoleCreateOrReplace + :param role: The resource instance. Required. + :type role: ~azure.messaging.webpubsubchatservice.types.ChatRoleCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1631,7 +1632,7 @@ def create_or_replace_role( def create_or_replace_role( self, role_name: str, - resource: IO[bytes], + role: IO[bytes], *, content_type: str = "application/json", etag: Optional[str] = None, @@ -1644,8 +1645,8 @@ def create_or_replace_role( :param role_name: Role name. Must start with 'user.' or 'room.' prefix. Required. :type role_name: str - :param resource: The resource instance. Required. - :type resource: IO[bytes] + :param role: The resource instance. Required. + :type role: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -1663,7 +1664,7 @@ def create_or_replace_role( def create_or_replace_role( self, role_name: str, - resource: Union[_models.ChatRoleCreateOrReplace, _types.ChatRoleCreateOrReplace, IO[bytes]], + role: Union[_models.ChatRoleCreateOrReplace, _types.ChatRoleCreateOrReplace, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -1675,9 +1676,9 @@ def create_or_replace_role( :param role_name: Role name. Must start with 'user.' or 'room.' prefix. Required. :type role_name: str - :param resource: The resource instance. Is either a ChatRoleCreateOrReplace type or a IO[bytes] + :param role: The resource instance. Is either a ChatRoleCreateOrReplace type or a IO[bytes] type. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoleCreateOrReplace or + :type role: ~azure.messaging.webpubsubchatservice.models.ChatRoleCreateOrReplace or ~azure.messaging.webpubsubchatservice.types.ChatRoleCreateOrReplace or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. @@ -1710,10 +1711,10 @@ def create_or_replace_role( content_type = content_type or "application/json" _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource + if isinstance(role, (IOBase, bytes)): + _content = role else: - _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(role, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_web_pub_sub_chat_service_create_or_replace_role_request( role_name=role_name, @@ -1935,7 +1936,7 @@ def get_next(next_link=None): def create_or_replace_room( self, room_id: str, - resource: _models.ChatRoomCreateOrReplace, + room: _models.ChatRoomCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -1948,8 +1949,8 @@ def create_or_replace_room( :param room_id: Room identifier. Required. :type room_id: str - :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomCreateOrReplace + :param room: The resource instance. Required. + :type room: ~azure.messaging.webpubsubchatservice.models.ChatRoomCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1967,7 +1968,7 @@ def create_or_replace_room( def create_or_replace_room( self, room_id: str, - resource: _types.ChatRoomCreateOrReplace, + room: _types.ChatRoomCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -1980,8 +1981,8 @@ def create_or_replace_room( :param room_id: Room identifier. Required. :type room_id: str - :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatRoomCreateOrReplace + :param room: The resource instance. Required. + :type room: ~azure.messaging.webpubsubchatservice.types.ChatRoomCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1999,7 +2000,7 @@ def create_or_replace_room( def create_or_replace_room( self, room_id: str, - resource: IO[bytes], + room: IO[bytes], *, content_type: str = "application/json", etag: Optional[str] = None, @@ -2012,8 +2013,8 @@ def create_or_replace_room( :param room_id: Room identifier. Required. :type room_id: str - :param resource: The resource instance. Required. - :type resource: IO[bytes] + :param room: The resource instance. Required. + :type room: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -2031,7 +2032,7 @@ def create_or_replace_room( def create_or_replace_room( self, room_id: str, - resource: Union[_models.ChatRoomCreateOrReplace, _types.ChatRoomCreateOrReplace, IO[bytes]], + room: Union[_models.ChatRoomCreateOrReplace, _types.ChatRoomCreateOrReplace, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -2043,9 +2044,9 @@ def create_or_replace_room( :param room_id: Room identifier. Required. :type room_id: str - :param resource: The resource instance. Is either a ChatRoomCreateOrReplace type or a IO[bytes] + :param room: The resource instance. Is either a ChatRoomCreateOrReplace type or a IO[bytes] type. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomCreateOrReplace or + :type room: ~azure.messaging.webpubsubchatservice.models.ChatRoomCreateOrReplace or ~azure.messaging.webpubsubchatservice.types.ChatRoomCreateOrReplace or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. @@ -2078,10 +2079,10 @@ def create_or_replace_room( content_type = content_type or "application/json" _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource + if isinstance(room, (IOBase, bytes)): + _content = room else: - _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(room, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_web_pub_sub_chat_service_create_or_replace_room_request( room_id=room_id, @@ -2373,7 +2374,7 @@ def create_or_replace_topic( self, room_id: str, topic_id: str, - resource: _models.ChatTopicCreateOrReplace, + topic: _models.ChatTopicCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -2388,8 +2389,8 @@ def create_or_replace_topic( :type room_id: str :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str - :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopicCreateOrReplace + :param topic: The resource instance. Required. + :type topic: ~azure.messaging.webpubsubchatservice.models.ChatTopicCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2408,7 +2409,7 @@ def create_or_replace_topic( self, room_id: str, topic_id: str, - resource: _types.ChatTopicCreateOrReplace, + topic: _types.ChatTopicCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -2423,8 +2424,8 @@ def create_or_replace_topic( :type room_id: str :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str - :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatTopicCreateOrReplace + :param topic: The resource instance. Required. + :type topic: ~azure.messaging.webpubsubchatservice.types.ChatTopicCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2443,7 +2444,7 @@ def create_or_replace_topic( self, room_id: str, topic_id: str, - resource: IO[bytes], + topic: IO[bytes], *, content_type: str = "application/json", etag: Optional[str] = None, @@ -2458,8 +2459,8 @@ def create_or_replace_topic( :type room_id: str :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str - :param resource: The resource instance. Required. - :type resource: IO[bytes] + :param topic: The resource instance. Required. + :type topic: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -2494,7 +2495,7 @@ def create_or_replace_topic( self, room_id: str, topic_id: str, - resource: Union[_models.ChatTopicCreateOrReplace, _types.ChatTopicCreateOrReplace, IO[bytes]], + topic: Union[_models.ChatTopicCreateOrReplace, _types.ChatTopicCreateOrReplace, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -2508,9 +2509,9 @@ def create_or_replace_topic( :type room_id: str :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str - :param resource: The resource instance. Is either a ChatTopicCreateOrReplace type or a - IO[bytes] type. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopicCreateOrReplace or + :param topic: The resource instance. Is either a ChatTopicCreateOrReplace type or a IO[bytes] + type. Required. + :type topic: ~azure.messaging.webpubsubchatservice.models.ChatTopicCreateOrReplace or ~azure.messaging.webpubsubchatservice.types.ChatTopicCreateOrReplace or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. @@ -2543,10 +2544,10 @@ def create_or_replace_topic( content_type = content_type or "application/json" _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource + if isinstance(topic, (IOBase, bytes)): + _content = topic else: - _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(topic, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_web_pub_sub_chat_service_create_or_replace_topic_request( room_id=room_id, @@ -2672,7 +2673,7 @@ def update_topic( self, room_id: str, topic_id: str, - resource: _models.ChatTopicUpdate, + topic: _models.ChatTopicUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = None, @@ -2687,8 +2688,8 @@ def update_topic( :type room_id: str :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str - :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopicUpdate + :param topic: The resource instance. Required. + :type topic: ~azure.messaging.webpubsubchatservice.models.ChatTopicUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -2707,7 +2708,7 @@ def update_topic( self, room_id: str, topic_id: str, - resource: _types.ChatTopicUpdate, + topic: _types.ChatTopicUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = None, @@ -2722,8 +2723,8 @@ def update_topic( :type room_id: str :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str - :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatTopicUpdate + :param topic: The resource instance. Required. + :type topic: ~azure.messaging.webpubsubchatservice.types.ChatTopicUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -2742,7 +2743,7 @@ def update_topic( self, room_id: str, topic_id: str, - resource: IO[bytes], + topic: IO[bytes], *, content_type: str = "application/merge-patch+json", etag: Optional[str] = None, @@ -2757,8 +2758,8 @@ def update_topic( :type room_id: str :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str - :param resource: The resource instance. Required. - :type resource: IO[bytes] + :param topic: The resource instance. Required. + :type topic: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -2793,7 +2794,7 @@ def update_topic( self, room_id: str, topic_id: str, - resource: Union[_models.ChatTopicUpdate, _types.ChatTopicUpdate, IO[bytes]], + topic: Union[_models.ChatTopicUpdate, _types.ChatTopicUpdate, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -2807,9 +2808,9 @@ def update_topic( :type room_id: str :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str - :param resource: The resource instance. Is either a ChatTopicUpdate type or a IO[bytes] type. + :param topic: The resource instance. Is either a ChatTopicUpdate type or a IO[bytes] type. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopicUpdate or + :type topic: ~azure.messaging.webpubsubchatservice.models.ChatTopicUpdate or ~azure.messaging.webpubsubchatservice.types.ChatTopicUpdate or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. @@ -2842,10 +2843,10 @@ def update_topic( content_type = content_type or "application/merge-patch+json" _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource + if isinstance(topic, (IOBase, bytes)): + _content = topic else: - _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(topic, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_web_pub_sub_chat_service_update_topic_request( room_id=room_id, @@ -3081,7 +3082,7 @@ def create_or_replace_room_member( self, room_id: str, user_id: str, - resource: _models.ChatRoomMemberCreateOrReplace, + member: _models.ChatRoomMemberCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -3096,8 +3097,8 @@ def create_or_replace_room_member( :type room_id: str :param user_id: User ID of the member. Required. :type user_id: str - :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomMemberCreateOrReplace + :param member: The resource instance. Required. + :type member: ~azure.messaging.webpubsubchatservice.models.ChatRoomMemberCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -3116,7 +3117,7 @@ def create_or_replace_room_member( self, room_id: str, user_id: str, - resource: _types.ChatRoomMemberCreateOrReplace, + member: _types.ChatRoomMemberCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -3131,8 +3132,8 @@ def create_or_replace_room_member( :type room_id: str :param user_id: User ID of the member. Required. :type user_id: str - :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatRoomMemberCreateOrReplace + :param member: The resource instance. Required. + :type member: ~azure.messaging.webpubsubchatservice.types.ChatRoomMemberCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -3151,7 +3152,7 @@ def create_or_replace_room_member( self, room_id: str, user_id: str, - resource: IO[bytes], + member: IO[bytes], *, content_type: str = "application/json", etag: Optional[str] = None, @@ -3166,8 +3167,8 @@ def create_or_replace_room_member( :type room_id: str :param user_id: User ID of the member. Required. :type user_id: str - :param resource: The resource instance. Required. - :type resource: IO[bytes] + :param member: The resource instance. Required. + :type member: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -3186,7 +3187,7 @@ def create_or_replace_room_member( self, room_id: str, user_id: str, - resource: Union[_models.ChatRoomMemberCreateOrReplace, _types.ChatRoomMemberCreateOrReplace, IO[bytes]], + member: Union[_models.ChatRoomMemberCreateOrReplace, _types.ChatRoomMemberCreateOrReplace, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -3200,9 +3201,9 @@ def create_or_replace_room_member( :type room_id: str :param user_id: User ID of the member. Required. :type user_id: str - :param resource: The resource instance. Is either a ChatRoomMemberCreateOrReplace type or a + :param member: The resource instance. Is either a ChatRoomMemberCreateOrReplace type or a IO[bytes] type. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomMemberCreateOrReplace or + :type member: ~azure.messaging.webpubsubchatservice.models.ChatRoomMemberCreateOrReplace or ~azure.messaging.webpubsubchatservice.types.ChatRoomMemberCreateOrReplace or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. @@ -3235,10 +3236,10 @@ def create_or_replace_room_member( content_type = content_type or "application/json" _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource + if isinstance(member, (IOBase, bytes)): + _content = member else: - _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(member, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_web_pub_sub_chat_service_create_or_replace_room_member_request( room_id=room_id, @@ -3530,7 +3531,7 @@ def get_user(self, user_id: str, **kwargs: Any) -> _models.ChatUser: def create_or_replace_user( self, user_id: str, - resource: _models.ChatUserCreateOrReplace, + user: _models.ChatUserCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -3544,8 +3545,8 @@ def create_or_replace_user( :param user_id: User identifier. Required. :type user_id: str - :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatUserCreateOrReplace + :param user: The resource instance. Required. + :type user: ~azure.messaging.webpubsubchatservice.models.ChatUserCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -3563,7 +3564,7 @@ def create_or_replace_user( def create_or_replace_user( self, user_id: str, - resource: _types.ChatUserCreateOrReplace, + user: _types.ChatUserCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -3577,8 +3578,8 @@ def create_or_replace_user( :param user_id: User identifier. Required. :type user_id: str - :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatUserCreateOrReplace + :param user: The resource instance. Required. + :type user: ~azure.messaging.webpubsubchatservice.types.ChatUserCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -3596,7 +3597,7 @@ def create_or_replace_user( def create_or_replace_user( self, user_id: str, - resource: IO[bytes], + user: IO[bytes], *, content_type: str = "application/json", etag: Optional[str] = None, @@ -3610,8 +3611,8 @@ def create_or_replace_user( :param user_id: User identifier. Required. :type user_id: str - :param resource: The resource instance. Required. - :type resource: IO[bytes] + :param user: The resource instance. Required. + :type user: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -3629,7 +3630,7 @@ def create_or_replace_user( def create_or_replace_user( self, user_id: str, - resource: Union[_models.ChatUserCreateOrReplace, _types.ChatUserCreateOrReplace, IO[bytes]], + user: Union[_models.ChatUserCreateOrReplace, _types.ChatUserCreateOrReplace, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -3642,9 +3643,9 @@ def create_or_replace_user( :param user_id: User identifier. Required. :type user_id: str - :param resource: The resource instance. Is either a ChatUserCreateOrReplace type or a IO[bytes] + :param user: The resource instance. Is either a ChatUserCreateOrReplace type or a IO[bytes] type. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatUserCreateOrReplace or + :type user: ~azure.messaging.webpubsubchatservice.models.ChatUserCreateOrReplace or ~azure.messaging.webpubsubchatservice.types.ChatUserCreateOrReplace or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. @@ -3677,10 +3678,10 @@ def create_or_replace_user( content_type = content_type or "application/json" _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource + if isinstance(user, (IOBase, bytes)): + _content = user else: - _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(user, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_web_pub_sub_chat_service_create_or_replace_user_request( user_id=user_id, diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_operations/_operations.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_operations/_operations.py index 23031867f1bc..268386a7ebfa 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_operations/_operations.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_operations/_operations.py @@ -149,7 +149,8 @@ def list_messages( ) -> AsyncItemPaged["_models.ChatMessage"]: """Query messages in a conversation from latest to earliest. - Query messages in a conversation from latest to earliest. + Message IDs are used as pagination cursors. Follow the response nextLink, which contains the + message ID cursor, to retrieve the next page. :param conversation_id: Conversation identifier. Required. :type conversation_id: str @@ -331,7 +332,7 @@ async def update_message( self, conversation_id: str, message_id: str, - resource: _models.ChatMessageUpdate, + message: _models.ChatMessageUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = None, @@ -346,8 +347,8 @@ async def update_message( :type conversation_id: str :param message_id: Message identifier. Required. :type message_id: str - :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatMessageUpdate + :param message: The resource instance. Required. + :type message: ~azure.messaging.webpubsubchatservice.models.ChatMessageUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -366,7 +367,7 @@ async def update_message( self, conversation_id: str, message_id: str, - resource: _types.ChatMessageUpdate, + message: _types.ChatMessageUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = None, @@ -381,8 +382,8 @@ async def update_message( :type conversation_id: str :param message_id: Message identifier. Required. :type message_id: str - :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatMessageUpdate + :param message: The resource instance. Required. + :type message: ~azure.messaging.webpubsubchatservice.types.ChatMessageUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -401,7 +402,7 @@ async def update_message( self, conversation_id: str, message_id: str, - resource: IO[bytes], + message: IO[bytes], *, content_type: str = "application/merge-patch+json", etag: Optional[str] = None, @@ -416,8 +417,8 @@ async def update_message( :type conversation_id: str :param message_id: Message identifier. Required. :type message_id: str - :param resource: The resource instance. Required. - :type resource: IO[bytes] + :param message: The resource instance. Required. + :type message: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -436,7 +437,7 @@ async def update_message( self, conversation_id: str, message_id: str, - resource: Union[_models.ChatMessageUpdate, _types.ChatMessageUpdate, IO[bytes]], + message: Union[_models.ChatMessageUpdate, _types.ChatMessageUpdate, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -450,9 +451,9 @@ async def update_message( :type conversation_id: str :param message_id: Message identifier. Required. :type message_id: str - :param resource: The resource instance. Is either a ChatMessageUpdate type or a IO[bytes] type. + :param message: The resource instance. Is either a ChatMessageUpdate type or a IO[bytes] type. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatMessageUpdate or + :type message: ~azure.messaging.webpubsubchatservice.models.ChatMessageUpdate or ~azure.messaging.webpubsubchatservice.types.ChatMessageUpdate or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. @@ -485,10 +486,10 @@ async def update_message( content_type = content_type or "application/merge-patch+json" _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource + if isinstance(message, (IOBase, bytes)): + _content = message else: - _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(message, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_web_pub_sub_chat_service_update_message_request( conversation_id=conversation_id, @@ -700,7 +701,7 @@ async def get_role(self, role_name: str, **kwargs: Any) -> _models.ChatRole: async def create_or_replace_role( self, role_name: str, - resource: _models.ChatRoleCreateOrReplace, + role: _models.ChatRoleCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -713,8 +714,8 @@ async def create_or_replace_role( :param role_name: Role name. Must start with 'user.' or 'room.' prefix. Required. :type role_name: str - :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoleCreateOrReplace + :param role: The resource instance. Required. + :type role: ~azure.messaging.webpubsubchatservice.models.ChatRoleCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -732,7 +733,7 @@ async def create_or_replace_role( async def create_or_replace_role( self, role_name: str, - resource: _types.ChatRoleCreateOrReplace, + role: _types.ChatRoleCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -745,8 +746,8 @@ async def create_or_replace_role( :param role_name: Role name. Must start with 'user.' or 'room.' prefix. Required. :type role_name: str - :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatRoleCreateOrReplace + :param role: The resource instance. Required. + :type role: ~azure.messaging.webpubsubchatservice.types.ChatRoleCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -764,7 +765,7 @@ async def create_or_replace_role( async def create_or_replace_role( self, role_name: str, - resource: IO[bytes], + role: IO[bytes], *, content_type: str = "application/json", etag: Optional[str] = None, @@ -777,8 +778,8 @@ async def create_or_replace_role( :param role_name: Role name. Must start with 'user.' or 'room.' prefix. Required. :type role_name: str - :param resource: The resource instance. Required. - :type resource: IO[bytes] + :param role: The resource instance. Required. + :type role: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -796,7 +797,7 @@ async def create_or_replace_role( async def create_or_replace_role( self, role_name: str, - resource: Union[_models.ChatRoleCreateOrReplace, _types.ChatRoleCreateOrReplace, IO[bytes]], + role: Union[_models.ChatRoleCreateOrReplace, _types.ChatRoleCreateOrReplace, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -808,9 +809,9 @@ async def create_or_replace_role( :param role_name: Role name. Must start with 'user.' or 'room.' prefix. Required. :type role_name: str - :param resource: The resource instance. Is either a ChatRoleCreateOrReplace type or a IO[bytes] + :param role: The resource instance. Is either a ChatRoleCreateOrReplace type or a IO[bytes] type. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoleCreateOrReplace or + :type role: ~azure.messaging.webpubsubchatservice.models.ChatRoleCreateOrReplace or ~azure.messaging.webpubsubchatservice.types.ChatRoleCreateOrReplace or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. @@ -843,10 +844,10 @@ async def create_or_replace_role( content_type = content_type or "application/json" _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource + if isinstance(role, (IOBase, bytes)): + _content = role else: - _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(role, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_web_pub_sub_chat_service_create_or_replace_role_request( role_name=role_name, @@ -1069,7 +1070,7 @@ async def get_next(next_link=None): async def create_or_replace_room( self, room_id: str, - resource: _models.ChatRoomCreateOrReplace, + room: _models.ChatRoomCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -1082,8 +1083,8 @@ async def create_or_replace_room( :param room_id: Room identifier. Required. :type room_id: str - :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomCreateOrReplace + :param room: The resource instance. Required. + :type room: ~azure.messaging.webpubsubchatservice.models.ChatRoomCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1101,7 +1102,7 @@ async def create_or_replace_room( async def create_or_replace_room( self, room_id: str, - resource: _types.ChatRoomCreateOrReplace, + room: _types.ChatRoomCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -1114,8 +1115,8 @@ async def create_or_replace_room( :param room_id: Room identifier. Required. :type room_id: str - :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatRoomCreateOrReplace + :param room: The resource instance. Required. + :type room: ~azure.messaging.webpubsubchatservice.types.ChatRoomCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1133,7 +1134,7 @@ async def create_or_replace_room( async def create_or_replace_room( self, room_id: str, - resource: IO[bytes], + room: IO[bytes], *, content_type: str = "application/json", etag: Optional[str] = None, @@ -1146,8 +1147,8 @@ async def create_or_replace_room( :param room_id: Room identifier. Required. :type room_id: str - :param resource: The resource instance. Required. - :type resource: IO[bytes] + :param room: The resource instance. Required. + :type room: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -1165,7 +1166,7 @@ async def create_or_replace_room( async def create_or_replace_room( self, room_id: str, - resource: Union[_models.ChatRoomCreateOrReplace, _types.ChatRoomCreateOrReplace, IO[bytes]], + room: Union[_models.ChatRoomCreateOrReplace, _types.ChatRoomCreateOrReplace, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -1177,9 +1178,9 @@ async def create_or_replace_room( :param room_id: Room identifier. Required. :type room_id: str - :param resource: The resource instance. Is either a ChatRoomCreateOrReplace type or a IO[bytes] + :param room: The resource instance. Is either a ChatRoomCreateOrReplace type or a IO[bytes] type. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomCreateOrReplace or + :type room: ~azure.messaging.webpubsubchatservice.models.ChatRoomCreateOrReplace or ~azure.messaging.webpubsubchatservice.types.ChatRoomCreateOrReplace or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. @@ -1212,10 +1213,10 @@ async def create_or_replace_room( content_type = content_type or "application/json" _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource + if isinstance(room, (IOBase, bytes)): + _content = room else: - _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(room, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_web_pub_sub_chat_service_create_or_replace_room_request( room_id=room_id, @@ -1508,7 +1509,7 @@ async def create_or_replace_topic( self, room_id: str, topic_id: str, - resource: _models.ChatTopicCreateOrReplace, + topic: _models.ChatTopicCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -1523,8 +1524,8 @@ async def create_or_replace_topic( :type room_id: str :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str - :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopicCreateOrReplace + :param topic: The resource instance. Required. + :type topic: ~azure.messaging.webpubsubchatservice.models.ChatTopicCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1543,7 +1544,7 @@ async def create_or_replace_topic( self, room_id: str, topic_id: str, - resource: _types.ChatTopicCreateOrReplace, + topic: _types.ChatTopicCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -1558,8 +1559,8 @@ async def create_or_replace_topic( :type room_id: str :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str - :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatTopicCreateOrReplace + :param topic: The resource instance. Required. + :type topic: ~azure.messaging.webpubsubchatservice.types.ChatTopicCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1578,7 +1579,7 @@ async def create_or_replace_topic( self, room_id: str, topic_id: str, - resource: IO[bytes], + topic: IO[bytes], *, content_type: str = "application/json", etag: Optional[str] = None, @@ -1593,8 +1594,8 @@ async def create_or_replace_topic( :type room_id: str :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str - :param resource: The resource instance. Required. - :type resource: IO[bytes] + :param topic: The resource instance. Required. + :type topic: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -1629,7 +1630,7 @@ async def create_or_replace_topic( self, room_id: str, topic_id: str, - resource: Union[_models.ChatTopicCreateOrReplace, _types.ChatTopicCreateOrReplace, IO[bytes]], + topic: Union[_models.ChatTopicCreateOrReplace, _types.ChatTopicCreateOrReplace, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -1643,9 +1644,9 @@ async def create_or_replace_topic( :type room_id: str :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str - :param resource: The resource instance. Is either a ChatTopicCreateOrReplace type or a - IO[bytes] type. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopicCreateOrReplace or + :param topic: The resource instance. Is either a ChatTopicCreateOrReplace type or a IO[bytes] + type. Required. + :type topic: ~azure.messaging.webpubsubchatservice.models.ChatTopicCreateOrReplace or ~azure.messaging.webpubsubchatservice.types.ChatTopicCreateOrReplace or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. @@ -1678,10 +1679,10 @@ async def create_or_replace_topic( content_type = content_type or "application/json" _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource + if isinstance(topic, (IOBase, bytes)): + _content = topic else: - _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(topic, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_web_pub_sub_chat_service_create_or_replace_topic_request( room_id=room_id, @@ -1807,7 +1808,7 @@ async def update_topic( self, room_id: str, topic_id: str, - resource: _models.ChatTopicUpdate, + topic: _models.ChatTopicUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = None, @@ -1822,8 +1823,8 @@ async def update_topic( :type room_id: str :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str - :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopicUpdate + :param topic: The resource instance. Required. + :type topic: ~azure.messaging.webpubsubchatservice.models.ChatTopicUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -1842,7 +1843,7 @@ async def update_topic( self, room_id: str, topic_id: str, - resource: _types.ChatTopicUpdate, + topic: _types.ChatTopicUpdate, *, content_type: str = "application/merge-patch+json", etag: Optional[str] = None, @@ -1857,8 +1858,8 @@ async def update_topic( :type room_id: str :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str - :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatTopicUpdate + :param topic: The resource instance. Required. + :type topic: ~azure.messaging.webpubsubchatservice.types.ChatTopicUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -1877,7 +1878,7 @@ async def update_topic( self, room_id: str, topic_id: str, - resource: IO[bytes], + topic: IO[bytes], *, content_type: str = "application/merge-patch+json", etag: Optional[str] = None, @@ -1892,8 +1893,8 @@ async def update_topic( :type room_id: str :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str - :param resource: The resource instance. Required. - :type resource: IO[bytes] + :param topic: The resource instance. Required. + :type topic: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -1928,7 +1929,7 @@ async def update_topic( self, room_id: str, topic_id: str, - resource: Union[_models.ChatTopicUpdate, _types.ChatTopicUpdate, IO[bytes]], + topic: Union[_models.ChatTopicUpdate, _types.ChatTopicUpdate, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -1942,9 +1943,9 @@ async def update_topic( :type room_id: str :param topic_id: Topic identifier unique within the room. Required. :type topic_id: str - :param resource: The resource instance. Is either a ChatTopicUpdate type or a IO[bytes] type. + :param topic: The resource instance. Is either a ChatTopicUpdate type or a IO[bytes] type. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatTopicUpdate or + :type topic: ~azure.messaging.webpubsubchatservice.models.ChatTopicUpdate or ~azure.messaging.webpubsubchatservice.types.ChatTopicUpdate or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. @@ -1977,10 +1978,10 @@ async def update_topic( content_type = content_type or "application/merge-patch+json" _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource + if isinstance(topic, (IOBase, bytes)): + _content = topic else: - _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(topic, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_web_pub_sub_chat_service_update_topic_request( room_id=room_id, @@ -2216,7 +2217,7 @@ async def create_or_replace_room_member( self, room_id: str, user_id: str, - resource: _models.ChatRoomMemberCreateOrReplace, + member: _models.ChatRoomMemberCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -2231,8 +2232,8 @@ async def create_or_replace_room_member( :type room_id: str :param user_id: User ID of the member. Required. :type user_id: str - :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomMemberCreateOrReplace + :param member: The resource instance. Required. + :type member: ~azure.messaging.webpubsubchatservice.models.ChatRoomMemberCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2251,7 +2252,7 @@ async def create_or_replace_room_member( self, room_id: str, user_id: str, - resource: _types.ChatRoomMemberCreateOrReplace, + member: _types.ChatRoomMemberCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -2266,8 +2267,8 @@ async def create_or_replace_room_member( :type room_id: str :param user_id: User ID of the member. Required. :type user_id: str - :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatRoomMemberCreateOrReplace + :param member: The resource instance. Required. + :type member: ~azure.messaging.webpubsubchatservice.types.ChatRoomMemberCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2286,7 +2287,7 @@ async def create_or_replace_room_member( self, room_id: str, user_id: str, - resource: IO[bytes], + member: IO[bytes], *, content_type: str = "application/json", etag: Optional[str] = None, @@ -2301,8 +2302,8 @@ async def create_or_replace_room_member( :type room_id: str :param user_id: User ID of the member. Required. :type user_id: str - :param resource: The resource instance. Required. - :type resource: IO[bytes] + :param member: The resource instance. Required. + :type member: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -2321,7 +2322,7 @@ async def create_or_replace_room_member( self, room_id: str, user_id: str, - resource: Union[_models.ChatRoomMemberCreateOrReplace, _types.ChatRoomMemberCreateOrReplace, IO[bytes]], + member: Union[_models.ChatRoomMemberCreateOrReplace, _types.ChatRoomMemberCreateOrReplace, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -2335,9 +2336,9 @@ async def create_or_replace_room_member( :type room_id: str :param user_id: User ID of the member. Required. :type user_id: str - :param resource: The resource instance. Is either a ChatRoomMemberCreateOrReplace type or a + :param member: The resource instance. Is either a ChatRoomMemberCreateOrReplace type or a IO[bytes] type. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatRoomMemberCreateOrReplace or + :type member: ~azure.messaging.webpubsubchatservice.models.ChatRoomMemberCreateOrReplace or ~azure.messaging.webpubsubchatservice.types.ChatRoomMemberCreateOrReplace or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. @@ -2370,10 +2371,10 @@ async def create_or_replace_room_member( content_type = content_type or "application/json" _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource + if isinstance(member, (IOBase, bytes)): + _content = member else: - _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(member, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_web_pub_sub_chat_service_create_or_replace_room_member_request( room_id=room_id, @@ -2666,7 +2667,7 @@ async def get_user(self, user_id: str, **kwargs: Any) -> _models.ChatUser: async def create_or_replace_user( self, user_id: str, - resource: _models.ChatUserCreateOrReplace, + user: _models.ChatUserCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -2680,8 +2681,8 @@ async def create_or_replace_user( :param user_id: User identifier. Required. :type user_id: str - :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatUserCreateOrReplace + :param user: The resource instance. Required. + :type user: ~azure.messaging.webpubsubchatservice.models.ChatUserCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2699,7 +2700,7 @@ async def create_or_replace_user( async def create_or_replace_user( self, user_id: str, - resource: _types.ChatUserCreateOrReplace, + user: _types.ChatUserCreateOrReplace, *, content_type: str = "application/json", etag: Optional[str] = None, @@ -2713,8 +2714,8 @@ async def create_or_replace_user( :param user_id: User identifier. Required. :type user_id: str - :param resource: The resource instance. Required. - :type resource: ~azure.messaging.webpubsubchatservice.types.ChatUserCreateOrReplace + :param user: The resource instance. Required. + :type user: ~azure.messaging.webpubsubchatservice.types.ChatUserCreateOrReplace :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2732,7 +2733,7 @@ async def create_or_replace_user( async def create_or_replace_user( self, user_id: str, - resource: IO[bytes], + user: IO[bytes], *, content_type: str = "application/json", etag: Optional[str] = None, @@ -2746,8 +2747,8 @@ async def create_or_replace_user( :param user_id: User identifier. Required. :type user_id: str - :param resource: The resource instance. Required. - :type resource: IO[bytes] + :param user: The resource instance. Required. + :type user: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -2765,7 +2766,7 @@ async def create_or_replace_user( async def create_or_replace_user( self, user_id: str, - resource: Union[_models.ChatUserCreateOrReplace, _types.ChatUserCreateOrReplace, IO[bytes]], + user: Union[_models.ChatUserCreateOrReplace, _types.ChatUserCreateOrReplace, IO[bytes]], *, etag: Optional[str] = None, match_condition: Optional[MatchConditions] = None, @@ -2778,9 +2779,9 @@ async def create_or_replace_user( :param user_id: User identifier. Required. :type user_id: str - :param resource: The resource instance. Is either a ChatUserCreateOrReplace type or a IO[bytes] + :param user: The resource instance. Is either a ChatUserCreateOrReplace type or a IO[bytes] type. Required. - :type resource: ~azure.messaging.webpubsubchatservice.models.ChatUserCreateOrReplace or + :type user: ~azure.messaging.webpubsubchatservice.models.ChatUserCreateOrReplace or ~azure.messaging.webpubsubchatservice.types.ChatUserCreateOrReplace or IO[bytes] :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is None. @@ -2813,10 +2814,10 @@ async def create_or_replace_user( content_type = content_type or "application/json" _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource + if isinstance(user, (IOBase, bytes)): + _content = user else: - _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(user, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_web_pub_sub_chat_service_create_or_replace_user_request( user_id=user_id, diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/_models.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/_models.py index 1bf1a96641aa..af7407bb8058 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/_models.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/models/_models.py @@ -23,15 +23,15 @@ class ChatConversation(_Model): # pylint: disable=docstring-keyword-should-matc :ivar id: Conversation identifier. Required. :vartype id: str - :ivar parent_room: Parent room identifier. Required. - :vartype parent_room: str + :ivar room_id: Parent room identifier. Required. + :vartype room_id: str :ivar etag: The entity tag for this resource. Required. :vartype etag: str """ id: str = rest_field(visibility=["read"]) """Conversation identifier. Required.""" - parent_room: str = rest_field(name="parentRoom", visibility=["read", "create", "update", "delete", "query"]) + room_id: str = rest_field(name="parentRoom", visibility=["read", "create", "update", "delete", "query"]) """Parent room identifier. Required.""" etag: str = rest_field(visibility=["read"]) """The entity tag for this resource. Required.""" @@ -40,7 +40,7 @@ class ChatConversation(_Model): # pylint: disable=docstring-keyword-should-matc def __init__( self, *, - parent_room: str, + room_id: str, ) -> None: ... @overload diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_role.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_role.py deleted file mode 100644 index e0b3453fc157..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_role.py +++ /dev/null @@ -1,43 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-messaging-webpubsubchatservice -# USAGE - python create_or_replace_role.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = WebPubSubChatServiceClient( - endpoint="ENDPOINT", - credential=DefaultAzureCredential(), - hub="HUB", - ) - - response = client.create_or_replace_role( - role_name="room.moderator", - resource={"permissions": ["room.history", "room.remove_user", "room.publish_message"]}, - ) - print(response) - - -# x-ms-original-file: 2026-08-01-preview/CreateOrReplaceRole.json -if __name__ == "__main__": - main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_room.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_room.py deleted file mode 100644 index 316c879cf38b..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_room.py +++ /dev/null @@ -1,43 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-messaging-webpubsubchatservice -# USAGE - python create_or_replace_room.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = WebPubSubChatServiceClient( - endpoint="ENDPOINT", - credential=DefaultAzureCredential(), - hub="HUB", - ) - - response = client.create_or_replace_room( - room_id="room1", - resource={"title": "General Chat"}, - ) - print(response) - - -# x-ms-original-file: 2026-08-01-preview/CreateOrReplaceRoom.json -if __name__ == "__main__": - main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_room_member.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_room_member.py deleted file mode 100644 index 9148863099ba..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_room_member.py +++ /dev/null @@ -1,44 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-messaging-webpubsubchatservice -# USAGE - python create_or_replace_room_member.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = WebPubSubChatServiceClient( - endpoint="ENDPOINT", - credential=DefaultAzureCredential(), - hub="HUB", - ) - - response = client.create_or_replace_room_member( - room_id="room1", - user_id="user1", - resource={"roleName": "room.member"}, - ) - print(response) - - -# x-ms-original-file: 2026-08-01-preview/CreateOrReplaceRoomMember.json -if __name__ == "__main__": - main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_topic.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_topic.py deleted file mode 100644 index 94f745112aaf..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_topic.py +++ /dev/null @@ -1,44 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-messaging-webpubsubchatservice -# USAGE - python create_or_replace_topic.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = WebPubSubChatServiceClient( - endpoint="ENDPOINT", - credential=DefaultAzureCredential(), - hub="HUB", - ) - - response = client.create_or_replace_topic( - room_id="general", - topic_id="product-updates", - resource={"state": "Normal", "title": "Product updates"}, - ) - print(response) - - -# x-ms-original-file: 2026-08-01-preview/CreateOrReplaceTopic.json -if __name__ == "__main__": - main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_user.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_user.py deleted file mode 100644 index 8156c33fd3fc..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_user.py +++ /dev/null @@ -1,43 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-messaging-webpubsubchatservice -# USAGE - python create_or_replace_user.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = WebPubSubChatServiceClient( - endpoint="ENDPOINT", - credential=DefaultAzureCredential(), - hub="HUB", - ) - - response = client.create_or_replace_user( - user_id="user1", - resource={"kind": "Human", "nickname": "John", "roleName": "user.normal"}, - ) - print(response) - - -# x-ms-original-file: 2026-08-01-preview/CreateOrReplaceUser.json -if __name__ == "__main__": - main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_message.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_message.py deleted file mode 100644 index 1527addb226d..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_message.py +++ /dev/null @@ -1,42 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-messaging-webpubsubchatservice -# USAGE - python delete_message.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = WebPubSubChatServiceClient( - endpoint="ENDPOINT", - credential=DefaultAzureCredential(), - hub="HUB", - ) - - client.delete_message( - conversation_id="c.room1.abcd1234", - message_id="123", - ) - - -# x-ms-original-file: 2026-08-01-preview/DeleteMessage.json -if __name__ == "__main__": - main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_role.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_role.py deleted file mode 100644 index addfcf6c1f82..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_role.py +++ /dev/null @@ -1,41 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-messaging-webpubsubchatservice -# USAGE - python delete_role.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = WebPubSubChatServiceClient( - endpoint="ENDPOINT", - credential=DefaultAzureCredential(), - hub="HUB", - ) - - client.delete_role( - role_name="room.moderator", - ) - - -# x-ms-original-file: 2026-08-01-preview/DeleteRole.json -if __name__ == "__main__": - main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_room.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_room.py deleted file mode 100644 index dba2c279bef4..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_room.py +++ /dev/null @@ -1,41 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-messaging-webpubsubchatservice -# USAGE - python delete_room.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = WebPubSubChatServiceClient( - endpoint="ENDPOINT", - credential=DefaultAzureCredential(), - hub="HUB", - ) - - client.delete_room( - room_id="room1", - ) - - -# x-ms-original-file: 2026-08-01-preview/DeleteRoom.json -if __name__ == "__main__": - main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_room_member.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_room_member.py deleted file mode 100644 index ab99523d2bda..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_room_member.py +++ /dev/null @@ -1,42 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-messaging-webpubsubchatservice -# USAGE - python delete_room_member.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = WebPubSubChatServiceClient( - endpoint="ENDPOINT", - credential=DefaultAzureCredential(), - hub="HUB", - ) - - client.delete_room_member( - room_id="room1", - user_id="user1", - ) - - -# x-ms-original-file: 2026-08-01-preview/DeleteRoomMember.json -if __name__ == "__main__": - main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_topic.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_topic.py deleted file mode 100644 index 67d977717dbf..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_topic.py +++ /dev/null @@ -1,42 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-messaging-webpubsubchatservice -# USAGE - python delete_topic.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = WebPubSubChatServiceClient( - endpoint="ENDPOINT", - credential=DefaultAzureCredential(), - hub="HUB", - ) - - client.delete_topic( - room_id="general", - topic_id="product-updates", - ) - - -# x-ms-original-file: 2026-08-01-preview/DeleteTopic.json -if __name__ == "__main__": - main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_user.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_user.py deleted file mode 100644 index 902ced02d693..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_user.py +++ /dev/null @@ -1,41 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-messaging-webpubsubchatservice -# USAGE - python delete_user.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = WebPubSubChatServiceClient( - endpoint="ENDPOINT", - credential=DefaultAzureCredential(), - hub="HUB", - ) - - client.delete_user( - user_id="user1", - ) - - -# x-ms-original-file: 2026-08-01-preview/DeleteUser.json -if __name__ == "__main__": - main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_conversation.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_conversation.py deleted file mode 100644 index e28d14316bd9..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_conversation.py +++ /dev/null @@ -1,42 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-messaging-webpubsubchatservice -# USAGE - python get_conversation.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = WebPubSubChatServiceClient( - endpoint="ENDPOINT", - credential=DefaultAzureCredential(), - hub="HUB", - ) - - response = client.get_conversation( - conversation_id="c.room1.abcd1234", - ) - print(response) - - -# x-ms-original-file: 2026-08-01-preview/GetConversation.json -if __name__ == "__main__": - main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_role.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_role.py deleted file mode 100644 index 98bca6032d60..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_role.py +++ /dev/null @@ -1,42 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-messaging-webpubsubchatservice -# USAGE - python get_role.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = WebPubSubChatServiceClient( - endpoint="ENDPOINT", - credential=DefaultAzureCredential(), - hub="HUB", - ) - - response = client.get_role( - role_name="room.operator", - ) - print(response) - - -# x-ms-original-file: 2026-08-01-preview/GetRole.json -if __name__ == "__main__": - main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_room.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_room.py deleted file mode 100644 index 690e24b8f7d3..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_room.py +++ /dev/null @@ -1,42 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-messaging-webpubsubchatservice -# USAGE - python get_room.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = WebPubSubChatServiceClient( - endpoint="ENDPOINT", - credential=DefaultAzureCredential(), - hub="HUB", - ) - - response = client.get_room( - room_id="room1", - ) - print(response) - - -# x-ms-original-file: 2026-08-01-preview/GetRoom.json -if __name__ == "__main__": - main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_topic.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_topic.py deleted file mode 100644 index 86ac3e9f5d71..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_topic.py +++ /dev/null @@ -1,43 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-messaging-webpubsubchatservice -# USAGE - python get_topic.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = WebPubSubChatServiceClient( - endpoint="ENDPOINT", - credential=DefaultAzureCredential(), - hub="HUB", - ) - - response = client.get_topic( - room_id="general", - topic_id="product-updates", - ) - print(response) - - -# x-ms-original-file: 2026-08-01-preview/GetTopic.json -if __name__ == "__main__": - main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_user.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_user.py deleted file mode 100644 index e3d1f924b73e..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_user.py +++ /dev/null @@ -1,42 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-messaging-webpubsubchatservice -# USAGE - python get_user.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = WebPubSubChatServiceClient( - endpoint="ENDPOINT", - credential=DefaultAzureCredential(), - hub="HUB", - ) - - response = client.get_user( - user_id="user1", - ) - print(response) - - -# x-ms-original-file: 2026-08-01-preview/GetUser.json -if __name__ == "__main__": - main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_messages.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_messages.py deleted file mode 100644 index cfc2db10651e..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_messages.py +++ /dev/null @@ -1,43 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-messaging-webpubsubchatservice -# USAGE - python list_messages.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = WebPubSubChatServiceClient( - endpoint="ENDPOINT", - credential=DefaultAzureCredential(), - hub="HUB", - ) - - response = client.list_messages( - conversation_id="c.room1.abcd1234", - ) - for item in response: - print(item) - - -# x-ms-original-file: 2026-08-01-preview/ListMessages.json -if __name__ == "__main__": - main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_roles.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_roles.py deleted file mode 100644 index 84022601b080..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_roles.py +++ /dev/null @@ -1,41 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-messaging-webpubsubchatservice -# USAGE - python list_roles.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = WebPubSubChatServiceClient( - endpoint="ENDPOINT", - credential=DefaultAzureCredential(), - hub="HUB", - ) - - response = client.list_roles() - for item in response: - print(item) - - -# x-ms-original-file: 2026-08-01-preview/ListRoles.json -if __name__ == "__main__": - main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_room_members.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_room_members.py deleted file mode 100644 index eae5bf7cb81d..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_room_members.py +++ /dev/null @@ -1,43 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-messaging-webpubsubchatservice -# USAGE - python list_room_members.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = WebPubSubChatServiceClient( - endpoint="ENDPOINT", - credential=DefaultAzureCredential(), - hub="HUB", - ) - - response = client.list_room_members( - room_id="room1", - ) - for item in response: - print(item) - - -# x-ms-original-file: 2026-08-01-preview/ListRoomMembers.json -if __name__ == "__main__": - main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_rooms.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_rooms.py deleted file mode 100644 index 524984c1a2c1..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_rooms.py +++ /dev/null @@ -1,41 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-messaging-webpubsubchatservice -# USAGE - python list_rooms.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = WebPubSubChatServiceClient( - endpoint="ENDPOINT", - credential=DefaultAzureCredential(), - hub="HUB", - ) - - response = client.list_rooms() - for item in response: - print(item) - - -# x-ms-original-file: 2026-08-01-preview/ListRooms.json -if __name__ == "__main__": - main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_rooms_for_user.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_rooms_for_user.py deleted file mode 100644 index 947ee42589ff..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_rooms_for_user.py +++ /dev/null @@ -1,43 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-messaging-webpubsubchatservice -# USAGE - python list_rooms_for_user.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = WebPubSubChatServiceClient( - endpoint="ENDPOINT", - credential=DefaultAzureCredential(), - hub="HUB", - ) - - response = client.list_rooms_for_user( - user_id="alex", - ) - for item in response: - print(item) - - -# x-ms-original-file: 2026-08-01-preview/ListRoomsForUser.json -if __name__ == "__main__": - main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_topics.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_topics.py deleted file mode 100644 index d70491b74985..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_topics.py +++ /dev/null @@ -1,43 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-messaging-webpubsubchatservice -# USAGE - python list_topics.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = WebPubSubChatServiceClient( - endpoint="ENDPOINT", - credential=DefaultAzureCredential(), - hub="HUB", - ) - - response = client.list_topics( - room_id="general", - ) - for item in response: - print(item) - - -# x-ms-original-file: 2026-08-01-preview/ListTopics.json -if __name__ == "__main__": - main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_users.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_users.py deleted file mode 100644 index 7c76c30636eb..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_users.py +++ /dev/null @@ -1,41 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-messaging-webpubsubchatservice -# USAGE - python list_users.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = WebPubSubChatServiceClient( - endpoint="ENDPOINT", - credential=DefaultAzureCredential(), - hub="HUB", - ) - - response = client.list_users() - for item in response: - print(item) - - -# x-ms-original-file: 2026-08-01-preview/ListUsers.json -if __name__ == "__main__": - main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/update_message.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/update_message.py deleted file mode 100644 index 1e68882d5e4f..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/update_message.py +++ /dev/null @@ -1,44 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-messaging-webpubsubchatservice -# USAGE - python update_message.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = WebPubSubChatServiceClient( - endpoint="ENDPOINT", - credential=DefaultAzureCredential(), - hub="HUB", - ) - - response = client.update_message( - conversation_id="c.room1.abcd1234", - message_id="123", - resource={"content": {"text": "Updated message text"}, "createdBy": "user1"}, - ) - print(response) - - -# x-ms-original-file: 2026-08-01-preview/UpdateMessage.json -if __name__ == "__main__": - main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/update_topic.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/update_topic.py deleted file mode 100644 index f15da011222d..000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/update_topic.py +++ /dev/null @@ -1,44 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-messaging-webpubsubchatservice -# USAGE - python update_topic.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = WebPubSubChatServiceClient( - endpoint="ENDPOINT", - credential=DefaultAzureCredential(), - hub="HUB", - ) - - response = client.update_topic( - room_id="general", - topic_id="product-updates", - resource={"state": "Archived"}, - ) - print(response) - - -# x-ms-original-file: 2026-08-01-preview/UpdateTopic.json -if __name__ == "__main__": - main() diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service.py index bb6731b0f563..44b1ea15f37d 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service.py @@ -53,7 +53,7 @@ def test_update_message(self, webpubsubchatservice_endpoint): response = client.update_message( conversation_id="str", message_id="str", - resource={"content": {"binary": bytes("bytes", encoding="utf-8"), "text": "str"}, "createdBy": "str"}, + message={"content": {"binary": bytes("bytes", encoding="utf-8"), "text": "str"}, "createdBy": "str"}, ) # please add some check logic here by yourself @@ -85,7 +85,7 @@ def test_create_or_replace_role(self, webpubsubchatservice_endpoint): client = self.create_client(endpoint=webpubsubchatservice_endpoint) response = client.create_or_replace_role( role_name="str", - resource={"permissions": ["str"]}, + role={"permissions": ["str"]}, ) # please add some check logic here by yourself @@ -117,7 +117,7 @@ def test_create_or_replace_room(self, webpubsubchatservice_endpoint): client = self.create_client(endpoint=webpubsubchatservice_endpoint) response = client.create_or_replace_room( room_id="str", - resource={"title": "str"}, + room={"title": "str"}, ) # please add some check logic here by yourself @@ -163,7 +163,7 @@ def test_create_or_replace_topic(self, webpubsubchatservice_endpoint): response = client.create_or_replace_topic( room_id="str", topic_id="str", - resource={"title": "str", "state": "str"}, + topic={"title": "str", "state": "str"}, ) # please add some check logic here by yourself @@ -188,7 +188,7 @@ def test_update_topic(self, webpubsubchatservice_endpoint): response = client.update_topic( room_id="str", topic_id="str", - resource={"state": "str", "title": "str"}, + topic={"state": "str", "title": "str"}, ) # please add some check logic here by yourself @@ -224,7 +224,7 @@ def test_create_or_replace_room_member(self, webpubsubchatservice_endpoint): response = client.create_or_replace_room_member( room_id="str", user_id="str", - resource={"roleName": "str"}, + member={"roleName": "str"}, ) # please add some check logic here by yourself @@ -268,7 +268,7 @@ def test_create_or_replace_user(self, webpubsubchatservice_endpoint): client = self.create_client(endpoint=webpubsubchatservice_endpoint) response = client.create_or_replace_user( user_id="str", - resource={"kind": "Human", "nickname": "str", "roleName": "str"}, + user={"kind": "Human", "nickname": "str", "roleName": "str"}, ) # please add some check logic here by yourself diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service_async.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service_async.py index a3c10505e531..5e13224d43f8 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service_async.py @@ -54,7 +54,7 @@ async def test_update_message(self, webpubsubchatservice_endpoint): response = await client.update_message( conversation_id="str", message_id="str", - resource={"content": {"binary": bytes("bytes", encoding="utf-8"), "text": "str"}, "createdBy": "str"}, + message={"content": {"binary": bytes("bytes", encoding="utf-8"), "text": "str"}, "createdBy": "str"}, ) # please add some check logic here by yourself @@ -86,7 +86,7 @@ async def test_create_or_replace_role(self, webpubsubchatservice_endpoint): client = self.create_async_client(endpoint=webpubsubchatservice_endpoint) response = await client.create_or_replace_role( role_name="str", - resource={"permissions": ["str"]}, + role={"permissions": ["str"]}, ) # please add some check logic here by yourself @@ -118,7 +118,7 @@ async def test_create_or_replace_room(self, webpubsubchatservice_endpoint): client = self.create_async_client(endpoint=webpubsubchatservice_endpoint) response = await client.create_or_replace_room( room_id="str", - resource={"title": "str"}, + room={"title": "str"}, ) # please add some check logic here by yourself @@ -164,7 +164,7 @@ async def test_create_or_replace_topic(self, webpubsubchatservice_endpoint): response = await client.create_or_replace_topic( room_id="str", topic_id="str", - resource={"title": "str", "state": "str"}, + topic={"title": "str", "state": "str"}, ) # please add some check logic here by yourself @@ -189,7 +189,7 @@ async def test_update_topic(self, webpubsubchatservice_endpoint): response = await client.update_topic( room_id="str", topic_id="str", - resource={"state": "str", "title": "str"}, + topic={"state": "str", "title": "str"}, ) # please add some check logic here by yourself @@ -225,7 +225,7 @@ async def test_create_or_replace_room_member(self, webpubsubchatservice_endpoint response = await client.create_or_replace_room_member( room_id="str", user_id="str", - resource={"roleName": "str"}, + member={"roleName": "str"}, ) # please add some check logic here by yourself @@ -269,7 +269,7 @@ async def test_create_or_replace_user(self, webpubsubchatservice_endpoint): client = self.create_async_client(endpoint=webpubsubchatservice_endpoint) response = await client.create_or_replace_user( user_id="str", - resource={"kind": "Human", "nickname": "str", "roleName": "str"}, + user={"kind": "Human", "nickname": "str", "roleName": "str"}, ) # please add some check logic here by yourself diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md index 6d0f6ea0a006..be904ecf7c34 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md @@ -18,8 +18,7 @@ Operations with a JSON request body support three styles: `typed_dictionary` in the [three-style comparison](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_request_body_styles.py). - **Plain dictionary:** pass a JSON-shaped dictionary directly, without an explicit `TypedDict` annotation. See `plain_dictionary` in the - [three-style comparison](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_request_body_styles.py) - and the [generated operation examples](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples). + [three-style comparison](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_request_body_styles.py). For example, these request bodies express the same room membership: @@ -77,37 +76,22 @@ remove the specified resource (topic deletion is a soft delete). Use isolated sample resources and review each operation before running it. The samples do not create unrelated prerequisites or send WebSocket messages. -Generated examples use placeholder endpoints and example identifiers; -replace them and configure authentication as described in each file. - -| Operation | Generated example | Model-based request-body example | -| --- | --- | --- | -| `get_client_access_token` | SDK convenience method; no generated sample. | [Sync](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_client_access.py) / [async](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_client_access_async.py) | -| `create_or_replace_role` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_role.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_role.py) | -| `get_role` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_role.py) | No request body | -| `list_roles` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_roles.py) | No request body | -| `delete_role` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_role.py) | No request body | -| `create_or_replace_room` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_room.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_room.py) | -| `get_room` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_room.py) | No request body | -| `list_rooms` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_rooms.py) | No request body | -| `delete_room` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_room.py) | No request body | -| `create_or_replace_room_member` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_room_member.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_room_member.py) | -| `list_room_members` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_room_members.py) | No request body | -| `delete_room_member` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_room_member.py) | No request body | -| `create_or_replace_user` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_user.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_user.py) | -| `get_user` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_user.py) | No request body | -| `list_users` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_users.py) | No request body | -| `delete_user` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_user.py) | No request body | -| `list_rooms_for_user` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_rooms_for_user.py) | No request body | -| `create_or_replace_topic` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/create_or_replace_topic.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_topic.py) | -| `get_topic` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_topic.py) | No request body | -| `list_topics` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_topics.py) | No request body | -| `update_topic` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/update_topic.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_update_topic.py) | -| `delete_topic` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_topic.py) | No request body | -| `get_conversation` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/get_conversation.py) | No request body | -| `list_messages` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/list_messages.py) | No request body | -| `update_message` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/update_message.py) | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_update_message.py) | -| `delete_message` | [Sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/delete_message.py) | No request body | +Standalone generated examples are not included. The handwritten examples below +cover every service operation; use the three-style comparison for dictionary inputs. + +| Operation | Handwritten example | +| --- | --- | +| `get_client_access_token` | [Sync](sample_client_access.py) / [async](sample_client_access_async.py) | +| `create_or_replace_role` | [Model request](sample_create_or_replace_role.py) | +| `create_or_replace_room` | [Model request](sample_create_or_replace_room.py) | +| `create_or_replace_room_member` | [Model request](sample_create_or_replace_room_member.py) / [dictionary styles](sample_request_body_styles.py) | +| `create_or_replace_user` | [Model request](sample_create_or_replace_user.py) | +| `create_or_replace_topic` | [Model request](sample_create_or_replace_topic.py) / [typed dictionary replacement](sample_request_body_styles.py) | +| `update_topic` | [Model request](sample_update_topic.py) | +| `update_message` | [Model request](sample_update_message.py) | +| `get_role`, `get_room`, `get_user`, `get_topic`, `get_conversation` | [Read operation functions](sample_read_operations.py) | +| `list_roles`, `list_rooms`, `list_room_members`, `list_users`, `list_topics`, `list_rooms_for_user`, `list_messages` | [List operation functions](sample_read_operations.py) | +| `delete_role`, `delete_room`, `delete_room_member`, `delete_user`, `delete_topic`, `delete_message` | [Delete operation functions](sample_delete_operations.py) | The synchronous and asynchronous clients expose the same service operations. Await asynchronous non-paging calls, and use `async for` to iterate asynchronous diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_operations.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_operations.py new file mode 100644 index 000000000000..c9dcecae38a4 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_operations.py @@ -0,0 +1,31 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Independent destructive examples. Replace identifiers with isolated sample resources.""" + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient + + +def delete_role(client: WebPubSubChatServiceClient) -> None: + client.delete_role("room.sample") + + +def delete_room(client: WebPubSubChatServiceClient) -> None: + client.delete_room("sample-room") + + +def delete_room_member(client: WebPubSubChatServiceClient) -> None: + client.delete_room_member("sample-room", "sample-user") + + +def delete_user(client: WebPubSubChatServiceClient) -> None: + client.delete_user("sample-user") + + +def delete_topic(client: WebPubSubChatServiceClient) -> None: + client.delete_topic("sample-room", "sample-topic") + + +def delete_message(client: WebPubSubChatServiceClient) -> None: + client.delete_message("c.sample-room.sample-topic", "123456789") diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_read_operations.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_read_operations.py new file mode 100644 index 000000000000..ece5667a82ea --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_read_operations.py @@ -0,0 +1,67 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Independent read examples. Supply an authenticated client and existing identifiers.""" + +from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient + + +def get_role(client: WebPubSubChatServiceClient) -> None: + role = client.get_role("room.sample") + print(role.name, role.permissions) + + +def get_room(client: WebPubSubChatServiceClient) -> None: + room = client.get_room("sample-room") + print(room.id, room.title) + + +def get_user(client: WebPubSubChatServiceClient) -> None: + user = client.get_user("sample-user") + print(user.id, user.kind) + + +def get_topic(client: WebPubSubChatServiceClient) -> None: + topic = client.get_topic("sample-room", "sample-topic") + print(topic.id, topic.title, topic.state) + + +def get_conversation(client: WebPubSubChatServiceClient) -> None: + conversation = client.get_conversation("c.sample-room.sample-topic") + print(conversation.id, conversation.room_id) + + +def list_roles(client: WebPubSubChatServiceClient) -> None: + for role in client.list_roles(max_page_size=10): + print(role.name) + + +def list_rooms(client: WebPubSubChatServiceClient) -> None: + for room in client.list_rooms(max_page_size=10): + print(room.id, room.title) + + +def list_room_members(client: WebPubSubChatServiceClient) -> None: + for member in client.list_room_members("sample-room", max_page_size=10): + print(member.user_id, member.role_name) + + +def list_users(client: WebPubSubChatServiceClient) -> None: + for user in client.list_users(max_page_size=10): + print(user.id, user.kind) + + +def list_topics(client: WebPubSubChatServiceClient) -> None: + for topic in client.list_topics("sample-room", max_page_size=10): + print(topic.id, topic.title) + + +def list_rooms_for_user(client: WebPubSubChatServiceClient) -> None: + for room in client.list_rooms_for_user("sample-user", max_page_size=10): + print(room.id, room.title) + + +def list_messages(client: WebPubSubChatServiceClient) -> None: + for message in client.list_messages("c.sample-room.sample-topic", max_page_size=10): + print(message.id, message.created_by, message.content) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_request_body_styles.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_request_body_styles.py index 545db992c146..85c561410462 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_request_body_styles.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_request_body_styles.py @@ -29,3 +29,10 @@ def typed_dictionary(client: WebPubSubChatServiceClient) -> None: def plain_dictionary(client: WebPubSubChatServiceClient) -> None: member = client.create_or_replace_room_member("sample-room", "sample-user", {"roleName": "room.member"}) print(member.user_id, member.role_name) + + +def replace_topic_with_typed_dictionary(client: WebPubSubChatServiceClient) -> None: + """Replace an existing topic, retaining an explicit lifecycle state.""" + topic: types.ChatTopicCreateOrReplace = {"title": "Sample topic", "state": models.ChatTopicState.NORMAL} + result = client.create_or_replace_topic("sample-room", "sample-topic", topic=topic) + print(result.id, result.state) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview.py index 78dc892df302..47bb6b0f91fe 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview.py @@ -71,7 +71,8 @@ def _response(payload, status=200): def _paging_responses(path, fields, identity): - query = urlencode({"api-version": "2026-08-01-preview", "continuationToken": "next+/=token"}) + cursor = "first" if path.endswith("/messages") else "next+/=token" + query = urlencode({"api-version": "2026-08-01-preview", "continuationToken": cursor}) next_link = f"{ENDPOINT}/api/hubs/chat/chat/{path}?{query}" return [ _response({"value": [{**fields, identity: "first"}], "nextLink": next_link}), @@ -87,7 +88,8 @@ def _assert_page_requests(run, path): assert "continuationToken" not in parse_qs(urlparse(first.url).query) assert parse_qs(urlparse(first.url).query)["api-version"] == ["2026-08-01-preview"] assert urlparse(second.url).path == f"/api/hubs/chat/chat/{path}" - assert parse_qs(urlparse(second.url).query)["continuationToken"] == ["next+/=token"] + cursor = "first" if path.endswith("/messages") else "next+/=token" + assert parse_qs(urlparse(second.url).query)["continuationToken"] == [cursor] assert parse_qs(urlparse(second.url).query)["api-version"] == ["2026-08-01-preview"] @@ -114,6 +116,8 @@ def test_listing_api_surface(client_type): assert not any("continuation_token" in parameter for parameter in inspect.signature(method).parameters) assert ":keyword continuation_token" not in method.__doc__ assert ":paramtype continuation_token" not in method.__doc__ + assert "Message IDs are used as pagination cursors." in " ".join(client_type.list_messages.__doc__.split()) + assert "nextLink" in client_type.list_messages.__doc__ @pytest.mark.parametrize("resume", [False, True]) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live.py index 8f06c2fb54c6..7eaa8ecd712b 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live.py @@ -51,7 +51,7 @@ def test_topic_lifecycle_and_paging(self, wps_chat_endpoint): assert topic.etag conversation = client.get_conversation(topic.conversation_id) assert conversation.id == topic.conversation_id - assert conversation.parent_room == room_id + assert conversation.room_id == room_id assert not list(client.list_messages(topic.conversation_id)) assert {topic.id for topic in client.list_topics(room_id, max_page_size=1)}.issuperset({"first", "second"}) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live_async.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live_async.py index 4f7b9e5d68f7..f1c896dd32e1 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_2026_08_01_preview_live_async.py @@ -61,7 +61,7 @@ async def test_async_topic_lifecycle_and_paging(self, wps_chat_endpoint): assert topic.etag conversation = await client.get_conversation(topic.conversation_id) assert conversation.id == topic.conversation_id - assert conversation.parent_room == room_id + assert conversation.room_id == room_id assert await _collect(client.list_messages(topic.conversation_id)) == [] assert {topic.id async for topic in client.list_topics(room_id, max_page_size=1)}.issuperset( diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live.py index 06713c609e28..da1457a6bf6e 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live.py @@ -145,7 +145,7 @@ def test_room_conversation_and_empty_pages(self, wps_chat_endpoint): conversation = client.get_conversation(room.default_conversation) assert conversation.id == room.default_conversation - assert conversation.parent_room == room_id + assert conversation.room_id == room_id assert not list(client.list_messages(room.default_conversation)) assert not list(client.list_room_members(room_id)) finally: diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live_async.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live_async.py index 06541c5632c0..2479ecb70afd 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live_async.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live_async.py @@ -154,7 +154,7 @@ async def test_async_room_conversation_and_empty_pages(self, wps_chat_endpoint): conversation = await client.get_conversation(room.default_conversation) assert conversation.id == room.default_conversation - assert conversation.parent_room == room_id + assert conversation.room_id == room_id assert await _collect(client.list_messages(room.default_conversation)) == [] assert await _collect(client.list_room_members(room_id)) == [] finally: diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_operation_samples.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_operation_samples.py index 5b815e5675a6..2c030a0b6b2f 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_operation_samples.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_operation_samples.py @@ -12,7 +12,7 @@ from azure.core import MatchConditions from azure.messaging.webpubsubchatservice import WebPubSubChatServiceClient, models - +from azure.messaging.webpubsubchatservice.aio import WebPubSubChatServiceClient as AsyncClient PACKAGE = Path(__file__).resolve().parents[1] SAMPLES = PACKAGE / "samples" @@ -65,7 +65,7 @@ def _client(): conversation_id="conversation", etag='"sample-etag"', state="Archived", - parent_room="sample-room", + room_id="sample-room", created_by="sample-user", content=None, ) @@ -100,9 +100,7 @@ def test_operation_sample_uses_matching_method_and_models(operation): def test_operation_sample_coverage(): body_operations = { - path.stem - for path in (PACKAGE / "generated_samples").glob("*.py") - if path.stem.startswith(("create_or_replace_", "update_")) + name for name in dir(WebPubSubChatServiceClient) if name.startswith(("create_or_replace_", "update_")) } assert set(REQUESTS) == body_operations assert all((SAMPLES / f"sample_{operation}.py").is_file() for operation in body_operations) @@ -124,17 +122,81 @@ def test_request_body_styles_are_equivalent(style): assert body == {"roleName": "room.member"} -def test_generated_topic_put_example_serializes_replace_state(): - tree = ast.parse((PACKAGE / "generated_samples" / "create_or_replace_topic.py").read_text()) - calls = [ - node - for node in ast.walk(tree) - if isinstance(node, ast.Call) - and isinstance(node.func, ast.Attribute) - and node.func.attr == "create_or_replace_topic" - ] - assert len(calls) == 1 - body = next(keyword.value for keyword in calls[0].keywords if keyword.arg == "resource") - request = ast.literal_eval(body) +def test_typed_dictionary_topic_put_example_serializes_replace_state(): + module = _load_sample("sample_request_body_styles") + client = _client() + module.replace_topic_with_typed_dictionary(client) + client.create_or_replace_topic.assert_called_once() + request = client.create_or_replace_topic.call_args.kwargs["topic"] assert request["state"] == models.ChatTopicState.NORMAL assert models.ChatTopicCreateOrReplace(request).as_dict() == request + + +def test_handwritten_examples_cover_all_service_operations(): + operations = { + name + for name in dir(WebPubSubChatServiceClient) + if name.startswith(("create_or_replace_", "update_", "get_", "list_", "delete_")) + and name != "get_client_access_token" + } + covered = set() + for path in SAMPLES.glob("*.py"): + for node in ast.walk(ast.parse(path.read_text())): + if isinstance(node, ast.Call) and isinstance(node.func, ast.Attribute) and node.func.attr in operations: + covered.add(node.func.attr) + assert covered == operations + + +def test_standalone_generated_samples_are_not_delivered(): + assert not list((PACKAGE / "generated_samples").glob("*.py")) + for path in (PACKAGE / "README.md", SAMPLES / "README.md"): + assert "generated_samples/" not in path.read_text() + + +@pytest.mark.parametrize("client_type", [WebPubSubChatServiceClient, AsyncClient]) +@pytest.mark.parametrize("operation", REQUESTS) +def test_retained_method_documentation_describes_resource_body(client_type, operation): + parameter = operation.removeprefix("create_or_replace_").removeprefix("update_") + if parameter == "room_member": + parameter = "member" + doc = getattr(client_type, operation).__doc__ + assert f":param {parameter}:" in doc + assert ":param resource:" not in doc + assert "JSON input template" not in doc + + +@pytest.mark.parametrize( + "operation", + [ + "get_role", + "get_room", + "get_user", + "get_topic", + "get_conversation", + "list_roles", + "list_rooms", + "list_room_members", + "list_users", + "list_topics", + "list_rooms_for_user", + "list_messages", + ], +) +def test_read_operation_samples(operation): + module = _load_sample("sample_read_operations") + client = _client() + method = getattr(client, operation) + method.return_value = [] if operation.startswith("list_") else client.get_topic.return_value + getattr(module, operation)(client) + method.assert_called_once() + assert [call[0] for call in client.method_calls] == [operation] + + +@pytest.mark.parametrize("entity", ["role", "room", "room_member", "user", "topic", "message"]) +def test_delete_operation_samples(entity): + module = _load_sample("sample_delete_operations") + client = _client() + operation = f"delete_{entity}" + getattr(module, operation)(client) + getattr(client, operation).assert_called_once_with(*IDENTIFIERS[entity]) + assert [call[0] for call in client.method_calls] == [operation] diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_request_models.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_request_models.py index 4377cdf9655e..0263ba955e2f 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_request_models.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_request_models.py @@ -33,6 +33,16 @@ (models.HumanChatUserCreateOrReplace, models.HumanChatUser, {"create", "update"}), ] +BODY_PARAMETERS = { + "create_or_replace_role": "role", + "create_or_replace_room": "room", + "create_or_replace_room_member": "member", + "create_or_replace_user": "user", + "create_or_replace_topic": "topic", + "update_topic": "topic", + "update_message": "message", +} + CASES = [ ( "create_or_replace_topic", @@ -223,28 +233,75 @@ def _assert_request(run, method, body): assert request.headers["Content-Type"] == "application/merge-patch+json" +@pytest.mark.parametrize("use_keyword", [False, True]) @pytest.mark.parametrize("method,args,resource,response_model,body", CASES) -def test_lifecycle_request_and_resource_response(method, args, resource, response_model, body): +def test_lifecycle_request_and_resource_response(method, args, resource, response_model, body, use_keyword): with WebPubSubChatServiceClient( "https://example.webpubsub.azure.com", "chat", AzureKeyCredential("test-key") ) as client: with patch.object(client._client._pipeline, "run", return_value=_response(body)) as run: - result = getattr(client, method)( - *args, resource, etag='"old"', match_condition=MatchConditions.IfNotModified - ) + options = {"etag": '"old"', "match_condition": MatchConditions.IfNotModified} + if use_keyword: + options[BODY_PARAMETERS[method]] = resource + result = getattr(client, method)(*args, **options) + else: + result = getattr(client, method)(*args, resource, **options) assert isinstance(result, response_model) assert result.etag == '"new"' _assert_request(run, method, body) @pytest.mark.asyncio +@pytest.mark.parametrize("use_keyword", [False, True]) @pytest.mark.parametrize("method,args,resource,response_model,body", CASES) -async def test_async_lifecycle_request_and_resource_response(method, args, resource, response_model, body): +async def test_async_lifecycle_request_and_resource_response(method, args, resource, response_model, body, use_keyword): async with AsyncClient("https://example.webpubsub.azure.com", "chat", AzureKeyCredential("test-key")) as client: with patch.object(client._client._pipeline, "run", new_callable=AsyncMock, return_value=_response(body)) as run: - result = await getattr(client, method)( - *args, resource, etag='"old"', match_condition=MatchConditions.IfNotModified - ) + options = {"etag": '"old"', "match_condition": MatchConditions.IfNotModified} + if use_keyword: + options[BODY_PARAMETERS[method]] = resource + result = await getattr(client, method)(*args, **options) + else: + result = await getattr(client, method)(*args, resource, **options) assert isinstance(result, response_model) assert result.etag == '"new"' _assert_request(run, method, body) + + +@pytest.mark.parametrize("client_type", [WebPubSubChatServiceClient, AsyncClient]) +@pytest.mark.parametrize("method,body_parameter", BODY_PARAMETERS.items()) +def test_resource_specific_body_parameter(client_type, method, body_parameter): + parameters = inspect.signature(getattr(client_type, method)).parameters + assert body_parameter in parameters + assert "resource" not in parameters + + +def test_conversation_room_id_preserves_wire_name(): + conversation = models.ChatConversation(room_id="room") + assert conversation.room_id == "room" + assert conversation.as_dict() == {"parentRoom": "room"} + + +def test_get_conversation_deserializes_room_id(): + with WebPubSubChatServiceClient( + "https://example.webpubsub.azure.com", "chat", AzureKeyCredential("test-key") + ) as client: + with patch.object(client._client._pipeline, "run", return_value=_response({"parentRoom": "room"})): + conversation = client.get_conversation("conversation") + assert isinstance(conversation, models.ChatConversation) + assert conversation.room_id == "room" + assert conversation.id == "returned-id" + assert conversation.etag == '"new"' + + +@pytest.mark.asyncio +async def test_async_get_conversation_deserializes_room_id(): + async with AsyncClient("https://example.webpubsub.azure.com", "chat", AzureKeyCredential("test-key")) as client: + with patch.object( + client._client._pipeline, "run", new_callable=AsyncMock, return_value=_response({"parentRoom": "room"}) + ): + conversation = await client.get_conversation("conversation") + assert isinstance(conversation, models.ChatConversation) + assert conversation.room_id == "room" + assert conversation.id == "returned-id" + assert conversation.etag == '"new"' diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/typing/request_models.py b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/typing/request_models.py index 5c22a9b21654..1eb285ab1faf 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/typing/request_models.py +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/typing/request_models.py @@ -16,17 +16,17 @@ def check_request_types(client: WebPubSubChatServiceClient) -> None: - client.update_topic("room", "topic", models.ChatTopicUpdate(title="New title")) + client.update_topic("room", "topic", topic=models.ChatTopicUpdate(title="New title")) client.update_topic("room", "topic", models.ChatTopicUpdate(state=models.ChatTopicState.ARCHIVED)) client.update_topic("room", "topic", types.ChatTopicUpdate(title="New title")) client.update_topic("room", "topic", types.ChatTopicUpdate(state=models.ChatTopicState.ARCHIVED)) - client.update_message("conversation", "message", models.ChatMessageUpdate(created_by="user")) + client.update_message("conversation", "message", message=models.ChatMessageUpdate(created_by="user")) client.update_message( "conversation", "message", models.ChatMessageUpdate(content=models.MessageContent(text="Updated")) ) client.update_message("conversation", "message", types.ChatMessageUpdate(createdBy="user")) client.update_message("conversation", "message", types.ChatMessageUpdate(content={"text": "Updated"})) - client.create_or_replace_topic("room", "topic", models.ChatTopicCreateOrReplace(title="Title")) + client.create_or_replace_topic("room", "topic", topic=models.ChatTopicCreateOrReplace(title="Title")) client.create_or_replace_topic( "room", "topic", models.ChatTopicCreateOrReplace(title="Title", state=models.ChatTopicState.ARCHIVED) ) @@ -34,17 +34,19 @@ def check_request_types(client: WebPubSubChatServiceClient) -> None: client.create_or_replace_topic( "room", "topic", types.ChatTopicCreateOrReplace(title="Title", state=models.ChatTopicState.ARCHIVED) ) - client.create_or_replace_role("user.role", models.ChatRoleCreateOrReplace(permissions=["user.create_room"])) + client.create_or_replace_role("user.role", role=models.ChatRoleCreateOrReplace(permissions=["user.create_room"])) client.create_or_replace_role("user.role", types.ChatRoleCreateOrReplace(permissions=["user.create_room"])) - client.create_or_replace_room("room", models.ChatRoomCreateOrReplace(title="Room")) + client.create_or_replace_room("room", room=models.ChatRoomCreateOrReplace(title="Room")) client.create_or_replace_room("room", types.ChatRoomCreateOrReplace(title="Room")) - client.create_or_replace_room_member("room", "user", models.ChatRoomMemberCreateOrReplace(role_name="room.member")) + client.create_or_replace_room_member( + "room", "user", member=models.ChatRoomMemberCreateOrReplace(role_name="room.member") + ) client.create_or_replace_room_member("room", "user", types.ChatRoomMemberCreateOrReplace(roleName="room.member")) user: models.ChatUserCreateOrReplace = models.HumanChatUserCreateOrReplace(nickname="User", role_name="user.member") user_dict: types.ChatUserCreateOrReplace = types.HumanChatUserCreateOrReplace( kind=models.ChatUserKind.HUMAN, nickname="User", roleName="user.member" ) - client.create_or_replace_user("user", user) + client.create_or_replace_user("user", user=user) client.create_or_replace_user("user", user_dict) models.ChatTopicUpdate(title=123) # type: ignore[call-overload] models.ChatTopicUpdate(state=123) # type: ignore[call-overload] @@ -60,7 +62,7 @@ def check_request_types(client: WebPubSubChatServiceClient) -> None: async def check_async_request_types(client: AsyncClient) -> None: - await client.create_or_replace_topic("room", "topic", models.ChatTopicCreateOrReplace(title="Title")) + await client.create_or_replace_topic("room", "topic", topic=models.ChatTopicCreateOrReplace(title="Title")) await client.create_or_replace_topic( "room", "topic", models.ChatTopicCreateOrReplace(title="Title", state=models.ChatTopicState.ARCHIVED) ) @@ -68,12 +70,14 @@ async def check_async_request_types(client: AsyncClient) -> None: await client.create_or_replace_topic( "room", "topic", types.ChatTopicCreateOrReplace(title="Title", state=models.ChatTopicState.ARCHIVED) ) - await client.create_or_replace_role("user.role", models.ChatRoleCreateOrReplace(permissions=["user.create_room"])) + await client.create_or_replace_role( + "user.role", role=models.ChatRoleCreateOrReplace(permissions=["user.create_room"]) + ) await client.create_or_replace_role("user.role", types.ChatRoleCreateOrReplace(permissions=["user.create_room"])) - await client.create_or_replace_room("room", models.ChatRoomCreateOrReplace(title="Room")) + await client.create_or_replace_room("room", room=models.ChatRoomCreateOrReplace(title="Room")) await client.create_or_replace_room("room", types.ChatRoomCreateOrReplace(title="Room")) await client.create_or_replace_room_member( - "room", "user", models.ChatRoomMemberCreateOrReplace(role_name="room.member") + "room", "user", member=models.ChatRoomMemberCreateOrReplace(role_name="room.member") ) await client.create_or_replace_room_member( "room", "user", types.ChatRoomMemberCreateOrReplace(roleName="room.member") @@ -82,13 +86,13 @@ async def check_async_request_types(client: AsyncClient) -> None: user_dict: types.ChatUserCreateOrReplace = types.HumanChatUserCreateOrReplace( kind=models.ChatUserKind.HUMAN, nickname="User", roleName="user.member" ) - await client.create_or_replace_user("user", user) + await client.create_or_replace_user("user", user=user) await client.create_or_replace_user("user", user_dict) - await client.update_topic("room", "topic", models.ChatTopicUpdate(title="New title")) + await client.update_topic("room", "topic", topic=models.ChatTopicUpdate(title="New title")) await client.update_topic("room", "topic", models.ChatTopicUpdate(state=models.ChatTopicState.ARCHIVED)) await client.update_topic("room", "topic", types.ChatTopicUpdate(title="New title")) await client.update_topic("room", "topic", types.ChatTopicUpdate(state=models.ChatTopicState.ARCHIVED)) - await client.update_message("conversation", "message", models.ChatMessageUpdate(created_by="user")) + await client.update_message("conversation", "message", message=models.ChatMessageUpdate(created_by="user")) await client.update_message( "conversation", "message", models.ChatMessageUpdate(content=models.MessageContent(text="Updated")) ) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml index bd4401843ea2..16c9da8ac574 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml @@ -1,5 +1,5 @@ directory: specification/webpubsub/data-plane/WebPubSubChat -commit: 2d9fd4ac7fa10dce72c79e35ec144c04ed2e269f +commit: 3165fe1969a8254e3f17ed5323e2818220b68012 repo: Y-Sindo/azure-rest-api-specs # cspell:ignore Sindo additionalDirectories: [] entrypointFile: client.tsp \ No newline at end of file From 00ae8608e2bed2f8ad94dc1861b128152ce9b076 Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Fri, 30 Oct 2026 01:26:48 +1100 Subject: [PATCH 20/22] Use absolute links in Chat sample operation index Fix Verify Links failures by following repository absolute-link guidance. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../samples/README.md | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md index be904ecf7c34..87f8b3d2ab03 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/README.md @@ -81,17 +81,17 @@ cover every service operation; use the three-style comparison for dictionary inp | Operation | Handwritten example | | --- | --- | -| `get_client_access_token` | [Sync](sample_client_access.py) / [async](sample_client_access_async.py) | -| `create_or_replace_role` | [Model request](sample_create_or_replace_role.py) | -| `create_or_replace_room` | [Model request](sample_create_or_replace_room.py) | -| `create_or_replace_room_member` | [Model request](sample_create_or_replace_room_member.py) / [dictionary styles](sample_request_body_styles.py) | -| `create_or_replace_user` | [Model request](sample_create_or_replace_user.py) | -| `create_or_replace_topic` | [Model request](sample_create_or_replace_topic.py) / [typed dictionary replacement](sample_request_body_styles.py) | -| `update_topic` | [Model request](sample_update_topic.py) | -| `update_message` | [Model request](sample_update_message.py) | -| `get_role`, `get_room`, `get_user`, `get_topic`, `get_conversation` | [Read operation functions](sample_read_operations.py) | -| `list_roles`, `list_rooms`, `list_room_members`, `list_users`, `list_topics`, `list_rooms_for_user`, `list_messages` | [List operation functions](sample_read_operations.py) | -| `delete_role`, `delete_room`, `delete_room_member`, `delete_user`, `delete_topic`, `delete_message` | [Delete operation functions](sample_delete_operations.py) | +| `get_client_access_token` | [Sync](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_client_access.py) / [async](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_client_access_async.py) | +| `create_or_replace_role` | [Model request](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_role.py) | +| `create_or_replace_room` | [Model request](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_room.py) | +| `create_or_replace_room_member` | [Model request](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_room_member.py) / [dictionary styles](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_request_body_styles.py) | +| `create_or_replace_user` | [Model request](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_user.py) | +| `create_or_replace_topic` | [Model request](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_create_or_replace_topic.py) / [typed dictionary replacement](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_request_body_styles.py) | +| `update_topic` | [Model request](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_update_topic.py) | +| `update_message` | [Model request](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_update_message.py) | +| `get_role`, `get_room`, `get_user`, `get_topic`, `get_conversation` | [Read operation functions](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_read_operations.py) | +| `list_roles`, `list_rooms`, `list_room_members`, `list_users`, `list_topics`, `list_rooms_for_user`, `list_messages` | [List operation functions](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_read_operations.py) | +| `delete_role`, `delete_room`, `delete_room_member`, `delete_user`, `delete_topic`, `delete_message` | [Delete operation functions](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_delete_operations.py) | The synchronous and asynchronous clients expose the same service operations. Await asynchronous non-paging calls, and use `async for` to iterate asynchronous From 5f28296456796f97295e76d5de83ffec4a49a576 Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Fri, 6 Nov 2026 19:33:29 +1100 Subject: [PATCH 21/22] Refresh Chat TypeSpec source reference Regenerate from the latest published TypeSpec customization revision and refresh APIView source mappings. Python SDK code and tests are unchanged. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../apiview-properties.json | 54 +++++++++---------- .../tsp-location.yaml | 2 +- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json b/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json index 698aad3e427d..d7e789e6c120 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json @@ -28,50 +28,50 @@ "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.list_messages": "WebPubSubChat.WebPubSubChatServiceClient.listMessages", "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.delete_message": "WebPubSubChat.WebPubSubChatServiceClient.deleteMessage", "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.delete_message": "WebPubSubChat.WebPubSubChatServiceClient.deleteMessage", - "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.update_message": "WebPubSubChat.WebPubSubChatServiceClient.updateMessage", - "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.update_message": "WebPubSubChat.WebPubSubChatServiceClient.updateMessage", - "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.list_roles": "WebPubSubChat.WebPubSubChatServiceClient.listRoles", - "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.list_roles": "WebPubSubChat.WebPubSubChatServiceClient.listRoles", + "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.update_message": "Customizations.WebPubSubChatServiceClient.updateMessage", + "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.update_message": "Customizations.WebPubSubChatServiceClient.updateMessage", + "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.list_roles": "Customizations.WebPubSubChatServiceClient.listRoles", + "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.list_roles": "Customizations.WebPubSubChatServiceClient.listRoles", "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.get_role": "WebPubSubChat.WebPubSubChatServiceClient.getRole", "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.get_role": "WebPubSubChat.WebPubSubChatServiceClient.getRole", - "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.create_or_replace_role": "WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole", - "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.create_or_replace_role": "WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole", + "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.create_or_replace_role": "Customizations.WebPubSubChatServiceClient.createOrReplaceRole", + "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.create_or_replace_role": "Customizations.WebPubSubChatServiceClient.createOrReplaceRole", "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.delete_role": "WebPubSubChat.WebPubSubChatServiceClient.deleteRole", "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.delete_role": "WebPubSubChat.WebPubSubChatServiceClient.deleteRole", - "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.list_rooms": "WebPubSubChat.WebPubSubChatServiceClient.listRooms", - "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.list_rooms": "WebPubSubChat.WebPubSubChatServiceClient.listRooms", - "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.create_or_replace_room": "WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom", - "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.create_or_replace_room": "WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom", + "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.list_rooms": "Customizations.WebPubSubChatServiceClient.listRooms", + "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.list_rooms": "Customizations.WebPubSubChatServiceClient.listRooms", + "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.create_or_replace_room": "Customizations.WebPubSubChatServiceClient.createOrReplaceRoom", + "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.create_or_replace_room": "Customizations.WebPubSubChatServiceClient.createOrReplaceRoom", "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.get_room": "WebPubSubChat.WebPubSubChatServiceClient.getRoom", "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.get_room": "WebPubSubChat.WebPubSubChatServiceClient.getRoom", "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.delete_room": "WebPubSubChat.WebPubSubChatServiceClient.deleteRoom", "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.delete_room": "WebPubSubChat.WebPubSubChatServiceClient.deleteRoom", - "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.list_topics": "WebPubSubChat.WebPubSubChatServiceClient.listTopics", - "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.list_topics": "WebPubSubChat.WebPubSubChatServiceClient.listTopics", - "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.create_or_replace_topic": "WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic", - "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.create_or_replace_topic": "WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic", + "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.list_topics": "Customizations.WebPubSubChatServiceClient.listTopics", + "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.list_topics": "Customizations.WebPubSubChatServiceClient.listTopics", + "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.create_or_replace_topic": "Customizations.WebPubSubChatServiceClient.createOrReplaceTopic", + "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.create_or_replace_topic": "Customizations.WebPubSubChatServiceClient.createOrReplaceTopic", "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.get_topic": "WebPubSubChat.WebPubSubChatServiceClient.getTopic", "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.get_topic": "WebPubSubChat.WebPubSubChatServiceClient.getTopic", - "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.update_topic": "WebPubSubChat.WebPubSubChatServiceClient.updateTopic", - "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.update_topic": "WebPubSubChat.WebPubSubChatServiceClient.updateTopic", + "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.update_topic": "Customizations.WebPubSubChatServiceClient.updateTopic", + "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.update_topic": "Customizations.WebPubSubChatServiceClient.updateTopic", "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.delete_topic": "WebPubSubChat.WebPubSubChatServiceClient.deleteTopic", "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.delete_topic": "WebPubSubChat.WebPubSubChatServiceClient.deleteTopic", - "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.list_room_members": "WebPubSubChat.WebPubSubChatServiceClient.listRoomMembers", - "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.list_room_members": "WebPubSubChat.WebPubSubChatServiceClient.listRoomMembers", - "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.create_or_replace_room_member": "WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember", - "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.create_or_replace_room_member": "WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember", + "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.list_room_members": "Customizations.WebPubSubChatServiceClient.listRoomMembers", + "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.list_room_members": "Customizations.WebPubSubChatServiceClient.listRoomMembers", + "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.create_or_replace_room_member": "Customizations.WebPubSubChatServiceClient.createOrReplaceRoomMember", + "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.create_or_replace_room_member": "Customizations.WebPubSubChatServiceClient.createOrReplaceRoomMember", "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.delete_room_member": "WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember", "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.delete_room_member": "WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember", - "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.list_users": "WebPubSubChat.WebPubSubChatServiceClient.listUsers", - "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.list_users": "WebPubSubChat.WebPubSubChatServiceClient.listUsers", + "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.list_users": "Customizations.WebPubSubChatServiceClient.listUsers", + "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.list_users": "Customizations.WebPubSubChatServiceClient.listUsers", "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.get_user": "WebPubSubChat.WebPubSubChatServiceClient.getUser", "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.get_user": "WebPubSubChat.WebPubSubChatServiceClient.getUser", - "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.create_or_replace_user": "WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser", - "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.create_or_replace_user": "WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser", + "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.create_or_replace_user": "Customizations.WebPubSubChatServiceClient.createOrReplaceUser", + "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.create_or_replace_user": "Customizations.WebPubSubChatServiceClient.createOrReplaceUser", "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.delete_user": "WebPubSubChat.WebPubSubChatServiceClient.deleteUser", "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.delete_user": "WebPubSubChat.WebPubSubChatServiceClient.deleteUser", - "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.list_rooms_for_user": "WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser", - "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.list_rooms_for_user": "WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser" + "azure.messaging.webpubsubchatservice.WebPubSubChatServiceClient.list_rooms_for_user": "Customizations.WebPubSubChatServiceClient.listRoomsForUser", + "azure.messaging.webpubsubchatservice.aio.WebPubSubChatServiceClient.list_rooms_for_user": "Customizations.WebPubSubChatServiceClient.listRoomsForUser" }, - "CrossLanguageVersion": "c47dbe5e13af" + "CrossLanguageVersion": "7f7888447aa3" } \ No newline at end of file diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml index 16c9da8ac574..e72fd63006c3 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml @@ -1,5 +1,5 @@ directory: specification/webpubsub/data-plane/WebPubSubChat -commit: 3165fe1969a8254e3f17ed5323e2818220b68012 +commit: f3aa40d8afd5474f09689233dadd045372395ac1 repo: Y-Sindo/azure-rest-api-specs # cspell:ignore Sindo additionalDirectories: [] entrypointFile: client.tsp \ No newline at end of file From f19e3a06bc45899fbb897664cd22df0c908cd01f Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Fri, 13 Nov 2026 12:25:45 +0800 Subject: [PATCH 22/22] Address Chat changelog review feedback Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../azure-messaging-webpubsubchatservice/CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md b/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md index f5368cc25b43..823989596dd2 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md +++ b/sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History -## 1.0.0b2 (Unreleased) +## 1.0.0b2 (2026-11-13) ### Features Added @@ -11,7 +11,6 @@ - Changed the default service API version from `2026-02-01-preview` to `2026-08-01-preview` for both existing and newly added Chat operations - Clarified that message IDs are pagination cursors for `list_messages`. The pager follows the service's `nextLink`; resume with `by_page(continuation_token=...)`. - - Replaced standalone generated samples with handwritten operation examples and Model/TypedDict request-body examples. ### Breaking Changes