Skip to content

Commit 04e6769

Browse files
[ACS][Chat][Interop] File Sharing GA (#33938)
* init * Update _version.py * Update SWAGGER.md * updated recording * removed debug * updated samples to showcase attachment type * migrate to sphinx docs * updated common sdk reference to the latest --------- Co-authored-by: Jim Chou <[email protected]>
1 parent e0da2aa commit 04e6769

30 files changed

+352
-325
lines changed

sdk/communication/azure-communication-chat/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# Release History
22

3-
## 1.3.0b1 (Unreleased)
3+
## 1.3.0 (Unreleased)
44

55
### Features Added
66

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

910
### Breaking Changes

sdk/communication/azure-communication-chat/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "python",
44
"TagPrefix": "python/communication/azure-communication-chat",
5-
"Tag": "python/communication/azure-communication-chat_555e22e625"
5+
"Tag": "python/communication/azure-communication-chat_d9f766767c"
66
}

sdk/communication/azure-communication-chat/azure/communication/chat/_chat_thread_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ def list_messages(
373373
374374
:keyword int results_per_page: The maximum number of messages to be returned per page.
375375
:keyword ~datetime.datetime start_time: The earliest point in time to get messages up to.
376-
The timestamp should be in RFC3339 format: ``yyyy-MM-ddTHH:mm:ssZ``.
376+
The timestamp should be in RFC3339 format: ``yyyy-MM-ddTHH:mm:ssZ``.
377377
:return: An iterator like instance of ChatMessage
378378
:rtype: ~azure.core.paging.ItemPaged[~azure.communication.chat.ChatMessage]
379379
:raises: ~azure.core.exceptions.HttpResponseError, ValueError

sdk/communication/azure-communication-chat/azure/communication/chat/_generated/_azure_communication_chat_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class AzureCommunicationChatService: # pylint: disable=client-accepts-api-versi
2828
:vartype chat: azure.communication.chat.operations.ChatOperations
2929
:param endpoint: The endpoint of the Azure Communication resource. Required.
3030
:type endpoint: str
31-
:keyword api_version: Api Version. Default value is "2023-11-07". Note that overriding this
31+
:keyword api_version: Api Version. Default value is "2024-03-07". Note that overriding this
3232
default value may result in unsupported behavior.
3333
:paramtype api_version: str
3434
"""

sdk/communication/azure-communication-chat/azure/communication/chat/_generated/_configuration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ class AzureCommunicationChatServiceConfiguration: # pylint: disable=too-many-in
2121
2222
:param endpoint: The endpoint of the Azure Communication resource. Required.
2323
:type endpoint: str
24-
:keyword api_version: Api Version. Default value is "2023-11-07". Note that overriding this
24+
:keyword api_version: Api Version. Default value is "2024-03-07". Note that overriding this
2525
default value may result in unsupported behavior.
2626
:paramtype api_version: str
2727
"""
2828

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

3232
if endpoint is None:
3333
raise ValueError("Parameter 'endpoint' must not be None.")

sdk/communication/azure-communication-chat/azure/communication/chat/_generated/_serialization.py

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,6 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]],
170170
return None
171171

172172

173-
try:
174-
basestring # type: ignore
175-
unicode_str = unicode # type: ignore
176-
except NameError:
177-
basestring = str
178-
unicode_str = str
179-
180173
_LOGGER = logging.getLogger(__name__)
181174

182175
try:
@@ -545,7 +538,7 @@ class Serializer(object):
545538
"multiple": lambda x, y: x % y != 0,
546539
}
547540

548-
def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None):
541+
def __init__(self, classes: Optional[Mapping[str, type]] = None):
549542
self.serialize_type = {
550543
"iso-8601": Serializer.serialize_iso,
551544
"rfc-1123": Serializer.serialize_rfc,
@@ -561,7 +554,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None):
561554
"[]": self.serialize_iter,
562555
"{}": self.serialize_dict,
563556
}
564-
self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {}
557+
self.dependencies: Dict[str, type] = dict(classes) if classes else {}
565558
self.key_transformer = full_restapi_key_transformer
566559
self.client_side_validation = True
567560

@@ -649,7 +642,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs):
649642
else: # That's a basic type
650643
# Integrate namespace if necessary
651644
local_node = _create_xml_node(xml_name, xml_prefix, xml_ns)
652-
local_node.text = unicode_str(new_attr)
645+
local_node.text = str(new_attr)
653646
serialized.append(local_node) # type: ignore
654647
else: # JSON
655648
for k in reversed(keys): # type: ignore
@@ -745,7 +738,7 @@ def query(self, name, data, data_type, **kwargs):
745738
:param str data_type: The type to be serialized from.
746739
:keyword bool skip_quote: Whether to skip quote the serialized result.
747740
Defaults to False.
748-
:rtype: str
741+
:rtype: str, list
749742
:raises: TypeError if serialization fails.
750743
:raises: ValueError if data is None
751744
"""
@@ -994,7 +987,7 @@ def serialize_object(self, attr, **kwargs):
994987
return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs)
995988
if obj_type is _long_type:
996989
return self.serialize_long(attr)
997-
if obj_type is unicode_str:
990+
if obj_type is str:
998991
return self.serialize_unicode(attr)
999992
if obj_type is datetime.datetime:
1000993
return self.serialize_iso(attr)
@@ -1370,7 +1363,7 @@ class Deserializer(object):
13701363

13711364
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}]?")
13721365

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

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

1446-
if isinstance(response, basestring):
1439+
if isinstance(response, str):
14471440
return self.deserialize_data(data, response)
14481441
elif isinstance(response, type) and issubclass(response, Enum):
14491442
return self.deserialize_enum(data, response)
@@ -1514,14 +1507,14 @@ def _classify_target(self, target, data):
15141507
if target is None:
15151508
return None, None
15161509

1517-
if isinstance(target, basestring):
1510+
if isinstance(target, str):
15181511
try:
15191512
target = self.dependencies[target]
15201513
except KeyError:
15211514
return target, target
15221515

15231516
try:
1524-
target = target._classify(data, self.dependencies)
1517+
target = target._classify(data, self.dependencies) # type: ignore
15251518
except AttributeError:
15261519
pass # Target is not a Model, no classify
15271520
return target, target.__class__.__name__ # type: ignore
@@ -1577,7 +1570,7 @@ def _unpack_content(raw_data, content_type=None):
15771570
if hasattr(raw_data, "_content_consumed"):
15781571
return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers)
15791572

1580-
if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"):
1573+
if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"):
15811574
return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore
15821575
return raw_data
15831576

@@ -1699,7 +1692,7 @@ def deserialize_object(self, attr, **kwargs):
16991692
if isinstance(attr, ET.Element):
17001693
# Do no recurse on XML, just return the tree as-is
17011694
return attr
1702-
if isinstance(attr, basestring):
1695+
if isinstance(attr, str):
17031696
return self.deserialize_basic(attr, "str")
17041697
obj_type = type(attr)
17051698
if obj_type in self.basic_types:
@@ -1756,7 +1749,7 @@ def deserialize_basic(self, attr, data_type):
17561749
if data_type == "bool":
17571750
if attr in [True, False, 1, 0]:
17581751
return bool(attr)
1759-
elif isinstance(attr, basestring):
1752+
elif isinstance(attr, str):
17601753
if attr.lower() in ["true", "1"]:
17611754
return True
17621755
elif attr.lower() in ["false", "0"]:
@@ -1860,7 +1853,7 @@ def deserialize_decimal(attr):
18601853
if isinstance(attr, ET.Element):
18611854
attr = attr.text
18621855
try:
1863-
return decimal.Decimal(attr) # type: ignore
1856+
return decimal.Decimal(str(attr)) # type: ignore
18641857
except decimal.DecimalException as err:
18651858
msg = "Invalid decimal {}".format(attr)
18661859
raise DeserializationError(msg) from err
@@ -1996,6 +1989,7 @@ def deserialize_unix(attr):
19961989
if isinstance(attr, ET.Element):
19971990
attr = int(attr.text) # type: ignore
19981991
try:
1992+
attr = int(attr)
19991993
date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC)
20001994
except ValueError as err:
20011995
msg = "Cannot deserialize to unix datetime object."

sdk/communication/azure-communication-chat/azure/communication/chat/_generated/aio/_azure_communication_chat_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class AzureCommunicationChatService: # pylint: disable=client-accepts-api-versi
2828
:vartype chat: azure.communication.chat.aio.operations.ChatOperations
2929
:param endpoint: The endpoint of the Azure Communication resource. Required.
3030
:type endpoint: str
31-
:keyword api_version: Api Version. Default value is "2023-11-07". Note that overriding this
31+
:keyword api_version: Api Version. Default value is "2024-03-07". Note that overriding this
3232
default value may result in unsupported behavior.
3333
:paramtype api_version: str
3434
"""

sdk/communication/azure-communication-chat/azure/communication/chat/_generated/aio/_configuration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ class AzureCommunicationChatServiceConfiguration: # pylint: disable=too-many-in
2121
2222
:param endpoint: The endpoint of the Azure Communication resource. Required.
2323
:type endpoint: str
24-
:keyword api_version: Api Version. Default value is "2023-11-07". Note that overriding this
24+
:keyword api_version: Api Version. Default value is "2024-03-07". Note that overriding this
2525
default value may result in unsupported behavior.
2626
:paramtype api_version: str
2727
"""
2828

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

3232
if endpoint is None:
3333
raise ValueError("Parameter 'endpoint' must not be None.")

sdk/communication/azure-communication-chat/azure/communication/chat/_generated/aio/operations/_chat_operations.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# pylint: disable=too-many-lines
1+
# pylint: disable=too-many-lines,too-many-statements
22
# coding=utf-8
33
# --------------------------------------------------------------------------
44
# Copyright (c) Microsoft Corporation. All rights reserved.
@@ -83,7 +83,6 @@ async def create_chat_thread(
8383
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
8484
Default value is "application/json".
8585
:paramtype content_type: str
86-
:keyword callable cls: A custom type or function that will be passed the direct response
8786
:return: CreateChatThreadResult or the result of cls(response)
8887
:rtype: ~azure.communication.chat.models.CreateChatThreadResult
8988
:raises ~azure.core.exceptions.HttpResponseError:
@@ -92,7 +91,7 @@ async def create_chat_thread(
9291
@overload
9392
async def create_chat_thread(
9493
self,
95-
create_chat_thread_request: IO,
94+
create_chat_thread_request: IO[bytes],
9695
repeatability_request_id: Optional[str] = None,
9796
*,
9897
content_type: str = "application/json",
@@ -103,7 +102,7 @@ async def create_chat_thread(
103102
Creates a chat thread.
104103
105104
:param create_chat_thread_request: Request payload for creating a chat thread. Required.
106-
:type create_chat_thread_request: IO
105+
:type create_chat_thread_request: IO[bytes]
107106
:param repeatability_request_id: If specified, the client directs that the request is
108107
repeatable; that is, that the client can make the request multiple times with the same
109108
Repeatability-Request-Id and get back an appropriate response without the server executing the
@@ -114,7 +113,6 @@ async def create_chat_thread(
114113
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
115114
Default value is "application/json".
116115
:paramtype content_type: str
117-
:keyword callable cls: A custom type or function that will be passed the direct response
118116
:return: CreateChatThreadResult or the result of cls(response)
119117
:rtype: ~azure.communication.chat.models.CreateChatThreadResult
120118
:raises ~azure.core.exceptions.HttpResponseError:
@@ -123,7 +121,7 @@ async def create_chat_thread(
123121
@distributed_trace_async
124122
async def create_chat_thread(
125123
self,
126-
create_chat_thread_request: Union[_models.CreateChatThreadRequest, IO],
124+
create_chat_thread_request: Union[_models.CreateChatThreadRequest, IO[bytes]],
127125
repeatability_request_id: Optional[str] = None,
128126
**kwargs: Any
129127
) -> _models.CreateChatThreadResult:
@@ -132,20 +130,16 @@ async def create_chat_thread(
132130
Creates a chat thread.
133131
134132
:param create_chat_thread_request: Request payload for creating a chat thread. Is either a
135-
CreateChatThreadRequest type or a IO type. Required.
133+
CreateChatThreadRequest type or a IO[bytes] type. Required.
136134
:type create_chat_thread_request: ~azure.communication.chat.models.CreateChatThreadRequest or
137-
IO
135+
IO[bytes]
138136
:param repeatability_request_id: If specified, the client directs that the request is
139137
repeatable; that is, that the client can make the request multiple times with the same
140138
Repeatability-Request-Id and get back an appropriate response without the server executing the
141139
request multiple times. The value of the Repeatability-Request-Id is an opaque string
142140
representing a client-generated, globally unique for all time, identifier for the request. It
143141
is recommended to use version 4 (random) UUIDs. Default value is None.
144142
:type repeatability_request_id: str
145-
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
146-
Default value is None.
147-
:paramtype content_type: str
148-
:keyword callable cls: A custom type or function that will be passed the direct response
149143
:return: CreateChatThreadResult or the result of cls(response)
150144
:rtype: ~azure.communication.chat.models.CreateChatThreadResult
151145
:raises ~azure.core.exceptions.HttpResponseError:
@@ -207,7 +201,7 @@ async def create_chat_thread(
207201
response = pipeline_response.http_response
208202

209203
if response.status_code not in [201]:
210-
map_error(status_code=response.status_code, response=response, error_map=error_map)
204+
map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore
211205
raise HttpResponseError(response=response)
212206

213207
deserialized = self._deserialize("CreateChatThreadResult", pipeline_response)
@@ -231,7 +225,6 @@ def list_chat_threads(
231225
:param start_time: The earliest point in time to get chat threads up to. The timestamp should
232226
be in RFC3339 format: ``yyyy-MM-ddTHH:mm:ssZ``. Default value is None.
233227
:type start_time: ~datetime.datetime
234-
:keyword callable cls: A custom type or function that will be passed the direct response
235228
:return: An iterator like instance of either ChatThreadItem or the result of cls(response)
236229
:rtype:
237230
~azure.core.async_paging.AsyncItemPaged[~azure.communication.chat.models.ChatThreadItem]
@@ -320,7 +313,7 @@ async def get_next(next_link=None):
320313
response = pipeline_response.http_response
321314

322315
if response.status_code not in [200]:
323-
map_error(status_code=response.status_code, response=response, error_map=error_map)
316+
map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore
324317
raise HttpResponseError(response=response)
325318

326319
return pipeline_response
@@ -337,7 +330,6 @@ async def delete_chat_thread( # pylint: disable=inconsistent-return-statements
337330
338331
:param chat_thread_id: Id of the thread to be deleted. Required.
339332
:type chat_thread_id: str
340-
:keyword callable cls: A custom type or function that will be passed the direct response
341333
:return: None or the result of cls(response)
342334
:rtype: None
343335
:raises ~azure.core.exceptions.HttpResponseError:
@@ -387,7 +379,7 @@ async def delete_chat_thread( # pylint: disable=inconsistent-return-statements
387379
response = pipeline_response.http_response
388380

389381
if response.status_code not in [204]:
390-
map_error(status_code=response.status_code, response=response, error_map=error_map)
382+
map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore
391383
raise HttpResponseError(response=response)
392384

393385
if cls:

0 commit comments

Comments
 (0)