Skip to content

Commit 6a687e3

Browse files
authored
Add support for more media message types: Video, Document and Audio (Azure#37690)
* updating w.r.t. new api chnages * updating change log * fixing Whats_App kind issue * test fixes * adding new sample * update asset tag * updated w.r.t. to latest API spec * remove MediaContent * updating tests * fixing build * release date update * release date update * release date update * release date update * updated samples * update version * updating latest rest commit
1 parent 41eb652 commit 6a687e3

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

+1844
-1653
lines changed

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
# Release History
22

3-
## 1.0.1 (Unreleased)
3+
## 1.1.0 (2024-10-25)
4+
This is feature addition release.
45

56
### Features Added
6-
7-
### Breaking Changes
8-
9-
### Bugs Fixed
10-
11-
### Other Changes
7+
- Using `NotificationMessagesClient`
8+
- Send Video messages
9+
- Send Audio messages
10+
- Send Document messages
1211

1312
## 1.0.0 (2024-03-25)
1413

@@ -18,7 +17,7 @@ This is the GA release of Azure Communication Messages Python SDK. For more info
1817
- Using `NotificationMessagesClient`
1918
- Send Text messages
2019
- Send Template messages
21-
- Send Media messages
20+
- Send Image messages
2221
- Using `MessageTemplateClient`
2322
- Get list of all WhatsApp templates.
2423

sdk/communication/azure-communication-messages/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-messages",
5-
"Tag": "python/communication/azure-communication-messages_22ab5a97f3"
5+
"Tag": "python/communication/azure-communication-messages_302bf9560e"
66
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
1+
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
1+
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
except ImportError:
1919
_patch_all = []
2020
from ._patch import patch_sdk as _patch_sdk
21+
2122
__all__ = [
22-
'NotificationMessagesClient',
23-
'MessageTemplateClient',
23+
"NotificationMessagesClient",
24+
"MessageTemplateClient",
2425
]
2526
__all__.extend([p for p in _patch_all if p not in __all__])
2627

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
class ApiVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta):
1111
V2023_08_24_PREVIEW = "2023-08-24-preview"
1212
V2024_02_01 = "2024-02-01"
13+
V2024_08_30 = "2024-08-30"
1314

1415

15-
DEFAULT_VERSION = ApiVersion.V2024_02_01.value
16+
DEFAULT_VERSION = ApiVersion.V2024_08_30.value

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

Lines changed: 53 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from copy import deepcopy
1010
from typing import Any, TYPE_CHECKING, Union
11+
from typing_extensions import Self
1112

1213
from azure.core import PipelineClient
1314
from azure.core.credentials import AzureKeyCredential
@@ -22,53 +23,51 @@
2223
# pylint: disable=unused-import,ungrouped-imports
2324
from azure.core.credentials import TokenCredential
2425

25-
class NotificationMessagesClient(NotificationMessagesClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword
26+
27+
class NotificationMessagesClient(
28+
NotificationMessagesClientOperationsMixin
29+
): # pylint: disable=client-accepts-api-version-keyword
2630
"""NotificationMessagesClient.
2731
2832
:param endpoint: The communication resource, for example
2933
https://my-resource.communication.azure.com. Required.
3034
:type endpoint: str
31-
:param credential: Credential needed for the client to connect to Azure. Is either a
35+
:param credential: Credential used to authenticate requests to the service. Is either a
3236
TokenCredential type or a AzureKeyCredential type. Required.
3337
:type credential: ~azure.core.credentials.TokenCredential or
3438
~azure.core.credentials.AzureKeyCredential
35-
:keyword api_version: The API version to use for this operation. Default value is "2024-02-01".
39+
:keyword api_version: The API version to use for this operation. Default value is "2024-08-30".
3640
Note that overriding this default value may result in unsupported behavior.
3741
:paramtype api_version: str
3842
"""
3943

40-
def __init__(
41-
self,
42-
endpoint: str,
43-
credential: Union["TokenCredential", AzureKeyCredential],
44-
**kwargs: Any
45-
) -> None:
46-
_endpoint = '{endpoint}'
44+
def __init__(self, endpoint: str, credential: Union["TokenCredential", AzureKeyCredential], **kwargs: Any) -> None:
45+
_endpoint = "{endpoint}"
4746
self._config = NotificationMessagesClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
48-
_policies = kwargs.pop('policies', None)
47+
_policies = kwargs.pop("policies", None)
4948
if _policies is None:
50-
_policies = [policies.RequestIdPolicy(**kwargs),self._config.headers_policy,
51-
self._config.user_agent_policy,self._config.proxy_policy,
52-
policies.ContentDecodePolicy(**kwargs),
53-
self._config.redirect_policy,self._config.retry_policy,
54-
self._config.authentication_policy,
55-
self._config.custom_hook_policy,self._config.logging_policy,
56-
policies.DistributedTracingPolicy(**kwargs),
57-
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
58-
self._config.http_logging_policy]
49+
_policies = [
50+
policies.RequestIdPolicy(**kwargs),
51+
self._config.headers_policy,
52+
self._config.user_agent_policy,
53+
self._config.proxy_policy,
54+
policies.ContentDecodePolicy(**kwargs),
55+
self._config.redirect_policy,
56+
self._config.retry_policy,
57+
self._config.authentication_policy,
58+
self._config.custom_hook_policy,
59+
self._config.logging_policy,
60+
policies.DistributedTracingPolicy(**kwargs),
61+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
62+
self._config.http_logging_policy,
63+
]
5964
self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs)
6065

61-
6266
self._serialize = Serializer()
6367
self._deserialize = Deserializer()
6468
self._serialize.client_side_validation = False
6569

66-
67-
def send_request(
68-
self,
69-
request: HttpRequest, *, stream: bool = False,
70-
**kwargs: Any
71-
) -> HttpResponse:
70+
def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
7271
"""Runs the network request through the client's chained policies.
7372
7473
>>> from azure.core.rest import HttpRequest
@@ -88,7 +87,7 @@ def send_request(
8887

8988
request_copy = deepcopy(request)
9089
path_format_arguments = {
91-
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
90+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
9291
}
9392

9493
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
@@ -97,56 +96,56 @@ def send_request(
9796
def close(self) -> None:
9897
self._client.close()
9998

100-
def __enter__(self) -> "NotificationMessagesClient":
99+
def __enter__(self) -> Self:
101100
self._client.__enter__()
102101
return self
103102

104103
def __exit__(self, *exc_details: Any) -> None:
105104
self._client.__exit__(*exc_details)
105+
106+
106107
class MessageTemplateClient(MessageTemplateClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword
107108
"""MessageTemplateClient.
108109
109110
:param endpoint: The communication resource, for example
110111
https://my-resource.communication.azure.com. Required.
111112
:type endpoint: str
112-
:param credential: Credential needed for the client to connect to Azure. Is either a
113+
:param credential: Credential used to authenticate requests to the service. Is either a
113114
TokenCredential type or a AzureKeyCredential type. Required.
114115
:type credential: ~azure.core.credentials.TokenCredential or
115116
~azure.core.credentials.AzureKeyCredential
116-
:keyword api_version: The API version to use for this operation. Default value is "2024-02-01".
117+
:keyword api_version: The API version to use for this operation. Default value is "2024-08-30".
117118
Note that overriding this default value may result in unsupported behavior.
118119
:paramtype api_version: str
119120
"""
120121

121-
def __init__(
122-
self,
123-
endpoint: str,
124-
credential: Union["TokenCredential", AzureKeyCredential],
125-
**kwargs: Any
126-
) -> None:
127-
_endpoint = '{endpoint}'
122+
def __init__(self, endpoint: str, credential: Union["TokenCredential", AzureKeyCredential], **kwargs: Any) -> None:
123+
_endpoint = "{endpoint}"
128124
self._config = MessageTemplateClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
129-
_policies = kwargs.pop('policies', None)
125+
_policies = kwargs.pop("policies", None)
130126
if _policies is None:
131-
_policies = [policies.RequestIdPolicy(**kwargs),self._config.headers_policy,self._config.user_agent_policy,
132-
self._config.proxy_policy,policies.ContentDecodePolicy(**kwargs),self._config.redirect_policy,
133-
self._config.retry_policy,self._config.authentication_policy,self._config.custom_hook_policy,
134-
self._config.logging_policy,policies.DistributedTracingPolicy(**kwargs),
135-
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
136-
self._config.http_logging_policy]
127+
_policies = [
128+
policies.RequestIdPolicy(**kwargs),
129+
self._config.headers_policy,
130+
self._config.user_agent_policy,
131+
self._config.proxy_policy,
132+
policies.ContentDecodePolicy(**kwargs),
133+
self._config.redirect_policy,
134+
self._config.retry_policy,
135+
self._config.authentication_policy,
136+
self._config.custom_hook_policy,
137+
self._config.logging_policy,
138+
policies.DistributedTracingPolicy(**kwargs),
139+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
140+
self._config.http_logging_policy,
141+
]
137142
self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs)
138143

139-
140144
self._serialize = Serializer()
141145
self._deserialize = Deserializer()
142146
self._serialize.client_side_validation = False
143147

144-
145-
def send_request(
146-
self,
147-
request: HttpRequest, *, stream: bool = False,
148-
**kwargs: Any
149-
) -> HttpResponse:
148+
def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
150149
"""Runs the network request through the client's chained policies.
151150
152151
>>> from azure.core.rest import HttpRequest
@@ -166,7 +165,7 @@ def send_request(
166165

167166
request_copy = deepcopy(request)
168167
path_format_arguments = {
169-
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
168+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
170169
}
171170

172171
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
@@ -175,7 +174,7 @@ def send_request(
175174
def close(self) -> None:
176175
self._client.close()
177176

178-
def __enter__(self) -> "MessageTemplateClient":
177+
def __enter__(self) -> Self:
179178
self._client.__enter__()
180179
return self
181180

0 commit comments

Comments
 (0)