Skip to content

Commit

Permalink
Add support for more media message types: Video, Document and Audio (A…
Browse files Browse the repository at this point in the history
…zure#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
  • Loading branch information
Shamkh authored Oct 18, 2024
1 parent 41eb652 commit 6a687e3
Show file tree
Hide file tree
Showing 52 changed files with 1,844 additions and 1,653 deletions.
15 changes: 7 additions & 8 deletions sdk/communication/azure-communication-messages/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# Release History

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

### Features Added

### Breaking Changes

### Bugs Fixed

### Other Changes
- Using `NotificationMessagesClient`
- Send Video messages
- Send Audio messages
- Send Document messages

## 1.0.0 (2024-03-25)

Expand All @@ -18,7 +17,7 @@ This is the GA release of Azure Communication Messages Python SDK. For more info
- Using `NotificationMessagesClient`
- Send Text messages
- Send Template messages
- Send Media messages
- Send Image messages
- Using `MessageTemplateClient`
- Get list of all WhatsApp templates.

Expand Down
2 changes: 1 addition & 1 deletion sdk/communication/azure-communication-messages/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-messages",
"Tag": "python/communication/azure-communication-messages_22ab5a97f3"
"Tag": "python/communication/azure-communication-messages_302bf9560e"
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
except ImportError:
_patch_all = []
from ._patch import patch_sdk as _patch_sdk

__all__ = [
'NotificationMessagesClient',
'MessageTemplateClient',
"NotificationMessagesClient",
"MessageTemplateClient",
]
__all__.extend([p for p in _patch_all if p not in __all__])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
class ApiVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta):
V2023_08_24_PREVIEW = "2023-08-24-preview"
V2024_02_01 = "2024-02-01"
V2024_08_30 = "2024-08-30"


DEFAULT_VERSION = ApiVersion.V2024_02_01.value
DEFAULT_VERSION = ApiVersion.V2024_08_30.value
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from copy import deepcopy
from typing import Any, TYPE_CHECKING, Union
from typing_extensions import Self

from azure.core import PipelineClient
from azure.core.credentials import AzureKeyCredential
Expand All @@ -22,53 +23,51 @@
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials import TokenCredential

class NotificationMessagesClient(NotificationMessagesClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword

class NotificationMessagesClient(
NotificationMessagesClientOperationsMixin
): # pylint: disable=client-accepts-api-version-keyword
"""NotificationMessagesClient.
:param endpoint: The communication resource, for example
https://my-resource.communication.azure.com. Required.
:type endpoint: str
:param credential: Credential needed for the client to connect to Azure. Is either a
:param credential: Credential used to authenticate requests to the service. Is either a
TokenCredential type or a AzureKeyCredential type. Required.
:type credential: ~azure.core.credentials.TokenCredential or
~azure.core.credentials.AzureKeyCredential
:keyword api_version: The API version to use for this operation. Default value is "2024-02-01".
:keyword api_version: The API version to use for this operation. Default value is "2024-08-30".
Note that overriding this default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(
self,
endpoint: str,
credential: Union["TokenCredential", AzureKeyCredential],
**kwargs: Any
) -> None:
_endpoint = '{endpoint}'
def __init__(self, endpoint: str, credential: Union["TokenCredential", AzureKeyCredential], **kwargs: Any) -> None:
_endpoint = "{endpoint}"
self._config = NotificationMessagesClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
_policies = kwargs.pop('policies', None)
_policies = kwargs.pop("policies", None)
if _policies is None:
_policies = [policies.RequestIdPolicy(**kwargs),self._config.headers_policy,
self._config.user_agent_policy,self._config.proxy_policy,
policies.ContentDecodePolicy(**kwargs),
self._config.redirect_policy,self._config.retry_policy,
self._config.authentication_policy,
self._config.custom_hook_policy,self._config.logging_policy,
policies.DistributedTracingPolicy(**kwargs),
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
self._config.http_logging_policy]
_policies = [
policies.RequestIdPolicy(**kwargs),
self._config.headers_policy,
self._config.user_agent_policy,
self._config.proxy_policy,
policies.ContentDecodePolicy(**kwargs),
self._config.redirect_policy,
self._config.retry_policy,
self._config.authentication_policy,
self._config.custom_hook_policy,
self._config.logging_policy,
policies.DistributedTracingPolicy(**kwargs),
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
self._config.http_logging_policy,
]
self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs)


self._serialize = Serializer()
self._deserialize = Deserializer()
self._serialize.client_side_validation = False


def send_request(
self,
request: HttpRequest, *, stream: bool = False,
**kwargs: Any
) -> HttpResponse:
def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
"""Runs the network request through the client's chained policies.
>>> from azure.core.rest import HttpRequest
Expand All @@ -88,7 +87,7 @@ def send_request(

request_copy = deepcopy(request)
path_format_arguments = {
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
}

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

def __enter__(self) -> "NotificationMessagesClient":
def __enter__(self) -> Self:
self._client.__enter__()
return self

def __exit__(self, *exc_details: Any) -> None:
self._client.__exit__(*exc_details)


class MessageTemplateClient(MessageTemplateClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword
"""MessageTemplateClient.
:param endpoint: The communication resource, for example
https://my-resource.communication.azure.com. Required.
:type endpoint: str
:param credential: Credential needed for the client to connect to Azure. Is either a
:param credential: Credential used to authenticate requests to the service. Is either a
TokenCredential type or a AzureKeyCredential type. Required.
:type credential: ~azure.core.credentials.TokenCredential or
~azure.core.credentials.AzureKeyCredential
:keyword api_version: The API version to use for this operation. Default value is "2024-02-01".
:keyword api_version: The API version to use for this operation. Default value is "2024-08-30".
Note that overriding this default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(
self,
endpoint: str,
credential: Union["TokenCredential", AzureKeyCredential],
**kwargs: Any
) -> None:
_endpoint = '{endpoint}'
def __init__(self, endpoint: str, credential: Union["TokenCredential", AzureKeyCredential], **kwargs: Any) -> None:
_endpoint = "{endpoint}"
self._config = MessageTemplateClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
_policies = kwargs.pop('policies', None)
_policies = kwargs.pop("policies", None)
if _policies is None:
_policies = [policies.RequestIdPolicy(**kwargs),self._config.headers_policy,self._config.user_agent_policy,
self._config.proxy_policy,policies.ContentDecodePolicy(**kwargs),self._config.redirect_policy,
self._config.retry_policy,self._config.authentication_policy,self._config.custom_hook_policy,
self._config.logging_policy,policies.DistributedTracingPolicy(**kwargs),
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
self._config.http_logging_policy]
_policies = [
policies.RequestIdPolicy(**kwargs),
self._config.headers_policy,
self._config.user_agent_policy,
self._config.proxy_policy,
policies.ContentDecodePolicy(**kwargs),
self._config.redirect_policy,
self._config.retry_policy,
self._config.authentication_policy,
self._config.custom_hook_policy,
self._config.logging_policy,
policies.DistributedTracingPolicy(**kwargs),
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
self._config.http_logging_policy,
]
self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs)


self._serialize = Serializer()
self._deserialize = Deserializer()
self._serialize.client_side_validation = False


def send_request(
self,
request: HttpRequest, *, stream: bool = False,
**kwargs: Any
) -> HttpResponse:
def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
"""Runs the network request through the client's chained policies.
>>> from azure.core.rest import HttpRequest
Expand All @@ -166,7 +165,7 @@ def send_request(

request_copy = deepcopy(request)
path_format_arguments = {
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
}

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

def __enter__(self) -> "MessageTemplateClient":
def __enter__(self) -> Self:
self._client.__enter__()
return self

Expand Down
Loading

0 comments on commit 6a687e3

Please sign in to comment.