Skip to content

Commit

Permalink
Latest ARB and build fixes. (#31542)
Browse files Browse the repository at this point in the history
* Code refactored as per main

* Fixed issues

* Fixed testcases

* Reverted play_media_to_all changes

* Updated readme as per latest changes

* [Core] Add CAE flag to auth policies (#31012)

This first adds a keyword argument to the TokenCredential protocol method `get_token`.

This enables users and client SDKs to pass in a flag to denote that
`get_token` requests should be requesting CAE tokens.

If the underlying credential's `get_token` implementation supports this
flag, then a CAE token will be requested. Otherwise, a non-CAE token
will be requested.

Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>

(cherry picked from commit a7519f9)

* fix tests (#31526)

* fix tests

* update

(cherry picked from commit d1d0ef6)

* Packaging update of azure-mgmt-azureadb2c

---------

Co-authored-by: Paul Van Eck <paulvaneck@microsoft.com>
Co-authored-by: Xiang Yan <xiangsjtu@gmail.com>
Co-authored-by: Azure SDK Bot <adxpysdk@microsoft.com>
  • Loading branch information
4 people authored Aug 9, 2023
1 parent 9506187 commit d5e3c1e
Show file tree
Hide file tree
Showing 55 changed files with 1,563 additions and 888 deletions.
4 changes: 3 additions & 1 deletion sdk/azureadb2c/azure-mgmt-azureadb2c/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
include _meta.json
recursive-include tests *.py *.yaml
recursive-include tests *.py *.json
recursive-include samples *.py *.md
include *.md
include azure/__init__.py
include azure/mgmt/__init__.py
include LICENSE
include azure/mgmt/azureadb2c/py.typed
50 changes: 42 additions & 8 deletions sdk/azureadb2c/azure-mgmt-azureadb2c/README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,60 @@
# Microsoft Azure SDK for Python

This is the Microsoft Azure Azureadb2c Management Client Library.
This package has been tested with Python 3.6+.
This package has been tested with Python 3.7+.
For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all).

## _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_

# Usage
## Getting started

### Prerequisites

To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt)
- Python 3.7+ is required to use this package.
- [Azure subscription](https://azure.microsoft.com/free/)

### Install the package

For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/)
Code samples for this package can be found at [Azureadb2c Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com.
Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples)
```bash
pip install azure-mgmt-azureadb2c
pip install azure-identity
```

### Authentication

# Provide Feedback
By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configure of following environment variables.

- `AZURE_CLIENT_ID` for Azure client ID.
- `AZURE_TENANT_ID` for Azure tenant ID.
- `AZURE_CLIENT_SECRET` for Azure client secret.

In addition, Azure subscription ID can be configured via environment variable `AZURE_SUBSCRIPTION_ID`.

With above configuration, client can be authenticated by following code:

```python
from azure.identity import DefaultAzureCredential
from azure.mgmt.azureadb2c import CPIMConfigurationClient
import os

sub_id = os.getenv("AZURE_SUBSCRIPTION_ID")
client = CPIMConfigurationClient(credential=DefaultAzureCredential(), subscription_id=sub_id)
```

## Examples

Code samples for this package can be found at:
- [Search Azureadb2c Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com
- [Azure Python Mgmt SDK Samples Repo](https://aka.ms/azsdk/python/mgmt/samples)


## Troubleshooting

## Next steps

## Provide Feedback

If you encounter any bugs or have suggestions, please file an issue in the
[Issues](https://github.com/Azure/azure-sdk-for-python/issues)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# 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.
# --------------------------------------------------------------------------
from .v2019_01_01_preview.models import *
from .v2020_05_01_preview.models import *
from azure.core.credentials import AccessToken


class FakeTokenCredential(object):
def __init__(self):
self.token = AccessToken("Fake Token", 0)

def get_token(self, *args, **kwargs):
return self.token
87 changes: 48 additions & 39 deletions sdk/azureadb2c/azure-mgmt-azureadb2c/setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env python

#-------------------------------------------------------------------------
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#--------------------------------------------------------------------------
# --------------------------------------------------------------------------

import re
import os.path
Expand All @@ -16,59 +16,68 @@
PACKAGE_PPRINT_NAME = "Azureadb2c Management"

# a-b-c => a/b/c
package_folder_path = PACKAGE_NAME.replace('-', '/')
package_folder_path = PACKAGE_NAME.replace("-", "/")
# a-b-c => a.b.c
namespace_name = PACKAGE_NAME.replace('-', '.')
namespace_name = PACKAGE_NAME.replace("-", ".")

# Version extraction inspired from 'requests'
with open(os.path.join(package_folder_path, 'version.py')
if os.path.exists(os.path.join(package_folder_path, 'version.py'))
else os.path.join(package_folder_path, '_version.py'), 'r') as fd:
version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]',
fd.read(), re.MULTILINE).group(1)
with open(
os.path.join(package_folder_path, "version.py")
if os.path.exists(os.path.join(package_folder_path, "version.py"))
else os.path.join(package_folder_path, "_version.py"),
"r",
) as fd:
version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1)

if not version:
raise RuntimeError('Cannot find version information')
raise RuntimeError("Cannot find version information")

with open('README.md', encoding='utf-8') as f:
with open("README.md", encoding="utf-8") as f:
readme = f.read()
with open('CHANGELOG.md', encoding='utf-8') as f:
with open("CHANGELOG.md", encoding="utf-8") as f:
changelog = f.read()

setup(
name=PACKAGE_NAME,
version=version,
description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME),
long_description=readme + '\n\n' + changelog,
long_description_content_type='text/markdown',
license='MIT License',
author='Microsoft Corporation',
author_email='azpysdkhelp@microsoft.com',
url='https://github.com/Azure/azure-sdk-for-python',
description="Microsoft Azure {} Client Library for Python".format(PACKAGE_PPRINT_NAME),
long_description=readme + "\n\n" + changelog,
long_description_content_type="text/markdown",
license="MIT License",
author="Microsoft Corporation",
author_email="azpysdkhelp@microsoft.com",
url="https://github.com/Azure/azure-sdk-for-python",
keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product
classifiers=[
'Development Status :: 4 - Beta',
'Programming Language :: Python',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'License :: OSI Approved :: MIT License',
"Development Status :: 4 - Beta",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"License :: OSI Approved :: MIT License",
],
zip_safe=False,
packages=find_packages(exclude=[
'tests',
# Exclude packages that will be covered by PEP420 or nspkg
'azure',
'azure.mgmt',
]),
packages=find_packages(
exclude=[
"tests",
# Exclude packages that will be covered by PEP420 or nspkg
"azure",
"azure.mgmt",
]
),
include_package_data=True,
package_data={
"pytyped": ["py.typed"],
},
install_requires=[
'msrest>=0.6.21',
'azure-common~=1.1',
'azure-mgmt-core>=1.3.0,<2.0.0',
"isodate<1.0.0,>=0.6.1",
"azure-common~=1.1",
"azure-mgmt-core>=1.3.2,<2.0.0",
"typing-extensions>=4.3.0; python_version<'3.8.0'",
],
python_requires=">=3.6"
python_requires=">=3.7",
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
- Send DTMF tones to a participant in the call.
- Mute participant in the call.

### Other Changes
- The models `ServerCallLocator` and `GroupCallLocator` have been deprecated, and the ID values can now be passed directly into `CallAutomationClient.start_recording` as keyword arguments.
- The model `CallInvite` has been deprecated and now the target `CommunicationIdentifier` and associated properties can be passed directly into `create_call`, `redirect_call` and `add_participant`.
- The method `CallAutomationClient.create_group_call` has been deprecated, this can now be achieved by passing a list of `CommunicationIdentifier`s into `create_call`.
- The method `CallConnectionClient.play_media_to_all` has been deprecated, this can now be achieved as the default behaviour of `play_media`.

## 1.0.0 (2023-06-14)
Call Automation enables developers to build call workflows. Personalise customer interactions by listening to call events and take actions based on your business logic. For more information, please see the [README][read_me].

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,17 @@ client = CallAutomationClient.from_connection_string(endpoint_url)
```Python
from azure.communication.callautomation import (
CallAutomationClient,
CallInvite,
CommunicationUserIdentifier
)

# target endpoint for ACS User
user = CommunicationUserIdentifier("8:acs:...")

# make invitation
call_invite = CallInvite(target=user)

# callback url to receive callback events
callback_url = "https://<MY-EVENT-HANDLER-URL>/events"

# send out the invitation, creating call
result = client.create_call(call_invite, callback_url)
result = client.create_call(user, callback_url)

# this id can be used to do further actions in the call
call_connection_id = result.call_connection_id
Expand All @@ -70,7 +66,7 @@ call_connection = client.get_call_connection(call_connection_id)

# from callconnection of result above, play media to all participants
my_file = FileSource(url="https://<FILE-SOURCE>/<SOME-FILE>.wav")
call_connection.play_to_all(my_file)
call_connection.play_media(my_file)
```

## Troubleshooting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
import warnings

from ._version import VERSION
from ._call_automation_client import CallAutomationClient
from ._call_connection_client import CallConnectionClient
from ._models import (
CallConnectionProperties,
CallInvite,
ServerCallLocator,
GroupCallLocator,
FileSource,
TextSource,
SsmlSource,
Expand Down Expand Up @@ -51,9 +50,6 @@
"CallConnectionClient",

# models for input
"CallInvite",
"ServerCallLocator",
"GroupCallLocator",
"FileSource",
"TextSource",
"SsmlSource",
Expand Down Expand Up @@ -92,3 +88,29 @@
"VoiceKind"
]
__version__ = VERSION


def __getattr__(name):
if name == 'CallInvite':
warnings.warn(
"CallInvite is deprecated and should not be used. Please pass in keyword arguments directly.",
DeprecationWarning
)
from ._models import CallInvite
return CallInvite
if name == 'GroupCallLocator':
warnings.warn(
"GroupCallLocator is deprecated and should not be used. Please pass in 'group_call_id' directly.",
DeprecationWarning
)
from ._models import GroupCallLocator
return GroupCallLocator
if name == 'ServerCallLocator':
warnings.warn(
"ServerCallLocator is deprecated and should not be used. Please pass in 'server_call_id' directly.",
DeprecationWarning
)
from ._models import ServerCallLocator
return ServerCallLocator

raise AttributeError(f"module 'azure.communication.callautomation' has no attribute {name}")
Loading

0 comments on commit d5e3c1e

Please sign in to comment.