diff --git a/sdk/communication/azure-communication-chat/CHANGELOG.md b/sdk/communication/azure-communication-chat/CHANGELOG.md index be1513897756..18f80b75ada3 100644 --- a/sdk/communication/azure-communication-chat/CHANGELOG.md +++ b/sdk/communication/azure-communication-chat/CHANGELOG.md @@ -1,7 +1,9 @@ # Release History -## 1.0.1 (Unreleased) +## 1.1.0b1 (Unreleased) +### Added +- Added support to add `metadata` for `message` ## 1.0.0 (2021-03-29) ### Breaking Changes diff --git a/sdk/communication/azure-communication-chat/azure/communication/chat/_chat_thread_client.py b/sdk/communication/azure-communication-chat/azure/communication/chat/_chat_thread_client.py index d41ec2dfce37..eb9312efce25 100644 --- a/sdk/communication/azure-communication-chat/azure/communication/chat/_chat_thread_client.py +++ b/sdk/communication/azure-communication-chat/azure/communication/chat/_chat_thread_client.py @@ -280,6 +280,7 @@ def send_message( :paramtype chat_message_type: Union[str, ~azure.communication.chat.ChatMessageType] :keyword str sender_display_name: The display name of the message sender. This property is used to populate sender name for push notifications. + :keyword dict[str, str] metadata : Message metadata. :return: SendChatMessageResult :rtype: ~azure.communication.chat.SendChatMessageResult :raises: ~azure.core.exceptions.HttpResponseError, ValueError @@ -311,11 +312,13 @@ def send_message( "chat_message_type: {message_type} can be only 'text' or 'html'".format(message_type=chat_message_type)) sender_display_name = kwargs.pop("sender_display_name", None) + metadata = kwargs.pop("metadata", None) create_message_request = SendChatMessageRequest( content=content, type=chat_message_type, - sender_display_name=sender_display_name + sender_display_name=sender_display_name, + metadata=metadata ) send_chat_message_result = self._client.chat_thread.send_chat_message( @@ -403,6 +406,7 @@ def update_message( :type message_id: str :param content: Chat message content. :type content: str + :keyword dict[str, str] metadata : Message metadata. :return: None :rtype: None :raises: ~azure.core.exceptions.HttpResponseError, ValueError @@ -419,7 +423,8 @@ def update_message( if not message_id: raise ValueError("message_id cannot be None.") - update_message_request = UpdateChatMessageRequest(content=content) + metadata = kwargs.pop("metadata", None) + update_message_request = UpdateChatMessageRequest(content=content, metadata=metadata) return self._client.chat_thread.update_chat_message( chat_thread_id=self._thread_id, diff --git a/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/_configuration.py b/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/_configuration.py index d236f9893c99..9ab172fca1ef 100644 --- a/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/_configuration.py +++ b/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/_configuration.py @@ -38,7 +38,7 @@ def __init__( super(AzureCommunicationChatServiceConfiguration, self).__init__(**kwargs) self.endpoint = endpoint - self.api_version = "2021-03-07" + self.api_version = "2021-04-05-preview6" kwargs.setdefault('sdk_moniker', 'azurecommunicationchatservice/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/aio/_configuration.py b/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/aio/_configuration.py index c61ce6d61adf..5b16d25053d0 100644 --- a/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/aio/_configuration.py +++ b/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/aio/_configuration.py @@ -33,7 +33,7 @@ def __init__( super(AzureCommunicationChatServiceConfiguration, self).__init__(**kwargs) self.endpoint = endpoint - self.api_version = "2021-03-07" + self.api_version = "2021-04-05-preview6" kwargs.setdefault('sdk_moniker', 'azurecommunicationchatservice/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/aio/operations/_chat_operations.py b/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/aio/operations/_chat_operations.py index 636d62de8f36..54143070f4ee 100644 --- a/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/aio/operations/_chat_operations.py +++ b/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/aio/operations/_chat_operations.py @@ -75,7 +75,7 @@ async def create_chat_thread( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -146,7 +146,7 @@ def list_chat_threads( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" accept = "application/json" def prepare_request(next_link=None): @@ -230,7 +230,7 @@ async def delete_chat_thread( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" accept = "application/json" # Construct URL diff --git a/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/aio/operations/_chat_thread_operations.py b/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/aio/operations/_chat_thread_operations.py index 1e8e54f8c52f..36fce5e93b63 100644 --- a/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/aio/operations/_chat_thread_operations.py +++ b/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/aio/operations/_chat_thread_operations.py @@ -73,7 +73,7 @@ def list_chat_read_receipts( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" accept = "application/json" def prepare_request(next_link=None): @@ -162,7 +162,7 @@ async def send_chat_read_receipt( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -228,7 +228,7 @@ async def send_chat_message( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -301,7 +301,7 @@ def list_chat_messages( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" accept = "application/json" def prepare_request(next_link=None): @@ -390,7 +390,7 @@ async def get_chat_message( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" accept = "application/json" # Construct URL @@ -458,7 +458,7 @@ async def update_chat_message( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" content_type = kwargs.pop("content_type", "application/merge-patch+json") accept = "application/json" @@ -525,7 +525,7 @@ async def delete_chat_message( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" accept = "application/json" # Construct URL @@ -584,7 +584,7 @@ async def send_typing_notification( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" accept = "application/json" # Construct URL @@ -648,7 +648,7 @@ def list_chat_participants( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" accept = "application/json" def prepare_request(next_link=None): @@ -738,7 +738,7 @@ async def remove_chat_participant( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -804,7 +804,7 @@ async def add_chat_participants( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -873,7 +873,7 @@ async def update_chat_thread_properties( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" content_type = kwargs.pop("content_type", "application/merge-patch+json") accept = "application/json" @@ -936,7 +936,7 @@ async def get_chat_thread_properties( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" accept = "application/json" # Construct URL diff --git a/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/models/_models.py b/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/models/_models.py index 85dc53f35190..451cdadaf56b 100644 --- a/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/models/_models.py +++ b/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/models/_models.py @@ -141,6 +141,8 @@ class ChatMessage(msrest.serialization.Model): :param edited_on: The last timestamp (if applicable) when the message was edited. The timestamp is in RFC3339 format: ``yyyy-MM-ddTHH:mm:ssZ``. :type edited_on: ~datetime.datetime + :param metadata: Message metadata. + :type metadata: dict[str, str] """ _validation = { @@ -162,6 +164,7 @@ class ChatMessage(msrest.serialization.Model): 'sender_communication_identifier': {'key': 'senderCommunicationIdentifier', 'type': 'CommunicationIdentifierModel'}, 'deleted_on': {'key': 'deletedOn', 'type': 'iso-8601'}, 'edited_on': {'key': 'editedOn', 'type': 'iso-8601'}, + 'metadata': {'key': 'metadata', 'type': '{str}'}, } def __init__( @@ -179,6 +182,7 @@ def __init__( self.sender_communication_identifier = kwargs.get('sender_communication_identifier', None) self.deleted_on = kwargs.get('deleted_on', None) self.edited_on = kwargs.get('edited_on', None) + self.metadata = kwargs.get('metadata', None) class ChatMessageContent(msrest.serialization.Model): @@ -733,6 +737,8 @@ class SendChatMessageRequest(msrest.serialization.Model): :param type: The chat message type. Possible values include: "text", "html", "topicUpdated", "participantAdded", "participantRemoved". :type type: str or ~azure.communication.chat.models.ChatMessageType + :param metadata: Message metadata. + :type metadata: dict[str, str] """ _validation = { @@ -743,6 +749,7 @@ class SendChatMessageRequest(msrest.serialization.Model): 'content': {'key': 'content', 'type': 'str'}, 'sender_display_name': {'key': 'senderDisplayName', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': '{str}'}, } def __init__( @@ -753,6 +760,7 @@ def __init__( self.content = kwargs['content'] self.sender_display_name = kwargs.get('sender_display_name', None) self.type = kwargs.get('type', None) + self.metadata = kwargs.get('metadata', None) class SendChatMessageResult(msrest.serialization.Model): @@ -810,10 +818,13 @@ class UpdateChatMessageRequest(msrest.serialization.Model): :param content: Chat message content. :type content: str + :param metadata: Message metadata. + :type metadata: dict[str, str] """ _attribute_map = { 'content': {'key': 'content', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': '{str}'}, } def __init__( @@ -822,6 +833,7 @@ def __init__( ): super(UpdateChatMessageRequest, self).__init__(**kwargs) self.content = kwargs.get('content', None) + self.metadata = kwargs.get('metadata', None) class UpdateChatThreadRequest(msrest.serialization.Model): diff --git a/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/models/_models_py3.py b/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/models/_models_py3.py index a2979f14da39..0958fcb5e8ee 100644 --- a/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/models/_models_py3.py +++ b/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/models/_models_py3.py @@ -7,7 +7,7 @@ # -------------------------------------------------------------------------- import datetime -from typing import List, Optional, Union +from typing import Dict, List, Optional, Union from azure.core.exceptions import HttpResponseError import msrest.serialization @@ -151,6 +151,8 @@ class ChatMessage(msrest.serialization.Model): :param edited_on: The last timestamp (if applicable) when the message was edited. The timestamp is in RFC3339 format: ``yyyy-MM-ddTHH:mm:ssZ``. :type edited_on: ~datetime.datetime + :param metadata: Message metadata. + :type metadata: dict[str, str] """ _validation = { @@ -172,6 +174,7 @@ class ChatMessage(msrest.serialization.Model): 'sender_communication_identifier': {'key': 'senderCommunicationIdentifier', 'type': 'CommunicationIdentifierModel'}, 'deleted_on': {'key': 'deletedOn', 'type': 'iso-8601'}, 'edited_on': {'key': 'editedOn', 'type': 'iso-8601'}, + 'metadata': {'key': 'metadata', 'type': '{str}'}, } def __init__( @@ -187,6 +190,7 @@ def __init__( sender_communication_identifier: Optional["CommunicationIdentifierModel"] = None, deleted_on: Optional[datetime.datetime] = None, edited_on: Optional[datetime.datetime] = None, + metadata: Optional[Dict[str, str]] = None, **kwargs ): super(ChatMessage, self).__init__(**kwargs) @@ -200,6 +204,7 @@ def __init__( self.sender_communication_identifier = sender_communication_identifier self.deleted_on = deleted_on self.edited_on = edited_on + self.metadata = metadata class ChatMessageContent(msrest.serialization.Model): @@ -805,6 +810,8 @@ class SendChatMessageRequest(msrest.serialization.Model): :param type: The chat message type. Possible values include: "text", "html", "topicUpdated", "participantAdded", "participantRemoved". :type type: str or ~azure.communication.chat.models.ChatMessageType + :param metadata: Message metadata. + :type metadata: dict[str, str] """ _validation = { @@ -815,6 +822,7 @@ class SendChatMessageRequest(msrest.serialization.Model): 'content': {'key': 'content', 'type': 'str'}, 'sender_display_name': {'key': 'senderDisplayName', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': '{str}'}, } def __init__( @@ -823,12 +831,14 @@ def __init__( content: str, sender_display_name: Optional[str] = None, type: Optional[Union[str, "ChatMessageType"]] = None, + metadata: Optional[Dict[str, str]] = None, **kwargs ): super(SendChatMessageRequest, self).__init__(**kwargs) self.content = content self.sender_display_name = sender_display_name self.type = type + self.metadata = metadata class SendChatMessageResult(msrest.serialization.Model): @@ -890,20 +900,25 @@ class UpdateChatMessageRequest(msrest.serialization.Model): :param content: Chat message content. :type content: str + :param metadata: Message metadata. + :type metadata: dict[str, str] """ _attribute_map = { 'content': {'key': 'content', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': '{str}'}, } def __init__( self, *, content: Optional[str] = None, + metadata: Optional[Dict[str, str]] = None, **kwargs ): super(UpdateChatMessageRequest, self).__init__(**kwargs) self.content = content + self.metadata = metadata class UpdateChatThreadRequest(msrest.serialization.Model): diff --git a/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/operations/_chat_operations.py b/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/operations/_chat_operations.py index e1f4d2d16971..2a56d3af58c2 100644 --- a/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/operations/_chat_operations.py +++ b/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/operations/_chat_operations.py @@ -80,7 +80,7 @@ def create_chat_thread( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -152,7 +152,7 @@ def list_chat_threads( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" accept = "application/json" def prepare_request(next_link=None): @@ -237,7 +237,7 @@ def delete_chat_thread( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" accept = "application/json" # Construct URL diff --git a/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/operations/_chat_thread_operations.py b/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/operations/_chat_thread_operations.py index b19161eb3964..281fdc103125 100644 --- a/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/operations/_chat_thread_operations.py +++ b/sdk/communication/azure-communication-chat/azure/communication/chat/_generated/operations/_chat_thread_operations.py @@ -78,7 +78,7 @@ def list_chat_read_receipts( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" accept = "application/json" def prepare_request(next_link=None): @@ -168,7 +168,7 @@ def send_chat_read_receipt( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -235,7 +235,7 @@ def send_chat_message( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -309,7 +309,7 @@ def list_chat_messages( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" accept = "application/json" def prepare_request(next_link=None): @@ -399,7 +399,7 @@ def get_chat_message( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" accept = "application/json" # Construct URL @@ -468,7 +468,7 @@ def update_chat_message( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" content_type = kwargs.pop("content_type", "application/merge-patch+json") accept = "application/json" @@ -536,7 +536,7 @@ def delete_chat_message( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" accept = "application/json" # Construct URL @@ -596,7 +596,7 @@ def send_typing_notification( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" accept = "application/json" # Construct URL @@ -661,7 +661,7 @@ def list_chat_participants( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" accept = "application/json" def prepare_request(next_link=None): @@ -752,7 +752,7 @@ def remove_chat_participant( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -819,7 +819,7 @@ def add_chat_participants( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -889,7 +889,7 @@ def update_chat_thread_properties( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" content_type = kwargs.pop("content_type", "application/merge-patch+json") accept = "application/json" @@ -953,7 +953,7 @@ def get_chat_thread_properties( 503: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-07" + api_version = "2021-04-05-preview6" accept = "application/json" # Construct URL diff --git a/sdk/communication/azure-communication-chat/azure/communication/chat/_models.py b/sdk/communication/azure-communication-chat/azure/communication/chat/_models.py index e09bfc842d61..e3a33fa8d180 100644 --- a/sdk/communication/azure-communication-chat/azure/communication/chat/_models.py +++ b/sdk/communication/azure-communication-chat/azure/communication/chat/_models.py @@ -57,7 +57,7 @@ def _to_generated(self): ) -class ChatMessage(object): +class ChatMessage(object): # pylint: disable=too-many-instance-attributes """Chat message. Variables are only populated by the server, and will be ignored when sending a request. @@ -87,6 +87,8 @@ class ChatMessage(object): :ivar edited_on: The last timestamp (if applicable) when the message was edited. The timestamp is in RFC3339 format: ``yyyy-MM-ddTHH:mm:ssZ``. :type edited_on: ~datetime.datetime + :ivar metadata: Message metadata. + :type metadata: dict[str, str] """ def __init__( @@ -105,6 +107,7 @@ def __init__( self.sender = kwargs['sender'] self.deleted_on = kwargs['deleted_on'] self.edited_on = kwargs['edited_on'] + self.metadata = kwargs.get('metadata') @classmethod def _get_message_type(cls, chat_message_type): @@ -131,7 +134,8 @@ def _from_generated(cls, chat_message): created_on=chat_message.created_on, sender=sender_communication_identifier, deleted_on=chat_message.deleted_on, - edited_on=chat_message.edited_on + edited_on=chat_message.edited_on, + metadata=chat_message.metadata ) diff --git a/sdk/communication/azure-communication-chat/azure/communication/chat/_version.py b/sdk/communication/azure-communication-chat/azure/communication/chat/_version.py index a1ebc0a0c570..a83b9274f4f8 100644 --- a/sdk/communication/azure-communication-chat/azure/communication/chat/_version.py +++ b/sdk/communication/azure-communication-chat/azure/communication/chat/_version.py @@ -4,6 +4,6 @@ # license information. # -------------------------------------------------------------------------- -VERSION = "1.0.1" +VERSION = "1.1.0b1" SDK_MONIKER = "communication-chat/{}".format(VERSION) # type: str diff --git a/sdk/communication/azure-communication-chat/azure/communication/chat/aio/_chat_thread_client_async.py b/sdk/communication/azure-communication-chat/azure/communication/chat/aio/_chat_thread_client_async.py index 93bff72acd83..76f29d55a69f 100644 --- a/sdk/communication/azure-communication-chat/azure/communication/chat/aio/_chat_thread_client_async.py +++ b/sdk/communication/azure-communication-chat/azure/communication/chat/aio/_chat_thread_client_async.py @@ -261,6 +261,8 @@ async def send_typing_notification( async def send_message( self, content: str, + *, + metadata: Dict[str, str] = None, **kwargs ) -> SendChatMessageResult: """Sends a message to a thread. @@ -272,6 +274,7 @@ async def send_message( :paramtype chat_message_type: Union[str, ~azure.communication.chat.ChatMessageType] :keyword str sender_display_name: The display name of the message sender. This property is used to populate sender name for push notifications. + :keyword dict[str, str] metadata : Message metadata. :return: SendChatMessageResult :rtype: ~azure.communication.chat.SendChatMessageResult :raises: ~azure.core.exceptions.HttpResponseError, ValueError @@ -307,7 +310,8 @@ async def send_message( create_message_request = SendChatMessageRequest( content=content, type=chat_message_type, - sender_display_name=sender_display_name + sender_display_name=sender_display_name, + metadata=metadata ) send_chat_message_result = await self._client.chat_thread.send_chat_message( chat_thread_id=self._thread_id, @@ -382,14 +386,16 @@ async def update_message( self, message_id: str, content: str = None, + *, + metadata: Dict[str, str] = None, **kwargs ) -> None: """Updates a message. :param message_id: Required. The message id. :type message_id: str - :param content: Chat message content. - :type content: str + :keyword content: Chat message content + :keyword dict[str, str] metadata : Message metadata. :return: None :rtype: None :raises: ~azure.core.exceptions.HttpResponseError, ValueError @@ -406,7 +412,7 @@ async def update_message( if not message_id: raise ValueError("message_id cannot be None.") - update_message_request = UpdateChatMessageRequest(content=content) + update_message_request = UpdateChatMessageRequest(content=content, metadata=metadata) return await self._client.chat_thread.update_chat_message( chat_thread_id=self._thread_id, diff --git a/sdk/communication/azure-communication-chat/samples/chat_thread_client_sample_async.py b/sdk/communication/azure-communication-chat/samples/chat_thread_client_sample_async.py index 2a2853adba4d..9a3803abd5df 100644 --- a/sdk/communication/azure-communication-chat/samples/chat_thread_client_sample_async.py +++ b/sdk/communication/azure-communication-chat/samples/chat_thread_client_sample_async.py @@ -132,7 +132,8 @@ async def send_message_async(self): # Scenario 1: Send message without specifying chat_message_type send_message_result = await chat_thread_client.send_message( "Hello! My name is Fred Flinstone", - sender_display_name="Fred Flinstone") + sender_display_name="Fred Flinstone", + metadata={"tags": "tags"}) send_message_result_id = send_message_result.id # Scenario 2: Send message specifying chat_message_type @@ -143,7 +144,8 @@ async def send_message_async(self): send_message_result_w_type_id = send_message_result_w_type.id # Verify message content - print("First Message:", (await chat_thread_client.get_message(send_message_result_id)).content.message) + chat_message_1 = await chat_thread_client.get_message(send_message_result_id) + print("First Message:", chat_message_1.content.message, chat_message_1.metadata) print("Second Message:", (await chat_thread_client.get_message(send_message_result_w_type_id)).content.message) # [END send_message] self._message_id = send_message_result_id diff --git a/sdk/communication/azure-communication-chat/swagger/SWAGGER.md b/sdk/communication/azure-communication-chat/swagger/SWAGGER.md index 79d6dc41295f..bf5e841746e4 100644 --- a/sdk/communication/azure-communication-chat/swagger/SWAGGER.md +++ b/sdk/communication/azure-communication-chat/swagger/SWAGGER.md @@ -16,7 +16,7 @@ autorest SWAGGER.md ### Settings ```yaml -tag: package-chat-2021-03-07 +tag: package-chat-2021-04-05-preview6 require: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/896d05e37dbb00712726620b8d679cc3c3be09fb/specification/communication/data-plane/Chat/readme.md output-folder: ../azure/communication/chat/_generated namespace: azure.communication.chat diff --git a/sdk/communication/azure-communication-chat/tests/_shared/testcase.py b/sdk/communication/azure-communication-chat/tests/_shared/testcase.py index 82b95493cc58..93088fe54085 100644 --- a/sdk/communication/azure-communication-chat/tests/_shared/testcase.py +++ b/sdk/communication/azure-communication-chat/tests/_shared/testcase.py @@ -71,7 +71,6 @@ def __init__(self, method_name, *args, **kwargs): def setUp(self): super(CommunicationTestCase, self).setUp() - if self.is_playback(): self.connection_str = "endpoint=https://sanitized/;accesskey=fake===" else: diff --git a/sdk/communication/azure-communication-chat/tests/test_chat_thread_client.py b/sdk/communication/azure-communication-chat/tests/test_chat_thread_client.py index 59b8d0bb224d..3731bd6381cb 100644 --- a/sdk/communication/azure-communication-chat/tests/test_chat_thread_client.py +++ b/sdk/communication/azure-communication-chat/tests/test_chat_thread_client.py @@ -67,9 +67,11 @@ def mock_send(*_, **__): try: content='hello world' sender_display_name='sender name' + metadata={ "tags": "tag" } create_message_result = chat_thread_client.send_message( content=content, - sender_display_name=sender_display_name) + sender_display_name=sender_display_name, + metadata=metadata) create_message_result_id = create_message_result.id except: raised = True @@ -192,7 +194,10 @@ def mock_send(*_, **__): "senderCommunicationIdentifier": {"rawId": "string", "communicationUser": { "id": "8:acs:8540c0de-899f-5cce-acb5-3ec493af3800_0e59221d-0c1d-46ae-9544-c963ce56c10b"}}, "deletedOn": "2021-01-27T01:37:33Z", - "editedOn": "2021-01-27T01:37:33Z" + "editedOn": "2021-01-27T01:37:33Z", + "metadata": { + "tags": "tag" + } }) chat_thread_client = ChatThreadClient("https://endpoint", TestChatThreadClient.credential, thread_id, transport=Mock(send=mock_send)) @@ -206,6 +211,7 @@ def mock_send(*_, **__): assert message.id == message_id assert message.content.message == message_str assert message.type == ChatMessageType.TEXT + assert message.metadata["tags"] == "tag" assert len(message.content.participants) > 0 def test_list_messages(self): @@ -332,7 +338,7 @@ def mock_send(*_, **__): l = list(chat_message) assert len(l) == 2 - def test_update_message(self): + def test_update_message_content(self): thread_id = "19:bcaebfba0d314c2aa3e920d38fa3df08@thread.v2" message_id='1596823919339' raised = False @@ -349,6 +355,23 @@ def mock_send(*_, **__): self.assertFalse(raised, 'Expected is no excpetion raised') + def test_update_message_metadata(self): + thread_id = "19:bcaebfba0d314c2aa3e920d38fa3df08@thread.v2" + message_id='1596823919339' + raised = False + + def mock_send(*_, **__): + return mock_response(status_code=204) + chat_thread_client = ChatThreadClient("https://endpoint", TestChatThreadClient.credential, thread_id, transport=Mock(send=mock_send)) + + try: + metadata={ "tags": "tag" } + chat_thread_client.update_message(message_id, metadata=metadata) + except: + raised = True + + self.assertFalse(raised, 'Expected is no excpetion raised') + def test_delete_message(self): thread_id = "19:bcaebfba0d314c2aa3e920d38fa3df08@thread.v2" message_id='1596823919339' diff --git a/sdk/communication/azure-communication-chat/tests/test_chat_thread_client_async.py b/sdk/communication/azure-communication-chat/tests/test_chat_thread_client_async.py index a1817a73816a..3f95e3827449 100644 --- a/sdk/communication/azure-communication-chat/tests/test_chat_thread_client_async.py +++ b/sdk/communication/azure-communication-chat/tests/test_chat_thread_client_async.py @@ -67,10 +67,12 @@ async def mock_send(*_, **__): try: content='hello world' sender_display_name='sender name' + metadata={ "tags": "tag" } create_message_result = await chat_thread_client.send_message( content, - sender_display_name=sender_display_name) + sender_display_name=sender_display_name, + metadata=metadata) create_message_result_id = create_message_result.id except: raised = True @@ -197,7 +199,10 @@ async def mock_send(*_, **__): "senderCommunicationIdentifier": {"rawId": "string", "communicationUser": { "id": "8:acs:8540c0de-899f-5cce-acb5-3ec493af3800_0e59221d-0c1d-46ae-9544-c963ce56c10b"}}, "deletedOn": "2021-01-27T01:37:33Z", - "editedOn": "2021-01-27T01:37:33Z" + "editedOn": "2021-01-27T01:37:33Z", + "metadata": { + "tags": "tag" + } }) chat_thread_client = ChatThreadClient("https://endpoint", credential, thread_id, transport=Mock(send=mock_send)) @@ -211,6 +216,7 @@ async def mock_send(*_, **__): assert message.id == message_id assert message.type == ChatMessageType.TEXT assert message.content.message == message_str + assert message.metadata["tags"] == "tag" assert len(message.content.participants) > 0 @pytest.mark.asyncio @@ -343,7 +349,7 @@ async def mock_send(*_, **__): assert len(items) == 2 @pytest.mark.asyncio -async def test_update_message(): +async def test_update_message_content(): thread_id = "19:bcaebfba0d314c2aa3e920d38fa3df08@thread.v2" message_id='1596823919339' raised = False @@ -360,6 +366,24 @@ async def mock_send(*_, **__): assert raised == False +@pytest.mark.asyncio +async def test_update_message_metadata(): + thread_id = "19:bcaebfba0d314c2aa3e920d38fa3df08@thread.v2" + message_id='1596823919339' + raised = False + + async def mock_send(*_, **__): + return mock_response(status_code=204) + chat_thread_client = ChatThreadClient("https://endpoint", credential, thread_id, transport=Mock(send=mock_send)) + + try: + metadata={ "tags": "tag" } + await chat_thread_client.update_message(message_id, metadata=metadata) + except: + raised = True + + assert raised == False + @pytest.mark.asyncio async def test_delete_message(): thread_id = "19:bcaebfba0d314c2aa3e920d38fa3df08@thread.v2"