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

[ACS][Chat][Interop] File Sharing GA #33938

Merged
merged 8 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion sdk/communication/azure-communication-chat/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Release History

## 1.3.0b1 (Unreleased)
## 1.3.0 (Unreleased)

### Features Added

- Updated `chat_attachment.attachment_type`to include type `file` to support ACS users to recieve files shared by Teams user.
- Added support for a new communication identifier `MicrosoftTeamsAppIdentifier`.

### Breaking Changes
Expand Down
2 changes: 1 addition & 1 deletion sdk/communication/azure-communication-chat/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "python",
"TagPrefix": "python/communication/azure-communication-chat",
"Tag": "python/communication/azure-communication-chat_555e22e625"
"Tag": "python/communication/azure-communication-chat_d9f766767c"
}
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def list_messages(

:keyword int results_per_page: The maximum number of messages to be returned per page.
:keyword ~datetime.datetime start_time: The earliest point in time to get messages up to.
The timestamp should be in RFC3339 format: ``yyyy-MM-ddTHH:mm:ssZ``.
The timestamp should be in RFC3339 format: ``yyyy-MM-ddTHH:mm:ssZ``.
:return: An iterator like instance of ChatMessage
:rtype: ~azure.core.paging.ItemPaged[~azure.communication.chat.ChatMessage]
:raises: ~azure.core.exceptions.HttpResponseError, ValueError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AzureCommunicationChatService: # pylint: disable=client-accepts-api-versi
:vartype chat: azure.communication.chat.operations.ChatOperations
:param endpoint: The endpoint of the Azure Communication resource. Required.
:type endpoint: str
:keyword api_version: Api Version. Default value is "2023-11-07". Note that overriding this
:keyword api_version: Api Version. Default value is "2024-03-07". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ class AzureCommunicationChatServiceConfiguration: # pylint: disable=too-many-in

:param endpoint: The endpoint of the Azure Communication resource. Required.
:type endpoint: str
:keyword api_version: Api Version. Default value is "2023-11-07". Note that overriding this
:keyword api_version: Api Version. Default value is "2024-03-07". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(self, endpoint: str, **kwargs: Any) -> None:
api_version: str = kwargs.pop("api_version", "2023-11-07")
api_version: str = kwargs.pop("api_version", "2024-03-07")

if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,6 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]],
return None


try:
basestring # type: ignore
unicode_str = unicode # type: ignore
except NameError:
basestring = str
unicode_str = str

_LOGGER = logging.getLogger(__name__)

try:
Expand Down Expand Up @@ -545,7 +538,7 @@ class Serializer(object):
"multiple": lambda x, y: x % y != 0,
}

def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None):
def __init__(self, classes: Optional[Mapping[str, type]] = None):
self.serialize_type = {
"iso-8601": Serializer.serialize_iso,
"rfc-1123": Serializer.serialize_rfc,
Expand All @@ -561,7 +554,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None):
"[]": self.serialize_iter,
"{}": self.serialize_dict,
}
self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {}
self.dependencies: Dict[str, type] = dict(classes) if classes else {}
self.key_transformer = full_restapi_key_transformer
self.client_side_validation = True

Expand Down Expand Up @@ -649,7 +642,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs):
else: # That's a basic type
# Integrate namespace if necessary
local_node = _create_xml_node(xml_name, xml_prefix, xml_ns)
local_node.text = unicode_str(new_attr)
local_node.text = str(new_attr)
serialized.append(local_node) # type: ignore
else: # JSON
for k in reversed(keys): # type: ignore
Expand Down Expand Up @@ -745,7 +738,7 @@ def query(self, name, data, data_type, **kwargs):
:param str data_type: The type to be serialized from.
:keyword bool skip_quote: Whether to skip quote the serialized result.
Defaults to False.
:rtype: str
:rtype: str, list
:raises: TypeError if serialization fails.
:raises: ValueError if data is None
"""
Expand Down Expand Up @@ -994,7 +987,7 @@ def serialize_object(self, attr, **kwargs):
return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs)
if obj_type is _long_type:
return self.serialize_long(attr)
if obj_type is unicode_str:
if obj_type is str:
return self.serialize_unicode(attr)
if obj_type is datetime.datetime:
return self.serialize_iso(attr)
Expand Down Expand Up @@ -1370,7 +1363,7 @@ class Deserializer(object):

valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?")

def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None):
def __init__(self, classes: Optional[Mapping[str, type]] = None):
self.deserialize_type = {
"iso-8601": Deserializer.deserialize_iso,
"rfc-1123": Deserializer.deserialize_rfc,
Expand All @@ -1390,7 +1383,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None):
"duration": (isodate.Duration, datetime.timedelta),
"iso-8601": (datetime.datetime),
}
self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {}
self.dependencies: Dict[str, type] = dict(classes) if classes else {}
self.key_extractors = [rest_key_extractor, xml_key_extractor]
# Additional properties only works if the "rest_key_extractor" is used to
# extract the keys. Making it to work whatever the key extractor is too much
Expand Down Expand Up @@ -1443,7 +1436,7 @@ def _deserialize(self, target_obj, data):

response, class_name = self._classify_target(target_obj, data)

if isinstance(response, basestring):
if isinstance(response, str):
return self.deserialize_data(data, response)
elif isinstance(response, type) and issubclass(response, Enum):
return self.deserialize_enum(data, response)
Expand Down Expand Up @@ -1514,14 +1507,14 @@ def _classify_target(self, target, data):
if target is None:
return None, None

if isinstance(target, basestring):
if isinstance(target, str):
try:
target = self.dependencies[target]
except KeyError:
return target, target

try:
target = target._classify(data, self.dependencies)
target = target._classify(data, self.dependencies) # type: ignore
except AttributeError:
pass # Target is not a Model, no classify
return target, target.__class__.__name__ # type: ignore
Expand Down Expand Up @@ -1577,7 +1570,7 @@ def _unpack_content(raw_data, content_type=None):
if hasattr(raw_data, "_content_consumed"):
return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers)

if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"):
if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"):
return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore
return raw_data

Expand Down Expand Up @@ -1699,7 +1692,7 @@ def deserialize_object(self, attr, **kwargs):
if isinstance(attr, ET.Element):
# Do no recurse on XML, just return the tree as-is
return attr
if isinstance(attr, basestring):
if isinstance(attr, str):
return self.deserialize_basic(attr, "str")
obj_type = type(attr)
if obj_type in self.basic_types:
Expand Down Expand Up @@ -1756,7 +1749,7 @@ def deserialize_basic(self, attr, data_type):
if data_type == "bool":
if attr in [True, False, 1, 0]:
return bool(attr)
elif isinstance(attr, basestring):
elif isinstance(attr, str):
if attr.lower() in ["true", "1"]:
return True
elif attr.lower() in ["false", "0"]:
Expand Down Expand Up @@ -1860,7 +1853,7 @@ def deserialize_decimal(attr):
if isinstance(attr, ET.Element):
attr = attr.text
try:
return decimal.Decimal(attr) # type: ignore
return decimal.Decimal(str(attr)) # type: ignore
except decimal.DecimalException as err:
msg = "Invalid decimal {}".format(attr)
raise DeserializationError(msg) from err
Expand Down Expand Up @@ -1996,6 +1989,7 @@ def deserialize_unix(attr):
if isinstance(attr, ET.Element):
attr = int(attr.text) # type: ignore
try:
attr = int(attr)
date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC)
except ValueError as err:
msg = "Cannot deserialize to unix datetime object."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AzureCommunicationChatService: # pylint: disable=client-accepts-api-versi
:vartype chat: azure.communication.chat.aio.operations.ChatOperations
:param endpoint: The endpoint of the Azure Communication resource. Required.
:type endpoint: str
:keyword api_version: Api Version. Default value is "2023-11-07". Note that overriding this
:keyword api_version: Api Version. Default value is "2024-03-07". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ class AzureCommunicationChatServiceConfiguration: # pylint: disable=too-many-in

:param endpoint: The endpoint of the Azure Communication resource. Required.
:type endpoint: str
:keyword api_version: Api Version. Default value is "2023-11-07". Note that overriding this
:keyword api_version: Api Version. Default value is "2024-03-07". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(self, endpoint: str, **kwargs: Any) -> None:
api_version: str = kwargs.pop("api_version", "2023-11-07")
api_version: str = kwargs.pop("api_version", "2024-03-07")

if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pylint: disable=too-many-lines
# pylint: disable=too-many-lines,too-many-statements
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
Expand Down Expand Up @@ -83,7 +83,6 @@ async def create_chat_thread(
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: CreateChatThreadResult or the result of cls(response)
:rtype: ~azure.communication.chat.models.CreateChatThreadResult
:raises ~azure.core.exceptions.HttpResponseError:
Expand All @@ -92,7 +91,7 @@ async def create_chat_thread(
@overload
async def create_chat_thread(
self,
create_chat_thread_request: IO,
create_chat_thread_request: IO[bytes],
repeatability_request_id: Optional[str] = None,
*,
content_type: str = "application/json",
Expand All @@ -103,7 +102,7 @@ async def create_chat_thread(
Creates a chat thread.

:param create_chat_thread_request: Request payload for creating a chat thread. Required.
:type create_chat_thread_request: IO
:type create_chat_thread_request: IO[bytes]
:param repeatability_request_id: If specified, the client directs that the request is
repeatable; that is, that the client can make the request multiple times with the same
Repeatability-Request-Id and get back an appropriate response without the server executing the
Expand All @@ -114,7 +113,6 @@ async def create_chat_thread(
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: CreateChatThreadResult or the result of cls(response)
:rtype: ~azure.communication.chat.models.CreateChatThreadResult
:raises ~azure.core.exceptions.HttpResponseError:
Expand All @@ -123,7 +121,7 @@ async def create_chat_thread(
@distributed_trace_async
async def create_chat_thread(
self,
create_chat_thread_request: Union[_models.CreateChatThreadRequest, IO],
create_chat_thread_request: Union[_models.CreateChatThreadRequest, IO[bytes]],
repeatability_request_id: Optional[str] = None,
**kwargs: Any
) -> _models.CreateChatThreadResult:
Expand All @@ -132,20 +130,16 @@ async def create_chat_thread(
Creates a chat thread.

:param create_chat_thread_request: Request payload for creating a chat thread. Is either a
CreateChatThreadRequest type or a IO type. Required.
CreateChatThreadRequest type or a IO[bytes] type. Required.
:type create_chat_thread_request: ~azure.communication.chat.models.CreateChatThreadRequest or
IO
IO[bytes]
:param repeatability_request_id: If specified, the client directs that the request is
repeatable; that is, that the client can make the request multiple times with the same
Repeatability-Request-Id and get back an appropriate response without the server executing the
request multiple times. The value of the Repeatability-Request-Id is an opaque string
representing a client-generated, globally unique for all time, identifier for the request. It
is recommended to use version 4 (random) UUIDs. Default value is None.
:type repeatability_request_id: str
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: CreateChatThreadResult or the result of cls(response)
:rtype: ~azure.communication.chat.models.CreateChatThreadResult
:raises ~azure.core.exceptions.HttpResponseError:
Expand Down Expand Up @@ -207,7 +201,7 @@ async def create_chat_thread(
response = pipeline_response.http_response

if response.status_code not in [201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore
raise HttpResponseError(response=response)

deserialized = self._deserialize("CreateChatThreadResult", pipeline_response)
Expand All @@ -231,7 +225,6 @@ def list_chat_threads(
:param start_time: The earliest point in time to get chat threads up to. The timestamp should
be in RFC3339 format: ``yyyy-MM-ddTHH:mm:ssZ``. Default value is None.
:type start_time: ~datetime.datetime
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either ChatThreadItem or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.communication.chat.models.ChatThreadItem]
Expand Down Expand Up @@ -320,7 +313,7 @@ async def get_next(next_link=None):
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)
map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore
raise HttpResponseError(response=response)

return pipeline_response
Expand All @@ -337,7 +330,6 @@ async def delete_chat_thread( # pylint: disable=inconsistent-return-statements

:param chat_thread_id: Id of the thread to be deleted. Required.
:type chat_thread_id: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
Expand Down Expand Up @@ -387,7 +379,7 @@ async def delete_chat_thread( # pylint: disable=inconsistent-return-statements
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)
map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore
raise HttpResponseError(response=response)

if cls:
Expand Down
Loading
Loading