Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Communication]Acs chat preview6 #19232

Merged
merged 12 commits into from
Jul 6, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,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)
LuChen-Microsoft marked this conversation as resolved.
Show resolved Hide resolved

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(
Expand Down Expand Up @@ -394,6 +396,7 @@ def update_message(
self,
message_id, # type: str
content=None, # type: Optional[str]
metadata=None, # type: Optional[dict[str, str]]
sarkar-rajarshi marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this into kwargs, and document it as keyword only (same as we did for send_message)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@annatisch do we need to also put content in kwargs? it's also optional.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depends on whether this library has already has a GA 1.0 release. If so - to move content into kwargs would be a breaking change.

**kwargs # type: Any
):
# type: (...) -> None
Expand All @@ -419,7 +422,7 @@ 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 self._client.chat_thread.update_chat_message(
chat_thread_id=self._thread_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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__(
Expand All @@ -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):
Expand Down Expand Up @@ -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 = {
Expand All @@ -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__(
Expand All @@ -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):
Expand Down Expand Up @@ -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__(
Expand All @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = {
Expand All @@ -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__(
Expand All @@ -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)
Expand All @@ -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):
Expand Down Expand Up @@ -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 = {
Expand All @@ -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__(
Expand All @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down
Loading