Skip to content

Commit 6943ced

Browse files
author
SDKAuto
committed
CodeGen from PR 32475 in Azure/azure-rest-api-specs
Merge 80062439bf65f789141cdb2ef22973443e2348b4 into 599c6d54b292ee8827330a81b967b07c5871d7af
1 parent 74ece68 commit 6943ced

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+676
-1619
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"commit": "532ef9745d000ab936829d573138f937d9761bd6",
3+
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
4+
"typespec_src": "specification/communication/Communication.Messages",
5+
"@azure-tools/typespec-python": "0.38.2"
6+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"CrossLanguagePackageId": "Azure.Communication.MessagesService",
3+
"CrossLanguageDefinitionId": {
4+
"azure.communication.messages.models.NotificationContent": "Azure.Communication.MessagesService.NotificationContent",
5+
"azure.communication.messages.models.AudioNotificationContent": "Azure.Communication.MessagesService.AudioNotificationContent",
6+
"azure.communication.messages.models.DocumentNotificationContent": "Azure.Communication.MessagesService.DocumentNotificationContent",
7+
"azure.communication.messages.models.ImageNotificationContent": "Azure.Communication.MessagesService.ImageNotificationContent",
8+
"azure.communication.messages.models.MediaNotificationContent": "Azure.Communication.MessagesService.MediaNotificationContent",
9+
"azure.communication.messages.models.MessageReceipt": "Azure.Communication.MessagesService.MessageReceipt",
10+
"azure.communication.messages.models.MessageTemplate": "Azure.Communication.MessagesService.MessageTemplate",
11+
"azure.communication.messages.models.MessageTemplateBindings": "Azure.Communication.MessagesService.MessageTemplateBindings",
12+
"azure.communication.messages.models.MessageTemplateValue": "Azure.Communication.MessagesService.MessageTemplateValue",
13+
"azure.communication.messages.models.MessageTemplateDocument": "Azure.Communication.MessagesService.MessageTemplateDocument",
14+
"azure.communication.messages.models.MessageTemplateImage": "Azure.Communication.MessagesService.MessageTemplateImage",
15+
"azure.communication.messages.models.MessageTemplateItem": "Azure.Communication.MessagesService.MessageTemplateItem",
16+
"azure.communication.messages.models.MessageTemplateLocation": "Azure.Communication.MessagesService.MessageTemplateLocation",
17+
"azure.communication.messages.models.MessageTemplateQuickAction": "Azure.Communication.MessagesService.MessageTemplateQuickAction",
18+
"azure.communication.messages.models.MessageTemplateText": "Azure.Communication.MessagesService.MessageTemplateText",
19+
"azure.communication.messages.models.MessageTemplateVideo": "Azure.Communication.MessagesService.MessageTemplateVideo",
20+
"azure.communication.messages.models.SendMessageResult": "Azure.Communication.MessagesService.SendMessageResult",
21+
"azure.communication.messages.models.TemplateNotificationContent": "Azure.Communication.MessagesService.TemplateNotificationContent",
22+
"azure.communication.messages.models.TextNotificationContent": "Azure.Communication.MessagesService.TextNotificationContent",
23+
"azure.communication.messages.models.VideoNotificationContent": "Azure.Communication.MessagesService.VideoNotificationContent",
24+
"azure.communication.messages.models.WhatsAppMessageTemplateBindings": "Azure.Communication.MessagesService.WhatsAppMessageTemplateBindings",
25+
"azure.communication.messages.models.WhatsAppMessageTemplateBindingsButton": "Azure.Communication.MessagesService.WhatsAppMessageTemplateBindingsButton",
26+
"azure.communication.messages.models.WhatsAppMessageTemplateBindingsComponent": "Azure.Communication.MessagesService.WhatsAppMessageTemplateBindingsComponent",
27+
"azure.communication.messages.models.WhatsAppMessageTemplateItem": "Azure.Communication.MessagesService.WhatsAppMessageTemplateItem",
28+
"azure.communication.messages.models.RepeatabilityResult": "Azure.Core.RepeatabilityResult",
29+
"azure.communication.messages.models.CommunicationMessageKind": "Azure.Communication.MessagesService.CommunicationMessageKind",
30+
"azure.communication.messages.models.MessageTemplateValueKind": "Azure.Communication.MessagesService.MessageTemplateValueKind",
31+
"azure.communication.messages.models.MessageTemplateBindingsKind": "Azure.Communication.MessagesService.MessageTemplateBindingsKind",
32+
"azure.communication.messages.models.WhatsAppMessageButtonSubType": "Azure.Communication.MessagesService.WhatsAppMessageButtonSubType",
33+
"azure.communication.messages.models.MessageTemplateStatus": "Azure.Communication.MessagesService.MessageTemplateStatus",
34+
"azure.communication.messages.models.CommunicationMessagesChannel": "Azure.Communication.MessagesService.CommunicationMessagesChannel",
35+
"azure.communication.messages.NotificationMessagesClient.send": "Azure.Communication.MessagesService.NotificationMessagesClient.send",
36+
"azure.communication.messages.NotificationMessagesClient.download_media": "ClientForAcsMessages.NotificationMessagesClient.downloadMedia",
37+
"azure.communication.messages.MessageTemplateClient.list_templates": "Azure.Communication.MessagesService.MessageTemplateClient.listTemplates"
38+
}
39+
}

sdk/communication/azure-communication-messages/azure/communication/messages/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,22 @@
55
# Code generated by Microsoft (R) Python Code Generator.
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
8+
# pylint: disable=wrong-import-position
89

9-
from ._client import NotificationMessagesClient
10-
from ._client import MessageTemplateClient
10+
from typing import TYPE_CHECKING
11+
12+
if TYPE_CHECKING:
13+
from ._patch import * # pylint: disable=unused-wildcard-import
14+
15+
from ._client import NotificationMessagesClient # type: ignore
16+
from ._client import MessageTemplateClient # type: ignore
1117
from ._version import VERSION
1218

1319
__version__ = VERSION
1420

1521
try:
1622
from ._patch import __all__ as _patch_all
17-
from ._patch import * # pylint: disable=unused-wildcard-import
23+
from ._patch import *
1824
except ImportError:
1925
_patch_all = []
2026
from ._patch import patch_sdk as _patch_sdk
@@ -23,6 +29,6 @@
2329
"NotificationMessagesClient",
2430
"MessageTemplateClient",
2531
]
26-
__all__.extend([p for p in _patch_all if p not in __all__])
32+
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
2733

2834
_patch_sdk()

sdk/communication/azure-communication-messages/azure/communication/messages/_api_versions.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

sdk/communication/azure-communication-messages/azure/communication/messages/_client.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,17 @@
2020
from ._serialization import Deserializer, Serializer
2121

2222
if TYPE_CHECKING:
23-
# pylint: disable=unused-import,ungrouped-imports
2423
from azure.core.credentials import TokenCredential
2524

2625

27-
class NotificationMessagesClient(
28-
NotificationMessagesClientOperationsMixin
29-
): # pylint: disable=client-accepts-api-version-keyword
26+
class NotificationMessagesClient(NotificationMessagesClientOperationsMixin):
3027
"""NotificationMessagesClient.
3128
3229
:param endpoint: The communication resource, for example
3330
https://my-resource.communication.azure.com. Required.
3431
:type endpoint: str
35-
:param credential: Credential used to authenticate requests to the service. Is either a
36-
TokenCredential type or a AzureKeyCredential type. Required.
32+
:param credential: Credential used to authenticate requests to the service. Is either a token
33+
credential type or a key credential type. Required.
3734
:type credential: ~azure.core.credentials.TokenCredential or
3835
~azure.core.credentials.AzureKeyCredential
3936
:keyword api_version: The API version to use for this operation. Default value is "2024-08-30".
@@ -104,14 +101,14 @@ def __exit__(self, *exc_details: Any) -> None:
104101
self._client.__exit__(*exc_details)
105102

106103

107-
class MessageTemplateClient(MessageTemplateClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword
104+
class MessageTemplateClient(MessageTemplateClientOperationsMixin):
108105
"""MessageTemplateClient.
109106
110107
:param endpoint: The communication resource, for example
111108
https://my-resource.communication.azure.com. Required.
112109
:type endpoint: str
113-
:param credential: Credential used to authenticate requests to the service. Is either a
114-
TokenCredential type or a AzureKeyCredential type. Required.
110+
:param credential: Credential used to authenticate requests to the service. Is either a token
111+
credential type or a key credential type. Required.
115112
:type credential: ~azure.core.credentials.TokenCredential or
116113
~azure.core.credentials.AzureKeyCredential
117114
:keyword api_version: The API version to use for this operation. Default value is "2024-08-30".

sdk/communication/azure-communication-messages/azure/communication/messages/_configuration.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@
1414
from ._version import VERSION
1515

1616
if TYPE_CHECKING:
17-
# pylint: disable=unused-import,ungrouped-imports
1817
from azure.core.credentials import TokenCredential
1918

2019

21-
class NotificationMessagesClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
20+
class NotificationMessagesClientConfiguration: # pylint: disable=too-many-instance-attributes
2221
"""Configuration for NotificationMessagesClient.
2322
2423
Note that all parameters used to create this instance are saved as instance
@@ -27,8 +26,8 @@ class NotificationMessagesClientConfiguration: # pylint: disable=too-many-insta
2726
:param endpoint: The communication resource, for example
2827
https://my-resource.communication.azure.com. Required.
2928
:type endpoint: str
30-
:param credential: Credential used to authenticate requests to the service. Is either a
31-
TokenCredential type or a AzureKeyCredential type. Required.
29+
:param credential: Credential used to authenticate requests to the service. Is either a token
30+
credential type or a key credential type. Required.
3231
:type credential: ~azure.core.credentials.TokenCredential or
3332
~azure.core.credentials.AzureKeyCredential
3433
:keyword api_version: The API version to use for this operation. Default value is "2024-08-30".
@@ -73,7 +72,7 @@ def _configure(self, **kwargs: Any) -> None:
7372
self.authentication_policy = self._infer_policy(**kwargs)
7473

7574

76-
class MessageTemplateClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
75+
class MessageTemplateClientConfiguration: # pylint: disable=too-many-instance-attributes
7776
"""Configuration for MessageTemplateClient.
7877
7978
Note that all parameters used to create this instance are saved as instance
@@ -82,8 +81,8 @@ class MessageTemplateClientConfiguration: # pylint: disable=too-many-instance-a
8281
:param endpoint: The communication resource, for example
8382
https://my-resource.communication.azure.com. Required.
8483
:type endpoint: str
85-
:param credential: Credential used to authenticate requests to the service. Is either a
86-
TokenCredential type or a AzureKeyCredential type. Required.
84+
:param credential: Credential used to authenticate requests to the service. Is either a token
85+
credential type or a key credential type. Required.
8786
:type credential: ~azure.core.credentials.TokenCredential or
8887
~azure.core.credentials.AzureKeyCredential
8988
:keyword api_version: The API version to use for this operation. Default value is "2024-08-30".

sdk/communication/azure-communication-messages/azure/communication/messages/_model_base.py

Lines changed: 88 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
# pylint: disable=too-many-lines
12
# coding=utf-8
23
# --------------------------------------------------------------------------
34
# Copyright (c) Microsoft Corporation. All rights reserved.
45
# Licensed under the MIT License. See License.txt in the project root for
56
# license information.
67
# --------------------------------------------------------------------------
7-
# pylint: disable=protected-access, arguments-differ, signature-differs, broad-except, too-many-lines
8+
# pylint: disable=protected-access, broad-except
89

910
import copy
1011
import calendar
@@ -372,15 +373,34 @@ def __ne__(self, other: typing.Any) -> bool:
372373
return not self.__eq__(other)
373374

374375
def keys(self) -> typing.KeysView[str]:
376+
"""
377+
:returns: a set-like object providing a view on D's keys
378+
:rtype: ~typing.KeysView
379+
"""
375380
return self._data.keys()
376381

377382
def values(self) -> typing.ValuesView[typing.Any]:
383+
"""
384+
:returns: an object providing a view on D's values
385+
:rtype: ~typing.ValuesView
386+
"""
378387
return self._data.values()
379388

380389
def items(self) -> typing.ItemsView[str, typing.Any]:
390+
"""
391+
:returns: set-like object providing a view on D's items
392+
:rtype: ~typing.ItemsView
393+
"""
381394
return self._data.items()
382395

383396
def get(self, key: str, default: typing.Any = None) -> typing.Any:
397+
"""
398+
Get the value for key if key is in the dictionary, else default.
399+
:param str key: The key to look up.
400+
:param any default: The value to return if key is not in the dictionary. Defaults to None
401+
:returns: D[k] if k in D, else d.
402+
:rtype: any
403+
"""
384404
try:
385405
return self[key]
386406
except KeyError:
@@ -396,17 +416,38 @@ def pop(self, key: str, default: _T) -> _T: ...
396416
def pop(self, key: str, default: typing.Any) -> typing.Any: ...
397417

398418
def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any:
419+
"""
420+
Removes specified key and return the corresponding value.
421+
:param str key: The key to pop.
422+
:param any default: The value to return if key is not in the dictionary
423+
:returns: The value corresponding to the key.
424+
:rtype: any
425+
:raises KeyError: If key is not found and default is not given.
426+
"""
399427
if default is _UNSET:
400428
return self._data.pop(key)
401429
return self._data.pop(key, default)
402430

403431
def popitem(self) -> typing.Tuple[str, typing.Any]:
432+
"""
433+
Removes and returns some (key, value) pair
434+
:returns: The (key, value) pair.
435+
:rtype: tuple
436+
:raises KeyError: if D is empty.
437+
"""
404438
return self._data.popitem()
405439

406440
def clear(self) -> None:
441+
"""
442+
Remove all items from D.
443+
"""
407444
self._data.clear()
408445

409446
def update(self, *args: typing.Any, **kwargs: typing.Any) -> None:
447+
"""
448+
Updates D from mapping/iterable E and F.
449+
:param any args: Either a mapping object or an iterable of key-value pairs.
450+
"""
410451
self._data.update(*args, **kwargs)
411452

412453
@typing.overload
@@ -416,6 +457,13 @@ def setdefault(self, key: str, default: None = None) -> None: ...
416457
def setdefault(self, key: str, default: typing.Any) -> typing.Any: ...
417458

418459
def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any:
460+
"""
461+
Same as calling D.get(k, d), and setting D[k]=d if k not found
462+
:param str key: The key to look up.
463+
:param any default: The value to set if key is not in the dictionary
464+
:returns: D[k] if k in D, else d.
465+
:rtype: any
466+
"""
419467
if default is _UNSET:
420468
return self._data.setdefault(key)
421469
return self._data.setdefault(key, default)
@@ -573,7 +621,7 @@ def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None:
573621
def copy(self) -> "Model":
574622
return Model(self.__dict__)
575623

576-
def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: disable=unused-argument
624+
def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self:
577625
if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated:
578626
# we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping',
579627
# 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object'
@@ -584,8 +632,8 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: di
584632
annotations = {
585633
k: v
586634
for mro_class in mros
587-
if hasattr(mro_class, "__annotations__") # pylint: disable=no-member
588-
for k, v in mro_class.__annotations__.items() # pylint: disable=no-member
635+
if hasattr(mro_class, "__annotations__")
636+
for k, v in mro_class.__annotations__.items()
589637
}
590638
for attr, rf in attr_to_rest_field.items():
591639
rf._module = cls.__module__
@@ -600,8 +648,8 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: di
600648

601649
def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None:
602650
for base in cls.__bases__:
603-
if hasattr(base, "__mapping__"): # pylint: disable=no-member
604-
base.__mapping__[discriminator or cls.__name__] = cls # type: ignore # pylint: disable=no-member
651+
if hasattr(base, "__mapping__"):
652+
base.__mapping__[discriminator or cls.__name__] = cls # type: ignore
605653

606654
@classmethod
607655
def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]:
@@ -612,7 +660,7 @@ def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField
612660

613661
@classmethod
614662
def _deserialize(cls, data, exist_discriminators):
615-
if not hasattr(cls, "__mapping__"): # pylint: disable=no-member
663+
if not hasattr(cls, "__mapping__"):
616664
return cls(data)
617665
discriminator = cls._get_discriminator(exist_discriminators)
618666
if discriminator is None:
@@ -632,11 +680,11 @@ def _deserialize(cls, data, exist_discriminators):
632680
discriminator_value = data.find(xml_name).text # pyright: ignore
633681
else:
634682
discriminator_value = data.get(discriminator._rest_name)
635-
mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore # pylint: disable=no-member
683+
mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore
636684
return mapped_cls._deserialize(data, exist_discriminators)
637685

638686
def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing.Any]:
639-
"""Return a dict that can be JSONify using json.dump.
687+
"""Return a dict that can be turned into json using json.dump.
640688
641689
:keyword bool exclude_readonly: Whether to remove the readonly properties.
642690
:returns: A dict JSON compatible object
@@ -733,7 +781,7 @@ def _sorted_annotations(types: typing.List[typing.Any]) -> typing.List[typing.An
733781
)
734782

735783

736-
def _get_deserialize_callable_from_annotation( # pylint: disable=R0911, R0915, R0912
784+
def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-branches
737785
annotation: typing.Any,
738786
module: typing.Optional[str],
739787
rf: typing.Optional["_RestField"] = None,
@@ -753,7 +801,7 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=R0911, R0915,
753801
except AttributeError:
754802
model_name = annotation
755803
if module is not None:
756-
annotation = _get_model(module, model_name)
804+
annotation = _get_model(module, model_name) # type: ignore
757805

758806
try:
759807
if module and _is_model(annotation):
@@ -893,6 +941,35 @@ def _deserialize(
893941
return _deserialize_with_callable(deserializer, value)
894942

895943

944+
def _failsafe_deserialize(
945+
deserializer: typing.Any,
946+
value: typing.Any,
947+
module: typing.Optional[str] = None,
948+
rf: typing.Optional["_RestField"] = None,
949+
format: typing.Optional[str] = None,
950+
) -> typing.Any:
951+
try:
952+
return _deserialize(deserializer, value, module, rf, format)
953+
except DeserializationError:
954+
_LOGGER.warning(
955+
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
956+
)
957+
return None
958+
959+
960+
def _failsafe_deserialize_xml(
961+
deserializer: typing.Any,
962+
value: typing.Any,
963+
) -> typing.Any:
964+
try:
965+
return _deserialize_xml(deserializer, value)
966+
except DeserializationError:
967+
_LOGGER.warning(
968+
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
969+
)
970+
return None
971+
972+
896973
class _RestField:
897974
def __init__(
898975
self,

0 commit comments

Comments
 (0)