-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Python SDK : Communication messages (#33946)
* messaging python SDK * reverting kind change * add new rest api commimt changes * adding samples * adding samples * latest rest api changes merge * review comments * build failures * build failures * build failures * Adding AAD auth * adding asset.json * readme update * plint issues fix * changelog update * plint issues fix * buildfix * test fix * revert job router change * test fix. * testfix * test fix * test fix * review comments * samples for Image messages * adding to code owners * review comments * adding iteratable bytes to download media * lint issues * lint issues * review comments * tsp commit update * Update sdk/communication/azure-communication-messages/samples/send_text_notification_messages_async.py Co-authored-by: Anna Tisch <[email protected]> * Update sdk/communication/azure-communication-messages/samples/send_text_notification_messages_async.py Co-authored-by: Anna Tisch <[email protected]> * Update sdk/communication/azure-communication-messages/samples/send_text_notification_messages_async.py Co-authored-by: Anna Tisch <[email protected]> * Update sdk/communication/azure-communication-messages/samples/send_text_notification_messages.py Co-authored-by: Anna Tisch <[email protected]> * review comments * Update sdk/communication/azure-communication-messages/samples/send_text_notification_messages.py Co-authored-by: Anna Tisch <[email protected]> * Update sdk/communication/azure-communication-messages/samples/send_image_notification_messages.py Co-authored-by: Anna Tisch <[email protected]> * Update sdk/communication/azure-communication-messages/README.md Co-authored-by: Anna Tisch <[email protected]> * Update sdk/communication/azure-communication-messages/samples/send_image_notification_messages.py Co-authored-by: Anna Tisch <[email protected]> * Update sdk/communication/azure-communication-messages/samples/send_image_notification_messages.py Co-authored-by: Anna Tisch <[email protected]> * Update sdk/communication/azure-communication-messages/samples/send_image_notification_messages_async.py Co-authored-by: Anna Tisch <[email protected]> * Update sdk/communication/azure-communication-messages/samples/send_image_notification_messages_async.py Co-authored-by: Anna Tisch <[email protected]> * Update sdk/communication/azure-communication-messages/samples/send_template_notification_messages.py Co-authored-by: Anna Tisch <[email protected]> * Update sdk/communication/azure-communication-messages/samples/send_template_notification_messages.py Co-authored-by: Anna Tisch <[email protected]> * Update sdk/communication/azure-communication-messages/samples/send_template_notification_messages_async.py Co-authored-by: Anna Tisch <[email protected]> * Update sdk/communication/azure-communication-messages/samples/send_text_notification_messages.py Co-authored-by: Anna Tisch <[email protected]> * Update sdk/communication/azure-communication-messages/samples/send_template_notification_messages_async.py Co-authored-by: Anna Tisch <[email protected]> * review comments * review comments * adding Token credential Sample * samples improvement * Iterable bytes changes * removing job router references. --------- Co-authored-by: Anna Tisch <[email protected]>
- Loading branch information
Showing
70 changed files
with
8,763 additions
and
1 deletion.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
sdk/communication/azure-communication-messages/CHANGELOG.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Release History | ||
|
||
## 1.0.0 (2024-02-01) | ||
|
||
This is the GA release of Azure Communication Messages Python SDK. For more information, please see the [README][read_me]. | ||
|
||
### Features Added | ||
- Using `NotificationMessagesClient` | ||
- Send Text messages | ||
- Send Template messages | ||
- Send Media messages | ||
- Using `MessageTemplateClient` | ||
- Get list of all WhatsApp templates. | ||
|
||
<!-- LINKS --> | ||
[read_me]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/communication/azure-communication-messages/README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Copyright (c) Microsoft Corporation. | ||
|
||
MIT License | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
include *.md | ||
include LICENSE | ||
include azure/communication/messages/py.typed | ||
recursive-include tests *.py | ||
recursive-include samples *.py *.md | ||
include azure/__init__.py | ||
include azure/communication/__init__.py |
104 changes: 104 additions & 0 deletions
104
sdk/communication/azure-communication-messages/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# Azure Communication Messages Package client library for Python | ||
|
||
This package contains a Python SDK for Azure Communication Services for Messages(Advanced Messaging). | ||
Read more about Azure Communication Services [here][product_docs] | ||
|
||
[Source code][source] | [Package (Pypi)][pypi] | [Product documentation][product_docs] | ||
|
||
## _Disclaimer_ | ||
|
||
_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_ | ||
|
||
## Getting started | ||
|
||
### Prequisites | ||
|
||
- Python 3.8 or later is required to use this package. | ||
- You need an [Azure subscription][azure_sub] to use this package. | ||
- An existing Communication Messages instance. | ||
|
||
## Key concepts | ||
|
||
Azure Communication Services enables you to send and receive WhatsApp messages using the Azure Communication Services Messages SDK. It can be used to send out messages like appointment reminders, shipping updates, two-factor authentication, and other notification scenarios. | ||
|
||
### Installating the package | ||
|
||
```bash | ||
python -m pip install azure-communication-messages | ||
``` | ||
|
||
### Create with an Azure Active Directory Credential | ||
|
||
To use an [Azure Active Directory (AAD) token credential][authenticate_with_token], | ||
provide an instance of the desired credential type obtained from the | ||
[azure-identity][azure_identity_credentials] library. | ||
|
||
To authenticate with AAD, you must first [pip][pip] install [`azure-identity`][azure_identity_pip] | ||
|
||
After setup, you can choose which type of [credential][azure_identity_credentials] from azure.identity to use. | ||
As an example, [DefaultAzureCredential][default_azure_credential] can be used to authenticate the client: | ||
|
||
Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: | ||
`AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET` | ||
|
||
Use the returned token credential to authenticate the client: | ||
|
||
```python | ||
>>> from azure.communication.messages import NotificationMessagesClient | ||
>>> from azure.identity import DefaultAzureCredential | ||
>>> client = NotificationMessagesClient(endpoint='<endpoint>', credential=DefaultAzureCredential()) | ||
``` | ||
|
||
### Examples | ||
|
||
```python | ||
>>> from azure.communication.messages import NotificationMessagesClient | ||
>>> from azure.identity import DefaultAzureCredential | ||
>>> from azure.core.exceptions import HttpResponseError | ||
|
||
>>> client = NotificationMessagesClient(endpoint='<endpoint>', credential=DefaultAzureCredential()) | ||
>>> try: | ||
# write test code here | ||
except HttpResponseError as e: | ||
print('service responds error: {}'.format(e.response.json())) | ||
|
||
``` | ||
|
||
## Troubleshooting | ||
|
||
Running into issues? This section should contain details as to what to do there. | ||
|
||
## Next steps | ||
|
||
- [Read more about Azure Communication Services Messages][nextsteps] | ||
|
||
## Contributing | ||
|
||
This project welcomes contributions and suggestions. Most contributions require | ||
you to agree to a Contributor License Agreement (CLA) declaring that you have | ||
the right to, and actually do, grant us the rights to use your contribution. | ||
For details, visit https://cla.microsoft.com. | ||
|
||
When you submit a pull request, a CLA-bot will automatically determine whether | ||
you need to provide a CLA and decorate the PR appropriately (e.g., label, | ||
comment). Simply follow the instructions provided by the bot. You will only | ||
need to do this once across all repos using our CLA. | ||
|
||
This project has adopted the | ||
[Microsoft Open Source Code of Conduct][code_of_conduct]. For more information, | ||
see the Code of Conduct FAQ or contact [email protected] with any | ||
additional questions or comments. | ||
|
||
<!-- LINKS --> | ||
[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/ | ||
[authenticate_with_token]: https://docs.microsoft.com/azure/cognitive-services/authentication?tabs=powershell#authenticate-with-an-authentication-token | ||
[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#credentials | ||
[azure_identity_pip]: https://pypi.org/project/azure-identity/ | ||
[default_azure_credential]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#defaultazurecredential | ||
[pip]: https://pypi.org/project/pip/ | ||
[azure_sub]: https://azure.microsoft.com | ||
|
||
[source]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/communication/azure-communication-messages | ||
[product_docs]: https://docs.microsoft.com/azure/communication-services/overview | ||
[pypi]: https://pypi.org | ||
[nextsteps]: https://learn.microsoft.com/azure/communication-services/concepts/advanced-messaging/whatsapp/whatsapp-overview |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"AssetsRepo": "Azure/azure-sdk-assets", | ||
"AssetsRepoPrefixPath": "python", | ||
"TagPrefix": "python/communication/azure-communication-messages", | ||
"Tag": "python/communication/azure-communication-messages_1c6b0f13ac" | ||
} |
1 change: 1 addition & 0 deletions
1
sdk/communication/azure-communication-messages/azure/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore |
1 change: 1 addition & 0 deletions
1
sdk/communication/azure-communication-messages/azure/communication/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore |
27 changes: 27 additions & 0 deletions
27
sdk/communication/azure-communication-messages/azure/communication/messages/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# Code generated by Microsoft (R) Python Code Generator. | ||
# Changes may cause incorrect behavior and will be lost if the code is regenerated. | ||
# -------------------------------------------------------------------------- | ||
|
||
from ._client import NotificationMessagesClient | ||
from ._client import MessageTemplateClient | ||
from ._version import VERSION | ||
|
||
__version__ = VERSION | ||
|
||
try: | ||
from ._patch import __all__ as _patch_all | ||
from ._patch import * # pylint: disable=unused-wildcard-import | ||
except ImportError: | ||
_patch_all = [] | ||
from ._patch import patch_sdk as _patch_sdk | ||
__all__ = [ | ||
'NotificationMessagesClient', | ||
'MessageTemplateClient', | ||
] | ||
__all__.extend([p for p in _patch_all if p not in __all__]) | ||
|
||
_patch_sdk() |
15 changes: 15 additions & 0 deletions
15
sdk/communication/azure-communication-messages/azure/communication/messages/_api_versions.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# ------------------------------------ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
# ------------------------------------ | ||
|
||
from enum import Enum | ||
from azure.core import CaseInsensitiveEnumMeta | ||
|
||
|
||
class ApiVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): | ||
V2023_08_24_PREVIEW = "2023-08-24-preview" | ||
V2024_02_01 = "2024-02-01" | ||
|
||
|
||
DEFAULT_VERSION = ApiVersion.V2024_02_01.value |
Oops, something went wrong.