Skip to content

Commit 02b6692

Browse files
author
SDKAuto
committed
CodeGen from PR 32939 in Azure/azure-rest-api-specs
Merge 78d83f28834f55232952867d8d2cb80fdc3b17a3 into 0247110f15f6558fa2eeaff18a0515e883ed6517
1 parent 08e7c8a commit 02b6692

Some content is hidden

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

52 files changed

+633
-1615
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"commit": "03c105f96d40a33dd7196727818297057ec643ae",
3+
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
4+
"typespec_src": "specification/communication/Communication.Messages",
5+
"@azure-tools/typespec-python": "0.39.0"
6+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"CrossLanguagePackageId": "Azure.Communication.MessagesService",
3+
"CrossLanguageDefinitionId": {
4+
"azure.communication.messages.models.ActionBindings": "Azure.Communication.MessagesService.ActionBindings",
5+
"azure.communication.messages.models.ActionGroup": "Azure.Communication.MessagesService.ActionGroup",
6+
"azure.communication.messages.models.MessageContent": "Azure.Communication.MessagesService.MessageContent",
7+
"azure.communication.messages.models.ActionGroupContent": "Azure.Communication.MessagesService.ActionGroupContent",
8+
"azure.communication.messages.models.ActionGroupItem": "Azure.Communication.MessagesService.ActionGroupItem",
9+
"azure.communication.messages.models.NotificationContent": "Azure.Communication.MessagesService.NotificationContent",
10+
"azure.communication.messages.models.AudioNotificationContent": "Azure.Communication.MessagesService.AudioNotificationContent",
11+
"azure.communication.messages.models.ButtonContent": "Azure.Communication.MessagesService.ButtonContent",
12+
"azure.communication.messages.models.ButtonSetContent": "Azure.Communication.MessagesService.ButtonSetContent",
13+
"azure.communication.messages.models.DocumentMessageContent": "Azure.Communication.MessagesService.DocumentMessageContent",
14+
"azure.communication.messages.models.DocumentNotificationContent": "Azure.Communication.MessagesService.DocumentNotificationContent",
15+
"azure.communication.messages.models.ImageMessageContent": "Azure.Communication.MessagesService.ImageMessageContent",
16+
"azure.communication.messages.models.ImageNotificationContent": "Azure.Communication.MessagesService.ImageNotificationContent",
17+
"azure.communication.messages.models.InteractiveMessage": "Azure.Communication.MessagesService.InteractiveMessage",
18+
"azure.communication.messages.models.InteractiveNotificationContent": "Azure.Communication.MessagesService.InteractiveNotificationContent",
19+
"azure.communication.messages.models.LinkContent": "Azure.Communication.MessagesService.LinkContent",
20+
"azure.communication.messages.models.MediaNotificationContent": "Azure.Communication.MessagesService.MediaNotificationContent",
21+
"azure.communication.messages.models.MessageReceipt": "Azure.Communication.MessagesService.MessageReceipt",
22+
"azure.communication.messages.models.MessageTemplate": "Azure.Communication.MessagesService.MessageTemplate",
23+
"azure.communication.messages.models.MessageTemplateBindings": "Azure.Communication.MessagesService.MessageTemplateBindings",
24+
"azure.communication.messages.models.MessageTemplateValue": "Azure.Communication.MessagesService.MessageTemplateValue",
25+
"azure.communication.messages.models.MessageTemplateDocument": "Azure.Communication.MessagesService.MessageTemplateDocument",
26+
"azure.communication.messages.models.MessageTemplateImage": "Azure.Communication.MessagesService.MessageTemplateImage",
27+
"azure.communication.messages.models.MessageTemplateItem": "Azure.Communication.MessagesService.MessageTemplateItem",
28+
"azure.communication.messages.models.MessageTemplateLocation": "Azure.Communication.MessagesService.MessageTemplateLocation",
29+
"azure.communication.messages.models.MessageTemplateQuickAction": "Azure.Communication.MessagesService.MessageTemplateQuickAction",
30+
"azure.communication.messages.models.MessageTemplateText": "Azure.Communication.MessagesService.MessageTemplateText",
31+
"azure.communication.messages.models.MessageTemplateVideo": "Azure.Communication.MessagesService.MessageTemplateVideo",
32+
"azure.communication.messages.models.ReactionNotificationContent": "Azure.Communication.MessagesService.ReactionNotificationContent",
33+
"azure.communication.messages.models.SendMessageResult": "Azure.Communication.MessagesService.SendMessageResult",
34+
"azure.communication.messages.models.StickerNotificationContent": "Azure.Communication.MessagesService.StickerNotificationContent",
35+
"azure.communication.messages.models.TemplateNotificationContent": "Azure.Communication.MessagesService.TemplateNotificationContent",
36+
"azure.communication.messages.models.TextMessageContent": "Azure.Communication.MessagesService.TextMessageContent",
37+
"azure.communication.messages.models.TextNotificationContent": "Azure.Communication.MessagesService.TextNotificationContent",
38+
"azure.communication.messages.models.VideoMessageContent": "Azure.Communication.MessagesService.VideoMessageContent",
39+
"azure.communication.messages.models.VideoNotificationContent": "Azure.Communication.MessagesService.VideoNotificationContent",
40+
"azure.communication.messages.models.WhatsAppButtonActionBindings": "Azure.Communication.MessagesService.WhatsAppButtonActionBindings",
41+
"azure.communication.messages.models.WhatsAppListActionBindings": "Azure.Communication.MessagesService.WhatsAppListActionBindings",
42+
"azure.communication.messages.models.WhatsAppMessageTemplateBindings": "Azure.Communication.MessagesService.WhatsAppMessageTemplateBindings",
43+
"azure.communication.messages.models.WhatsAppMessageTemplateBindingsButton": "Azure.Communication.MessagesService.WhatsAppMessageTemplateBindingsButton",
44+
"azure.communication.messages.models.WhatsAppMessageTemplateBindingsComponent": "Azure.Communication.MessagesService.WhatsAppMessageTemplateBindingsComponent",
45+
"azure.communication.messages.models.WhatsAppMessageTemplateItem": "Azure.Communication.MessagesService.WhatsAppMessageTemplateItem",
46+
"azure.communication.messages.models.WhatsAppUrlActionBindings": "Azure.Communication.MessagesService.WhatsAppUrlActionBindings",
47+
"azure.communication.messages.models.RepeatabilityResult": "Azure.Core.RepeatabilityResult",
48+
"azure.communication.messages.models.CommunicationMessageKind": "Azure.Communication.MessagesService.CommunicationMessageKind",
49+
"azure.communication.messages.models.MessageContentKind": "Azure.Communication.MessagesService.MessageContentKind",
50+
"azure.communication.messages.models.MessageActionBindingKind": "Azure.Communication.MessagesService.MessageActionBindingKind",
51+
"azure.communication.messages.models.MessageTemplateValueKind": "Azure.Communication.MessagesService.MessageTemplateValueKind",
52+
"azure.communication.messages.models.MessageTemplateBindingsKind": "Azure.Communication.MessagesService.MessageTemplateBindingsKind",
53+
"azure.communication.messages.models.WhatsAppMessageButtonSubType": "Azure.Communication.MessagesService.WhatsAppMessageButtonSubType",
54+
"azure.communication.messages.models.MessageTemplateStatus": "Azure.Communication.MessagesService.MessageTemplateStatus",
55+
"azure.communication.messages.models.CommunicationMessagesChannel": "Azure.Communication.MessagesService.CommunicationMessagesChannel",
56+
"azure.communication.messages.NotificationMessagesClient.send": "Azure.Communication.MessagesService.NotificationMessagesClient.send",
57+
"azure.communication.messages.NotificationMessagesClient.download_media": "ClientForAcsMessages.NotificationMessagesClient.downloadMedia",
58+
"azure.communication.messages.MessageTemplateClient.list_templates": "Azure.Communication.MessagesService.MessageTemplateClient.listTemplates"
59+
}
60+
}

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

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class NotificationMessagesClient(NotificationMessagesClientOperationsMixin):
3030
https://my-resource.communication.azure.com. Required.
3131
:type endpoint: str
3232
:param credential: Credential used to authenticate requests to the service. Is either a token
33-
credential type or a AzureKeyCredential type. Required.
33+
credential type or a key credential type. Required.
3434
:type credential: ~azure.core.credentials.TokenCredential or
3535
~azure.core.credentials.AzureKeyCredential
3636
:keyword api_version: The API version to use for this operation. Default value is
@@ -109,7 +109,7 @@ class MessageTemplateClient(MessageTemplateClientOperationsMixin):
109109
https://my-resource.communication.azure.com. Required.
110110
:type endpoint: str
111111
:param credential: Credential used to authenticate requests to the service. Is either a token
112-
credential type or a AzureKeyCredential type. Required.
112+
credential type or a key credential type. Required.
113113
:type credential: ~azure.core.credentials.TokenCredential or
114114
~azure.core.credentials.AzureKeyCredential
115115
:keyword api_version: The API version to use for this operation. Default value is

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class NotificationMessagesClientConfiguration: # pylint: disable=too-many-insta
2727
https://my-resource.communication.azure.com. Required.
2828
:type endpoint: str
2929
:param credential: Credential used to authenticate requests to the service. Is either a token
30-
credential type or a AzureKeyCredential type. Required.
30+
credential type or a key credential type. Required.
3131
:type credential: ~azure.core.credentials.TokenCredential or
3232
~azure.core.credentials.AzureKeyCredential
3333
:keyword api_version: The API version to use for this operation. Default value is
@@ -83,7 +83,7 @@ class MessageTemplateClientConfiguration: # pylint: disable=too-many-instance-a
8383
https://my-resource.communication.azure.com. Required.
8484
:type endpoint: str
8585
:param credential: Credential used to authenticate requests to the service. Is either a token
86-
credential type or a AzureKeyCredential type. Required.
86+
credential type or a key credential type. Required.
8787
:type credential: ~azure.core.credentials.TokenCredential or
8888
~azure.core.credentials.AzureKeyCredential
8989
:keyword api_version: The API version to use for this operation. Default value is

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

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,15 +373,34 @@ def __ne__(self, other: typing.Any) -> bool:
373373
return not self.__eq__(other)
374374

375375
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+
"""
376380
return self._data.keys()
377381

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

381389
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+
"""
382394
return self._data.items()
383395

384396
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+
"""
385404
try:
386405
return self[key]
387406
except KeyError:
@@ -397,17 +416,38 @@ def pop(self, key: str, default: _T) -> _T: ...
397416
def pop(self, key: str, default: typing.Any) -> typing.Any: ...
398417

399418
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+
"""
400427
if default is _UNSET:
401428
return self._data.pop(key)
402429
return self._data.pop(key, default)
403430

404431
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+
"""
405438
return self._data.popitem()
406439

407440
def clear(self) -> None:
441+
"""
442+
Remove all items from D.
443+
"""
408444
self._data.clear()
409445

410446
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+
"""
411451
self._data.update(*args, **kwargs)
412452

413453
@typing.overload
@@ -417,6 +457,13 @@ def setdefault(self, key: str, default: None = None) -> None: ...
417457
def setdefault(self, key: str, default: typing.Any) -> typing.Any: ...
418458

419459
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+
"""
420467
if default is _UNSET:
421468
return self._data.setdefault(key)
422469
return self._data.setdefault(key, default)
@@ -910,6 +957,19 @@ def _failsafe_deserialize(
910957
return None
911958

912959

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+
913973
class _RestField:
914974
def __init__(
915975
self,

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

Lines changed: 2 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -6,132 +6,9 @@
66
77
Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize
88
"""
9-
from typing import List, Any, Union
10-
from urllib.parse import urlparse
11-
from azure.core.credentials import TokenCredential, AzureKeyCredential
12-
from ._shared.utils import parse_connection_str
13-
from ._client import (
14-
NotificationMessagesClient as NotificationMessagesClientGenerated,
15-
MessageTemplateClient as MessageTemplateClientGenerated,
16-
)
17-
from ._shared.auth_policy_utils import get_authentication_policy
18-
from ._api_versions import DEFAULT_VERSION
9+
from typing import List
1910

20-
21-
class NotificationMessagesClient(NotificationMessagesClientGenerated):
22-
"""A client to interact with the AzureCommunicationService Messaging service.
23-
24-
This client provides operations to create and update jobs, policies and workers.
25-
26-
:param str endpoint:
27-
The endpoint of the Azure Communication resource.
28-
:param Union[TokenCredential, AsyncTokenCredential] credential:
29-
The credentials with which to authenticate
30-
31-
:keyword api_version: Azure Communication Messaging API version.
32-
Default value is "2023-11-01".
33-
Note that overriding this default value may result in unsupported behavior.
34-
"""
35-
36-
def __init__(self, endpoint: str, credential: Union[TokenCredential, AzureKeyCredential], **kwargs: Any) -> None:
37-
if not credential:
38-
raise ValueError("credential can not be None")
39-
40-
try:
41-
if not endpoint.lower().startswith("http"):
42-
endpoint = "https://" + endpoint
43-
except AttributeError:
44-
raise ValueError("Host URL must be a string") # pylint:disable=raise-missing-from
45-
46-
parsed_url = urlparse(endpoint.rstrip("/"))
47-
if not parsed_url.netloc:
48-
raise ValueError("Invalid URL: {}".format(endpoint))
49-
50-
self._endpoint = endpoint
51-
self._api_version = kwargs.pop("api_version", DEFAULT_VERSION)
52-
self._authentication_policy = get_authentication_policy(endpoint, credential)
53-
self._credential = credential
54-
super().__init__(
55-
self._endpoint,
56-
self._credential,
57-
authentication_policy=self._authentication_policy,
58-
api_version=self._api_version,
59-
**kwargs
60-
)
61-
62-
@classmethod
63-
def from_connection_string(cls, conn_str: str, **kwargs: Any) -> "NotificationMessagesClient":
64-
"""Create NotificationMessagesClient from a Connection String.
65-
66-
:param conn_str: Azure communication service connection string. Required.
67-
:type conn_str: str
68-
:return: instance of NotificationMessagesClient
69-
:rtype:
70-
~azure.communication.messages.NotificationMessagesClient
71-
"""
72-
endpoint, access_key = parse_connection_str(conn_str)
73-
return cls(endpoint, AzureKeyCredential(access_key), **kwargs)
74-
75-
76-
class MessageTemplateClient(MessageTemplateClientGenerated):
77-
"""A client to interact with the AzureCommunicationService Messaging service.
78-
79-
This client provides Advanced Messaging.
80-
81-
:param str endpoint:
82-
The endpoint of the Azure Communication resource.
83-
:param Union[TokenCredential, AsyncTokenCredential] credential:
84-
The credentials with which to authenticate
85-
86-
:keyword api_version: Azure Communication Messages API version. Default value is "2024-02-01".
87-
Note that overriding this default value may result in unsupported behavior.
88-
:paramtype api_version: str
89-
"""
90-
91-
def __init__(self, endpoint: str, credential: Union[TokenCredential, AzureKeyCredential], **kwargs: Any) -> "None":
92-
if not credential:
93-
raise ValueError("credential can not be None")
94-
95-
try:
96-
if not endpoint.lower().startswith("http"):
97-
endpoint = "https://" + endpoint
98-
except AttributeError:
99-
raise ValueError("Host URL must be a string") # pylint: disable=raise-missing-from
100-
101-
parsed_url = urlparse(endpoint.rstrip("/"))
102-
if not parsed_url.netloc:
103-
raise ValueError("Invalid URL: {}".format(endpoint))
104-
105-
self._endpoint = endpoint
106-
self._api_version = kwargs.pop("api_version", DEFAULT_VERSION)
107-
self._authentication_policy = get_authentication_policy(endpoint, credential)
108-
self._credential = credential
109-
super().__init__(
110-
self._endpoint,
111-
self._credential,
112-
authentication_policy=self._authentication_policy,
113-
api_version=self._api_version,
114-
**kwargs
115-
)
116-
117-
@classmethod
118-
def from_connection_string(cls, conn_str: str, **kwargs: Any) -> "MessageTemplateClient":
119-
"""Create MessageTemplateClient from a Connection String.
120-
121-
:param conn_str: Azure communication service connection string. Required.
122-
:type conn_str: str
123-
:return: instance of MessageTemplateClient
124-
:rtype:
125-
~azure.communication.messages.MessageTemplateClient
126-
"""
127-
endpoint, access_key = parse_connection_str(conn_str)
128-
return cls(endpoint, AzureKeyCredential(access_key), **kwargs)
129-
130-
131-
__all__: List[str] = [
132-
"NotificationMessagesClient",
133-
"MessageTemplateClient",
134-
] # Add all objects you want publicly available to users at this package level
11+
__all__: List[str] = [] # Add all objects you want publicly available to users at this package level
13512

13613

13714
def patch_sdk():

0 commit comments

Comments
 (0)