From 6f3989a222e73d0bbac1217f3e2dcc1b4afcfaf9 Mon Sep 17 00:00:00 2001 From: Bert Ong <823691+beltr0n@users.noreply.github.com> Date: Thu, 21 Jan 2021 15:35:36 -0800 Subject: [PATCH 01/33] initial commit: new folder for identity --- .../azure-communication-identity/CHANGELOG.md | 11 +++ .../azure-communication-identity/MANIFEST.in | 6 ++ .../azure-communication-identity/README.md | 70 +++++++++++++++++++ .../swagger/SWAGGER.md | 27 +++++++ 4 files changed, 114 insertions(+) create mode 100644 sdk/communication/azure-communication-identity/CHANGELOG.md create mode 100644 sdk/communication/azure-communication-identity/MANIFEST.in create mode 100644 sdk/communication/azure-communication-identity/README.md create mode 100644 sdk/communication/azure-communication-identity/swagger/SWAGGER.md diff --git a/sdk/communication/azure-communication-identity/CHANGELOG.md b/sdk/communication/azure-communication-identity/CHANGELOG.md new file mode 100644 index 000000000000..964b44312c40 --- /dev/null +++ b/sdk/communication/azure-communication-identity/CHANGELOG.md @@ -0,0 +1,11 @@ +# Release History + +## 1.0.0-beta.4 (Unreleased) + +### Added +- Added CommunicationIdentityClient (originally was part of the azure.communication.administration package). +- Added support for Azure Active Directory authentication for the Identity client + + +[read_me]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/communication/azure-communication-identity/README.md +[documentation]: https://docs.microsoft.com/azure/communication-services/quickstarts/access-tokens?pivots=programming-language-python \ No newline at end of file diff --git a/sdk/communication/azure-communication-identity/MANIFEST.in b/sdk/communication/azure-communication-identity/MANIFEST.in new file mode 100644 index 000000000000..a743efd0162b --- /dev/null +++ b/sdk/communication/azure-communication-identity/MANIFEST.in @@ -0,0 +1,6 @@ +include *.md +include azure/__init__.py +include azure/communication/__init__.py +include LICENSE.txt +recursive-include tests *.py +recursive-include samples *.py *.md \ No newline at end of file diff --git a/sdk/communication/azure-communication-identity/README.md b/sdk/communication/azure-communication-identity/README.md new file mode 100644 index 000000000000..42d1cbe4066c --- /dev/null +++ b/sdk/communication/azure-communication-identity/README.md @@ -0,0 +1,70 @@ +[![Build Status](https://dev.azure.com/azure-sdk/public/_apis/build/status/azure-sdk-for-python.client?branchName=master)](https://dev.azure.com/azure-sdk/public/_build/latest?definitionId=46?branchName=master) + +# Azure Communication Identity Package client library for Python + +Azure Communication Identity client package is intended to be used to setup the basics for opening a way to use Azure Communication Service offerings. This package helps to create identities user tokens to be used by other client packages such as chat, calling, sms. + +# Getting started +### Prerequisites +- Python 2.7, or 3.5 or later is required to use this package. +- You must have an [Azure subscription](https://azure.microsoft.com/free/) +- A deployed Communication Services resource. You can use the [Azure Portal](https://docs.microsoft.com/azure/communication-services/quickstarts/create-communication-resource?tabs=windows&pivots=platform-azp) or the [Azure PowerShell](https://docs.microsoft.com/powershell/module/az.communication/new-azcommunicationservice) to set it up. +### Install the package +Install the Azure Communication Identity client library for Python with [pip](https://pypi.org/project/pip/): + +```bash +pip install azure-communication-identity +``` + +# Key concepts +## CommunicationIdentityClient +`CommunicationIdentityClient` provides operations for: + +- Create/delete identities to be used in Azure Communication Services. Those identities can be used to make use of Azure Communication offerings and can be scoped to have limited abilities through token scopes. + +- Create/revoke scoped user access tokens to access services such as chat, calling, sms. Tokens are issued for a valid Azure Communication identity and can be revoked at any time. + +### Initializing Identity Client +```python +# You can find your endpoint and access token from your resource in the Azure Portal +import os +from azure.communication.identity import CommunicationIdentityClient +from azure.identity import DefaultAzureCredential + +connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') +endpoint = os.getenv('AZURE_COMMUNICATION_SERVICE_ENDPOINT') + +# To use Azure Active Directory Authentication (DefaultAzureCredential) make sure to have +# AZURE_TENANT_ID, AZURE_CLIENT_ID and AZURE_CLIENT_SECRET as env variables. +identity_client_managed_identity = CommunicationIdentityClient.(endpoint, DefaultAzureCredential()) + +#You can also authenticate using your connection string +identity_client = CommunicationIdentityClient.from_connection_string(connection_str) + +``` + +# Troubleshooting +The Azure Communication Service Identity client will raise exceptions defined in [Azure Core][azure_core]. + +# Next steps +## More sample code + +Please take a look at the [samples](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/communication/azure-communication-identity/samples) directory for detailed examples of how to use this library to manage identities and tokens. + +## 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) section of the project + +# 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](https://opensource.microsoft.com/codeofconduct/). +For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. + + +[identitysamples]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/communication/azure-communication-identity/samples/identity_samples.py +[azure_core]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/README.md diff --git a/sdk/communication/azure-communication-identity/swagger/SWAGGER.md b/sdk/communication/azure-communication-identity/swagger/SWAGGER.md new file mode 100644 index 000000000000..afb35325536c --- /dev/null +++ b/sdk/communication/azure-communication-identity/swagger/SWAGGER.md @@ -0,0 +1,27 @@ +# Azure Communication Administration for Python + +> see https://aka.ms/autorest + +### Setup +```ps +npm install -g autorest +``` + +### Generation +```ps +cd +autorest ./SWAGGER.md +``` + +### Settings +``` yaml +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/8818a603b78a1355ba1647ab9cd4e3354cdc4b69/specification/communication/data-plane/Microsoft.CommunicationServicesIdentity/preview/2020-07-20-preview2/CommunicationIdentity.json +output-folder: ../azure/communication/administration/_identity/_generated/ +namespace: azure.communication.administration +license-header: MICROSOFT_MIT_NO_VERSION +payload-flattening-threshold: 3 +no-namespace-folders: true +clear-output-folder: true +v3: true +python: true +``` \ No newline at end of file From 9c5f2c7b5110e492f775b1d7c26cf601c3e31b9b Mon Sep 17 00:00:00 2001 From: Lakshman Sundaralingam Date: Thu, 21 Jan 2021 16:20:52 -0800 Subject: [PATCH 02/33] Added root files to identity package --- .../azure-communication-identity/LICENSE.txt | 21 +++++ .../dev_requirements.txt | 7 ++ .../sdk_packaging.toml | 7 ++ .../azure-communication-identity/setup.cfg | 2 + .../azure-communication-identity/setup.py | 76 +++++++++++++++++++ 5 files changed, 113 insertions(+) create mode 100644 sdk/communication/azure-communication-identity/LICENSE.txt create mode 100644 sdk/communication/azure-communication-identity/dev_requirements.txt create mode 100644 sdk/communication/azure-communication-identity/sdk_packaging.toml create mode 100644 sdk/communication/azure-communication-identity/setup.cfg create mode 100644 sdk/communication/azure-communication-identity/setup.py diff --git a/sdk/communication/azure-communication-identity/LICENSE.txt b/sdk/communication/azure-communication-identity/LICENSE.txt new file mode 100644 index 000000000000..0313a903d76c --- /dev/null +++ b/sdk/communication/azure-communication-identity/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2017 Microsoft + +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. \ No newline at end of file diff --git a/sdk/communication/azure-communication-identity/dev_requirements.txt b/sdk/communication/azure-communication-identity/dev_requirements.txt new file mode 100644 index 000000000000..6feae79262c7 --- /dev/null +++ b/sdk/communication/azure-communication-identity/dev_requirements.txt @@ -0,0 +1,7 @@ +-e ../../../tools/azure-sdk-tools +-e ../../../tools/azure-devtools +-e ../../identity/azure-identity +../../core/azure-core +../azure-communication-nspkg +../azure-mgmt-communication +aiohttp>=3.0; python_version >= '3.5' \ No newline at end of file diff --git a/sdk/communication/azure-communication-identity/sdk_packaging.toml b/sdk/communication/azure-communication-identity/sdk_packaging.toml new file mode 100644 index 000000000000..5d4170e7bda2 --- /dev/null +++ b/sdk/communication/azure-communication-identity/sdk_packaging.toml @@ -0,0 +1,7 @@ +[packaging] +auto_update = false +package_name = "azure-communication-identity" +package_pprint_name = "Communication Service" +package_doc_id = "" +is_stable = false +is_arm = false \ No newline at end of file diff --git a/sdk/communication/azure-communication-identity/setup.cfg b/sdk/communication/azure-communication-identity/setup.cfg new file mode 100644 index 000000000000..3480374bc2f2 --- /dev/null +++ b/sdk/communication/azure-communication-identity/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 \ No newline at end of file diff --git a/sdk/communication/azure-communication-identity/setup.py b/sdk/communication/azure-communication-identity/setup.py new file mode 100644 index 000000000000..16d4f1a8f8f4 --- /dev/null +++ b/sdk/communication/azure-communication-identity/setup.py @@ -0,0 +1,76 @@ +from setuptools import setup, find_packages +import os +from io import open +import re + +# example setup.py Feel free to copy the entire "azure-template" folder into a package folder named +# with "azure-". Ensure that the below arguments to setup() are updated to reflect +# your package. + +# this setup.py is set up in a specific way to keep the azure* and azure-mgmt-* namespaces WORKING all the way +# up from python 2.7. Reference here: https://github.com/Azure/azure-sdk-for-python/wiki/Azure-packaging + +PACKAGE_NAME = "azure-communication-identity" +PACKAGE_PPRINT_NAME = "Communication Identity Service" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace('-', '/') +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace('-', '.') + +# Version extraction inspired from 'requests' +with open(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') + +with open('README.md', encoding='utf-8') as f: + long_description = f.read() + +setup( + name=PACKAGE_NAME, + version=version, + description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), + long_description_content_type='text/markdown', + + # ensure that these are updated to reflect the package owners' information + long_description=long_description, + url='https://github.com/Azure/azure-sdk-for-python', + author='Microsoft Corporation', + author_email='azuresdkengsysadmins@microsoft.com', + + license='MIT License', + # ensure that the development status reflects the status of your package + classifiers=[ + "Development Status :: 4 - Beta", + + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'License :: OSI Approved :: MIT License', + ], + packages=find_packages(exclude=[ + 'tests', + # Exclude packages that will be covered by PEP420 or nspkg + 'azure', + 'azure.communication' + ]), + install_requires=[ + "msrest>=0.6.0", + "azure-core<2.0.0,>=1.6.0", + ], + extras_require={ + ":python_version<'3.0'": ['azure-communication-nspkg'], + }, + project_urls={ + 'Bug Reports': 'https://github.com/Azure/azure-sdk-for-python/issues', + 'Source': 'https://github.com/Azure/azure-sdk-for-python', + } +) \ No newline at end of file From 58fc9eb296881ad6f1dc02287e4d793d8cbba716 Mon Sep 17 00:00:00 2001 From: Bert Ong <823691+beltr0n@users.noreply.github.com> Date: Thu, 21 Jan 2021 16:26:00 -0800 Subject: [PATCH 03/33] copy identity client files from admin to new pkg --- .../azure/__init__.py | 1 + .../azure/communication/__init__.py | 1 + .../azure/communication/identity/__init__ .py | 20 +++ .../_communication_identity_client.py | 153 ++++++++++++++++ .../identity/_shared/__init__.py | 5 + .../communication/identity/_shared/models.py | 55 ++++++ .../communication/identity/_shared/policy.py | 91 ++++++++++ .../identity/_shared/user_credential.py | 83 +++++++++ .../identity/_shared/user_credential_async.py | 87 +++++++++ .../_shared/user_token_refresh_options.py | 36 ++++ .../communication/identity/_shared/utils.py | 103 +++++++++++ .../communication/identity/aio/__init__.py | 5 + .../_communication_identity_client_async.py | 168 ++++++++++++++++++ .../swagger/SWAGGER.md | 4 +- 14 files changed, 810 insertions(+), 2 deletions(-) create mode 100644 sdk/communication/azure-communication-identity/azure/__init__.py create mode 100644 sdk/communication/azure-communication-identity/azure/communication/__init__.py create mode 100644 sdk/communication/azure-communication-identity/azure/communication/identity/__init__ .py create mode 100644 sdk/communication/azure-communication-identity/azure/communication/identity/_communication_identity_client.py create mode 100644 sdk/communication/azure-communication-identity/azure/communication/identity/_shared/__init__.py create mode 100644 sdk/communication/azure-communication-identity/azure/communication/identity/_shared/models.py create mode 100644 sdk/communication/azure-communication-identity/azure/communication/identity/_shared/policy.py create mode 100644 sdk/communication/azure-communication-identity/azure/communication/identity/_shared/user_credential.py create mode 100644 sdk/communication/azure-communication-identity/azure/communication/identity/_shared/user_credential_async.py create mode 100644 sdk/communication/azure-communication-identity/azure/communication/identity/_shared/user_token_refresh_options.py create mode 100644 sdk/communication/azure-communication-identity/azure/communication/identity/_shared/utils.py create mode 100644 sdk/communication/azure-communication-identity/azure/communication/identity/aio/__init__.py create mode 100644 sdk/communication/azure-communication-identity/azure/communication/identity/aio/_communication_identity_client_async.py diff --git a/sdk/communication/azure-communication-identity/azure/__init__.py b/sdk/communication/azure-communication-identity/azure/__init__.py new file mode 100644 index 000000000000..69e3be50dac4 --- /dev/null +++ b/sdk/communication/azure-communication-identity/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/sdk/communication/azure-communication-identity/azure/communication/__init__.py b/sdk/communication/azure-communication-identity/azure/communication/__init__.py new file mode 100644 index 000000000000..69e3be50dac4 --- /dev/null +++ b/sdk/communication/azure-communication-identity/azure/communication/__init__.py @@ -0,0 +1 @@ +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/__init__ .py b/sdk/communication/azure-communication-identity/azure/communication/identity/__init__ .py new file mode 100644 index 000000000000..15d5752cae58 --- /dev/null +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/__init__ .py @@ -0,0 +1,20 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- + +from ._communication_identity_client import CommunicationIdentityClient + +from ._generated.models import ( + CommunicationTokenRequest, + CommunicationIdentityToken +) + +__all__ = [ + 'CommunicationIdentityClient', + + # from _identity + 'CommunicationTokenRequest', + 'CommunicationIdentityToken', +] \ No newline at end of file diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_communication_identity_client.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_communication_identity_client.py new file mode 100644 index 000000000000..391a1572978a --- /dev/null +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_communication_identity_client.py @@ -0,0 +1,153 @@ +# coding=utf-8 +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ + +from azure.core.tracing.decorator import distributed_trace + +from ._generated._communication_identity_client\ + import CommunicationIdentityClient as CommunicationIdentityClientGen +from ._generated.models import CommunicationIdentityToken +from ._shared.utils import parse_connection_str, get_authentication_policy +from ._shared.models import CommunicationUserIdentifier +from ._version import SDK_MONIKER + +class CommunicationIdentityClient(object): + """Azure Communication Services Identity client. + + :param str endpoint: + The endpoint url for Azure Communication Service resource. + :param credential: + The credentials with which to authenticate. The value is an account + shared access key + + .. admonition:: Example: + + .. literalinclude:: ../samples/identity_samples.py + :language: python + :dedent: 8 + """ + def __init__( + self, + endpoint, # type: str + credential, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + try: + if not endpoint.lower().startswith('http'): + endpoint = "https://" + endpoint + except AttributeError: + raise ValueError("Account URL must be a string.") + + if not credential: + raise ValueError( + "You need to provide account shared key to authenticate.") + + self._endpoint = endpoint + self._identity_service_client = CommunicationIdentityClientGen( + self._endpoint, + authentication_policy=get_authentication_policy(endpoint, credential), + sdk_moniker=SDK_MONIKER, + **kwargs) + + @classmethod + def from_connection_string( + cls, conn_str, # type: str + **kwargs # type: Any + ): # type: (...) -> CommunicationIdentityClient + """Create CommunicationIdentityClient from a Connection String. + + :param str conn_str: + A connection string to an Azure Communication Service resource. + :returns: Instance of CommunicationIdentityClient. + :rtype: ~azure.communication.CommunicationIdentityClient + + .. admonition:: Example: + + .. literalinclude:: ../samples/identity_samples.py + :start-after: [START auth_from_connection_string] + :end-before: [END auth_from_connection_string] + :language: python + :dedent: 8 + :caption: Creating the CommunicationIdentityClient from a connection string. + """ + endpoint, access_key = parse_connection_str(conn_str) + + return cls(endpoint, access_key, **kwargs) + + @distributed_trace + def create_user(self, **kwargs): + # type: (...) -> CommunicationUserIdentifier + """create a single Communication user + + return: CommunicationUserIdentifier + rtype: ~azure.communication.administration.CommunicationUserIdentifier + """ + return self._identity_service_client.communication_identity.create( + cls=lambda pr, u, e: CommunicationUserIdentifier(u.id), + **kwargs) + + @distributed_trace + def delete_user( + self, + communication_user, # type: CommunicationUserIdentifier + **kwargs # type: Any + ): + # type: (...) -> None + """Triggers revocation event for user and deletes all its data. + + :param communication_user: + Azure Communication User to delete + :type communication_user: ~azure.communication.administration.CommunicationUserIdentifier + :return: None + :rtype: None + """ + self._identity_service_client.communication_identity.delete( + communication_user.identifier, **kwargs) + + @distributed_trace + def issue_token( + self, + user, # type: CommunicationUserIdentifier + scopes, # type: List[str] + **kwargs # type: Any + ): + # type: (...) -> CommunicationIdentityToken + """Generates a new token for an identity. + + :param user: Azure Communication User + :type user: ~azure.communication.administration.CommunicationUserIdentifier + :param scopes: + List of scopes to be added to the token. + :type scopes: list[str] + :return: CommunicationIdentityToken + :rtype: ~azure.communication.administration.CommunicationIdentityToken + """ + return self._identity_service_client.communication_identity.issue_token( + user.identifier, + scopes, + **kwargs) + + @distributed_trace + def revoke_tokens( + self, + user, # type: CommunicationUserIdentifier + issued_before=None, # type: Optional[datetime.datetime] + **kwargs # type: Any + ): + # type: (...) -> None + """Schedule revocation of all tokens of an identity. + + :param user: Azure Communication User. + :type user: ~azure.communication.administration.CommunicationUserIdentifier. + :param issued_before: All tokens that are issued prior to this time should get revoked. + :type issued_before: ~datetime.datetime. + :return: None + :rtype: None + """ + return self._identity_service_client.communication_identity.update( + user.identifier if user else None, + tokens_valid_from=issued_before, + **kwargs) diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_shared/__init__.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_shared/__init__.py new file mode 100644 index 000000000000..5b396cd202e8 --- /dev/null +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_shared/__init__.py @@ -0,0 +1,5 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_shared/models.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_shared/models.py new file mode 100644 index 000000000000..51260e07d2d9 --- /dev/null +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_shared/models.py @@ -0,0 +1,55 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ + +class CommunicationUserIdentifier(object): + """ + Represents a user in Azure Communication Service. + :ivar identifier: Communication user identifier. + :vartype identifier: str + :param identifier: Identifier to initialize CommunicationUserIdentifier. + :type identifier: str + """ + def __init__(self, identifier): + self.identifier = identifier + +class PhoneNumberIdentifier(object): + """ + Represents a phone number. + :ivar value: Value for a phone number. + :vartype value: str + :param value: Value to initialize PhoneNumberIdentifier. + :type value: str + """ + def __init__(self, value): + self.value = value + +class UnknownIdentifier(object): + """ + Represents an identifier of an unknown type. + It will be encountered in communications with endpoints that are not + identifiable by this version of the SDK. + :ivar identifier: Unknown communication identifier. + :vartype identifier: str + :param identifier: Value to initialize UnknownIdentifier. + :type identifier: str + """ + def __init__(self, identifier): + self.identifier = identifier + +class MicrosoftTeamsUserIdentifier(object): + """ + Represents an identifier for a Microsoft Teams user. + :ivar user_id: the string identifier representing the identity + :vartype user_id: str + :param user_id: Value to initialize MicrosoftTeamsUserIdentifier. + :type user_id: str + :ivar is_anonymous: set this to true if the user is anonymous for example when joining a meeting with a share link + :vartype is_anonymous: bool + :param is_anonymous: Value to initialize MicrosoftTeamsUserIdentifier. + :type is_anonymous: bool + """ + def __init__(self, user_id, is_anonymous=False): + self.user_id = user_id + self.is_anonymous = is_anonymous diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_shared/policy.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_shared/policy.py new file mode 100644 index 000000000000..b2a0de8d4238 --- /dev/null +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_shared/policy.py @@ -0,0 +1,91 @@ +# ------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ------------------------------------------------------------------------- + +import hashlib +import urllib +import base64 +import hmac +from azure.core.pipeline.policies import SansIOHTTPPolicy +from .utils import get_current_utc_time + +class HMACCredentialsPolicy(SansIOHTTPPolicy): + """Implementation of HMAC authentication policy. + """ + + def __init__(self, + host, # type: str + access_key, # type: str + decode_url=False # type: bool + ): + # type: (...) -> None + super(HMACCredentialsPolicy, self).__init__() + + if host.startswith("https://"): + self._host = host.replace("https://", "") + + if host.startswith("http://"): + self._host = host.replace("http://", "") + + self._access_key = access_key + self._decode_url = decode_url + + def _compute_hmac(self, + value # type: str + ): + decoded_secret = base64.b64decode(self._access_key) + digest = hmac.new( + decoded_secret, value.encode("utf-8"), hashlib.sha256 + ).digest() + + return base64.b64encode(digest).decode("utf-8") + + def _sign_request(self, request): + verb = request.http_request.method.upper() + + # Get the path and query from url, which looks like https://host/path/query + query_url = str(request.http_request.url[len(self._host) + 8:]) + + if self._decode_url: + query_url = urllib.parse.unquote(query_url) + + signed_headers = "date;host;x-ms-content-sha256" + + utc_now = get_current_utc_time() + if request.http_request.body is None: + request.http_request.body = "" + content_digest = hashlib.sha256( + (request.http_request.body.encode("utf-8")) + ).digest() + content_hash = base64.b64encode(content_digest).decode("utf-8") + + string_to_sign = ( + verb + + "\n" + + query_url + + "\n" + + utc_now + + ";" + + self._host + + ";" + + content_hash + ) + + signature = self._compute_hmac(string_to_sign) + + signature_header = { + "Date": utc_now, + "x-ms-content-sha256": content_hash, + "x-ms-return-client-request-id": "true", + "Authorization": "HMAC-SHA256 SignedHeaders=" +\ + signed_headers + "&Signature=" + signature, + } + + request.http_request.headers.update(signature_header) + + return request + + def on_request(self, request): + self._sign_request(request) diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_shared/user_credential.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_shared/user_credential.py new file mode 100644 index 000000000000..e920d356a518 --- /dev/null +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_shared/user_credential.py @@ -0,0 +1,83 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from threading import Lock, Condition +from datetime import datetime, timedelta +from typing import ( # pylint: disable=unused-import + cast, + Tuple, +) + +from msrest.serialization import TZ_UTC + +class CommunicationTokenCredential(object): + """Credential type used for authenticating to an Azure Communication service. + :param communication_token_refresh_options: The token used to authenticate to an Azure Communication service + :type communication_token_refresh_options: ~azure.communication.chat.CommunicationTokenRefreshOptions + """ + + ON_DEMAND_REFRESHING_INTERVAL_MINUTES = 2 + + def __init__(self, + communication_token_refresh_options + ): + self._token = communication_token_refresh_options.get_token() + self._token_refresher = communication_token_refresh_options.get_token_refresher() + self._lock = Condition(Lock()) + self._some_thread_refreshing = False + + def get_token(self): + # type () -> ~azure.core.credentials.AccessToken + """The value of the configured token. + :rtype: ~azure.core.credentials.AccessToken + """ + + if not self._token_refresher or not self._token_expiring(): + return self._token + + should_this_thread_refresh = False + + with self._lock: + while self._token_expiring(): + if self._some_thread_refreshing: + if self._is_currenttoken_valid(): + return self._token + + self._wait_till_inprogress_thread_finish_refreshing() + else: + should_this_thread_refresh = True + self._some_thread_refreshing = True + break + + if should_this_thread_refresh: + try: + newtoken = self._token_refresher() + + with self._lock: + self._token = newtoken + self._some_thread_refreshing = False + self._lock.notify_all() + except: + with self._lock: + self._some_thread_refreshing = False + self._lock.notify_all() + + raise + return self._token + + def _wait_till_inprogress_thread_finish_refreshing(self): + self._lock.release() + self._lock.acquire() + + def _token_expiring(self): + return self._token.expires_on - self._get_utc_now() <\ + timedelta(minutes=self.ON_DEMAND_REFRESHING_INTERVAL_MINUTES) + + def _is_currenttoken_valid(self): + return self._get_utc_now() < self._token.expires_on + + @classmethod + def _get_utc_now(cls): + return datetime.now().replace(tzinfo=TZ_UTC) diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_shared/user_credential_async.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_shared/user_credential_async.py new file mode 100644 index 000000000000..0918074eb04a --- /dev/null +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_shared/user_credential_async.py @@ -0,0 +1,87 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from asyncio import Condition, Lock +from datetime import datetime, timedelta +from typing import ( # pylint: disable=unused-import + cast, + Tuple, +) + +from msrest.serialization import TZ_UTC + +class CommunicationTokenCredential(object): + """Credential type used for authenticating to an Azure Communication service. + :param communication_token_refresh_options: The token used to authenticate to an Azure Communication service + :type communication_token_refresh_options: ~azure.communication.chat.aio.CommunicationTokenRefreshOptions + :raises: TypeError + """ + + ON_DEMAND_REFRESHING_INTERVAL_MINUTES = 2 + + def __init__(self, + communication_token_refresh_options + ): + self._token = communication_token_refresh_options.get_token() + self._token_refresher = communication_token_refresh_options.get_token_refresher() + self._lock = Condition(Lock()) + self._some_thread_refreshing = False + + def get_token(self): + # type () -> ~azure.core.credentials.AccessToken + """The value of the configured token. + :rtype: ~azure.core.credentials.AccessToken + """ + + if not self._token_refresher or not self._token_expiring(): + return self._token + + should_this_thread_refresh = False + + with self._lock: + + while self._token_expiring(): + if self._some_thread_refreshing: + if self._is_currenttoken_valid(): + return self._token + + self._wait_till_inprogress_thread_finish_refreshing() + else: + should_this_thread_refresh = True + self._some_thread_refreshing = True + break + + + if should_this_thread_refresh: + try: + newtoken = self._token_refresher() + + with self._lock: + self._token = newtoken + self._some_thread_refreshing = False + self._lock.notify_all() + except: + with self._lock: + self._some_thread_refreshing = False + self._lock.notify_all() + + raise + + return self._token + + def _wait_till_inprogress_thread_finish_refreshing(self): + self._lock.release() + self._lock.acquire() + + def _token_expiring(self): + return self._token.expires_on - self._get_utc_now() <\ + timedelta(minutes=self.ON_DEMAND_REFRESHING_INTERVAL_MINUTES) + + def _is_currenttoken_valid(self): + return self._get_utc_now() < self._token.expires_on + + @classmethod + def _get_utc_now(cls): + return datetime.now().replace(tzinfo=TZ_UTC) diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_shared/user_token_refresh_options.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_shared/user_token_refresh_options.py new file mode 100644 index 000000000000..6bdc0d456026 --- /dev/null +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_shared/user_token_refresh_options.py @@ -0,0 +1,36 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from typing import ( # pylint: disable=unused-import + cast, + Tuple, +) +import six +from .utils import create_access_token + +class CommunicationTokenRefreshOptions(object): + """Options for refreshing CommunicationTokenCredential. + :param str token: The token used to authenticate to an Azure Communication service + :param token_refresher: The token refresher to provide capacity to fetch fresh token + :raises: TypeError + """ + + def __init__(self, + token, # type: str + token_refresher=None + ): + # type: (str) -> None + if not isinstance(token, six.string_types): + raise TypeError("token must be a string.") + self._token = token + self._token_refresher = token_refresher + + def get_token(self): + """Return the the serialized JWT token.""" + return create_access_token(self._token) + + def get_token_refresher(self): + """Return the token refresher to provide capacity to fetch fresh token.""" + return self._token_refresher diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_shared/utils.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_shared/utils.py new file mode 100644 index 000000000000..18da505150ba --- /dev/null +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_shared/utils.py @@ -0,0 +1,103 @@ +# ------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ------------------------------------------------------------------------- + +import base64 +import json +from typing import ( # pylint: disable=unused-import + cast, + Tuple, +) +from datetime import datetime +from msrest.serialization import TZ_UTC +from azure.core.credentials import AccessToken + +def parse_connection_str(conn_str): + # type: (str) -> Tuple[str, str, str, str] + endpoint = None + shared_access_key = None + for element in conn_str.split(";"): + key, _, value = element.partition("=") + if key.lower() == "endpoint": + endpoint = value.rstrip("/") + elif key.lower() == "accesskey": + shared_access_key = value + if not all([endpoint, shared_access_key]): + raise ValueError( + "Invalid connection string. Should be in the format: " + "endpoint=sb:///;accesskey=" + ) + left_slash_pos = cast(str, endpoint).find("//") + if left_slash_pos != -1: + host = cast(str, endpoint)[left_slash_pos + 2:] + else: + host = str(endpoint) + + return host, str(shared_access_key) + + +def get_current_utc_time(): + # type: () -> str + return str(datetime.utcnow().strftime("%a, %d %b %Y %H:%M:%S ")) + "GMT" + +def create_access_token(token): + # type: (str) -> azure.core.credentials.AccessToken + """Creates an instance of azure.core.credentials.AccessToken from a + string token. The input string is jwt token in the following form: + .. + This method looks into the token_payload which is a json and extracts the expiry time + for that token and creates a tuple of type azure.core.credentials.AccessToken + (, ) + :param token: User token + :type token: str + :return: Instance of azure.core.credentials.AccessToken - token and expiry date of it + :rtype: ~azure.core.credentials.AccessToken + """ + + token_parse_err_msg = "Token is not formatted correctly" + parts = token.split(".") + + if len(parts) < 3: + raise ValueError(token_parse_err_msg) + + try: + padded_base64_payload = base64.b64decode(parts[1] + "==").decode('ascii') + payload = json.loads(padded_base64_payload) + return AccessToken(token, datetime.fromtimestamp(payload['exp']).replace(tzinfo=TZ_UTC)) + except ValueError: + raise ValueError(token_parse_err_msg) + +def get_authentication_policy( + endpoint, # type: str + credential, # type: TokenCredential or str + is_async=False, # type: bool +): + # type: (...) -> BearerTokenCredentialPolicy or HMACCredentialPolicy + """Returns the correct authentication policy based + on which credential is being passed. + + :param endpoint: The endpoint to which we are authenticating to. + :type endpoint: str + :param credential: The credential we use to authenticate to the service + :type credential: TokenCredential or str + :param isAsync: For async clients there is a need to decode the url + :type bool: isAsync or str + + :rtype: ~azure.core.pipeline.policies.BearerTokenCredentialPolicy + ~HMACCredentialsPolicy + """ + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if hasattr(credential, "get_token"): + from azure.core.pipeline.policies import BearerTokenCredentialPolicy + return BearerTokenCredentialPolicy( + credential, "https://communication.azure.com//.default") + if isinstance(credential, str): + from .._shared.policy import HMACCredentialsPolicy + return HMACCredentialsPolicy(endpoint, credential, decode_url=is_async) + + raise TypeError("Unsupported credential: {}. Use an access token string to use HMACCredentialsPolicy" + "or a token credential from azure.identity".format(type(credential))) diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/aio/__init__.py b/sdk/communication/azure-communication-identity/azure/communication/identity/aio/__init__.py new file mode 100644 index 000000000000..c2544f786cbf --- /dev/null +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/aio/__init__.py @@ -0,0 +1,5 @@ +from ._communication_identity_client_async import CommunicationIdentityClient + +__all__ = [ + 'CommunicationIdentityClient' +] diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_communication_identity_client_async.py b/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_communication_identity_client_async.py new file mode 100644 index 000000000000..8a9bc9523c1d --- /dev/null +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_communication_identity_client_async.py @@ -0,0 +1,168 @@ +# coding=utf-8 +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ + +from azure.core.tracing.decorator_async import distributed_trace_async + +from .._generated.aio._communication_identity_client\ + import CommunicationIdentityClient as CommunicationIdentityClientGen +from .._generated.models import CommunicationIdentityToken + +from .._shared.utils import parse_connection_str, get_authentication_policy +from .._shared.models import CommunicationUserIdentifier +from .._version import SDK_MONIKER + + +class CommunicationIdentityClient: + """Azure Communication Services Identity client. + + :param str endpoint: + The endpoint url for Azure Communication Service resource. + :param credential: + The credentials with which to authenticate. The value is an account + shared access key + + .. admonition:: Example: + + .. literalinclude:: ../../samples/identity_samples_async.py + :language: python + :dedent: 8 + """ + def __init__( + self, + endpoint, # type: str + credential, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + try: + if not endpoint.lower().startswith('http'): + endpoint = "https://" + endpoint + except AttributeError: + raise ValueError("Account URL must be a string.") + + if not credential: + raise ValueError( + "You need to provide account shared key to authenticate.") + + self._endpoint = endpoint + self._identity_service_client = CommunicationIdentityClientGen( + self._endpoint, + authentication_policy=get_authentication_policy(endpoint, credential, is_async=True), + sdk_moniker=SDK_MONIKER, + **kwargs) + + @classmethod + def from_connection_string( + cls, conn_str, # type: str + **kwargs # type: Any + ): # type: (...) -> CommunicationIdentityClient + """Create CommunicationIdentityClient from a Connection String. + + :param str conn_str: + A connection string to an Azure Communication Service resource. + :returns: Instance of CommunicationIdentityClient. + :rtype: ~azure.communication.aio.CommunicationIdentityClient + + .. admonition:: Example: + + .. literalinclude:: ../samples/identity_samples.py + :start-after: [START auth_from_connection_string] + :end-before: [END auth_from_connection_string] + :language: python + :dedent: 8 + :caption: Creating the CommunicationIdentityClient from a connection string. + """ + endpoint, access_key = parse_connection_str(conn_str) + + return cls(endpoint, access_key, **kwargs) + + @distributed_trace_async + async def create_user(self, **kwargs): + # type: (...) -> CommunicationUserIdentifier + """create a single Communication user + + return: CommunicationUserIdentifier + rtype: ~azure.communication.administration.CommunicationUserIdentifier + """ + return await self._identity_service_client.communication_identity.create( + cls=lambda pr, u, e: CommunicationUserIdentifier(u.id), + **kwargs) + + @distributed_trace_async + async def delete_user( + self, + communication_user, # type: CommunicationUserIdentifier + **kwargs # type: Any + ): + # type: (...) -> None + """Triggers revocation event for user and deletes all its data. + + :param communication_user: + Azure Communication User to delete + :type communication_user: ~azure.communication.administration.CommunicationUserIdentifier + :return: None + :rtype: None + """ + await self._identity_service_client.communication_identity.delete( + communication_user.identifier, **kwargs) + + @distributed_trace_async + async def issue_token( + self, + user, # type: CommunicationUserIdentifier + scopes, # type: List[str] + **kwargs # type: Any + ): + # type: (...) -> CommunicationIdentityToken + """Generates a new token for an identity. + + :param user: Azure Communication User + :type user: ~azure.communication.administration.CommunicationUserIdentifier + :param scopes: + List of scopes to be added to the token. + :type scopes: list[str] + :return: CommunicationIdentityToken + :rtype: ~azure.communication.administration.CommunicationIdentityToken + """ + return await self._identity_service_client.communication_identity.issue_token( + user.identifier, + scopes, + **kwargs) + + @distributed_trace_async + async def revoke_tokens( + self, + user, # type: CommunicationUserIdentifier + issued_before=None, # type: Optional[datetime.datetime] + **kwargs # type: Any + ): + # type: (...) -> None + """Schedule revocation of all tokens of an identity. + + :param user: Azure Communication User. + :type user: ~azure.communication.administration.CommunicationUserIdentifier + :param issued_before: All tokens that are issued prior to this time should get revoked. + :type issued_before: ~datetime.datetime + :return: None + :rtype: None + """ + return await self._identity_service_client.communication_identity.update( + user.identifier if user else None, + tokens_valid_from=issued_before, + **kwargs) + + async def __aenter__(self) -> "CommunicationIdentityClient": + await self._identity_service_client.__aenter__() + return self + + async def __aexit__(self, *args: "Any") -> None: + await self.close() + + async def close(self) -> None: + """Close the :class: + `~azure.communication.administration.aio.CommunicationIdentityClient` session. + """ + await self._identity_service_client.__aexit__() diff --git a/sdk/communication/azure-communication-identity/swagger/SWAGGER.md b/sdk/communication/azure-communication-identity/swagger/SWAGGER.md index afb35325536c..c44e83ad9eda 100644 --- a/sdk/communication/azure-communication-identity/swagger/SWAGGER.md +++ b/sdk/communication/azure-communication-identity/swagger/SWAGGER.md @@ -16,8 +16,8 @@ autorest ./SWAGGER.md ### Settings ``` yaml input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/8818a603b78a1355ba1647ab9cd4e3354cdc4b69/specification/communication/data-plane/Microsoft.CommunicationServicesIdentity/preview/2020-07-20-preview2/CommunicationIdentity.json -output-folder: ../azure/communication/administration/_identity/_generated/ -namespace: azure.communication.administration +output-folder: ../azure/communication/identity/_generated/ +namespace: azure.communication.identity license-header: MICROSOFT_MIT_NO_VERSION payload-flattening-threshold: 3 no-namespace-folders: true From 9801f74f35eabcf1029aaf0f95d82c4f3507e462 Mon Sep 17 00:00:00 2001 From: Bert Ong <823691+beltr0n@users.noreply.github.com> Date: Thu, 21 Jan 2021 16:32:53 -0800 Subject: [PATCH 04/33] add autorest generated files --- .../identity/_generated/__init__.py | 16 + .../_communication_identity_client.py | 60 ++++ .../identity/_generated/_configuration.py | 58 ++++ .../identity/_generated/aio/__init__.py | 10 + .../aio/_communication_identity_client.py | 52 ++++ .../identity/_generated/aio/_configuration.py | 52 ++++ .../_generated/aio/operations/__init__.py | 13 + .../_communication_identity_operations.py | 271 +++++++++++++++++ .../identity/_generated/models/__init__.py | 25 ++ .../identity/_generated/models/_models.py | 113 +++++++ .../identity/_generated/models/_models_py3.py | 126 ++++++++ .../_generated/operations/__init__.py | 13 + .../_communication_identity_operations.py | 279 ++++++++++++++++++ .../identity/_generated/py.typed | 1 + 14 files changed, 1089 insertions(+) create mode 100644 sdk/communication/azure-communication-identity/azure/communication/identity/_generated/__init__.py create mode 100644 sdk/communication/azure-communication-identity/azure/communication/identity/_generated/_communication_identity_client.py create mode 100644 sdk/communication/azure-communication-identity/azure/communication/identity/_generated/_configuration.py create mode 100644 sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/__init__.py create mode 100644 sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/_communication_identity_client.py create mode 100644 sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/_configuration.py create mode 100644 sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/operations/__init__.py create mode 100644 sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/operations/_communication_identity_operations.py create mode 100644 sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/__init__.py create mode 100644 sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/_models.py create mode 100644 sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/_models_py3.py create mode 100644 sdk/communication/azure-communication-identity/azure/communication/identity/_generated/operations/__init__.py create mode 100644 sdk/communication/azure-communication-identity/azure/communication/identity/_generated/operations/_communication_identity_operations.py create mode 100644 sdk/communication/azure-communication-identity/azure/communication/identity/_generated/py.typed diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/__init__.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/__init__.py new file mode 100644 index 000000000000..733b64f83c37 --- /dev/null +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/__init__.py @@ -0,0 +1,16 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._communication_identity_client import CommunicationIdentityClient +__all__ = ['CommunicationIdentityClient'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/_communication_identity_client.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/_communication_identity_client.py new file mode 100644 index 000000000000..9e20523636c1 --- /dev/null +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/_communication_identity_client.py @@ -0,0 +1,60 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING + +from azure.core import PipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + +from ._configuration import CommunicationIdentityClientConfiguration +from .operations import CommunicationIdentityOperations +from . import models + + +class CommunicationIdentityClient(object): + """Azure Communication Identity Service. + + :ivar communication_identity: CommunicationIdentityOperations operations + :vartype communication_identity: azure.communication.identity.operations.CommunicationIdentityOperations + :param endpoint: Auth and Identity endpoint. + :type endpoint: str + """ + + def __init__( + self, + endpoint, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + base_url = '{endpoint}' + self._config = CommunicationIdentityClientConfiguration(endpoint, **kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.communication_identity = CommunicationIdentityOperations( + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> CommunicationIdentityClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/_configuration.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/_configuration.py new file mode 100644 index 000000000000..079f98f2ffd0 --- /dev/null +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/_configuration.py @@ -0,0 +1,58 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + +VERSION = "unknown" + +class CommunicationIdentityClientConfiguration(Configuration): + """Configuration for CommunicationIdentityClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: Auth and Identity endpoint. + :type endpoint: str + """ + + def __init__( + self, + endpoint, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + if endpoint is None: + raise ValueError("Parameter 'endpoint' must not be None.") + super(CommunicationIdentityClientConfiguration, self).__init__(**kwargs) + + self.endpoint = endpoint + self.api_version = "2020-07-20-preview2" + kwargs.setdefault('sdk_moniker', 'communicationidentityclient/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/__init__.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/__init__.py new file mode 100644 index 000000000000..198816835b24 --- /dev/null +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/__init__.py @@ -0,0 +1,10 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._communication_identity_client import CommunicationIdentityClient +__all__ = ['CommunicationIdentityClient'] diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/_communication_identity_client.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/_communication_identity_client.py new file mode 100644 index 000000000000..998d60b4c35b --- /dev/null +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/_communication_identity_client.py @@ -0,0 +1,52 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any + +from azure.core import AsyncPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration import CommunicationIdentityClientConfiguration +from .operations import CommunicationIdentityOperations +from .. import models + + +class CommunicationIdentityClient(object): + """Azure Communication Identity Service. + + :ivar communication_identity: CommunicationIdentityOperations operations + :vartype communication_identity: azure.communication.identity.aio.operations.CommunicationIdentityOperations + :param endpoint: Auth and Identity endpoint. + :type endpoint: str + """ + + def __init__( + self, + endpoint: str, + **kwargs: Any + ) -> None: + base_url = '{endpoint}' + self._config = CommunicationIdentityClientConfiguration(endpoint, **kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.communication_identity = CommunicationIdentityOperations( + self._client, self._config, self._serialize, self._deserialize) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "CommunicationIdentityClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/_configuration.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/_configuration.py new file mode 100644 index 000000000000..4b91da974fe0 --- /dev/null +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/_configuration.py @@ -0,0 +1,52 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +VERSION = "unknown" + +class CommunicationIdentityClientConfiguration(Configuration): + """Configuration for CommunicationIdentityClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: Auth and Identity endpoint. + :type endpoint: str + """ + + def __init__( + self, + endpoint: str, + **kwargs: Any + ) -> None: + if endpoint is None: + raise ValueError("Parameter 'endpoint' must not be None.") + super(CommunicationIdentityClientConfiguration, self).__init__(**kwargs) + + self.endpoint = endpoint + self.api_version = "2020-07-20-preview2" + kwargs.setdefault('sdk_moniker', 'communicationidentityclient/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/operations/__init__.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/operations/__init__.py new file mode 100644 index 000000000000..09dd0f2d0661 --- /dev/null +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/operations/__init__.py @@ -0,0 +1,13 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._communication_identity_operations import CommunicationIdentityOperations + +__all__ = [ + 'CommunicationIdentityOperations', +] diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/operations/_communication_identity_operations.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/operations/_communication_identity_operations.py new file mode 100644 index 000000000000..b1143a98ca01 --- /dev/null +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/operations/_communication_identity_operations.py @@ -0,0 +1,271 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import datetime +from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class CommunicationIdentityOperations: + """CommunicationIdentityOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.communication.identity.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def create( + self, + **kwargs + ) -> "_models.CommunicationIdentity": + """Create a new identity. + + Create a new identity. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CommunicationIdentity, or the result of cls(response) + :rtype: ~azure.communication.identity.models.CommunicationIdentity + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunicationIdentity"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-20-preview2" + accept = "application/json" + + # Construct URL + url = self.create.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('CommunicationIdentity', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create.metadata = {'url': '/identities'} # type: ignore + + async def delete( + self, + id: str, + **kwargs + ) -> None: + """Delete the identity, revoke all tokens of the identity and delete all associated data. + + Delete the identity, revoke all tokens of the identity and delete all associated data. + + :param id: Identifier of the identity to be deleted. + :type id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-20-preview2" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'id': self._serialize.url("id", id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/identities/{id}'} # type: ignore + + async def update( + self, + id: str, + tokens_valid_from: Optional[datetime.datetime] = None, + **kwargs + ) -> None: + """Update an Identity. + + Update an Identity. + + :param id: Identifier of the identity. + :type id: str + :param tokens_valid_from: All tokens that are issued prior to this time will be revoked. + :type tokens_valid_from: ~datetime.datetime + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _body = _models.CommunicationIdentityUpdateRequest(tokens_valid_from=tokens_valid_from) + api_version = "2020-07-20-preview2" + content_type = kwargs.pop("content_type", "application/merge-patch+json") + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'id': self._serialize.url("id", id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_body, 'CommunicationIdentityUpdateRequest') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + update.metadata = {'url': '/identities/{id}'} # type: ignore + + async def issue_token( + self, + id: str, + scopes: List[str], + **kwargs + ) -> "_models.CommunicationIdentityToken": + """Generate a new token for an identity. + + Generate a new token for an identity. + + :param id: Identifier of the identity to issue token for. + :type id: str + :param scopes: List of scopes attached to the token. + :type scopes: list[str] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CommunicationIdentityToken, or the result of cls(response) + :rtype: ~azure.communication.identity.models.CommunicationIdentityToken + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunicationIdentityToken"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _body = _models.CommunicationTokenRequest(scopes=scopes) + api_version = "2020-07-20-preview2" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.issue_token.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'id': self._serialize.url("id", id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_body, 'CommunicationTokenRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('CommunicationIdentityToken', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + issue_token.metadata = {'url': '/identities/{id}/token'} # type: ignore diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/__init__.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/__init__.py new file mode 100644 index 000000000000..05dd3d4b6aab --- /dev/null +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/__init__.py @@ -0,0 +1,25 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import CommunicationIdentity + from ._models_py3 import CommunicationIdentityToken + from ._models_py3 import CommunicationIdentityUpdateRequest + from ._models_py3 import CommunicationTokenRequest +except (SyntaxError, ImportError): + from ._models import CommunicationIdentity # type: ignore + from ._models import CommunicationIdentityToken # type: ignore + from ._models import CommunicationIdentityUpdateRequest # type: ignore + from ._models import CommunicationTokenRequest # type: ignore + +__all__ = [ + 'CommunicationIdentity', + 'CommunicationIdentityToken', + 'CommunicationIdentityUpdateRequest', + 'CommunicationTokenRequest', +] diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/_models.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/_models.py new file mode 100644 index 000000000000..ce2106c91807 --- /dev/null +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/_models.py @@ -0,0 +1,113 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import msrest.serialization + + +class CommunicationIdentity(msrest.serialization.Model): + """A communication identity. + + All required parameters must be populated in order to send to Azure. + + :param id: Required. Identifier of the identity. + :type id: str + """ + + _validation = { + 'id': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CommunicationIdentity, self).__init__(**kwargs) + self.id = kwargs['id'] + + +class CommunicationIdentityToken(msrest.serialization.Model): + """CommunicationIdentityToken. + + All required parameters must be populated in order to send to Azure. + + :param id: Required. Identifier of the identity owning the token. + :type id: str + :param token: Required. The token issued for the identity. + :type token: str + :param expires_on: Required. The expiry time of the token. + :type expires_on: ~datetime.datetime + """ + + _validation = { + 'id': {'required': True}, + 'token': {'required': True}, + 'expires_on': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'token': {'key': 'token', 'type': 'str'}, + 'expires_on': {'key': 'expiresOn', 'type': 'iso-8601'}, + } + + def __init__( + self, + **kwargs + ): + super(CommunicationIdentityToken, self).__init__(**kwargs) + self.id = kwargs['id'] + self.token = kwargs['token'] + self.expires_on = kwargs['expires_on'] + + +class CommunicationIdentityUpdateRequest(msrest.serialization.Model): + """CommunicationIdentityUpdateRequest. + + :param tokens_valid_from: All tokens that are issued prior to this time will be revoked. + :type tokens_valid_from: ~datetime.datetime + """ + + _attribute_map = { + 'tokens_valid_from': {'key': 'tokensValidFrom', 'type': 'iso-8601'}, + } + + def __init__( + self, + **kwargs + ): + super(CommunicationIdentityUpdateRequest, self).__init__(**kwargs) + self.tokens_valid_from = kwargs.get('tokens_valid_from', None) + + +class CommunicationTokenRequest(msrest.serialization.Model): + """CommunicationTokenRequest. + + All required parameters must be populated in order to send to Azure. + + :param scopes: Required. List of scopes attached to the token. + :type scopes: list[str] + """ + + _validation = { + 'scopes': {'required': True}, + } + + _attribute_map = { + 'scopes': {'key': 'scopes', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + super(CommunicationTokenRequest, self).__init__(**kwargs) + self.scopes = kwargs['scopes'] diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/_models_py3.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/_models_py3.py new file mode 100644 index 000000000000..ba3988b1589a --- /dev/null +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/_models_py3.py @@ -0,0 +1,126 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import datetime +from typing import List, Optional + +import msrest.serialization + + +class CommunicationIdentity(msrest.serialization.Model): + """A communication identity. + + All required parameters must be populated in order to send to Azure. + + :param id: Required. Identifier of the identity. + :type id: str + """ + + _validation = { + 'id': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + *, + id: str, + **kwargs + ): + super(CommunicationIdentity, self).__init__(**kwargs) + self.id = id + + +class CommunicationIdentityToken(msrest.serialization.Model): + """CommunicationIdentityToken. + + All required parameters must be populated in order to send to Azure. + + :param id: Required. Identifier of the identity owning the token. + :type id: str + :param token: Required. The token issued for the identity. + :type token: str + :param expires_on: Required. The expiry time of the token. + :type expires_on: ~datetime.datetime + """ + + _validation = { + 'id': {'required': True}, + 'token': {'required': True}, + 'expires_on': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'token': {'key': 'token', 'type': 'str'}, + 'expires_on': {'key': 'expiresOn', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + id: str, + token: str, + expires_on: datetime.datetime, + **kwargs + ): + super(CommunicationIdentityToken, self).__init__(**kwargs) + self.id = id + self.token = token + self.expires_on = expires_on + + +class CommunicationIdentityUpdateRequest(msrest.serialization.Model): + """CommunicationIdentityUpdateRequest. + + :param tokens_valid_from: All tokens that are issued prior to this time will be revoked. + :type tokens_valid_from: ~datetime.datetime + """ + + _attribute_map = { + 'tokens_valid_from': {'key': 'tokensValidFrom', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + tokens_valid_from: Optional[datetime.datetime] = None, + **kwargs + ): + super(CommunicationIdentityUpdateRequest, self).__init__(**kwargs) + self.tokens_valid_from = tokens_valid_from + + +class CommunicationTokenRequest(msrest.serialization.Model): + """CommunicationTokenRequest. + + All required parameters must be populated in order to send to Azure. + + :param scopes: Required. List of scopes attached to the token. + :type scopes: list[str] + """ + + _validation = { + 'scopes': {'required': True}, + } + + _attribute_map = { + 'scopes': {'key': 'scopes', 'type': '[str]'}, + } + + def __init__( + self, + *, + scopes: List[str], + **kwargs + ): + super(CommunicationTokenRequest, self).__init__(**kwargs) + self.scopes = scopes diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/operations/__init__.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/operations/__init__.py new file mode 100644 index 000000000000..09dd0f2d0661 --- /dev/null +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/operations/__init__.py @@ -0,0 +1,13 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._communication_identity_operations import CommunicationIdentityOperations + +__all__ = [ + 'CommunicationIdentityOperations', +] diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/operations/_communication_identity_operations.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/operations/_communication_identity_operations.py new file mode 100644 index 000000000000..745b0e36a4f3 --- /dev/null +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/operations/_communication_identity_operations.py @@ -0,0 +1,279 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import datetime +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class CommunicationIdentityOperations(object): + """CommunicationIdentityOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.communication.identity.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def create( + self, + **kwargs # type: Any + ): + # type: (...) -> "_models.CommunicationIdentity" + """Create a new identity. + + Create a new identity. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CommunicationIdentity, or the result of cls(response) + :rtype: ~azure.communication.identity.models.CommunicationIdentity + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunicationIdentity"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-20-preview2" + accept = "application/json" + + # Construct URL + url = self.create.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('CommunicationIdentity', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create.metadata = {'url': '/identities'} # type: ignore + + def delete( + self, + id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Delete the identity, revoke all tokens of the identity and delete all associated data. + + Delete the identity, revoke all tokens of the identity and delete all associated data. + + :param id: Identifier of the identity to be deleted. + :type id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-20-preview2" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'id': self._serialize.url("id", id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/identities/{id}'} # type: ignore + + def update( + self, + id, # type: str + tokens_valid_from=None, # type: Optional[datetime.datetime] + **kwargs # type: Any + ): + # type: (...) -> None + """Update an Identity. + + Update an Identity. + + :param id: Identifier of the identity. + :type id: str + :param tokens_valid_from: All tokens that are issued prior to this time will be revoked. + :type tokens_valid_from: ~datetime.datetime + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _body = _models.CommunicationIdentityUpdateRequest(tokens_valid_from=tokens_valid_from) + api_version = "2020-07-20-preview2" + content_type = kwargs.pop("content_type", "application/merge-patch+json") + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'id': self._serialize.url("id", id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_body, 'CommunicationIdentityUpdateRequest') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + update.metadata = {'url': '/identities/{id}'} # type: ignore + + def issue_token( + self, + id, # type: str + scopes, # type: List[str] + **kwargs # type: Any + ): + # type: (...) -> "_models.CommunicationIdentityToken" + """Generate a new token for an identity. + + Generate a new token for an identity. + + :param id: Identifier of the identity to issue token for. + :type id: str + :param scopes: List of scopes attached to the token. + :type scopes: list[str] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CommunicationIdentityToken, or the result of cls(response) + :rtype: ~azure.communication.identity.models.CommunicationIdentityToken + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunicationIdentityToken"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _body = _models.CommunicationTokenRequest(scopes=scopes) + api_version = "2020-07-20-preview2" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.issue_token.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'id': self._serialize.url("id", id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_body, 'CommunicationTokenRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('CommunicationIdentityToken', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + issue_token.metadata = {'url': '/identities/{id}/token'} # type: ignore diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/py.typed b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file From 114167627d6edb84848fd7912bac29fee4dbb4ed Mon Sep 17 00:00:00 2001 From: Bert Ong <823691+beltr0n@users.noreply.github.com> Date: Thu, 21 Jan 2021 16:44:57 -0800 Subject: [PATCH 05/33] copy samples over --- .../samples/identity_samples.py | 81 ++++++++++++++++ .../samples/identity_samples_async.py | 93 +++++++++++++++++++ 2 files changed, 174 insertions(+) create mode 100644 sdk/communication/azure-communication-identity/samples/identity_samples.py create mode 100644 sdk/communication/azure-communication-identity/samples/identity_samples_async.py diff --git a/sdk/communication/azure-communication-identity/samples/identity_samples.py b/sdk/communication/azure-communication-identity/samples/identity_samples.py new file mode 100644 index 000000000000..cf28e9fe18e8 --- /dev/null +++ b/sdk/communication/azure-communication-identity/samples/identity_samples.py @@ -0,0 +1,81 @@ +# 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. +# -------------------------------------------------------------------------- + +""" +FILE: identity_sample.py +DESCRIPTION: + These samples demonstrate identity client samples. + + ///authenticating a client via a connection string +USAGE: + python identity_samples.py +""" +import os + +class CommunicationIdentityClientSamples(object): + + def __init__(self): + self.connection_string = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') + self.endpoint = os.getenv('AZURE_COMMUNICATION_SERVICE_ENDPOINT') + self.client_id = os.getenv('AZURE_CLIENT_ID') + self.client_secret = os.getenv('AZURE_CLIENT_SECRET') + self.tenant_id = os.getnenv('AZURE_TENANT_ID') + + def issue_token(self): + from azure.communication.identity import CommunicationIdentityClient + + if self.client_id is not None and self.client_secret is not None and self.tenant_id is not None: + from azure.identity import DefaultAzureCredential + identity_client = CommunicationIdentityClient(self.endpoint, DefaultAzureCredential()) + else: + identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) + user = identity_client.create_user() + tokenresponse = identity_client.issue_token(user, scopes=["chat"]) + print(tokenresponse) + + def revoke_tokens(self): + from azure.communication.identity import CommunicationIdentityClient + + if self.client_id is not None and self.client_secret is not None and self.tenant_id is not None: + from azure.identity import DefaultAzureCredential + identity_client = CommunicationIdentityClient(self.endpoint, DefaultAzureCredential()) + else: + identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) + user = identity_client.create_user() + tokenresponse = identity_client.issue_token(user, scopes=["chat"]) + identity_client.revoke_tokens(user) + print(tokenresponse) + + def create_user(self): + from azure.communication.identity import CommunicationIdentityClient + + if self.client_id is not None and self.client_secret is not None and self.tenant_id is not None: + from azure.identity import DefaultAzureCredential + identity_client = CommunicationIdentityClient(self.endpoint, DefaultAzureCredential()) + else: + identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) + user = identity_client.create_user() + print(user.identifier) + + def delete_user(self): + from azure.communication.identity import CommunicationIdentityClient + + if self.client_id is not None and self.client_secret is not None and self.tenant_id is not None: + from azure.identity import DefaultAzureCredential + identity_client = CommunicationIdentityClient(self.endpoint, DefaultAzureCredential()) + else: + identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) + user = identity_client.create_user() + identity_client.delete_user(user) + +if __name__ == '__main__': + sample = CommunicationIdentityClientSamples() + sample.create_user() + sample.delete_user() + sample.issue_token() + sample.revoke_tokens() diff --git a/sdk/communication/azure-communication-identity/samples/identity_samples_async.py b/sdk/communication/azure-communication-identity/samples/identity_samples_async.py new file mode 100644 index 000000000000..2b2b8e17b992 --- /dev/null +++ b/sdk/communication/azure-communication-identity/samples/identity_samples_async.py @@ -0,0 +1,93 @@ +# 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. +# -------------------------------------------------------------------------- + +""" +FILE: identity_sample_async.py +DESCRIPTION: + These samples demonstrate async identity client samples. + + ///authenticating a client via a connection string +USAGE: + python identity_samples_async.py +""" + +import asyncio +import os + + +class CommunicationIdentityClientSamples(object): + + def __init__(self): + self.connection_string = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') + self.endpoint = os.getenv('AZURE_COMMUNICATION_SERVICE_ENDPOINT') + self.client_id = os.getenv('AZURE_CLIENT_ID') + self.client_secret = os.getenv('AZURE_CLIENT_SECRET') + self.tenant_id = os.getnenv('AZURE_TENANT_ID') + + async def issue_token(self): + from azure.communication.identity.aio import CommunicationIdentityClient + if self.client_id is not None and self.client_secret is not None and self.tenant_id is not None: + from azure.identity import DefaultAzureCredential + identity_client = CommunicationIdentityClient(self.endpoint, DefaultAzureCredential()) + else: + identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) + + async with identity_client: + user = await identity_client.create_user() + print(user.identifier) + tokenresponse = await identity_client.issue_token(user, scopes=["chat"]) + print(tokenresponse) + + async def revoke_tokens(self): + from azure.communication.identity.aio import CommunicationIdentityClient + if self.client_id is not None and self.client_secret is not None and self.tenant_id is not None: + from azure.identity import DefaultAzureCredential + identity_client = CommunicationIdentityClient(self.endpoint, DefaultAzureCredential()) + else: + identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) + + async with identity_client: + user = await identity_client.create_user() + tokenresponse = await identity_client.issue_token(user, scopes=["chat"]) + await identity_client.revoke_tokens(user) + print(tokenresponse) + + async def create_user(self): + from azure.communication.identity.aio import CommunicationIdentityClient + if self.client_id is not None and self.client_secret is not None and self.tenant_id is not None: + from azure.identity import DefaultAzureCredential + identity_client = CommunicationIdentityClient(self.endpoint, DefaultAzureCredential()) + else: + identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) + + async with identity_client: + user = await identity_client.create_user() + print(user.identifier) + + async def delete_user(self): + from azure.communication.identity.aio import CommunicationIdentityClient + if self.client_id is not None and self.client_secret is not None and self.tenant_id is not None: + from azure.identity import DefaultAzureCredential + identity_client = CommunicationIdentityClient(self.endpoint, DefaultAzureCredential()) + else: + identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) + + async with identity_client: + user = await identity_client.create_user() + await identity_client.delete_user(user) + +async def main(): + sample = CommunicationIdentityClientSamples() + await sample.create_user() + await sample.delete_user() + await sample.issue_token() + await sample.revoke_tokens() + +if __name__ == '__main__': + loop = asyncio.get_event_loop() + loop.run_until_complete(main()) From bbda113be0696de7437332e58814a2422be520ac Mon Sep 17 00:00:00 2001 From: Bert Ong <823691+beltr0n@users.noreply.github.com> Date: Thu, 21 Jan 2021 16:53:14 -0800 Subject: [PATCH 06/33] update references in other packages --- .../azure-communication-chat/samples/chat_client_sample.py | 2 +- .../samples/chat_client_sample_async.py | 2 +- .../samples/chat_thread_client_sample.py | 2 +- .../samples/chat_thread_client_sample_async.py | 2 +- .../azure-communication-chat/tests/test_chat_client_e2e.py | 2 +- .../tests/test_chat_client_e2e_async.py | 4 ++-- .../tests/test_chat_thread_client_e2e.py | 2 +- .../tests/test_chat_thread_client_e2e_async.py | 4 ++-- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/sdk/communication/azure-communication-chat/samples/chat_client_sample.py b/sdk/communication/azure-communication-chat/samples/chat_client_sample.py index ec6746fb2120..25963095f8fd 100644 --- a/sdk/communication/azure-communication-chat/samples/chat_client_sample.py +++ b/sdk/communication/azure-communication-chat/samples/chat_client_sample.py @@ -27,7 +27,7 @@ class ChatClientSamples(object): - from azure.communication.administration import CommunicationIdentityClient + from azure.communication.identity import CommunicationIdentityClient connection_string = os.environ.get("AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING", None) if not connection_string: raise ValueError("Set AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING env before run this sample.") diff --git a/sdk/communication/azure-communication-chat/samples/chat_client_sample_async.py b/sdk/communication/azure-communication-chat/samples/chat_client_sample_async.py index 7c22b5d8acb2..fc8874226f8b 100644 --- a/sdk/communication/azure-communication-chat/samples/chat_client_sample_async.py +++ b/sdk/communication/azure-communication-chat/samples/chat_client_sample_async.py @@ -27,7 +27,7 @@ class ChatClientSamplesAsync(object): - from azure.communication.administration import CommunicationIdentityClient + from azure.communication.identity import CommunicationIdentityClient connection_string = os.environ.get("AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING", None) if not connection_string: raise ValueError("Set AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING env before run this sample.") diff --git a/sdk/communication/azure-communication-chat/samples/chat_thread_client_sample.py b/sdk/communication/azure-communication-chat/samples/chat_thread_client_sample.py index c20ba6be0977..8ba955777a08 100644 --- a/sdk/communication/azure-communication-chat/samples/chat_thread_client_sample.py +++ b/sdk/communication/azure-communication-chat/samples/chat_thread_client_sample.py @@ -27,7 +27,7 @@ class ChatThreadClientSamples(object): - from azure.communication.administration import CommunicationIdentityClient + from azure.communication.identity import CommunicationIdentityClient connection_string = os.environ.get("AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING", None) if not connection_string: raise ValueError("Set AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING env before run this sample.") diff --git a/sdk/communication/azure-communication-chat/samples/chat_thread_client_sample_async.py b/sdk/communication/azure-communication-chat/samples/chat_thread_client_sample_async.py index 129c2c057e44..135fd274970c 100644 --- a/sdk/communication/azure-communication-chat/samples/chat_thread_client_sample_async.py +++ b/sdk/communication/azure-communication-chat/samples/chat_thread_client_sample_async.py @@ -28,7 +28,7 @@ class ChatThreadClientSamplesAsync(object): - from azure.communication.administration import CommunicationIdentityClient + from azure.communication.identity import CommunicationIdentityClient connection_string = os.environ.get("AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING", None) if not connection_string: raise ValueError("Set AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING env before run this sample.") diff --git a/sdk/communication/azure-communication-chat/tests/test_chat_client_e2e.py b/sdk/communication/azure-communication-chat/tests/test_chat_client_e2e.py index f0b4a5189d80..0036d0b263f4 100644 --- a/sdk/communication/azure-communication-chat/tests/test_chat_client_e2e.py +++ b/sdk/communication/azure-communication-chat/tests/test_chat_client_e2e.py @@ -10,7 +10,7 @@ from devtools_testutils import AzureTestCase from msrest.serialization import TZ_UTC -from azure.communication.administration import CommunicationIdentityClient +from azure.communication.identity import CommunicationIdentityClient from azure.communication.chat import ( ChatClient, CommunicationTokenCredential, diff --git a/sdk/communication/azure-communication-chat/tests/test_chat_client_e2e_async.py b/sdk/communication/azure-communication-chat/tests/test_chat_client_e2e_async.py index a3fe1a3750d4..72f727dcaeec 100644 --- a/sdk/communication/azure-communication-chat/tests/test_chat_client_e2e_async.py +++ b/sdk/communication/azure-communication-chat/tests/test_chat_client_e2e_async.py @@ -9,7 +9,7 @@ from datetime import datetime from msrest.serialization import TZ_UTC -from azure.communication.administration import CommunicationIdentityClient +from azure.communication.identity import CommunicationIdentityClient from azure.communication.chat.aio import ( ChatClient, CommunicationTokenCredential, @@ -18,7 +18,7 @@ from azure.communication.chat import ( ChatThreadMember ) -from azure.communication.administration._shared.utils import parse_connection_str +from azure.communication.identity._shared.utils import parse_connection_str from azure_devtools.scenario_tests import RecordingProcessor from helper import URIIdentityReplacer from chat_e2e_helper import ChatURIReplacer diff --git a/sdk/communication/azure-communication-chat/tests/test_chat_thread_client_e2e.py b/sdk/communication/azure-communication-chat/tests/test_chat_thread_client_e2e.py index 9a90b1a79662..eadf9f8114ab 100644 --- a/sdk/communication/azure-communication-chat/tests/test_chat_thread_client_e2e.py +++ b/sdk/communication/azure-communication-chat/tests/test_chat_thread_client_e2e.py @@ -10,7 +10,7 @@ from devtools_testutils import AzureTestCase from msrest.serialization import TZ_UTC -from azure.communication.administration import CommunicationIdentityClient +from azure.communication.identity import CommunicationIdentityClient from azure.communication.chat import ( ChatClient, CommunicationTokenCredential, diff --git a/sdk/communication/azure-communication-chat/tests/test_chat_thread_client_e2e_async.py b/sdk/communication/azure-communication-chat/tests/test_chat_thread_client_e2e_async.py index 7c0c6c7b80cc..e3deffa02236 100644 --- a/sdk/communication/azure-communication-chat/tests/test_chat_thread_client_e2e_async.py +++ b/sdk/communication/azure-communication-chat/tests/test_chat_thread_client_e2e_async.py @@ -9,7 +9,7 @@ from datetime import datetime from msrest.serialization import TZ_UTC -from azure.communication.administration import CommunicationIdentityClient +from azure.communication.identity import CommunicationIdentityClient from azure.communication.chat.aio import ( ChatClient, CommunicationTokenCredential, @@ -19,7 +19,7 @@ ChatThreadMember, ChatMessagePriority ) -from azure.communication.administration._shared.utils import parse_connection_str +from azure.communication.identity._shared.utils import parse_connection_str from azure_devtools.scenario_tests import RecordingProcessor from helper import URIIdentityReplacer from chat_e2e_helper import ChatURIReplacer From 98902d85b045205667b06ffd6b1af0d22e0e3d17 Mon Sep 17 00:00:00 2001 From: Lakshman Sundaralingam Date: Thu, 21 Jan 2021 16:57:35 -0800 Subject: [PATCH 07/33] Added tests to identity package --- .../tests/_shared/__init__.py | 6 + .../tests/_shared/asynctestcase.py | 27 ++++ .../_shared/communication_service_preparer.py | 89 +++++++++++ .../tests/_shared/helper.py | 19 +++ .../tests/_shared/testcase.py | 69 +++++++++ .../tests/conftest.py | 11 ++ ...tion_identity_client.test_create_user.yaml | 42 ++++++ ...est_create_user_from_managed_identity.yaml | 38 +++++ ...tion_identity_client.test_delete_user.yaml | 78 ++++++++++ ...est_delete_user_from_managed_identity.yaml | 70 +++++++++ ...tion_identity_client.test_issue_token.yaml | 84 +++++++++++ ...est_issue_token_from_managed_identity.yaml | 76 ++++++++++ ...on_identity_client.test_revoke_tokens.yaml | 122 +++++++++++++++ ...t_revoke_tokens_from_managed_identity.yaml | 110 ++++++++++++++ ...dentity_client_async.test_create_user.yaml | 30 ++++ ...est_create_user_from_managed_identity.yaml | 26 ++++ ...dentity_client_async.test_delete_user.yaml | 54 +++++++ ...est_delete_user_from_managed_identity.yaml | 46 ++++++ ...dentity_client_async.test_issue_token.yaml | 62 ++++++++ ...est_issue_token_from_managed_identity.yaml | 54 +++++++ ...ntity_client_async.test_revoke_tokens.yaml | 90 +++++++++++ ...t_revoke_tokens_from_managed_identity.yaml | 78 ++++++++++ .../test_communication_identity_client.py | 141 ++++++++++++++++++ ...est_communication_identity_client_async.py | 138 +++++++++++++++++ .../tests/user_credential_tests.py | 61 ++++++++ 25 files changed, 1621 insertions(+) create mode 100644 sdk/communication/azure-communication-identity/tests/_shared/__init__.py create mode 100644 sdk/communication/azure-communication-identity/tests/_shared/asynctestcase.py create mode 100644 sdk/communication/azure-communication-identity/tests/_shared/communication_service_preparer.py create mode 100644 sdk/communication/azure-communication-identity/tests/_shared/helper.py create mode 100644 sdk/communication/azure-communication-identity/tests/_shared/testcase.py create mode 100644 sdk/communication/azure-communication-identity/tests/conftest.py create mode 100644 sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_create_user.yaml create mode 100644 sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_create_user_from_managed_identity.yaml create mode 100644 sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_delete_user.yaml create mode 100644 sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_delete_user_from_managed_identity.yaml create mode 100644 sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_issue_token.yaml create mode 100644 sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_issue_token_from_managed_identity.yaml create mode 100644 sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_revoke_tokens.yaml create mode 100644 sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_revoke_tokens_from_managed_identity.yaml create mode 100644 sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_create_user.yaml create mode 100644 sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_create_user_from_managed_identity.yaml create mode 100644 sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_delete_user.yaml create mode 100644 sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_delete_user_from_managed_identity.yaml create mode 100644 sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_issue_token.yaml create mode 100644 sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_issue_token_from_managed_identity.yaml create mode 100644 sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_revoke_tokens.yaml create mode 100644 sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_revoke_tokens_from_managed_identity.yaml create mode 100644 sdk/communication/azure-communication-identity/tests/test_communication_identity_client.py create mode 100644 sdk/communication/azure-communication-identity/tests/test_communication_identity_client_async.py create mode 100644 sdk/communication/azure-communication-identity/tests/user_credential_tests.py diff --git a/sdk/communication/azure-communication-identity/tests/_shared/__init__.py b/sdk/communication/azure-communication-identity/tests/_shared/__init__.py new file mode 100644 index 000000000000..841b812e10ba --- /dev/null +++ b/sdk/communication/azure-communication-identity/tests/_shared/__init__.py @@ -0,0 +1,6 @@ +# 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. +# -------------------------------------------------------------------------- \ No newline at end of file diff --git a/sdk/communication/azure-communication-identity/tests/_shared/asynctestcase.py b/sdk/communication/azure-communication-identity/tests/_shared/asynctestcase.py new file mode 100644 index 000000000000..197c48e0079b --- /dev/null +++ b/sdk/communication/azure-communication-identity/tests/_shared/asynctestcase.py @@ -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. +# -------------------------------------------------------------------------- +import functools +import asyncio +from azure_devtools.scenario_tests.utilities import trim_kwargs_from_test_function +from .testcase import CommunicationTestCase + +class AsyncCommunicationTestCase(CommunicationTestCase): + + @staticmethod + def await_prepared_test(test_fn): + """Synchronous wrapper for async test methods. Used to avoid making changes + upstream to AbstractPreparer (which doesn't await the functions it wraps) + """ + + @functools.wraps(test_fn) + def run(test_class_instance, *args, **kwargs): + trim_kwargs_from_test_function(test_fn, kwargs) + loop = asyncio.get_event_loop() + return loop.run_until_complete(test_fn(test_class_instance, **kwargs)) + + return run diff --git a/sdk/communication/azure-communication-identity/tests/_shared/communication_service_preparer.py b/sdk/communication/azure-communication-identity/tests/_shared/communication_service_preparer.py new file mode 100644 index 000000000000..e3907ff011e0 --- /dev/null +++ b/sdk/communication/azure-communication-identity/tests/_shared/communication_service_preparer.py @@ -0,0 +1,89 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ + +import datetime + +from azure.mgmt.communication import CommunicationServiceManagementClient +from azure.mgmt.communication.models import CommunicationServiceResource +from devtools_testutils import( + AzureMgmtPreparer, + ResourceGroupPreparer, + FakeResource +) +from devtools_testutils.resource_testcase import RESOURCE_GROUP_PARAM +from azure_devtools.scenario_tests.exceptions import AzureTestError + +class CommunicationServicePreparer(AzureMgmtPreparer): + """Communication Service Preparer. + Creating and destroying test resources on demand + """ + def __init__( + self, + name_prefix="communication", + resource_group_parameter_name=RESOURCE_GROUP_PARAM, + disable_recording=True, + use_cache=False, + playback_fake_resource=None, + client_kwargs=None, + ): + super(CommunicationServicePreparer, self).__init__( + name_prefix, + random_name_length=24, + disable_recording=disable_recording, + playback_fake_resource=playback_fake_resource, + client_kwargs=client_kwargs, + ) + self.resource_group_parameter_name = resource_group_parameter_name + self.random_name_enabled = True + self.service_name = "TEST-SERVICE-NAME" + self.mgmt_client = None + self.set_cache(use_cache) + self.scrubbed_resource_name = "communicationegrcrs" + + def _get_resource_group(self, **kwargs): + try: + return kwargs[self.resource_group_parameter_name] + except KeyError: + template = ( + "To create a communication service a resource group is required. Please add " + "decorator @{} in front of this preparer." + ) + raise AzureTestError(template.format(ResourceGroupPreparer.__name__)) + + def create_resource(self, name, **kwargs): + if not self.is_live: + self.resource = FakeResource(name=self.scrubbed_resource_name, id=name) + + return { + "connection_string": "endpoint=https://{}.communication.azure.com/;accesskey=fake===".format(self.resource.name), + } + + self.test_class_instance.scrubber.register_name_pair(name, self.scrubbed_resource_name) + group_name = self._get_resource_group(**kwargs).name + + self.client = self.create_mgmt_client(CommunicationServiceManagementClient, polling_interval=30) + + self.resource = self.client.communication_service.begin_create_or_update( + group_name, + name, + CommunicationServiceResource(location="global", data_location="UnitedStates") + ).result() + + self.service_name = self.resource.name + + primary_connection_string = self.client.communication_service.list_keys( + group_name, + self.resource.name).primary_connection_string + + return { + "connection_string": primary_connection_string, + } + + def remove_resource(self, name, **kwargs): + if not self.is_live: + return + + group_name = self._get_resource_group(**kwargs).name + self.client.communication_service.begin_delete(group_name, self.service_name).wait() diff --git a/sdk/communication/azure-communication-identity/tests/_shared/helper.py b/sdk/communication/azure-communication-identity/tests/_shared/helper.py new file mode 100644 index 000000000000..7338f10940a0 --- /dev/null +++ b/sdk/communication/azure-communication-identity/tests/_shared/helper.py @@ -0,0 +1,19 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from azure_devtools.scenario_tests import RecordingProcessor + +class URIIdentityReplacer(RecordingProcessor): + """Replace the identity in request uri""" + def process_request(self, request): + import re + request.uri = re.sub('/identities/([^/?]+)', '/identities/sanitized', request.uri) + return request + + def process_response(self, response): + import re + if 'url' in response: + response['url'] = re.sub('/identities/([^/?]+)', '/identities/sanitized', response['url']) + return response \ No newline at end of file diff --git a/sdk/communication/azure-communication-identity/tests/_shared/testcase.py b/sdk/communication/azure-communication-identity/tests/_shared/testcase.py new file mode 100644 index 000000000000..f56f17e56a46 --- /dev/null +++ b/sdk/communication/azure-communication-identity/tests/_shared/testcase.py @@ -0,0 +1,69 @@ + +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import re +from devtools_testutils import AzureTestCase +from azure_devtools.scenario_tests import RecordingProcessor, ReplayableTest +from azure_devtools.scenario_tests.utilities import is_text_payload + +class ResponseReplacerProcessor(RecordingProcessor): + def __init__(self, keys=None, replacement="sanitized"): + self._keys = keys if keys else [] + self._replacement = replacement + + def process_response(self, response): + def sanitize_dict(dictionary): + for key in dictionary: + value = dictionary[key] + if isinstance(value, str): + dictionary[key] = re.sub( + r"("+'|'.join(self._keys)+r")", + self._replacement, + dictionary[key]) + elif isinstance(value, dict): + sanitize_dict(value) + + sanitize_dict(response) + + return response + +class BodyReplacerProcessor(RecordingProcessor): + """Sanitize the sensitive info inside request or response bodies""" + + def __init__(self, keys=None, replacement="sanitized"): + self._replacement = replacement + self._keys = keys if keys else [] + + def process_request(self, request): + if is_text_payload(request) and request.body: + request.body = self._replace_keys(request.body.decode()).encode() + + return request + + def process_response(self, response): + if is_text_payload(response) and response['body']['string']: + response['body']['string'] = self._replace_keys(response['body']['string']) + + return response + + def _replace_keys(self, body): + import json + try: + body = json.loads(body) + for key in self._keys: + if key in body: + body[key] = self._replacement + + except (KeyError, ValueError): + return body + + return json.dumps(body) + +class CommunicationTestCase(AzureTestCase): + FILTER_HEADERS = ReplayableTest.FILTER_HEADERS + ['x-azure-ref', 'x-ms-content-sha256', 'location'] + + def __init__(self, method_name, *args, **kwargs): + super(CommunicationTestCase, self).__init__(method_name, *args, **kwargs) \ No newline at end of file diff --git a/sdk/communication/azure-communication-identity/tests/conftest.py b/sdk/communication/azure-communication-identity/tests/conftest.py new file mode 100644 index 000000000000..9f69fcac8bdc --- /dev/null +++ b/sdk/communication/azure-communication-identity/tests/conftest.py @@ -0,0 +1,11 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import sys + +# Ignore collection of async tests for Python 2 +collect_ignore_glob = [] +if sys.version_info < (3, 5): + collect_ignore_glob.append("*_async.py") diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_create_user.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_create_user.yaml new file mode 100644 index 000000000000..c2bc1d2d7dc8 --- /dev/null +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_create_user.yaml @@ -0,0 +1,42 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Date: + - Tue, 22 Dec 2020 18:26:56 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: POST + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + response: + body: + string: '{"id": "sanitized"}' + headers: + api-supported-versions: + - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + content-type: + - application/json; charset=utf-8 + date: + - Tue, 22 Dec 2020 18:26:55 GMT + ms-cv: + - 4whAoum970WIzePHLz1Ujg.0 + strict-transport-security: + - max-age=2592000 + transfer-encoding: + - chunked + x-processing-time: + - 18ms + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_create_user_from_managed_identity.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_create_user_from_managed_identity.yaml new file mode 100644 index 000000000000..f159cc5d3c7c --- /dev/null +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_create_user_from_managed_identity.yaml @@ -0,0 +1,38 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + response: + body: + string: '{"id": "sanitized"}' + headers: + api-supported-versions: + - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + content-type: + - application/json; charset=utf-8 + date: + - Tue, 22 Dec 2020 18:28:04 GMT + ms-cv: + - /4JsXqUuEkmQ1v304iaBTw.0 + strict-transport-security: + - max-age=2592000 + transfer-encoding: + - chunked + x-processing-time: + - 635ms + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_delete_user.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_delete_user.yaml new file mode 100644 index 000000000000..392431b12f89 --- /dev/null +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_delete_user.yaml @@ -0,0 +1,78 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Date: + - Tue, 22 Dec 2020 18:29:13 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: POST + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + response: + body: + string: '{"id": "sanitized"}' + headers: + api-supported-versions: + - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + content-type: + - application/json; charset=utf-8 + date: + - Tue, 22 Dec 2020 18:29:12 GMT + ms-cv: + - UzbbWyNM6Ee4hx1Ym7MwSA.0 + strict-transport-security: + - max-age=2592000 + transfer-encoding: + - chunked + x-processing-time: + - 19ms + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Date: + - Tue, 22 Dec 2020 18:29:14 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: DELETE + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 + response: + body: + string: '' + headers: + api-supported-versions: + - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + date: + - Tue, 22 Dec 2020 18:29:13 GMT + ms-cv: + - bD8oBIuNQEWXEaluFwupbA.0 + strict-transport-security: + - max-age=2592000 + x-processing-time: + - 764ms + status: + code: 204 + message: No Content +version: 1 diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_delete_user_from_managed_identity.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_delete_user_from_managed_identity.yaml new file mode 100644 index 000000000000..e1b92837214b --- /dev/null +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_delete_user_from_managed_identity.yaml @@ -0,0 +1,70 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + response: + body: + string: '{"id": "sanitized"}' + headers: + api-supported-versions: + - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + content-type: + - application/json; charset=utf-8 + date: + - Tue, 22 Dec 2020 18:30:23 GMT + ms-cv: + - eSMH8ZATxUWO5OamG49Wdg.0 + strict-transport-security: + - max-age=2592000 + transfer-encoding: + - chunked + x-processing-time: + - 811ms + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + method: DELETE + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 + response: + body: + string: '' + headers: + api-supported-versions: + - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + date: + - Tue, 22 Dec 2020 18:30:24 GMT + ms-cv: + - 91lJNqPMP0+hZnY0ay0tXA.0 + strict-transport-security: + - max-age=2592000 + x-processing-time: + - 741ms + status: + code: 204 + message: No Content +version: 1 diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_issue_token.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_issue_token.yaml new file mode 100644 index 000000000000..76d30c8ff3e6 --- /dev/null +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_issue_token.yaml @@ -0,0 +1,84 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Date: + - Tue, 22 Dec 2020 18:31:34 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: POST + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + response: + body: + string: '{"id": "sanitized"}' + headers: + api-supported-versions: + - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + content-type: + - application/json; charset=utf-8 + date: + - Tue, 22 Dec 2020 18:31:32 GMT + ms-cv: + - OXm+S4D9ak+t0Y4jKA3bFA.0 + strict-transport-security: + - max-age=2592000 + transfer-encoding: + - chunked + x-processing-time: + - 24ms + status: + code: 200 + message: OK +- request: + body: '{"scopes": ["chat"]}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '20' + Content-Type: + - application/json + Date: + - Tue, 22 Dec 2020 18:31:34 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: POST + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 + response: + body: + string: '{"id": "sanitized", "token": "sanitized", "expiresOn": "2020-12-23T18:31:32.3009076+00:00"}' + headers: + api-supported-versions: + - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + content-type: + - application/json; charset=utf-8 + date: + - Tue, 22 Dec 2020 18:31:32 GMT + ms-cv: + - EArcgkwtPkCU38ZbLjwJEQ.0 + strict-transport-security: + - max-age=2592000 + transfer-encoding: + - chunked + x-processing-time: + - 24ms + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_issue_token_from_managed_identity.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_issue_token_from_managed_identity.yaml new file mode 100644 index 000000000000..879ddee12d3c --- /dev/null +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_issue_token_from_managed_identity.yaml @@ -0,0 +1,76 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + response: + body: + string: '{"id": "sanitized"}' + headers: + api-supported-versions: + - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + content-type: + - application/json; charset=utf-8 + date: + - Tue, 22 Dec 2020 18:32:41 GMT + ms-cv: + - NcQPodkL5UOzC+AtKJcXvw.0 + strict-transport-security: + - max-age=2592000 + transfer-encoding: + - chunked + x-processing-time: + - 501ms + status: + code: 200 + message: OK +- request: + body: '{"scopes": ["chat"]}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '20' + Content-Type: + - application/json + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 + response: + body: + string: '{"id": "sanitized", "token": "sanitized", "expiresOn": "2020-12-23T18:32:41.3736569+00:00"}' + headers: + api-supported-versions: + - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + content-type: + - application/json; charset=utf-8 + date: + - Tue, 22 Dec 2020 18:32:41 GMT + ms-cv: + - W4rjQkxkvUSQqyJk5dUwCA.0 + strict-transport-security: + - max-age=2592000 + transfer-encoding: + - chunked + x-processing-time: + - 27ms + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_revoke_tokens.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_revoke_tokens.yaml new file mode 100644 index 000000000000..5e79664fa87f --- /dev/null +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_revoke_tokens.yaml @@ -0,0 +1,122 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Date: + - Tue, 22 Dec 2020 18:34:17 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: POST + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + response: + body: + string: '{"id": "sanitized"}' + headers: + api-supported-versions: + - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + content-type: + - application/json; charset=utf-8 + date: + - Tue, 22 Dec 2020 18:34:16 GMT + ms-cv: + - ZDSP6Prb6UGYOTBLvb6AdQ.0 + strict-transport-security: + - max-age=2592000 + transfer-encoding: + - chunked + x-processing-time: + - 23ms + status: + code: 200 + message: OK +- request: + body: '{"scopes": ["chat"]}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '20' + Content-Type: + - application/json + Date: + - Tue, 22 Dec 2020 18:34:18 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: POST + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 + response: + body: + string: '{"id": "sanitized", "token": "sanitized", "expiresOn": "2020-12-23T18:34:15.7537392+00:00"}' + headers: + api-supported-versions: + - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + content-type: + - application/json; charset=utf-8 + date: + - Tue, 22 Dec 2020 18:34:16 GMT + ms-cv: + - Hmv1R+jifUSsezIU2yJU8Q.0 + strict-transport-security: + - max-age=2592000 + transfer-encoding: + - chunked + x-processing-time: + - 31ms + status: + code: 200 + message: OK +- request: + body: '{}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '2' + Content-Type: + - application/merge-patch+json + Date: + - Tue, 22 Dec 2020 18:34:18 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: PATCH + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 + response: + body: + string: '' + headers: + api-supported-versions: + - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + date: + - Tue, 22 Dec 2020 18:34:16 GMT + ms-cv: + - vwznKj2MY0qO9HTJ9YWIRw.0 + strict-transport-security: + - max-age=2592000 + x-processing-time: + - 11ms + status: + code: 204 + message: No Content +version: 1 diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_revoke_tokens_from_managed_identity.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_revoke_tokens_from_managed_identity.yaml new file mode 100644 index 000000000000..853de6129c9d --- /dev/null +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_revoke_tokens_from_managed_identity.yaml @@ -0,0 +1,110 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + response: + body: + string: '{"id": "sanitized"}' + headers: + api-supported-versions: + - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + content-type: + - application/json; charset=utf-8 + date: + - Tue, 22 Dec 2020 18:35:27 GMT + ms-cv: + - QmngflWD+EOVXH7i/FS+iw.0 + strict-transport-security: + - max-age=2592000 + transfer-encoding: + - chunked + x-processing-time: + - 792ms + status: + code: 200 + message: OK +- request: + body: '{"scopes": ["chat"]}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '20' + Content-Type: + - application/json + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 + response: + body: + string: '{"id": "sanitized", "token": "sanitized", "expiresOn": "2020-12-23T18:35:27.28321+00:00"}' + headers: + api-supported-versions: + - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + content-type: + - application/json; charset=utf-8 + date: + - Tue, 22 Dec 2020 18:35:27 GMT + ms-cv: + - PRIzOxRVQkycMUEl6WNjHw.0 + strict-transport-security: + - max-age=2592000 + transfer-encoding: + - chunked + x-processing-time: + - 30ms + status: + code: 200 + message: OK +- request: + body: '{}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '2' + Content-Type: + - application/merge-patch+json + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + method: PATCH + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 + response: + body: + string: '' + headers: + api-supported-versions: + - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + date: + - Tue, 22 Dec 2020 18:35:27 GMT + ms-cv: + - mUk2cNSJI0e/Nz7J7yCGYg.0 + strict-transport-security: + - max-age=2592000 + x-processing-time: + - 11ms + status: + code: 204 + message: No Content +version: 1 diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_create_user.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_create_user.yaml new file mode 100644 index 000000000000..744fbd017292 --- /dev/null +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_create_user.yaml @@ -0,0 +1,30 @@ +interactions: +- request: + body: '' + headers: + Accept: + - application/json + Date: + - Tue, 22 Dec 2020 18:48:56 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: POST + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + response: + body: + string: '{"id": "sanitized"}' + headers: + api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + content-type: application/json; charset=utf-8 + date: Tue, 22 Dec 2020 18:48:54 GMT + ms-cv: vfIkgQk+J0OWSV4P3J1i0w.0 + strict-transport-security: max-age=2592000 + transfer-encoding: chunked + x-processing-time: 22ms + status: + code: 200 + message: OK + url: https://communicationtrnhzmurqrr.communication.azure.com/identities?api-version=2020-07-20-preview2 +version: 1 diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_create_user_from_managed_identity.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_create_user_from_managed_identity.yaml new file mode 100644 index 000000000000..883eb09da417 --- /dev/null +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_create_user_from_managed_identity.yaml @@ -0,0 +1,26 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + response: + body: + string: '{"id": "sanitized"}' + headers: + api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + content-type: application/json; charset=utf-8 + date: Tue, 22 Dec 2020 18:50:04 GMT + ms-cv: fj3guox5CUSvTCDG5gI0YA.0 + strict-transport-security: max-age=2592000 + transfer-encoding: chunked + x-processing-time: 534ms + status: + code: 200 + message: OK + url: https://communicationr7rdwwqs74n.communication.azure.com/identities?api-version=2020-07-20-preview2 +version: 1 diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_delete_user.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_delete_user.yaml new file mode 100644 index 000000000000..46f6bc7da32e --- /dev/null +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_delete_user.yaml @@ -0,0 +1,54 @@ +interactions: +- request: + body: '' + headers: + Accept: + - application/json + Date: + - Tue, 22 Dec 2020 18:51:13 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: POST + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + response: + body: + string: '{"id": "sanitized"}' + headers: + api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + content-type: application/json; charset=utf-8 + date: Tue, 22 Dec 2020 18:51:12 GMT + ms-cv: dHk7/E5BhUSf+g3Bkg94YQ.0 + strict-transport-security: max-age=2592000 + transfer-encoding: chunked + x-processing-time: 22ms + status: + code: 200 + message: OK + url: https://communication42hz4pfbosr.communication.azure.com/identities?api-version=2020-07-20-preview2 +- request: + body: '' + headers: + Date: + - Tue, 22 Dec 2020 18:51:14 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: DELETE + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 + response: + body: + string: '' + headers: + api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + date: Tue, 22 Dec 2020 18:51:12 GMT + ms-cv: 3DnY9x3jNUGrGnsi3LP0SA.0 + strict-transport-security: max-age=2592000 + x-processing-time: 440ms + status: + code: 204 + message: No Content + url: https://communication42hz4pfbosr.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 +version: 1 diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_delete_user_from_managed_identity.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_delete_user_from_managed_identity.yaml new file mode 100644 index 000000000000..3d5253742e18 --- /dev/null +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_delete_user_from_managed_identity.yaml @@ -0,0 +1,46 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + response: + body: + string: '{"id": "sanitized"}' + headers: + api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + content-type: application/json; charset=utf-8 + date: Tue, 22 Dec 2020 18:52:27 GMT + ms-cv: ww9tz7CpG0SXqqYPyV70Cw.0 + strict-transport-security: max-age=2592000 + transfer-encoding: chunked + x-processing-time: 192ms + status: + code: 200 + message: OK + url: https://communicationrscjfarclwr.communication.azure.com/identities?api-version=2020-07-20-preview2 +- request: + body: null + headers: + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + method: DELETE + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 + response: + body: + string: '' + headers: + api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + date: Tue, 22 Dec 2020 18:52:28 GMT + ms-cv: baDrTbu3H0qpWj2TJSno0A.0 + strict-transport-security: max-age=2592000 + x-processing-time: 864ms + status: + code: 204 + message: No Content + url: https://communicationrscjfarclwr.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 +version: 1 diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_issue_token.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_issue_token.yaml new file mode 100644 index 000000000000..fce3ec17e7e1 --- /dev/null +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_issue_token.yaml @@ -0,0 +1,62 @@ +interactions: +- request: + body: '' + headers: + Accept: + - application/json + Date: + - Tue, 22 Dec 2020 18:53:37 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: POST + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + response: + body: + string: '{"id": "sanitized"}' + headers: + api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + content-type: application/json; charset=utf-8 + date: Tue, 22 Dec 2020 18:53:36 GMT + ms-cv: Agl32miSq0CTEladXG7lbw.0 + strict-transport-security: max-age=2592000 + transfer-encoding: chunked + x-processing-time: 20ms + status: + code: 200 + message: OK + url: https://communicatione77tfh7y2ht.communication.azure.com/identities?api-version=2020-07-20-preview2 +- request: + body: '{"scopes": ["chat"]}' + headers: + Accept: + - application/json + Content-Length: + - '20' + Content-Type: + - application/json + Date: + - Tue, 22 Dec 2020 18:53:38 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: POST + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 + response: + body: + string: '{"id": "sanitized", "token": "sanitized", "expiresOn": "2020-12-23T18:53:35.7585148+00:00"}' + headers: + api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + content-type: application/json; charset=utf-8 + date: Tue, 22 Dec 2020 18:53:36 GMT + ms-cv: P3rSrWhwykmJcOW+Yb8Q2w.0 + strict-transport-security: max-age=2592000 + transfer-encoding: chunked + x-processing-time: 26ms + status: + code: 200 + message: OK + url: https://communicatione77tfh7y2ht.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 +version: 1 diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_issue_token_from_managed_identity.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_issue_token_from_managed_identity.yaml new file mode 100644 index 000000000000..44a889e13df3 --- /dev/null +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_issue_token_from_managed_identity.yaml @@ -0,0 +1,54 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + response: + body: + string: '{"id": "sanitized"}' + headers: + api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + content-type: application/json; charset=utf-8 + date: Tue, 22 Dec 2020 18:54:45 GMT + ms-cv: UywF8dbxrkyYXGTozRnuIw.0 + strict-transport-security: max-age=2592000 + transfer-encoding: chunked + x-processing-time: 773ms + status: + code: 200 + message: OK + url: https://communicationztg2acjbipc.communication.azure.com/identities?api-version=2020-07-20-preview2 +- request: + body: '{"scopes": ["chat"]}' + headers: + Accept: + - application/json + Content-Length: + - '20' + Content-Type: + - application/json + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 + response: + body: + string: '{"id": "sanitized", "token": "sanitized", "expiresOn": "2020-12-23T18:54:45.1115885+00:00"}' + headers: + api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + content-type: application/json; charset=utf-8 + date: Tue, 22 Dec 2020 18:54:45 GMT + ms-cv: ywaIOOtf9EiQs6pibQmCwg.0 + strict-transport-security: max-age=2592000 + transfer-encoding: chunked + x-processing-time: 25ms + status: + code: 200 + message: OK + url: https://communicationztg2acjbipc.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 +version: 1 diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_revoke_tokens.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_revoke_tokens.yaml new file mode 100644 index 000000000000..cefb985a000f --- /dev/null +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_revoke_tokens.yaml @@ -0,0 +1,90 @@ +interactions: +- request: + body: '' + headers: + Accept: + - application/json + Date: + - Tue, 22 Dec 2020 18:55:56 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: POST + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + response: + body: + string: '{"id": "sanitized"}' + headers: + api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + content-type: application/json; charset=utf-8 + date: Tue, 22 Dec 2020 18:55:55 GMT + ms-cv: M9b8kGAz8UGwsoZe2mFLCA.0 + strict-transport-security: max-age=2592000 + transfer-encoding: chunked + x-processing-time: 29ms + status: + code: 200 + message: OK + url: https://communicationngn6p2kywhg.communication.azure.com/identities?api-version=2020-07-20-preview2 +- request: + body: '{"scopes": ["chat"]}' + headers: + Accept: + - application/json + Content-Length: + - '20' + Content-Type: + - application/json + Date: + - Tue, 22 Dec 2020 18:55:57 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: POST + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 + response: + body: + string: '{"id": "sanitized", "token": "sanitized", "expiresOn": "2020-12-23T18:55:54.788117+00:00"}' + headers: + api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + content-type: application/json; charset=utf-8 + date: Tue, 22 Dec 2020 18:55:55 GMT + ms-cv: MBCUlMoRBECvCLmV00eWXw.0 + strict-transport-security: max-age=2592000 + transfer-encoding: chunked + x-processing-time: 27ms + status: + code: 200 + message: OK + url: https://communicationngn6p2kywhg.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 +- request: + body: '{}' + headers: + Content-Length: + - '2' + Content-Type: + - application/merge-patch+json + Date: + - Tue, 22 Dec 2020 18:55:57 GMT + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-return-client-request-id: + - 'true' + method: PATCH + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 + response: + body: + string: '' + headers: + api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + date: Tue, 22 Dec 2020 18:55:55 GMT + ms-cv: MVgoSrOVSkiU0c+teqMDZQ.0 + strict-transport-security: max-age=2592000 + x-processing-time: 10ms + status: + code: 204 + message: No Content + url: https://communicationngn6p2kywhg.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 +version: 1 diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_revoke_tokens_from_managed_identity.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_revoke_tokens_from_managed_identity.yaml new file mode 100644 index 000000000000..23b4c57c9632 --- /dev/null +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_revoke_tokens_from_managed_identity.yaml @@ -0,0 +1,78 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + response: + body: + string: '{"id": "sanitized"}' + headers: + api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + content-type: application/json; charset=utf-8 + date: Tue, 22 Dec 2020 18:57:03 GMT + ms-cv: a9v8/cRgN0uyuQQUguwkGA.0 + strict-transport-security: max-age=2592000 + transfer-encoding: chunked + x-processing-time: 195ms + status: + code: 200 + message: OK + url: https://communicationxheui257vce.communication.azure.com/identities?api-version=2020-07-20-preview2 +- request: + body: '{"scopes": ["chat"]}' + headers: + Accept: + - application/json + Content-Length: + - '20' + Content-Type: + - application/json + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 + response: + body: + string: '{"id": "sanitized", "token": "sanitized", "expiresOn": "2020-12-23T18:57:03.4428768+00:00"}' + headers: + api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + content-type: application/json; charset=utf-8 + date: Tue, 22 Dec 2020 18:57:03 GMT + ms-cv: Oc9n/N0oA0mLVBlk8UaTpw.0 + strict-transport-security: max-age=2592000 + transfer-encoding: chunked + x-processing-time: 24ms + status: + code: 200 + message: OK + url: https://communicationxheui257vce.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 +- request: + body: '{}' + headers: + Content-Length: + - '2' + Content-Type: + - application/merge-patch+json + User-Agent: + - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + method: PATCH + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 + response: + body: + string: '' + headers: + api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + date: Tue, 22 Dec 2020 18:57:03 GMT + ms-cv: lBOoIDU5lUe2vbpjz5+Gkg.0 + strict-transport-security: max-age=2592000 + x-processing-time: 11ms + status: + code: 204 + message: No Content + url: https://communicationxheui257vce.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 +version: 1 diff --git a/sdk/communication/azure-communication-identity/tests/test_communication_identity_client.py b/sdk/communication/azure-communication-identity/tests/test_communication_identity_client.py new file mode 100644 index 000000000000..9fc58152be3c --- /dev/null +++ b/sdk/communication/azure-communication-identity/tests/test_communication_identity_client.py @@ -0,0 +1,141 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.communication.identity import CommunicationIdentityClient +from azure.core.credentials import AccessToken +from _shared.helper import URIIdentityReplacer +from _shared.testcase import ( + CommunicationTestCase, + BodyReplacerProcessor +) +from devtools_testutils import ResourceGroupPreparer +from _shared.communication_service_preparer import CommunicationServicePreparer +from azure.identity import DefaultAzureCredential +from azure.communication.identity._shared.utils import parse_connection_str + +class FakeTokenCredential(object): + def __init__(self): + self.token = AccessToken("Fake Token", 0) + + def get_token(self, *args): + return self.token +class CommunicationIdentityClientTest(CommunicationTestCase): + def setUp(self): + super(CommunicationIdentityClientTest, self).setUp() + self.recording_processors.extend([ + BodyReplacerProcessor(keys=["id", "token"]), + URIIdentityReplacer()]) + + @ResourceGroupPreparer(random_name_enabled=True) + @CommunicationServicePreparer() + def test_create_user_from_managed_identity(self, connection_string): + endpoint, access_key = parse_connection_str(connection_string) + from devtools_testutils import is_live + if not is_live(): + credential = FakeTokenCredential() + else: + credential = DefaultAzureCredential() + identity_client = CommunicationIdentityClient(endpoint, credential) + user = identity_client.create_user() + + assert user.identifier is not None + + @ResourceGroupPreparer(random_name_enabled=True) + @CommunicationServicePreparer() + def test_create_user(self, connection_string): + identity_client = CommunicationIdentityClient.from_connection_string( + connection_string) + user = identity_client.create_user() + + assert user.identifier is not None + + @ResourceGroupPreparer(random_name_enabled=True) + @CommunicationServicePreparer() + def test_issue_token_from_managed_identity(self, connection_string): + endpoint, access_key = parse_connection_str(connection_string) + from devtools_testutils import is_live + if not is_live(): + credential = FakeTokenCredential() + else: + credential = DefaultAzureCredential() + identity_client = CommunicationIdentityClient(endpoint, credential) + user = identity_client.create_user() + + token_response = identity_client.issue_token(user, scopes=["chat"]) + + assert user.identifier is not None + assert token_response.token is not None + + @ResourceGroupPreparer(random_name_enabled=True) + @CommunicationServicePreparer() + def test_issue_token(self, connection_string): + identity_client = CommunicationIdentityClient.from_connection_string( + connection_string) + user = identity_client.create_user() + + token_response = identity_client.issue_token(user, scopes=["chat"]) + + assert user.identifier is not None + assert token_response.token is not None + + @ResourceGroupPreparer(random_name_enabled=True) + @CommunicationServicePreparer() + def test_revoke_tokens_from_managed_identity(self, connection_string): + endpoint, access_key = parse_connection_str(connection_string) + from devtools_testutils import is_live + if not is_live(): + credential = FakeTokenCredential() + else: + credential = DefaultAzureCredential() + identity_client = CommunicationIdentityClient(endpoint, credential) + user = identity_client.create_user() + + token_response = identity_client.issue_token(user, scopes=["chat"]) + identity_client.revoke_tokens(user) + + assert user.identifier is not None + assert token_response.token is not None + + @ResourceGroupPreparer(random_name_enabled=True) + @CommunicationServicePreparer() + def test_revoke_tokens(self, connection_string): + identity_client = CommunicationIdentityClient.from_connection_string( + connection_string) + user = identity_client.create_user() + + token_response = identity_client.issue_token(user, scopes=["chat"]) + identity_client.revoke_tokens(user) + + assert user.identifier is not None + assert token_response.token is not None + + @ResourceGroupPreparer(random_name_enabled=True) + @CommunicationServicePreparer() + def test_delete_user_from_managed_identity(self, connection_string): + endpoint, access_key = parse_connection_str(connection_string) + from devtools_testutils import is_live + if not is_live(): + credential = FakeTokenCredential() + else: + credential = DefaultAzureCredential() + identity_client = CommunicationIdentityClient(endpoint, credential) + user = identity_client.create_user() + + identity_client.delete_user(user) + + assert user.identifier is not None + + @ResourceGroupPreparer(random_name_enabled=True) + @CommunicationServicePreparer() + def test_delete_user(self, connection_string): + identity_client = CommunicationIdentityClient.from_connection_string( + connection_string) + user = identity_client.create_user() + + identity_client.delete_user(user) + + assert user.identifier is not None diff --git a/sdk/communication/azure-communication-identity/tests/test_communication_identity_client_async.py b/sdk/communication/azure-communication-identity/tests/test_communication_identity_client_async.py new file mode 100644 index 000000000000..0dafc2b5b76c --- /dev/null +++ b/sdk/communication/azure-communication-identity/tests/test_communication_identity_client_async.py @@ -0,0 +1,138 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.core.credentials import AccessToken +from azure.communication.identity.aio import CommunicationIdentityClient +from azure.communication.identity._shared.utils import parse_connection_str +from azure_devtools.scenario_tests import RecordingProcessor +from devtools_testutils import ResourceGroupPreparer +from _shared.helper import URIIdentityReplacer +from _shared.asynctestcase import AsyncCommunicationTestCase +from _shared.testcase import BodyReplacerProcessor +from _shared.communication_service_preparer import CommunicationServicePreparer +from azure.identity import DefaultAzureCredential + +class FakeTokenCredential(object): + def __init__(self): + self.token = AccessToken("Fake Token", 0) + + def get_token(self, *args): + return self.token +class CommunicationIdentityClientTestAsync(AsyncCommunicationTestCase): + def setUp(self): + super(CommunicationIdentityClientTestAsync, self).setUp() + self.recording_processors.extend([ + BodyReplacerProcessor(keys=["id", "token"]), + URIIdentityReplacer()]) + + @ResourceGroupPreparer(random_name_enabled=True) + @CommunicationServicePreparer() + async def test_create_user_from_managed_identity(self, connection_string): + endpoint, access_key = parse_connection_str(connection_string) + from devtools_testutils import is_live + if not is_live(): + credential = FakeTokenCredential() + else: + credential = DefaultAzureCredential() + identity_client = CommunicationIdentityClient(endpoint, credential) + async with identity_client: + user = await identity_client.create_user() + + assert user.identifier is not None + + @ResourceGroupPreparer(random_name_enabled=True) + @CommunicationServicePreparer() + async def test_create_user(self, connection_string): + identity_client = CommunicationIdentityClient.from_connection_string(connection_string) + async with identity_client: + user = await identity_client.create_user() + + assert user.identifier is not None + + @ResourceGroupPreparer(random_name_enabled=True) + @CommunicationServicePreparer() + async def test_issue_token_from_managed_identity(self, connection_string): + endpoint, access_key = parse_connection_str(connection_string) + from devtools_testutils import is_live + if not is_live(): + credential = FakeTokenCredential() + else: + credential = DefaultAzureCredential() + identity_client = CommunicationIdentityClient(endpoint, credential) + async with identity_client: + user = await identity_client.create_user() + token_response = await identity_client.issue_token(user, scopes=["chat"]) + + assert user.identifier is not None + assert token_response.token is not None + + @ResourceGroupPreparer(random_name_enabled=True) + @CommunicationServicePreparer() + async def test_issue_token(self, connection_string): + identity_client = CommunicationIdentityClient.from_connection_string(connection_string) + async with identity_client: + user = await identity_client.create_user() + token_response = await identity_client.issue_token(user, scopes=["chat"]) + + assert user.identifier is not None + assert token_response.token is not None + + @ResourceGroupPreparer(random_name_enabled=True) + @CommunicationServicePreparer() + async def test_revoke_tokens_from_managed_identity(self, connection_string): + endpoint, access_key = parse_connection_str(connection_string) + from devtools_testutils import is_live + if not is_live(): + credential = FakeTokenCredential() + else: + credential = DefaultAzureCredential() + identity_client = CommunicationIdentityClient(endpoint, credential) + async with identity_client: + user = await identity_client.create_user() + token_response = await identity_client.issue_token(user, scopes=["chat"]) + await identity_client.revoke_tokens(user) + + assert user.identifier is not None + assert token_response.token is not None + + @ResourceGroupPreparer(random_name_enabled=True) + @CommunicationServicePreparer() + async def test_revoke_tokens(self, connection_string): + identity_client = CommunicationIdentityClient.from_connection_string(connection_string) + async with identity_client: + user = await identity_client.create_user() + token_response = await identity_client.issue_token(user, scopes=["chat"]) + await identity_client.revoke_tokens(user) + + assert user.identifier is not None + assert token_response.token is not None + + @ResourceGroupPreparer(random_name_enabled=True) + @CommunicationServicePreparer() + async def test_delete_user_from_managed_identity(self, connection_string): + endpoint, access_key = parse_connection_str(connection_string) + from devtools_testutils import is_live + if not is_live(): + credential = FakeTokenCredential() + else: + credential = DefaultAzureCredential() + identity_client = CommunicationIdentityClient(endpoint, credential) + async with identity_client: + user = await identity_client.create_user() + await identity_client.delete_user(user) + + assert user.identifier is not None + + @ResourceGroupPreparer(random_name_enabled=True) + @CommunicationServicePreparer() + async def test_delete_user(self, connection_string): + identity_client = CommunicationIdentityClient.from_connection_string(connection_string) + async with identity_client: + user = await identity_client.create_user() + await identity_client.delete_user(user) + + assert user.identifier is not None diff --git a/sdk/communication/azure-communication-identity/tests/user_credential_tests.py b/sdk/communication/azure-communication-identity/tests/user_credential_tests.py new file mode 100644 index 000000000000..dddacc8784af --- /dev/null +++ b/sdk/communication/azure-communication-identity/tests/user_credential_tests.py @@ -0,0 +1,61 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from unittest import TestCase +from unittest.mock import MagicMock +from azure.communication.identity._shared.user_credential import CommunicationTokenCredential +from azure.communication.identity._shared.user_token_refresh_options import CommunicationTokenRefreshOptions +from azure.communication.identity._shared.utils import create_access_token + + +class TestCommunicationTokenCredential(TestCase): + sample_token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9."+\ + "eyJleHAiOjMyNTAzNjgwMDAwfQ.9i7FNNHHJT8cOzo-yrAUJyBSfJ-tPPk2emcHavOEpWc" + sample_token_expiry = 32503680000 + expired_token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9."+\ + "eyJleHAiOjEwMH0.1h_scYkNp-G98-O4cW6KvfJZwiz54uJMyeDACE4nypg" + + + def test_communicationtokencredential_decodes_token(self): + refresh_options = CommunicationTokenRefreshOptions(self.sample_token) + credential = CommunicationTokenCredential(refresh_options) + access_token = credential.get_token() + + self.assertEqual(access_token.token, self.sample_token) + + def test_communicationtokencredential_throws_if_invalid_token(self): + refresh_options = CommunicationTokenRefreshOptions("foo.bar.tar") + self.assertRaises(ValueError, lambda: CommunicationTokenCredential(refresh_options)) + + def test_communicationtokencredential_throws_if_nonstring_token(self): + refresh_options = CommunicationTokenRefreshOptions(454): + self.assertRaises(TypeError, lambda: CommunicationTokenCredential(refresh_options) + + def test_communicationtokencredential_static_token_returns_expired_token(self): + refresh_options = CommunicationTokenRefreshOptions(self.expired_token) + credential = CommunicationTokenCredential(refresh_options) + + self.assertEqual(credential.get_token().token, self.expired_token) + + def test_communicationtokencredential_token_expired_refresh_called(self): + refresher = MagicMock(return_value=self.sample_token) + refresh_options = CommunicationTokenRefreshOptions(self.sample_token, refresher) + access_token = CommunicationTokenCredential( + self.expired_token, + token_refresher=refresher).get_token() + refresher.assert_called_once() + self.assertEqual(access_token, self.sample_token) + + + def test_communicationtokencredential_token_expired_refresh_called_asnecessary(self): + refresher = MagicMock(return_value=create_access_token(self.expired_token)) + refresh_options = CommunicationTokenRefreshOptions(self.expired_token, refresher) + credential = CommunicationTokenCredential(refresh_options) + + credential.get_token() + access_token = credential.get_token() + + self.assertEqual(refresher.call_count, 2) + self.assertEqual(access_token.token, self.expired_token) From fdbd228e436082b538ab4ab4318acd182aec4ff7 Mon Sep 17 00:00:00 2001 From: Bert Ong <823691+beltr0n@users.noreply.github.com> Date: Thu, 21 Jan 2021 17:03:49 -0800 Subject: [PATCH 08/33] remove identity code from admin package --- .../communication/administration/__init__.py | 11 - .../_communication_identity_client.py | 153 ---------- .../administration/_identity/__init__.py | 0 .../_identity/_generated/__init__.py | 16 - .../_communication_identity_client.py | 60 ---- .../_identity/_generated/_configuration.py | 58 ---- .../_identity/_generated/aio/__init__.py | 10 - .../aio/_communication_identity_client.py | 52 ---- .../_generated/aio/_configuration.py | 52 ---- .../_generated/aio/operations/__init__.py | 13 - .../_communication_identity_operations.py | 271 ----------------- .../_identity/_generated/models/__init__.py | 25 -- .../_identity/_generated/models/_models.py | 113 ------- .../_generated/models/_models_py3.py | 126 -------- .../_generated/operations/__init__.py | 13 - .../_communication_identity_operations.py | 279 ------------------ .../_identity/_generated/py.typed | 1 - .../administration/aio/__init__.py | 2 - .../samples/identity_samples.py | 81 ----- .../samples/identity_samples_async.py | 93 ------ .../swagger/COMMUNICATION_IDENTITY.md | 27 -- 21 files changed, 1456 deletions(-) delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_communication_identity_client.py delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_identity/__init__.py delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/__init__.py delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/_communication_identity_client.py delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/_configuration.py delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/__init__.py delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/_communication_identity_client.py delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/_configuration.py delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/operations/__init__.py delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/operations/_communication_identity_operations.py delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/models/__init__.py delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/models/_models.py delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/models/_models_py3.py delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/operations/__init__.py delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/operations/_communication_identity_operations.py delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/py.typed delete mode 100644 sdk/communication/azure-communication-administration/samples/identity_samples.py delete mode 100644 sdk/communication/azure-communication-administration/samples/identity_samples_async.py delete mode 100644 sdk/communication/azure-communication-administration/swagger/COMMUNICATION_IDENTITY.md diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/__init__.py b/sdk/communication/azure-communication-administration/azure/communication/administration/__init__.py index 2ed40e51d71c..e10059fad1cc 100644 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/__init__.py +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/__init__.py @@ -4,15 +4,9 @@ # license information. # -------------------------------------------------------------------------- -from ._communication_identity_client import CommunicationIdentityClient from ._phone_number_administration_client import PhoneNumberAdministrationClient from ._polling import ReservePhoneNumberPolling, PurchaseReservationPolling, ReleasePhoneNumberPolling -from ._identity._generated.models import ( - CommunicationTokenRequest, - CommunicationIdentityToken -) - from ._phonenumber._generated.models import ( AcquiredPhoneNumber, AcquiredPhoneNumbers, @@ -42,16 +36,11 @@ ) __all__ = [ - 'CommunicationIdentityClient', 'PhoneNumberAdministrationClient', 'ReservePhoneNumberPolling', 'PurchaseReservationPolling', 'ReleasePhoneNumberPolling', - # from _identity - 'CommunicationTokenRequest', - 'CommunicationIdentityToken', - # from _phonenumber 'AcquiredPhoneNumber', 'AcquiredPhoneNumbers', diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_communication_identity_client.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_communication_identity_client.py deleted file mode 100644 index a97fd4407779..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_communication_identity_client.py +++ /dev/null @@ -1,153 +0,0 @@ -# coding=utf-8 -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ - -from azure.core.tracing.decorator import distributed_trace - -from ._identity._generated._communication_identity_client\ - import CommunicationIdentityClient as CommunicationIdentityClientGen -from ._identity._generated.models import CommunicationIdentityToken -from ._shared.utils import parse_connection_str, get_authentication_policy -from ._shared.models import CommunicationUserIdentifier -from ._version import SDK_MONIKER - -class CommunicationIdentityClient(object): - """Azure Communication Services Identity client. - - :param str endpoint: - The endpoint url for Azure Communication Service resource. - :param credential: - The credentials with which to authenticate. The value is an account - shared access key - - .. admonition:: Example: - - .. literalinclude:: ../samples/identity_samples.py - :language: python - :dedent: 8 - """ - def __init__( - self, - endpoint, # type: str - credential, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - try: - if not endpoint.lower().startswith('http'): - endpoint = "https://" + endpoint - except AttributeError: - raise ValueError("Account URL must be a string.") - - if not credential: - raise ValueError( - "You need to provide account shared key to authenticate.") - - self._endpoint = endpoint - self._identity_service_client = CommunicationIdentityClientGen( - self._endpoint, - authentication_policy=get_authentication_policy(endpoint, credential), - sdk_moniker=SDK_MONIKER, - **kwargs) - - @classmethod - def from_connection_string( - cls, conn_str, # type: str - **kwargs # type: Any - ): # type: (...) -> CommunicationIdentityClient - """Create CommunicationIdentityClient from a Connection String. - - :param str conn_str: - A connection string to an Azure Communication Service resource. - :returns: Instance of CommunicationIdentityClient. - :rtype: ~azure.communication.CommunicationIdentityClient - - .. admonition:: Example: - - .. literalinclude:: ../samples/identity_samples.py - :start-after: [START auth_from_connection_string] - :end-before: [END auth_from_connection_string] - :language: python - :dedent: 8 - :caption: Creating the CommunicationIdentityClient from a connection string. - """ - endpoint, access_key = parse_connection_str(conn_str) - - return cls(endpoint, access_key, **kwargs) - - @distributed_trace - def create_user(self, **kwargs): - # type: (...) -> CommunicationUserIdentifier - """create a single Communication user - - return: CommunicationUserIdentifier - rtype: ~azure.communication.administration.CommunicationUserIdentifier - """ - return self._identity_service_client.communication_identity.create( - cls=lambda pr, u, e: CommunicationUserIdentifier(u.id), - **kwargs) - - @distributed_trace - def delete_user( - self, - communication_user, # type: CommunicationUserIdentifier - **kwargs # type: Any - ): - # type: (...) -> None - """Triggers revocation event for user and deletes all its data. - - :param communication_user: - Azure Communication User to delete - :type communication_user: ~azure.communication.administration.CommunicationUserIdentifier - :return: None - :rtype: None - """ - self._identity_service_client.communication_identity.delete( - communication_user.identifier, **kwargs) - - @distributed_trace - def issue_token( - self, - user, # type: CommunicationUserIdentifier - scopes, # type: List[str] - **kwargs # type: Any - ): - # type: (...) -> CommunicationIdentityToken - """Generates a new token for an identity. - - :param user: Azure Communication User - :type user: ~azure.communication.administration.CommunicationUserIdentifier - :param scopes: - List of scopes to be added to the token. - :type scopes: list[str] - :return: CommunicationIdentityToken - :rtype: ~azure.communication.administration.CommunicationIdentityToken - """ - return self._identity_service_client.communication_identity.issue_token( - user.identifier, - scopes, - **kwargs) - - @distributed_trace - def revoke_tokens( - self, - user, # type: CommunicationUserIdentifier - issued_before=None, # type: Optional[datetime.datetime] - **kwargs # type: Any - ): - # type: (...) -> None - """Schedule revocation of all tokens of an identity. - - :param user: Azure Communication User. - :type user: ~azure.communication.administration.CommunicationUserIdentifier. - :param issued_before: All tokens that are issued prior to this time should get revoked. - :type issued_before: ~datetime.datetime. - :return: None - :rtype: None - """ - return self._identity_service_client.communication_identity.update( - user.identifier if user else None, - tokens_valid_from=issued_before, - **kwargs) diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/__init__.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/__init__.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/__init__.py deleted file mode 100644 index 733b64f83c37..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._communication_identity_client import CommunicationIdentityClient -__all__ = ['CommunicationIdentityClient'] - -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/_communication_identity_client.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/_communication_identity_client.py deleted file mode 100644 index c7a76a0d444d..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/_communication_identity_client.py +++ /dev/null @@ -1,60 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import TYPE_CHECKING - -from azure.core import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any - -from ._configuration import CommunicationIdentityClientConfiguration -from .operations import CommunicationIdentityOperations -from . import models - - -class CommunicationIdentityClient(object): - """Azure Communication Identity Service. - - :ivar communication_identity: CommunicationIdentityOperations operations - :vartype communication_identity: azure.communication.administration.operations.CommunicationIdentityOperations - :param endpoint: Auth and Identity endpoint. - :type endpoint: str - """ - - def __init__( - self, - endpoint, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - base_url = '{endpoint}' - self._config = CommunicationIdentityClientConfiguration(endpoint, **kwargs) - self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - - self.communication_identity = CommunicationIdentityOperations( - self._client, self._config, self._serialize, self._deserialize) - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> CommunicationIdentityClient - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/_configuration.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/_configuration.py deleted file mode 100644 index 079f98f2ffd0..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/_configuration.py +++ /dev/null @@ -1,58 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any - -VERSION = "unknown" - -class CommunicationIdentityClientConfiguration(Configuration): - """Configuration for CommunicationIdentityClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param endpoint: Auth and Identity endpoint. - :type endpoint: str - """ - - def __init__( - self, - endpoint, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - if endpoint is None: - raise ValueError("Parameter 'endpoint' must not be None.") - super(CommunicationIdentityClientConfiguration, self).__init__(**kwargs) - - self.endpoint = endpoint - self.api_version = "2020-07-20-preview2" - kwargs.setdefault('sdk_moniker', 'communicationidentityclient/{}'.format(VERSION)) - self._configure(**kwargs) - - def _configure( - self, - **kwargs # type: Any - ): - # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/__init__.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/__init__.py deleted file mode 100644 index 198816835b24..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._communication_identity_client import CommunicationIdentityClient -__all__ = ['CommunicationIdentityClient'] diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/_communication_identity_client.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/_communication_identity_client.py deleted file mode 100644 index 06c5aa66ddff..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/_communication_identity_client.py +++ /dev/null @@ -1,52 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any - -from azure.core import AsyncPipelineClient -from msrest import Deserializer, Serializer - -from ._configuration import CommunicationIdentityClientConfiguration -from .operations import CommunicationIdentityOperations -from .. import models - - -class CommunicationIdentityClient(object): - """Azure Communication Identity Service. - - :ivar communication_identity: CommunicationIdentityOperations operations - :vartype communication_identity: azure.communication.administration.aio.operations.CommunicationIdentityOperations - :param endpoint: Auth and Identity endpoint. - :type endpoint: str - """ - - def __init__( - self, - endpoint: str, - **kwargs: Any - ) -> None: - base_url = '{endpoint}' - self._config = CommunicationIdentityClientConfiguration(endpoint, **kwargs) - self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - - self.communication_identity = CommunicationIdentityOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "CommunicationIdentityClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/_configuration.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/_configuration.py deleted file mode 100644 index 4b91da974fe0..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/_configuration.py +++ /dev/null @@ -1,52 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies - -VERSION = "unknown" - -class CommunicationIdentityClientConfiguration(Configuration): - """Configuration for CommunicationIdentityClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param endpoint: Auth and Identity endpoint. - :type endpoint: str - """ - - def __init__( - self, - endpoint: str, - **kwargs: Any - ) -> None: - if endpoint is None: - raise ValueError("Parameter 'endpoint' must not be None.") - super(CommunicationIdentityClientConfiguration, self).__init__(**kwargs) - - self.endpoint = endpoint - self.api_version = "2020-07-20-preview2" - kwargs.setdefault('sdk_moniker', 'communicationidentityclient/{}'.format(VERSION)) - self._configure(**kwargs) - - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/operations/__init__.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/operations/__init__.py deleted file mode 100644 index 09dd0f2d0661..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/operations/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._communication_identity_operations import CommunicationIdentityOperations - -__all__ = [ - 'CommunicationIdentityOperations', -] diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/operations/_communication_identity_operations.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/operations/_communication_identity_operations.py deleted file mode 100644 index 9ff3934e2458..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/operations/_communication_identity_operations.py +++ /dev/null @@ -1,271 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import datetime -from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest - -from ... import models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class CommunicationIdentityOperations: - """CommunicationIdentityOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.communication.administration.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - async def create( - self, - **kwargs - ) -> "models.CommunicationIdentity": - """Create a new identity. - - Create a new identity. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CommunicationIdentity, or the result of cls(response) - :rtype: ~azure.communication.administration.models.CommunicationIdentity - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.CommunicationIdentity"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview2" - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize('CommunicationIdentity', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create.metadata = {'url': '/identities'} # type: ignore - - async def delete( - self, - id: str, - **kwargs - ) -> None: - """Delete the identity, revoke all tokens of the identity and delete all associated data. - - Delete the identity, revoke all tokens of the identity and delete all associated data. - - :param id: Identifier of the identity to be deleted. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview2" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {'url': '/identities/{id}'} # type: ignore - - async def update( - self, - id: str, - tokens_valid_from: Optional[datetime.datetime] = None, - **kwargs - ) -> None: - """Update an Identity. - - Update an Identity. - - :param id: Identifier of the identity. - :type id: str - :param tokens_valid_from: All tokens that are issued prior to this time will be revoked. - :type tokens_valid_from: ~datetime.datetime - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _body = models.CommunicationIdentityUpdateRequest(tokens_valid_from=tokens_valid_from) - api_version = "2020-07-20-preview2" - content_type = kwargs.pop("content_type", "application/merge-patch+json") - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_body, 'CommunicationIdentityUpdateRequest') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - update.metadata = {'url': '/identities/{id}'} # type: ignore - - async def issue_token( - self, - id: str, - scopes: List[str], - **kwargs - ) -> "models.CommunicationIdentityToken": - """Generate a new token for an identity. - - Generate a new token for an identity. - - :param id: Identifier of the identity to issue token for. - :type id: str - :param scopes: List of scopes attached to the token. - :type scopes: list[str] - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CommunicationIdentityToken, or the result of cls(response) - :rtype: ~azure.communication.administration.models.CommunicationIdentityToken - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.CommunicationIdentityToken"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _body = models.CommunicationTokenRequest(scopes=scopes) - api_version = "2020-07-20-preview2" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.issue_token.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_body, 'CommunicationTokenRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize('CommunicationIdentityToken', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - issue_token.metadata = {'url': '/identities/{id}/token'} # type: ignore diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/models/__init__.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/models/__init__.py deleted file mode 100644 index 05dd3d4b6aab..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/models/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -try: - from ._models_py3 import CommunicationIdentity - from ._models_py3 import CommunicationIdentityToken - from ._models_py3 import CommunicationIdentityUpdateRequest - from ._models_py3 import CommunicationTokenRequest -except (SyntaxError, ImportError): - from ._models import CommunicationIdentity # type: ignore - from ._models import CommunicationIdentityToken # type: ignore - from ._models import CommunicationIdentityUpdateRequest # type: ignore - from ._models import CommunicationTokenRequest # type: ignore - -__all__ = [ - 'CommunicationIdentity', - 'CommunicationIdentityToken', - 'CommunicationIdentityUpdateRequest', - 'CommunicationTokenRequest', -] diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/models/_models.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/models/_models.py deleted file mode 100644 index ce2106c91807..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/models/_models.py +++ /dev/null @@ -1,113 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import msrest.serialization - - -class CommunicationIdentity(msrest.serialization.Model): - """A communication identity. - - All required parameters must be populated in order to send to Azure. - - :param id: Required. Identifier of the identity. - :type id: str - """ - - _validation = { - 'id': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CommunicationIdentity, self).__init__(**kwargs) - self.id = kwargs['id'] - - -class CommunicationIdentityToken(msrest.serialization.Model): - """CommunicationIdentityToken. - - All required parameters must be populated in order to send to Azure. - - :param id: Required. Identifier of the identity owning the token. - :type id: str - :param token: Required. The token issued for the identity. - :type token: str - :param expires_on: Required. The expiry time of the token. - :type expires_on: ~datetime.datetime - """ - - _validation = { - 'id': {'required': True}, - 'token': {'required': True}, - 'expires_on': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'token': {'key': 'token', 'type': 'str'}, - 'expires_on': {'key': 'expiresOn', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(CommunicationIdentityToken, self).__init__(**kwargs) - self.id = kwargs['id'] - self.token = kwargs['token'] - self.expires_on = kwargs['expires_on'] - - -class CommunicationIdentityUpdateRequest(msrest.serialization.Model): - """CommunicationIdentityUpdateRequest. - - :param tokens_valid_from: All tokens that are issued prior to this time will be revoked. - :type tokens_valid_from: ~datetime.datetime - """ - - _attribute_map = { - 'tokens_valid_from': {'key': 'tokensValidFrom', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(CommunicationIdentityUpdateRequest, self).__init__(**kwargs) - self.tokens_valid_from = kwargs.get('tokens_valid_from', None) - - -class CommunicationTokenRequest(msrest.serialization.Model): - """CommunicationTokenRequest. - - All required parameters must be populated in order to send to Azure. - - :param scopes: Required. List of scopes attached to the token. - :type scopes: list[str] - """ - - _validation = { - 'scopes': {'required': True}, - } - - _attribute_map = { - 'scopes': {'key': 'scopes', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(CommunicationTokenRequest, self).__init__(**kwargs) - self.scopes = kwargs['scopes'] diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/models/_models_py3.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/models/_models_py3.py deleted file mode 100644 index ba3988b1589a..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/models/_models_py3.py +++ /dev/null @@ -1,126 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import datetime -from typing import List, Optional - -import msrest.serialization - - -class CommunicationIdentity(msrest.serialization.Model): - """A communication identity. - - All required parameters must be populated in order to send to Azure. - - :param id: Required. Identifier of the identity. - :type id: str - """ - - _validation = { - 'id': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - *, - id: str, - **kwargs - ): - super(CommunicationIdentity, self).__init__(**kwargs) - self.id = id - - -class CommunicationIdentityToken(msrest.serialization.Model): - """CommunicationIdentityToken. - - All required parameters must be populated in order to send to Azure. - - :param id: Required. Identifier of the identity owning the token. - :type id: str - :param token: Required. The token issued for the identity. - :type token: str - :param expires_on: Required. The expiry time of the token. - :type expires_on: ~datetime.datetime - """ - - _validation = { - 'id': {'required': True}, - 'token': {'required': True}, - 'expires_on': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'token': {'key': 'token', 'type': 'str'}, - 'expires_on': {'key': 'expiresOn', 'type': 'iso-8601'}, - } - - def __init__( - self, - *, - id: str, - token: str, - expires_on: datetime.datetime, - **kwargs - ): - super(CommunicationIdentityToken, self).__init__(**kwargs) - self.id = id - self.token = token - self.expires_on = expires_on - - -class CommunicationIdentityUpdateRequest(msrest.serialization.Model): - """CommunicationIdentityUpdateRequest. - - :param tokens_valid_from: All tokens that are issued prior to this time will be revoked. - :type tokens_valid_from: ~datetime.datetime - """ - - _attribute_map = { - 'tokens_valid_from': {'key': 'tokensValidFrom', 'type': 'iso-8601'}, - } - - def __init__( - self, - *, - tokens_valid_from: Optional[datetime.datetime] = None, - **kwargs - ): - super(CommunicationIdentityUpdateRequest, self).__init__(**kwargs) - self.tokens_valid_from = tokens_valid_from - - -class CommunicationTokenRequest(msrest.serialization.Model): - """CommunicationTokenRequest. - - All required parameters must be populated in order to send to Azure. - - :param scopes: Required. List of scopes attached to the token. - :type scopes: list[str] - """ - - _validation = { - 'scopes': {'required': True}, - } - - _attribute_map = { - 'scopes': {'key': 'scopes', 'type': '[str]'}, - } - - def __init__( - self, - *, - scopes: List[str], - **kwargs - ): - super(CommunicationTokenRequest, self).__init__(**kwargs) - self.scopes = scopes diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/operations/__init__.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/operations/__init__.py deleted file mode 100644 index 09dd0f2d0661..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/operations/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._communication_identity_operations import CommunicationIdentityOperations - -__all__ = [ - 'CommunicationIdentityOperations', -] diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/operations/_communication_identity_operations.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/operations/_communication_identity_operations.py deleted file mode 100644 index 26d1a86a88d2..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/operations/_communication_identity_operations.py +++ /dev/null @@ -1,279 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import datetime -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from .. import models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class CommunicationIdentityOperations(object): - """CommunicationIdentityOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.communication.administration.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def create( - self, - **kwargs # type: Any - ): - # type: (...) -> "models.CommunicationIdentity" - """Create a new identity. - - Create a new identity. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CommunicationIdentity, or the result of cls(response) - :rtype: ~azure.communication.administration.models.CommunicationIdentity - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.CommunicationIdentity"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview2" - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize('CommunicationIdentity', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create.metadata = {'url': '/identities'} # type: ignore - - def delete( - self, - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Delete the identity, revoke all tokens of the identity and delete all associated data. - - Delete the identity, revoke all tokens of the identity and delete all associated data. - - :param id: Identifier of the identity to be deleted. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview2" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {'url': '/identities/{id}'} # type: ignore - - def update( - self, - id, # type: str - tokens_valid_from=None, # type: Optional[datetime.datetime] - **kwargs # type: Any - ): - # type: (...) -> None - """Update an Identity. - - Update an Identity. - - :param id: Identifier of the identity. - :type id: str - :param tokens_valid_from: All tokens that are issued prior to this time will be revoked. - :type tokens_valid_from: ~datetime.datetime - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _body = models.CommunicationIdentityUpdateRequest(tokens_valid_from=tokens_valid_from) - api_version = "2020-07-20-preview2" - content_type = kwargs.pop("content_type", "application/merge-patch+json") - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_body, 'CommunicationIdentityUpdateRequest') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - update.metadata = {'url': '/identities/{id}'} # type: ignore - - def issue_token( - self, - id, # type: str - scopes, # type: List[str] - **kwargs # type: Any - ): - # type: (...) -> "models.CommunicationIdentityToken" - """Generate a new token for an identity. - - Generate a new token for an identity. - - :param id: Identifier of the identity to issue token for. - :type id: str - :param scopes: List of scopes attached to the token. - :type scopes: list[str] - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CommunicationIdentityToken, or the result of cls(response) - :rtype: ~azure.communication.administration.models.CommunicationIdentityToken - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.CommunicationIdentityToken"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _body = models.CommunicationTokenRequest(scopes=scopes) - api_version = "2020-07-20-preview2" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.issue_token.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_body, 'CommunicationTokenRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize('CommunicationIdentityToken', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - issue_token.metadata = {'url': '/identities/{id}/token'} # type: ignore diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/py.typed b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/aio/__init__.py b/sdk/communication/azure-communication-administration/azure/communication/administration/aio/__init__.py index ffe7feed48fa..a35d7f5eba44 100644 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/aio/__init__.py +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/aio/__init__.py @@ -1,11 +1,9 @@ -from ._communication_identity_client_async import CommunicationIdentityClient from ._phone_number_administration_client_async import PhoneNumberAdministrationClient from ._polling_async import ReservePhoneNumberPollingAsync, \ PurchaseReservationPollingAsync, \ ReleasePhoneNumberPollingAsync __all__ = [ - 'CommunicationIdentityClient', 'PhoneNumberAdministrationClient', 'ReservePhoneNumberPollingAsync', 'PurchaseReservationPollingAsync', diff --git a/sdk/communication/azure-communication-administration/samples/identity_samples.py b/sdk/communication/azure-communication-administration/samples/identity_samples.py deleted file mode 100644 index e20e5cfedfba..000000000000 --- a/sdk/communication/azure-communication-administration/samples/identity_samples.py +++ /dev/null @@ -1,81 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- - -""" -FILE: identity_sample.py -DESCRIPTION: - These samples demonstrate identity client samples. - - ///authenticating a client via a connection string -USAGE: - python identity_samples.py -""" -import os - -class CommunicationIdentityClientSamples(object): - - def __init__(self): - self.connection_string = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') - self.endpoint = os.getenv('AZURE_COMMUNICATION_SERVICE_ENDPOINT') - self.client_id = os.getenv('AZURE_CLIENT_ID') - self.client_secret = os.getenv('AZURE_CLIENT_SECRET') - self.tenant_id = os.getnenv('AZURE_TENANT_ID') - - def issue_token(self): - from azure.communication.administration import CommunicationIdentityClient - - if self.client_id is not None and self.client_secret is not None and self.tenant_id is not None: - from azure.identity import DefaultAzureCredential - identity_client = CommunicationIdentityClient(self.endpoint, DefaultAzureCredential()) - else: - identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) - user = identity_client.create_user() - tokenresponse = identity_client.issue_token(user, scopes=["chat"]) - print(tokenresponse) - - def revoke_tokens(self): - from azure.communication.administration import CommunicationIdentityClient - - if self.client_id is not None and self.client_secret is not None and self.tenant_id is not None: - from azure.identity import DefaultAzureCredential - identity_client = CommunicationIdentityClient(self.endpoint, DefaultAzureCredential()) - else: - identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) - user = identity_client.create_user() - tokenresponse = identity_client.issue_token(user, scopes=["chat"]) - identity_client.revoke_tokens(user) - print(tokenresponse) - - def create_user(self): - from azure.communication.administration import CommunicationIdentityClient - - if self.client_id is not None and self.client_secret is not None and self.tenant_id is not None: - from azure.identity import DefaultAzureCredential - identity_client = CommunicationIdentityClient(self.endpoint, DefaultAzureCredential()) - else: - identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) - user = identity_client.create_user() - print(user.identifier) - - def delete_user(self): - from azure.communication.administration import CommunicationIdentityClient - - if self.client_id is not None and self.client_secret is not None and self.tenant_id is not None: - from azure.identity import DefaultAzureCredential - identity_client = CommunicationIdentityClient(self.endpoint, DefaultAzureCredential()) - else: - identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) - user = identity_client.create_user() - identity_client.delete_user(user) - -if __name__ == '__main__': - sample = CommunicationIdentityClientSamples() - sample.create_user() - sample.delete_user() - sample.issue_token() - sample.revoke_tokens() diff --git a/sdk/communication/azure-communication-administration/samples/identity_samples_async.py b/sdk/communication/azure-communication-administration/samples/identity_samples_async.py deleted file mode 100644 index 0cbb8c147fb0..000000000000 --- a/sdk/communication/azure-communication-administration/samples/identity_samples_async.py +++ /dev/null @@ -1,93 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- - -""" -FILE: identity_sample_async.py -DESCRIPTION: - These samples demonstrate async identity client samples. - - ///authenticating a client via a connection string -USAGE: - python identity_samples_async.py -""" - -import asyncio -import os - - -class CommunicationIdentityClientSamples(object): - - def __init__(self): - self.connection_string = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') - self.endpoint = os.getenv('AZURE_COMMUNICATION_SERVICE_ENDPOINT') - self.client_id = os.getenv('AZURE_CLIENT_ID') - self.client_secret = os.getenv('AZURE_CLIENT_SECRET') - self.tenant_id = os.getnenv('AZURE_TENANT_ID') - - async def issue_token(self): - from azure.communication.administration.aio import CommunicationIdentityClient - if self.client_id is not None and self.client_secret is not None and self.tenant_id is not None: - from azure.identity import DefaultAzureCredential - identity_client = CommunicationIdentityClient(self.endpoint, DefaultAzureCredential()) - else: - identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) - - async with identity_client: - user = await identity_client.create_user() - print(user.identifier) - tokenresponse = await identity_client.issue_token(user, scopes=["chat"]) - print(tokenresponse) - - async def revoke_tokens(self): - from azure.communication.administration.aio import CommunicationIdentityClient - if self.client_id is not None and self.client_secret is not None and self.tenant_id is not None: - from azure.identity import DefaultAzureCredential - identity_client = CommunicationIdentityClient(self.endpoint, DefaultAzureCredential()) - else: - identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) - - async with identity_client: - user = await identity_client.create_user() - tokenresponse = await identity_client.issue_token(user, scopes=["chat"]) - await identity_client.revoke_tokens(user) - print(tokenresponse) - - async def create_user(self): - from azure.communication.administration.aio import CommunicationIdentityClient - if self.client_id is not None and self.client_secret is not None and self.tenant_id is not None: - from azure.identity import DefaultAzureCredential - identity_client = CommunicationIdentityClient(self.endpoint, DefaultAzureCredential()) - else: - identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) - - async with identity_client: - user = await identity_client.create_user() - print(user.identifier) - - async def delete_user(self): - from azure.communication.administration.aio import CommunicationIdentityClient - if self.client_id is not None and self.client_secret is not None and self.tenant_id is not None: - from azure.identity import DefaultAzureCredential - identity_client = CommunicationIdentityClient(self.endpoint, DefaultAzureCredential()) - else: - identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) - - async with identity_client: - user = await identity_client.create_user() - await identity_client.delete_user(user) - -async def main(): - sample = CommunicationIdentityClientSamples() - await sample.create_user() - await sample.delete_user() - await sample.issue_token() - await sample.revoke_tokens() - -if __name__ == '__main__': - loop = asyncio.get_event_loop() - loop.run_until_complete(main()) diff --git a/sdk/communication/azure-communication-administration/swagger/COMMUNICATION_IDENTITY.md b/sdk/communication/azure-communication-administration/swagger/COMMUNICATION_IDENTITY.md deleted file mode 100644 index 0a5477c97638..000000000000 --- a/sdk/communication/azure-communication-administration/swagger/COMMUNICATION_IDENTITY.md +++ /dev/null @@ -1,27 +0,0 @@ -# Azure Communication Administration for Python - -> see https://aka.ms/autorest - -### Setup -```ps -npm install -g autorest -``` - -### Generation -```ps -cd -autorest ./COMMUNICATION_IDENTITY.md -``` - -### Settings -``` yaml -input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/8818a603b78a1355ba1647ab9cd4e3354cdc4b69/specification/communication/data-plane/Microsoft.CommunicationServicesIdentity/preview/2020-07-20-preview2/CommunicationIdentity.json -output-folder: ../azure/communication/administration/_identity/_generated/ -namespace: azure.communication.administration -license-header: MICROSOFT_MIT_NO_VERSION -payload-flattening-threshold: 3 -no-namespace-folders: true -clear-output-folder: true -v3: true -python: true -``` \ No newline at end of file From 63c3468a9ef788a7b73eca5b19c3fd36ee3bd309 Mon Sep 17 00:00:00 2001 From: Bert Ong <823691+beltr0n@users.noreply.github.com> Date: Thu, 21 Jan 2021 17:12:27 -0800 Subject: [PATCH 09/33] update changelog --- .../azure-communication-administration/CHANGELOG.md | 1 + sdk/communication/azure-communication-identity/CHANGELOG.md | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/communication/azure-communication-administration/CHANGELOG.md b/sdk/communication/azure-communication-administration/CHANGELOG.md index 5ea9e283325d..3f3f0f55287a 100644 --- a/sdk/communication/azure-communication-administration/CHANGELOG.md +++ b/sdk/communication/azure-communication-administration/CHANGELOG.md @@ -3,6 +3,7 @@ ## 1.0.0b4 (Unreleased) ### Breaking Changes +- CommunicationIdentityClient is moved to a new package: "azure.communication.identity" ##### `PhoneNumberAdministrationClient` - `begin_reserve_phone_numbers` now takes `display_name`, `description`, `phone_plan_ids`, diff --git a/sdk/communication/azure-communication-identity/CHANGELOG.md b/sdk/communication/azure-communication-identity/CHANGELOG.md index 964b44312c40..cafa147a25ac 100644 --- a/sdk/communication/azure-communication-identity/CHANGELOG.md +++ b/sdk/communication/azure-communication-identity/CHANGELOG.md @@ -4,7 +4,6 @@ ### Added - Added CommunicationIdentityClient (originally was part of the azure.communication.administration package). -- Added support for Azure Active Directory authentication for the Identity client [read_me]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/communication/azure-communication-identity/README.md From c089d7a89f5f510ecd804e3867380f723da26a4b Mon Sep 17 00:00:00 2001 From: Bert Ong <823691+beltr0n@users.noreply.github.com> Date: Thu, 21 Jan 2021 17:03:49 -0800 Subject: [PATCH 10/33] remove identity code from admin package --- .../communication/administration/__init__.py | 11 - .../_communication_identity_client.py | 153 ---------- .../administration/_identity/__init__.py | 0 .../_identity/_generated/__init__.py | 16 - .../_communication_identity_client.py | 60 ---- .../_identity/_generated/_configuration.py | 58 ---- .../_identity/_generated/aio/__init__.py | 10 - .../aio/_communication_identity_client.py | 52 ---- .../_generated/aio/_configuration.py | 52 ---- .../_generated/aio/operations/__init__.py | 13 - .../_communication_identity_operations.py | 271 ----------------- .../_identity/_generated/models/__init__.py | 25 -- .../_identity/_generated/models/_models.py | 113 ------- .../_generated/models/_models_py3.py | 126 -------- .../_generated/operations/__init__.py | 13 - .../_communication_identity_operations.py | 279 ------------------ .../_identity/_generated/py.typed | 1 - .../administration/aio/__init__.py | 2 - .../samples/identity_samples.py | 81 ----- .../samples/identity_samples_async.py | 93 ------ .../swagger/COMMUNICATION_IDENTITY.md | 27 -- 21 files changed, 1456 deletions(-) delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_communication_identity_client.py delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_identity/__init__.py delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/__init__.py delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/_communication_identity_client.py delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/_configuration.py delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/__init__.py delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/_communication_identity_client.py delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/_configuration.py delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/operations/__init__.py delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/operations/_communication_identity_operations.py delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/models/__init__.py delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/models/_models.py delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/models/_models_py3.py delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/operations/__init__.py delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/operations/_communication_identity_operations.py delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/py.typed delete mode 100644 sdk/communication/azure-communication-administration/samples/identity_samples.py delete mode 100644 sdk/communication/azure-communication-administration/samples/identity_samples_async.py delete mode 100644 sdk/communication/azure-communication-administration/swagger/COMMUNICATION_IDENTITY.md diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/__init__.py b/sdk/communication/azure-communication-administration/azure/communication/administration/__init__.py index 2ed40e51d71c..e10059fad1cc 100644 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/__init__.py +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/__init__.py @@ -4,15 +4,9 @@ # license information. # -------------------------------------------------------------------------- -from ._communication_identity_client import CommunicationIdentityClient from ._phone_number_administration_client import PhoneNumberAdministrationClient from ._polling import ReservePhoneNumberPolling, PurchaseReservationPolling, ReleasePhoneNumberPolling -from ._identity._generated.models import ( - CommunicationTokenRequest, - CommunicationIdentityToken -) - from ._phonenumber._generated.models import ( AcquiredPhoneNumber, AcquiredPhoneNumbers, @@ -42,16 +36,11 @@ ) __all__ = [ - 'CommunicationIdentityClient', 'PhoneNumberAdministrationClient', 'ReservePhoneNumberPolling', 'PurchaseReservationPolling', 'ReleasePhoneNumberPolling', - # from _identity - 'CommunicationTokenRequest', - 'CommunicationIdentityToken', - # from _phonenumber 'AcquiredPhoneNumber', 'AcquiredPhoneNumbers', diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_communication_identity_client.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_communication_identity_client.py deleted file mode 100644 index a97fd4407779..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_communication_identity_client.py +++ /dev/null @@ -1,153 +0,0 @@ -# coding=utf-8 -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ - -from azure.core.tracing.decorator import distributed_trace - -from ._identity._generated._communication_identity_client\ - import CommunicationIdentityClient as CommunicationIdentityClientGen -from ._identity._generated.models import CommunicationIdentityToken -from ._shared.utils import parse_connection_str, get_authentication_policy -from ._shared.models import CommunicationUserIdentifier -from ._version import SDK_MONIKER - -class CommunicationIdentityClient(object): - """Azure Communication Services Identity client. - - :param str endpoint: - The endpoint url for Azure Communication Service resource. - :param credential: - The credentials with which to authenticate. The value is an account - shared access key - - .. admonition:: Example: - - .. literalinclude:: ../samples/identity_samples.py - :language: python - :dedent: 8 - """ - def __init__( - self, - endpoint, # type: str - credential, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - try: - if not endpoint.lower().startswith('http'): - endpoint = "https://" + endpoint - except AttributeError: - raise ValueError("Account URL must be a string.") - - if not credential: - raise ValueError( - "You need to provide account shared key to authenticate.") - - self._endpoint = endpoint - self._identity_service_client = CommunicationIdentityClientGen( - self._endpoint, - authentication_policy=get_authentication_policy(endpoint, credential), - sdk_moniker=SDK_MONIKER, - **kwargs) - - @classmethod - def from_connection_string( - cls, conn_str, # type: str - **kwargs # type: Any - ): # type: (...) -> CommunicationIdentityClient - """Create CommunicationIdentityClient from a Connection String. - - :param str conn_str: - A connection string to an Azure Communication Service resource. - :returns: Instance of CommunicationIdentityClient. - :rtype: ~azure.communication.CommunicationIdentityClient - - .. admonition:: Example: - - .. literalinclude:: ../samples/identity_samples.py - :start-after: [START auth_from_connection_string] - :end-before: [END auth_from_connection_string] - :language: python - :dedent: 8 - :caption: Creating the CommunicationIdentityClient from a connection string. - """ - endpoint, access_key = parse_connection_str(conn_str) - - return cls(endpoint, access_key, **kwargs) - - @distributed_trace - def create_user(self, **kwargs): - # type: (...) -> CommunicationUserIdentifier - """create a single Communication user - - return: CommunicationUserIdentifier - rtype: ~azure.communication.administration.CommunicationUserIdentifier - """ - return self._identity_service_client.communication_identity.create( - cls=lambda pr, u, e: CommunicationUserIdentifier(u.id), - **kwargs) - - @distributed_trace - def delete_user( - self, - communication_user, # type: CommunicationUserIdentifier - **kwargs # type: Any - ): - # type: (...) -> None - """Triggers revocation event for user and deletes all its data. - - :param communication_user: - Azure Communication User to delete - :type communication_user: ~azure.communication.administration.CommunicationUserIdentifier - :return: None - :rtype: None - """ - self._identity_service_client.communication_identity.delete( - communication_user.identifier, **kwargs) - - @distributed_trace - def issue_token( - self, - user, # type: CommunicationUserIdentifier - scopes, # type: List[str] - **kwargs # type: Any - ): - # type: (...) -> CommunicationIdentityToken - """Generates a new token for an identity. - - :param user: Azure Communication User - :type user: ~azure.communication.administration.CommunicationUserIdentifier - :param scopes: - List of scopes to be added to the token. - :type scopes: list[str] - :return: CommunicationIdentityToken - :rtype: ~azure.communication.administration.CommunicationIdentityToken - """ - return self._identity_service_client.communication_identity.issue_token( - user.identifier, - scopes, - **kwargs) - - @distributed_trace - def revoke_tokens( - self, - user, # type: CommunicationUserIdentifier - issued_before=None, # type: Optional[datetime.datetime] - **kwargs # type: Any - ): - # type: (...) -> None - """Schedule revocation of all tokens of an identity. - - :param user: Azure Communication User. - :type user: ~azure.communication.administration.CommunicationUserIdentifier. - :param issued_before: All tokens that are issued prior to this time should get revoked. - :type issued_before: ~datetime.datetime. - :return: None - :rtype: None - """ - return self._identity_service_client.communication_identity.update( - user.identifier if user else None, - tokens_valid_from=issued_before, - **kwargs) diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/__init__.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/__init__.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/__init__.py deleted file mode 100644 index 733b64f83c37..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._communication_identity_client import CommunicationIdentityClient -__all__ = ['CommunicationIdentityClient'] - -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/_communication_identity_client.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/_communication_identity_client.py deleted file mode 100644 index c7a76a0d444d..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/_communication_identity_client.py +++ /dev/null @@ -1,60 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import TYPE_CHECKING - -from azure.core import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any - -from ._configuration import CommunicationIdentityClientConfiguration -from .operations import CommunicationIdentityOperations -from . import models - - -class CommunicationIdentityClient(object): - """Azure Communication Identity Service. - - :ivar communication_identity: CommunicationIdentityOperations operations - :vartype communication_identity: azure.communication.administration.operations.CommunicationIdentityOperations - :param endpoint: Auth and Identity endpoint. - :type endpoint: str - """ - - def __init__( - self, - endpoint, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - base_url = '{endpoint}' - self._config = CommunicationIdentityClientConfiguration(endpoint, **kwargs) - self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - - self.communication_identity = CommunicationIdentityOperations( - self._client, self._config, self._serialize, self._deserialize) - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> CommunicationIdentityClient - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/_configuration.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/_configuration.py deleted file mode 100644 index 079f98f2ffd0..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/_configuration.py +++ /dev/null @@ -1,58 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any - -VERSION = "unknown" - -class CommunicationIdentityClientConfiguration(Configuration): - """Configuration for CommunicationIdentityClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param endpoint: Auth and Identity endpoint. - :type endpoint: str - """ - - def __init__( - self, - endpoint, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - if endpoint is None: - raise ValueError("Parameter 'endpoint' must not be None.") - super(CommunicationIdentityClientConfiguration, self).__init__(**kwargs) - - self.endpoint = endpoint - self.api_version = "2020-07-20-preview2" - kwargs.setdefault('sdk_moniker', 'communicationidentityclient/{}'.format(VERSION)) - self._configure(**kwargs) - - def _configure( - self, - **kwargs # type: Any - ): - # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/__init__.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/__init__.py deleted file mode 100644 index 198816835b24..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._communication_identity_client import CommunicationIdentityClient -__all__ = ['CommunicationIdentityClient'] diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/_communication_identity_client.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/_communication_identity_client.py deleted file mode 100644 index 06c5aa66ddff..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/_communication_identity_client.py +++ /dev/null @@ -1,52 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any - -from azure.core import AsyncPipelineClient -from msrest import Deserializer, Serializer - -from ._configuration import CommunicationIdentityClientConfiguration -from .operations import CommunicationIdentityOperations -from .. import models - - -class CommunicationIdentityClient(object): - """Azure Communication Identity Service. - - :ivar communication_identity: CommunicationIdentityOperations operations - :vartype communication_identity: azure.communication.administration.aio.operations.CommunicationIdentityOperations - :param endpoint: Auth and Identity endpoint. - :type endpoint: str - """ - - def __init__( - self, - endpoint: str, - **kwargs: Any - ) -> None: - base_url = '{endpoint}' - self._config = CommunicationIdentityClientConfiguration(endpoint, **kwargs) - self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - - self.communication_identity = CommunicationIdentityOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "CommunicationIdentityClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/_configuration.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/_configuration.py deleted file mode 100644 index 4b91da974fe0..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/_configuration.py +++ /dev/null @@ -1,52 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies - -VERSION = "unknown" - -class CommunicationIdentityClientConfiguration(Configuration): - """Configuration for CommunicationIdentityClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param endpoint: Auth and Identity endpoint. - :type endpoint: str - """ - - def __init__( - self, - endpoint: str, - **kwargs: Any - ) -> None: - if endpoint is None: - raise ValueError("Parameter 'endpoint' must not be None.") - super(CommunicationIdentityClientConfiguration, self).__init__(**kwargs) - - self.endpoint = endpoint - self.api_version = "2020-07-20-preview2" - kwargs.setdefault('sdk_moniker', 'communicationidentityclient/{}'.format(VERSION)) - self._configure(**kwargs) - - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/operations/__init__.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/operations/__init__.py deleted file mode 100644 index 09dd0f2d0661..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/operations/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._communication_identity_operations import CommunicationIdentityOperations - -__all__ = [ - 'CommunicationIdentityOperations', -] diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/operations/_communication_identity_operations.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/operations/_communication_identity_operations.py deleted file mode 100644 index 9ff3934e2458..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/aio/operations/_communication_identity_operations.py +++ /dev/null @@ -1,271 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import datetime -from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest - -from ... import models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class CommunicationIdentityOperations: - """CommunicationIdentityOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.communication.administration.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - async def create( - self, - **kwargs - ) -> "models.CommunicationIdentity": - """Create a new identity. - - Create a new identity. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CommunicationIdentity, or the result of cls(response) - :rtype: ~azure.communication.administration.models.CommunicationIdentity - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.CommunicationIdentity"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview2" - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize('CommunicationIdentity', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create.metadata = {'url': '/identities'} # type: ignore - - async def delete( - self, - id: str, - **kwargs - ) -> None: - """Delete the identity, revoke all tokens of the identity and delete all associated data. - - Delete the identity, revoke all tokens of the identity and delete all associated data. - - :param id: Identifier of the identity to be deleted. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview2" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {'url': '/identities/{id}'} # type: ignore - - async def update( - self, - id: str, - tokens_valid_from: Optional[datetime.datetime] = None, - **kwargs - ) -> None: - """Update an Identity. - - Update an Identity. - - :param id: Identifier of the identity. - :type id: str - :param tokens_valid_from: All tokens that are issued prior to this time will be revoked. - :type tokens_valid_from: ~datetime.datetime - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _body = models.CommunicationIdentityUpdateRequest(tokens_valid_from=tokens_valid_from) - api_version = "2020-07-20-preview2" - content_type = kwargs.pop("content_type", "application/merge-patch+json") - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_body, 'CommunicationIdentityUpdateRequest') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - update.metadata = {'url': '/identities/{id}'} # type: ignore - - async def issue_token( - self, - id: str, - scopes: List[str], - **kwargs - ) -> "models.CommunicationIdentityToken": - """Generate a new token for an identity. - - Generate a new token for an identity. - - :param id: Identifier of the identity to issue token for. - :type id: str - :param scopes: List of scopes attached to the token. - :type scopes: list[str] - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CommunicationIdentityToken, or the result of cls(response) - :rtype: ~azure.communication.administration.models.CommunicationIdentityToken - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.CommunicationIdentityToken"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _body = models.CommunicationTokenRequest(scopes=scopes) - api_version = "2020-07-20-preview2" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.issue_token.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_body, 'CommunicationTokenRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize('CommunicationIdentityToken', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - issue_token.metadata = {'url': '/identities/{id}/token'} # type: ignore diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/models/__init__.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/models/__init__.py deleted file mode 100644 index 05dd3d4b6aab..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/models/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -try: - from ._models_py3 import CommunicationIdentity - from ._models_py3 import CommunicationIdentityToken - from ._models_py3 import CommunicationIdentityUpdateRequest - from ._models_py3 import CommunicationTokenRequest -except (SyntaxError, ImportError): - from ._models import CommunicationIdentity # type: ignore - from ._models import CommunicationIdentityToken # type: ignore - from ._models import CommunicationIdentityUpdateRequest # type: ignore - from ._models import CommunicationTokenRequest # type: ignore - -__all__ = [ - 'CommunicationIdentity', - 'CommunicationIdentityToken', - 'CommunicationIdentityUpdateRequest', - 'CommunicationTokenRequest', -] diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/models/_models.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/models/_models.py deleted file mode 100644 index ce2106c91807..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/models/_models.py +++ /dev/null @@ -1,113 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import msrest.serialization - - -class CommunicationIdentity(msrest.serialization.Model): - """A communication identity. - - All required parameters must be populated in order to send to Azure. - - :param id: Required. Identifier of the identity. - :type id: str - """ - - _validation = { - 'id': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CommunicationIdentity, self).__init__(**kwargs) - self.id = kwargs['id'] - - -class CommunicationIdentityToken(msrest.serialization.Model): - """CommunicationIdentityToken. - - All required parameters must be populated in order to send to Azure. - - :param id: Required. Identifier of the identity owning the token. - :type id: str - :param token: Required. The token issued for the identity. - :type token: str - :param expires_on: Required. The expiry time of the token. - :type expires_on: ~datetime.datetime - """ - - _validation = { - 'id': {'required': True}, - 'token': {'required': True}, - 'expires_on': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'token': {'key': 'token', 'type': 'str'}, - 'expires_on': {'key': 'expiresOn', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(CommunicationIdentityToken, self).__init__(**kwargs) - self.id = kwargs['id'] - self.token = kwargs['token'] - self.expires_on = kwargs['expires_on'] - - -class CommunicationIdentityUpdateRequest(msrest.serialization.Model): - """CommunicationIdentityUpdateRequest. - - :param tokens_valid_from: All tokens that are issued prior to this time will be revoked. - :type tokens_valid_from: ~datetime.datetime - """ - - _attribute_map = { - 'tokens_valid_from': {'key': 'tokensValidFrom', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(CommunicationIdentityUpdateRequest, self).__init__(**kwargs) - self.tokens_valid_from = kwargs.get('tokens_valid_from', None) - - -class CommunicationTokenRequest(msrest.serialization.Model): - """CommunicationTokenRequest. - - All required parameters must be populated in order to send to Azure. - - :param scopes: Required. List of scopes attached to the token. - :type scopes: list[str] - """ - - _validation = { - 'scopes': {'required': True}, - } - - _attribute_map = { - 'scopes': {'key': 'scopes', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(CommunicationTokenRequest, self).__init__(**kwargs) - self.scopes = kwargs['scopes'] diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/models/_models_py3.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/models/_models_py3.py deleted file mode 100644 index ba3988b1589a..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/models/_models_py3.py +++ /dev/null @@ -1,126 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import datetime -from typing import List, Optional - -import msrest.serialization - - -class CommunicationIdentity(msrest.serialization.Model): - """A communication identity. - - All required parameters must be populated in order to send to Azure. - - :param id: Required. Identifier of the identity. - :type id: str - """ - - _validation = { - 'id': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - *, - id: str, - **kwargs - ): - super(CommunicationIdentity, self).__init__(**kwargs) - self.id = id - - -class CommunicationIdentityToken(msrest.serialization.Model): - """CommunicationIdentityToken. - - All required parameters must be populated in order to send to Azure. - - :param id: Required. Identifier of the identity owning the token. - :type id: str - :param token: Required. The token issued for the identity. - :type token: str - :param expires_on: Required. The expiry time of the token. - :type expires_on: ~datetime.datetime - """ - - _validation = { - 'id': {'required': True}, - 'token': {'required': True}, - 'expires_on': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'token': {'key': 'token', 'type': 'str'}, - 'expires_on': {'key': 'expiresOn', 'type': 'iso-8601'}, - } - - def __init__( - self, - *, - id: str, - token: str, - expires_on: datetime.datetime, - **kwargs - ): - super(CommunicationIdentityToken, self).__init__(**kwargs) - self.id = id - self.token = token - self.expires_on = expires_on - - -class CommunicationIdentityUpdateRequest(msrest.serialization.Model): - """CommunicationIdentityUpdateRequest. - - :param tokens_valid_from: All tokens that are issued prior to this time will be revoked. - :type tokens_valid_from: ~datetime.datetime - """ - - _attribute_map = { - 'tokens_valid_from': {'key': 'tokensValidFrom', 'type': 'iso-8601'}, - } - - def __init__( - self, - *, - tokens_valid_from: Optional[datetime.datetime] = None, - **kwargs - ): - super(CommunicationIdentityUpdateRequest, self).__init__(**kwargs) - self.tokens_valid_from = tokens_valid_from - - -class CommunicationTokenRequest(msrest.serialization.Model): - """CommunicationTokenRequest. - - All required parameters must be populated in order to send to Azure. - - :param scopes: Required. List of scopes attached to the token. - :type scopes: list[str] - """ - - _validation = { - 'scopes': {'required': True}, - } - - _attribute_map = { - 'scopes': {'key': 'scopes', 'type': '[str]'}, - } - - def __init__( - self, - *, - scopes: List[str], - **kwargs - ): - super(CommunicationTokenRequest, self).__init__(**kwargs) - self.scopes = scopes diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/operations/__init__.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/operations/__init__.py deleted file mode 100644 index 09dd0f2d0661..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/operations/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._communication_identity_operations import CommunicationIdentityOperations - -__all__ = [ - 'CommunicationIdentityOperations', -] diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/operations/_communication_identity_operations.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/operations/_communication_identity_operations.py deleted file mode 100644 index 26d1a86a88d2..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/operations/_communication_identity_operations.py +++ /dev/null @@ -1,279 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import datetime -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from .. import models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class CommunicationIdentityOperations(object): - """CommunicationIdentityOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.communication.administration.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def create( - self, - **kwargs # type: Any - ): - # type: (...) -> "models.CommunicationIdentity" - """Create a new identity. - - Create a new identity. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CommunicationIdentity, or the result of cls(response) - :rtype: ~azure.communication.administration.models.CommunicationIdentity - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.CommunicationIdentity"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview2" - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize('CommunicationIdentity', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create.metadata = {'url': '/identities'} # type: ignore - - def delete( - self, - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Delete the identity, revoke all tokens of the identity and delete all associated data. - - Delete the identity, revoke all tokens of the identity and delete all associated data. - - :param id: Identifier of the identity to be deleted. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview2" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {'url': '/identities/{id}'} # type: ignore - - def update( - self, - id, # type: str - tokens_valid_from=None, # type: Optional[datetime.datetime] - **kwargs # type: Any - ): - # type: (...) -> None - """Update an Identity. - - Update an Identity. - - :param id: Identifier of the identity. - :type id: str - :param tokens_valid_from: All tokens that are issued prior to this time will be revoked. - :type tokens_valid_from: ~datetime.datetime - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _body = models.CommunicationIdentityUpdateRequest(tokens_valid_from=tokens_valid_from) - api_version = "2020-07-20-preview2" - content_type = kwargs.pop("content_type", "application/merge-patch+json") - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_body, 'CommunicationIdentityUpdateRequest') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) - - update.metadata = {'url': '/identities/{id}'} # type: ignore - - def issue_token( - self, - id, # type: str - scopes, # type: List[str] - **kwargs # type: Any - ): - # type: (...) -> "models.CommunicationIdentityToken" - """Generate a new token for an identity. - - Generate a new token for an identity. - - :param id: Identifier of the identity to issue token for. - :type id: str - :param scopes: List of scopes attached to the token. - :type scopes: list[str] - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CommunicationIdentityToken, or the result of cls(response) - :rtype: ~azure.communication.administration.models.CommunicationIdentityToken - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.CommunicationIdentityToken"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - _body = models.CommunicationTokenRequest(scopes=scopes) - api_version = "2020-07-20-preview2" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.issue_token.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_body, 'CommunicationTokenRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = self._deserialize('CommunicationIdentityToken', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - issue_token.metadata = {'url': '/identities/{id}/token'} # type: ignore diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/py.typed b/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_identity/_generated/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/aio/__init__.py b/sdk/communication/azure-communication-administration/azure/communication/administration/aio/__init__.py index ffe7feed48fa..a35d7f5eba44 100644 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/aio/__init__.py +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/aio/__init__.py @@ -1,11 +1,9 @@ -from ._communication_identity_client_async import CommunicationIdentityClient from ._phone_number_administration_client_async import PhoneNumberAdministrationClient from ._polling_async import ReservePhoneNumberPollingAsync, \ PurchaseReservationPollingAsync, \ ReleasePhoneNumberPollingAsync __all__ = [ - 'CommunicationIdentityClient', 'PhoneNumberAdministrationClient', 'ReservePhoneNumberPollingAsync', 'PurchaseReservationPollingAsync', diff --git a/sdk/communication/azure-communication-administration/samples/identity_samples.py b/sdk/communication/azure-communication-administration/samples/identity_samples.py deleted file mode 100644 index e20e5cfedfba..000000000000 --- a/sdk/communication/azure-communication-administration/samples/identity_samples.py +++ /dev/null @@ -1,81 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- - -""" -FILE: identity_sample.py -DESCRIPTION: - These samples demonstrate identity client samples. - - ///authenticating a client via a connection string -USAGE: - python identity_samples.py -""" -import os - -class CommunicationIdentityClientSamples(object): - - def __init__(self): - self.connection_string = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') - self.endpoint = os.getenv('AZURE_COMMUNICATION_SERVICE_ENDPOINT') - self.client_id = os.getenv('AZURE_CLIENT_ID') - self.client_secret = os.getenv('AZURE_CLIENT_SECRET') - self.tenant_id = os.getnenv('AZURE_TENANT_ID') - - def issue_token(self): - from azure.communication.administration import CommunicationIdentityClient - - if self.client_id is not None and self.client_secret is not None and self.tenant_id is not None: - from azure.identity import DefaultAzureCredential - identity_client = CommunicationIdentityClient(self.endpoint, DefaultAzureCredential()) - else: - identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) - user = identity_client.create_user() - tokenresponse = identity_client.issue_token(user, scopes=["chat"]) - print(tokenresponse) - - def revoke_tokens(self): - from azure.communication.administration import CommunicationIdentityClient - - if self.client_id is not None and self.client_secret is not None and self.tenant_id is not None: - from azure.identity import DefaultAzureCredential - identity_client = CommunicationIdentityClient(self.endpoint, DefaultAzureCredential()) - else: - identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) - user = identity_client.create_user() - tokenresponse = identity_client.issue_token(user, scopes=["chat"]) - identity_client.revoke_tokens(user) - print(tokenresponse) - - def create_user(self): - from azure.communication.administration import CommunicationIdentityClient - - if self.client_id is not None and self.client_secret is not None and self.tenant_id is not None: - from azure.identity import DefaultAzureCredential - identity_client = CommunicationIdentityClient(self.endpoint, DefaultAzureCredential()) - else: - identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) - user = identity_client.create_user() - print(user.identifier) - - def delete_user(self): - from azure.communication.administration import CommunicationIdentityClient - - if self.client_id is not None and self.client_secret is not None and self.tenant_id is not None: - from azure.identity import DefaultAzureCredential - identity_client = CommunicationIdentityClient(self.endpoint, DefaultAzureCredential()) - else: - identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) - user = identity_client.create_user() - identity_client.delete_user(user) - -if __name__ == '__main__': - sample = CommunicationIdentityClientSamples() - sample.create_user() - sample.delete_user() - sample.issue_token() - sample.revoke_tokens() diff --git a/sdk/communication/azure-communication-administration/samples/identity_samples_async.py b/sdk/communication/azure-communication-administration/samples/identity_samples_async.py deleted file mode 100644 index 0cbb8c147fb0..000000000000 --- a/sdk/communication/azure-communication-administration/samples/identity_samples_async.py +++ /dev/null @@ -1,93 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- - -""" -FILE: identity_sample_async.py -DESCRIPTION: - These samples demonstrate async identity client samples. - - ///authenticating a client via a connection string -USAGE: - python identity_samples_async.py -""" - -import asyncio -import os - - -class CommunicationIdentityClientSamples(object): - - def __init__(self): - self.connection_string = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') - self.endpoint = os.getenv('AZURE_COMMUNICATION_SERVICE_ENDPOINT') - self.client_id = os.getenv('AZURE_CLIENT_ID') - self.client_secret = os.getenv('AZURE_CLIENT_SECRET') - self.tenant_id = os.getnenv('AZURE_TENANT_ID') - - async def issue_token(self): - from azure.communication.administration.aio import CommunicationIdentityClient - if self.client_id is not None and self.client_secret is not None and self.tenant_id is not None: - from azure.identity import DefaultAzureCredential - identity_client = CommunicationIdentityClient(self.endpoint, DefaultAzureCredential()) - else: - identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) - - async with identity_client: - user = await identity_client.create_user() - print(user.identifier) - tokenresponse = await identity_client.issue_token(user, scopes=["chat"]) - print(tokenresponse) - - async def revoke_tokens(self): - from azure.communication.administration.aio import CommunicationIdentityClient - if self.client_id is not None and self.client_secret is not None and self.tenant_id is not None: - from azure.identity import DefaultAzureCredential - identity_client = CommunicationIdentityClient(self.endpoint, DefaultAzureCredential()) - else: - identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) - - async with identity_client: - user = await identity_client.create_user() - tokenresponse = await identity_client.issue_token(user, scopes=["chat"]) - await identity_client.revoke_tokens(user) - print(tokenresponse) - - async def create_user(self): - from azure.communication.administration.aio import CommunicationIdentityClient - if self.client_id is not None and self.client_secret is not None and self.tenant_id is not None: - from azure.identity import DefaultAzureCredential - identity_client = CommunicationIdentityClient(self.endpoint, DefaultAzureCredential()) - else: - identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) - - async with identity_client: - user = await identity_client.create_user() - print(user.identifier) - - async def delete_user(self): - from azure.communication.administration.aio import CommunicationIdentityClient - if self.client_id is not None and self.client_secret is not None and self.tenant_id is not None: - from azure.identity import DefaultAzureCredential - identity_client = CommunicationIdentityClient(self.endpoint, DefaultAzureCredential()) - else: - identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) - - async with identity_client: - user = await identity_client.create_user() - await identity_client.delete_user(user) - -async def main(): - sample = CommunicationIdentityClientSamples() - await sample.create_user() - await sample.delete_user() - await sample.issue_token() - await sample.revoke_tokens() - -if __name__ == '__main__': - loop = asyncio.get_event_loop() - loop.run_until_complete(main()) diff --git a/sdk/communication/azure-communication-administration/swagger/COMMUNICATION_IDENTITY.md b/sdk/communication/azure-communication-administration/swagger/COMMUNICATION_IDENTITY.md deleted file mode 100644 index 0a5477c97638..000000000000 --- a/sdk/communication/azure-communication-administration/swagger/COMMUNICATION_IDENTITY.md +++ /dev/null @@ -1,27 +0,0 @@ -# Azure Communication Administration for Python - -> see https://aka.ms/autorest - -### Setup -```ps -npm install -g autorest -``` - -### Generation -```ps -cd -autorest ./COMMUNICATION_IDENTITY.md -``` - -### Settings -``` yaml -input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/8818a603b78a1355ba1647ab9cd4e3354cdc4b69/specification/communication/data-plane/Microsoft.CommunicationServicesIdentity/preview/2020-07-20-preview2/CommunicationIdentity.json -output-folder: ../azure/communication/administration/_identity/_generated/ -namespace: azure.communication.administration -license-header: MICROSOFT_MIT_NO_VERSION -payload-flattening-threshold: 3 -no-namespace-folders: true -clear-output-folder: true -v3: true -python: true -``` \ No newline at end of file From 418abcdaf6c637e372b424dde82d331f49205f9c Mon Sep 17 00:00:00 2001 From: Bert Ong <823691+beltr0n@users.noreply.github.com> Date: Thu, 21 Jan 2021 17:12:27 -0800 Subject: [PATCH 11/33] update changelog --- .../azure-communication-administration/CHANGELOG.md | 1 + sdk/communication/azure-communication-identity/CHANGELOG.md | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/communication/azure-communication-administration/CHANGELOG.md b/sdk/communication/azure-communication-administration/CHANGELOG.md index 5ea9e283325d..3f3f0f55287a 100644 --- a/sdk/communication/azure-communication-administration/CHANGELOG.md +++ b/sdk/communication/azure-communication-administration/CHANGELOG.md @@ -3,6 +3,7 @@ ## 1.0.0b4 (Unreleased) ### Breaking Changes +- CommunicationIdentityClient is moved to a new package: "azure.communication.identity" ##### `PhoneNumberAdministrationClient` - `begin_reserve_phone_numbers` now takes `display_name`, `description`, `phone_plan_ids`, diff --git a/sdk/communication/azure-communication-identity/CHANGELOG.md b/sdk/communication/azure-communication-identity/CHANGELOG.md index 964b44312c40..cafa147a25ac 100644 --- a/sdk/communication/azure-communication-identity/CHANGELOG.md +++ b/sdk/communication/azure-communication-identity/CHANGELOG.md @@ -4,7 +4,6 @@ ### Added - Added CommunicationIdentityClient (originally was part of the azure.communication.administration package). -- Added support for Azure Active Directory authentication for the Identity client [read_me]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/communication/azure-communication-identity/README.md From 96734b4b9427e9d2fa4e36f0bd80b903f0fb0255 Mon Sep 17 00:00:00 2001 From: Lakshman Sundaralingam Date: Thu, 21 Jan 2021 17:25:37 -0800 Subject: [PATCH 12/33] Removed identity tests from admin package --- ...tion_identity_client.test_create_user.yaml | 42 ------ ...est_create_user_from_managed_identity.yaml | 38 ----- ...tion_identity_client.test_delete_user.yaml | 78 ---------- ...est_delete_user_from_managed_identity.yaml | 70 --------- ...tion_identity_client.test_issue_token.yaml | 84 ----------- ...est_issue_token_from_managed_identity.yaml | 76 ---------- ...on_identity_client.test_revoke_tokens.yaml | 122 --------------- ...t_revoke_tokens_from_managed_identity.yaml | 110 -------------- ...dentity_client_async.test_create_user.yaml | 30 ---- ...est_create_user_from_managed_identity.yaml | 26 ---- ...dentity_client_async.test_delete_user.yaml | 54 ------- ...est_delete_user_from_managed_identity.yaml | 46 ------ ...dentity_client_async.test_issue_token.yaml | 62 -------- ...est_issue_token_from_managed_identity.yaml | 54 ------- ...ntity_client_async.test_revoke_tokens.yaml | 90 ----------- ...t_revoke_tokens_from_managed_identity.yaml | 78 ---------- .../test_communication_identity_client.py | 141 ------------------ ...est_communication_identity_client_async.py | 138 ----------------- 18 files changed, 1339 deletions(-) delete mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_create_user.yaml delete mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_create_user_from_managed_identity.yaml delete mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_delete_user.yaml delete mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_delete_user_from_managed_identity.yaml delete mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_issue_token.yaml delete mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_issue_token_from_managed_identity.yaml delete mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_revoke_tokens.yaml delete mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_revoke_tokens_from_managed_identity.yaml delete mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_create_user.yaml delete mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_create_user_from_managed_identity.yaml delete mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_delete_user.yaml delete mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_delete_user_from_managed_identity.yaml delete mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_issue_token.yaml delete mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_issue_token_from_managed_identity.yaml delete mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_revoke_tokens.yaml delete mode 100644 sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_revoke_tokens_from_managed_identity.yaml delete mode 100644 sdk/communication/azure-communication-administration/tests/test_communication_identity_client.py delete mode 100644 sdk/communication/azure-communication-administration/tests/test_communication_identity_client_async.py diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_create_user.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_create_user.yaml deleted file mode 100644 index c2bc1d2d7dc8..000000000000 --- a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_create_user.yaml +++ /dev/null @@ -1,42 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - Date: - - Tue, 22 Dec 2020 18:26:56 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 - response: - body: - string: '{"id": "sanitized"}' - headers: - api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - content-type: - - application/json; charset=utf-8 - date: - - Tue, 22 Dec 2020 18:26:55 GMT - ms-cv: - - 4whAoum970WIzePHLz1Ujg.0 - strict-transport-security: - - max-age=2592000 - transfer-encoding: - - chunked - x-processing-time: - - 18ms - status: - code: 200 - message: OK -version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_create_user_from_managed_identity.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_create_user_from_managed_identity.yaml deleted file mode 100644 index f159cc5d3c7c..000000000000 --- a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_create_user_from_managed_identity.yaml +++ /dev/null @@ -1,38 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 - response: - body: - string: '{"id": "sanitized"}' - headers: - api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - content-type: - - application/json; charset=utf-8 - date: - - Tue, 22 Dec 2020 18:28:04 GMT - ms-cv: - - /4JsXqUuEkmQ1v304iaBTw.0 - strict-transport-security: - - max-age=2592000 - transfer-encoding: - - chunked - x-processing-time: - - 635ms - status: - code: 200 - message: OK -version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_delete_user.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_delete_user.yaml deleted file mode 100644 index 392431b12f89..000000000000 --- a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_delete_user.yaml +++ /dev/null @@ -1,78 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - Date: - - Tue, 22 Dec 2020 18:29:13 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 - response: - body: - string: '{"id": "sanitized"}' - headers: - api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - content-type: - - application/json; charset=utf-8 - date: - - Tue, 22 Dec 2020 18:29:12 GMT - ms-cv: - - UzbbWyNM6Ee4hx1Ym7MwSA.0 - strict-transport-security: - - max-age=2592000 - transfer-encoding: - - chunked - x-processing-time: - - 19ms - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - Date: - - Tue, 22 Dec 2020 18:29:14 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - x-ms-return-client-request-id: - - 'true' - method: DELETE - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 - response: - body: - string: '' - headers: - api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - date: - - Tue, 22 Dec 2020 18:29:13 GMT - ms-cv: - - bD8oBIuNQEWXEaluFwupbA.0 - strict-transport-security: - - max-age=2592000 - x-processing-time: - - 764ms - status: - code: 204 - message: No Content -version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_delete_user_from_managed_identity.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_delete_user_from_managed_identity.yaml deleted file mode 100644 index e1b92837214b..000000000000 --- a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_delete_user_from_managed_identity.yaml +++ /dev/null @@ -1,70 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 - response: - body: - string: '{"id": "sanitized"}' - headers: - api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - content-type: - - application/json; charset=utf-8 - date: - - Tue, 22 Dec 2020 18:30:23 GMT - ms-cv: - - eSMH8ZATxUWO5OamG49Wdg.0 - strict-transport-security: - - max-age=2592000 - transfer-encoding: - - chunked - x-processing-time: - - 811ms - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - method: DELETE - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 - response: - body: - string: '' - headers: - api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - date: - - Tue, 22 Dec 2020 18:30:24 GMT - ms-cv: - - 91lJNqPMP0+hZnY0ay0tXA.0 - strict-transport-security: - - max-age=2592000 - x-processing-time: - - 741ms - status: - code: 204 - message: No Content -version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_issue_token.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_issue_token.yaml deleted file mode 100644 index 76d30c8ff3e6..000000000000 --- a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_issue_token.yaml +++ /dev/null @@ -1,84 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - Date: - - Tue, 22 Dec 2020 18:31:34 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 - response: - body: - string: '{"id": "sanitized"}' - headers: - api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - content-type: - - application/json; charset=utf-8 - date: - - Tue, 22 Dec 2020 18:31:32 GMT - ms-cv: - - OXm+S4D9ak+t0Y4jKA3bFA.0 - strict-transport-security: - - max-age=2592000 - transfer-encoding: - - chunked - x-processing-time: - - 24ms - status: - code: 200 - message: OK -- request: - body: '{"scopes": ["chat"]}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '20' - Content-Type: - - application/json - Date: - - Tue, 22 Dec 2020 18:31:34 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 - response: - body: - string: '{"id": "sanitized", "token": "sanitized", "expiresOn": "2020-12-23T18:31:32.3009076+00:00"}' - headers: - api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - content-type: - - application/json; charset=utf-8 - date: - - Tue, 22 Dec 2020 18:31:32 GMT - ms-cv: - - EArcgkwtPkCU38ZbLjwJEQ.0 - strict-transport-security: - - max-age=2592000 - transfer-encoding: - - chunked - x-processing-time: - - 24ms - status: - code: 200 - message: OK -version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_issue_token_from_managed_identity.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_issue_token_from_managed_identity.yaml deleted file mode 100644 index 879ddee12d3c..000000000000 --- a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_issue_token_from_managed_identity.yaml +++ /dev/null @@ -1,76 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 - response: - body: - string: '{"id": "sanitized"}' - headers: - api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - content-type: - - application/json; charset=utf-8 - date: - - Tue, 22 Dec 2020 18:32:41 GMT - ms-cv: - - NcQPodkL5UOzC+AtKJcXvw.0 - strict-transport-security: - - max-age=2592000 - transfer-encoding: - - chunked - x-processing-time: - - 501ms - status: - code: 200 - message: OK -- request: - body: '{"scopes": ["chat"]}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '20' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - method: POST - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 - response: - body: - string: '{"id": "sanitized", "token": "sanitized", "expiresOn": "2020-12-23T18:32:41.3736569+00:00"}' - headers: - api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - content-type: - - application/json; charset=utf-8 - date: - - Tue, 22 Dec 2020 18:32:41 GMT - ms-cv: - - W4rjQkxkvUSQqyJk5dUwCA.0 - strict-transport-security: - - max-age=2592000 - transfer-encoding: - - chunked - x-processing-time: - - 27ms - status: - code: 200 - message: OK -version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_revoke_tokens.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_revoke_tokens.yaml deleted file mode 100644 index 5e79664fa87f..000000000000 --- a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_revoke_tokens.yaml +++ /dev/null @@ -1,122 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - Date: - - Tue, 22 Dec 2020 18:34:17 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 - response: - body: - string: '{"id": "sanitized"}' - headers: - api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - content-type: - - application/json; charset=utf-8 - date: - - Tue, 22 Dec 2020 18:34:16 GMT - ms-cv: - - ZDSP6Prb6UGYOTBLvb6AdQ.0 - strict-transport-security: - - max-age=2592000 - transfer-encoding: - - chunked - x-processing-time: - - 23ms - status: - code: 200 - message: OK -- request: - body: '{"scopes": ["chat"]}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '20' - Content-Type: - - application/json - Date: - - Tue, 22 Dec 2020 18:34:18 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 - response: - body: - string: '{"id": "sanitized", "token": "sanitized", "expiresOn": "2020-12-23T18:34:15.7537392+00:00"}' - headers: - api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - content-type: - - application/json; charset=utf-8 - date: - - Tue, 22 Dec 2020 18:34:16 GMT - ms-cv: - - Hmv1R+jifUSsezIU2yJU8Q.0 - strict-transport-security: - - max-age=2592000 - transfer-encoding: - - chunked - x-processing-time: - - 31ms - status: - code: 200 - message: OK -- request: - body: '{}' - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '2' - Content-Type: - - application/merge-patch+json - Date: - - Tue, 22 Dec 2020 18:34:18 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - x-ms-return-client-request-id: - - 'true' - method: PATCH - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 - response: - body: - string: '' - headers: - api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - date: - - Tue, 22 Dec 2020 18:34:16 GMT - ms-cv: - - vwznKj2MY0qO9HTJ9YWIRw.0 - strict-transport-security: - - max-age=2592000 - x-processing-time: - - 11ms - status: - code: 204 - message: No Content -version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_revoke_tokens_from_managed_identity.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_revoke_tokens_from_managed_identity.yaml deleted file mode 100644 index 853de6129c9d..000000000000 --- a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client.test_revoke_tokens_from_managed_identity.yaml +++ /dev/null @@ -1,110 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 - response: - body: - string: '{"id": "sanitized"}' - headers: - api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - content-type: - - application/json; charset=utf-8 - date: - - Tue, 22 Dec 2020 18:35:27 GMT - ms-cv: - - QmngflWD+EOVXH7i/FS+iw.0 - strict-transport-security: - - max-age=2592000 - transfer-encoding: - - chunked - x-processing-time: - - 792ms - status: - code: 200 - message: OK -- request: - body: '{"scopes": ["chat"]}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '20' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - method: POST - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 - response: - body: - string: '{"id": "sanitized", "token": "sanitized", "expiresOn": "2020-12-23T18:35:27.28321+00:00"}' - headers: - api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - content-type: - - application/json; charset=utf-8 - date: - - Tue, 22 Dec 2020 18:35:27 GMT - ms-cv: - - PRIzOxRVQkycMUEl6WNjHw.0 - strict-transport-security: - - max-age=2592000 - transfer-encoding: - - chunked - x-processing-time: - - 30ms - status: - code: 200 - message: OK -- request: - body: '{}' - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '2' - Content-Type: - - application/merge-patch+json - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - method: PATCH - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 - response: - body: - string: '' - headers: - api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - date: - - Tue, 22 Dec 2020 18:35:27 GMT - ms-cv: - - mUk2cNSJI0e/Nz7J7yCGYg.0 - strict-transport-security: - - max-age=2592000 - x-processing-time: - - 11ms - status: - code: 204 - message: No Content -version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_create_user.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_create_user.yaml deleted file mode 100644 index 744fbd017292..000000000000 --- a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_create_user.yaml +++ /dev/null @@ -1,30 +0,0 @@ -interactions: -- request: - body: '' - headers: - Accept: - - application/json - Date: - - Tue, 22 Dec 2020 18:48:56 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 - response: - body: - string: '{"id": "sanitized"}' - headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - content-type: application/json; charset=utf-8 - date: Tue, 22 Dec 2020 18:48:54 GMT - ms-cv: vfIkgQk+J0OWSV4P3J1i0w.0 - strict-transport-security: max-age=2592000 - transfer-encoding: chunked - x-processing-time: 22ms - status: - code: 200 - message: OK - url: https://communicationtrnhzmurqrr.communication.azure.com/identities?api-version=2020-07-20-preview2 -version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_create_user_from_managed_identity.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_create_user_from_managed_identity.yaml deleted file mode 100644 index 883eb09da417..000000000000 --- a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_create_user_from_managed_identity.yaml +++ /dev/null @@ -1,26 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/json - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 - response: - body: - string: '{"id": "sanitized"}' - headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - content-type: application/json; charset=utf-8 - date: Tue, 22 Dec 2020 18:50:04 GMT - ms-cv: fj3guox5CUSvTCDG5gI0YA.0 - strict-transport-security: max-age=2592000 - transfer-encoding: chunked - x-processing-time: 534ms - status: - code: 200 - message: OK - url: https://communicationr7rdwwqs74n.communication.azure.com/identities?api-version=2020-07-20-preview2 -version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_delete_user.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_delete_user.yaml deleted file mode 100644 index 46f6bc7da32e..000000000000 --- a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_delete_user.yaml +++ /dev/null @@ -1,54 +0,0 @@ -interactions: -- request: - body: '' - headers: - Accept: - - application/json - Date: - - Tue, 22 Dec 2020 18:51:13 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 - response: - body: - string: '{"id": "sanitized"}' - headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - content-type: application/json; charset=utf-8 - date: Tue, 22 Dec 2020 18:51:12 GMT - ms-cv: dHk7/E5BhUSf+g3Bkg94YQ.0 - strict-transport-security: max-age=2592000 - transfer-encoding: chunked - x-processing-time: 22ms - status: - code: 200 - message: OK - url: https://communication42hz4pfbosr.communication.azure.com/identities?api-version=2020-07-20-preview2 -- request: - body: '' - headers: - Date: - - Tue, 22 Dec 2020 18:51:14 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - x-ms-return-client-request-id: - - 'true' - method: DELETE - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 - response: - body: - string: '' - headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - date: Tue, 22 Dec 2020 18:51:12 GMT - ms-cv: 3DnY9x3jNUGrGnsi3LP0SA.0 - strict-transport-security: max-age=2592000 - x-processing-time: 440ms - status: - code: 204 - message: No Content - url: https://communication42hz4pfbosr.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 -version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_delete_user_from_managed_identity.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_delete_user_from_managed_identity.yaml deleted file mode 100644 index 3d5253742e18..000000000000 --- a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_delete_user_from_managed_identity.yaml +++ /dev/null @@ -1,46 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/json - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 - response: - body: - string: '{"id": "sanitized"}' - headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - content-type: application/json; charset=utf-8 - date: Tue, 22 Dec 2020 18:52:27 GMT - ms-cv: ww9tz7CpG0SXqqYPyV70Cw.0 - strict-transport-security: max-age=2592000 - transfer-encoding: chunked - x-processing-time: 192ms - status: - code: 200 - message: OK - url: https://communicationrscjfarclwr.communication.azure.com/identities?api-version=2020-07-20-preview2 -- request: - body: null - headers: - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - method: DELETE - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 - response: - body: - string: '' - headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - date: Tue, 22 Dec 2020 18:52:28 GMT - ms-cv: baDrTbu3H0qpWj2TJSno0A.0 - strict-transport-security: max-age=2592000 - x-processing-time: 864ms - status: - code: 204 - message: No Content - url: https://communicationrscjfarclwr.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 -version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_issue_token.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_issue_token.yaml deleted file mode 100644 index fce3ec17e7e1..000000000000 --- a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_issue_token.yaml +++ /dev/null @@ -1,62 +0,0 @@ -interactions: -- request: - body: '' - headers: - Accept: - - application/json - Date: - - Tue, 22 Dec 2020 18:53:37 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 - response: - body: - string: '{"id": "sanitized"}' - headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - content-type: application/json; charset=utf-8 - date: Tue, 22 Dec 2020 18:53:36 GMT - ms-cv: Agl32miSq0CTEladXG7lbw.0 - strict-transport-security: max-age=2592000 - transfer-encoding: chunked - x-processing-time: 20ms - status: - code: 200 - message: OK - url: https://communicatione77tfh7y2ht.communication.azure.com/identities?api-version=2020-07-20-preview2 -- request: - body: '{"scopes": ["chat"]}' - headers: - Accept: - - application/json - Content-Length: - - '20' - Content-Type: - - application/json - Date: - - Tue, 22 Dec 2020 18:53:38 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 - response: - body: - string: '{"id": "sanitized", "token": "sanitized", "expiresOn": "2020-12-23T18:53:35.7585148+00:00"}' - headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - content-type: application/json; charset=utf-8 - date: Tue, 22 Dec 2020 18:53:36 GMT - ms-cv: P3rSrWhwykmJcOW+Yb8Q2w.0 - strict-transport-security: max-age=2592000 - transfer-encoding: chunked - x-processing-time: 26ms - status: - code: 200 - message: OK - url: https://communicatione77tfh7y2ht.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 -version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_issue_token_from_managed_identity.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_issue_token_from_managed_identity.yaml deleted file mode 100644 index 44a889e13df3..000000000000 --- a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_issue_token_from_managed_identity.yaml +++ /dev/null @@ -1,54 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/json - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 - response: - body: - string: '{"id": "sanitized"}' - headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - content-type: application/json; charset=utf-8 - date: Tue, 22 Dec 2020 18:54:45 GMT - ms-cv: UywF8dbxrkyYXGTozRnuIw.0 - strict-transport-security: max-age=2592000 - transfer-encoding: chunked - x-processing-time: 773ms - status: - code: 200 - message: OK - url: https://communicationztg2acjbipc.communication.azure.com/identities?api-version=2020-07-20-preview2 -- request: - body: '{"scopes": ["chat"]}' - headers: - Accept: - - application/json - Content-Length: - - '20' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - method: POST - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 - response: - body: - string: '{"id": "sanitized", "token": "sanitized", "expiresOn": "2020-12-23T18:54:45.1115885+00:00"}' - headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - content-type: application/json; charset=utf-8 - date: Tue, 22 Dec 2020 18:54:45 GMT - ms-cv: ywaIOOtf9EiQs6pibQmCwg.0 - strict-transport-security: max-age=2592000 - transfer-encoding: chunked - x-processing-time: 25ms - status: - code: 200 - message: OK - url: https://communicationztg2acjbipc.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 -version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_revoke_tokens.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_revoke_tokens.yaml deleted file mode 100644 index cefb985a000f..000000000000 --- a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_revoke_tokens.yaml +++ /dev/null @@ -1,90 +0,0 @@ -interactions: -- request: - body: '' - headers: - Accept: - - application/json - Date: - - Tue, 22 Dec 2020 18:55:56 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 - response: - body: - string: '{"id": "sanitized"}' - headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - content-type: application/json; charset=utf-8 - date: Tue, 22 Dec 2020 18:55:55 GMT - ms-cv: M9b8kGAz8UGwsoZe2mFLCA.0 - strict-transport-security: max-age=2592000 - transfer-encoding: chunked - x-processing-time: 29ms - status: - code: 200 - message: OK - url: https://communicationngn6p2kywhg.communication.azure.com/identities?api-version=2020-07-20-preview2 -- request: - body: '{"scopes": ["chat"]}' - headers: - Accept: - - application/json - Content-Length: - - '20' - Content-Type: - - application/json - Date: - - Tue, 22 Dec 2020 18:55:57 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 - response: - body: - string: '{"id": "sanitized", "token": "sanitized", "expiresOn": "2020-12-23T18:55:54.788117+00:00"}' - headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - content-type: application/json; charset=utf-8 - date: Tue, 22 Dec 2020 18:55:55 GMT - ms-cv: MBCUlMoRBECvCLmV00eWXw.0 - strict-transport-security: max-age=2592000 - transfer-encoding: chunked - x-processing-time: 27ms - status: - code: 200 - message: OK - url: https://communicationngn6p2kywhg.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 -- request: - body: '{}' - headers: - Content-Length: - - '2' - Content-Type: - - application/merge-patch+json - Date: - - Tue, 22 Dec 2020 18:55:57 GMT - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - x-ms-return-client-request-id: - - 'true' - method: PATCH - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 - response: - body: - string: '' - headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - date: Tue, 22 Dec 2020 18:55:55 GMT - ms-cv: MVgoSrOVSkiU0c+teqMDZQ.0 - strict-transport-security: max-age=2592000 - x-processing-time: 10ms - status: - code: 204 - message: No Content - url: https://communicationngn6p2kywhg.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 -version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_revoke_tokens_from_managed_identity.yaml b/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_revoke_tokens_from_managed_identity.yaml deleted file mode 100644 index 23b4c57c9632..000000000000 --- a/sdk/communication/azure-communication-administration/tests/recordings/test_communication_identity_client_async.test_revoke_tokens_from_managed_identity.yaml +++ /dev/null @@ -1,78 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/json - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 - response: - body: - string: '{"id": "sanitized"}' - headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - content-type: application/json; charset=utf-8 - date: Tue, 22 Dec 2020 18:57:03 GMT - ms-cv: a9v8/cRgN0uyuQQUguwkGA.0 - strict-transport-security: max-age=2592000 - transfer-encoding: chunked - x-processing-time: 195ms - status: - code: 200 - message: OK - url: https://communicationxheui257vce.communication.azure.com/identities?api-version=2020-07-20-preview2 -- request: - body: '{"scopes": ["chat"]}' - headers: - Accept: - - application/json - Content-Length: - - '20' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - method: POST - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 - response: - body: - string: '{"id": "sanitized", "token": "sanitized", "expiresOn": "2020-12-23T18:57:03.4428768+00:00"}' - headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - content-type: application/json; charset=utf-8 - date: Tue, 22 Dec 2020 18:57:03 GMT - ms-cv: Oc9n/N0oA0mLVBlk8UaTpw.0 - strict-transport-security: max-age=2592000 - transfer-encoding: chunked - x-processing-time: 24ms - status: - code: 200 - message: OK - url: https://communicationxheui257vce.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 -- request: - body: '{}' - headers: - Content-Length: - - '2' - Content-Type: - - application/merge-patch+json - User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - method: PATCH - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 - response: - body: - string: '' - headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - date: Tue, 22 Dec 2020 18:57:03 GMT - ms-cv: lBOoIDU5lUe2vbpjz5+Gkg.0 - strict-transport-security: max-age=2592000 - x-processing-time: 11ms - status: - code: 204 - message: No Content - url: https://communicationxheui257vce.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 -version: 1 diff --git a/sdk/communication/azure-communication-administration/tests/test_communication_identity_client.py b/sdk/communication/azure-communication-administration/tests/test_communication_identity_client.py deleted file mode 100644 index 9104aae5f915..000000000000 --- a/sdk/communication/azure-communication-administration/tests/test_communication_identity_client.py +++ /dev/null @@ -1,141 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -import pytest -from azure.communication.administration import CommunicationIdentityClient -from azure.core.credentials import AccessToken -from _shared.helper import URIIdentityReplacer -from _shared.testcase import ( - CommunicationTestCase, - BodyReplacerProcessor -) -from devtools_testutils import ResourceGroupPreparer -from _shared.communication_service_preparer import CommunicationServicePreparer -from azure.identity import DefaultAzureCredential -from azure.communication.administration._shared.utils import parse_connection_str - -class FakeTokenCredential(object): - def __init__(self): - self.token = AccessToken("Fake Token", 0) - - def get_token(self, *args): - return self.token -class CommunicationIdentityClientTest(CommunicationTestCase): - def setUp(self): - super(CommunicationIdentityClientTest, self).setUp() - self.recording_processors.extend([ - BodyReplacerProcessor(keys=["id", "token"]), - URIIdentityReplacer()]) - - @ResourceGroupPreparer(random_name_enabled=True) - @CommunicationServicePreparer() - def test_create_user_from_managed_identity(self, connection_string): - endpoint, access_key = parse_connection_str(connection_string) - from devtools_testutils import is_live - if not is_live(): - credential = FakeTokenCredential() - else: - credential = DefaultAzureCredential() - identity_client = CommunicationIdentityClient(endpoint, credential) - user = identity_client.create_user() - - assert user.identifier is not None - - @ResourceGroupPreparer(random_name_enabled=True) - @CommunicationServicePreparer() - def test_create_user(self, connection_string): - identity_client = CommunicationIdentityClient.from_connection_string( - connection_string) - user = identity_client.create_user() - - assert user.identifier is not None - - @ResourceGroupPreparer(random_name_enabled=True) - @CommunicationServicePreparer() - def test_issue_token_from_managed_identity(self, connection_string): - endpoint, access_key = parse_connection_str(connection_string) - from devtools_testutils import is_live - if not is_live(): - credential = FakeTokenCredential() - else: - credential = DefaultAzureCredential() - identity_client = CommunicationIdentityClient(endpoint, credential) - user = identity_client.create_user() - - token_response = identity_client.issue_token(user, scopes=["chat"]) - - assert user.identifier is not None - assert token_response.token is not None - - @ResourceGroupPreparer(random_name_enabled=True) - @CommunicationServicePreparer() - def test_issue_token(self, connection_string): - identity_client = CommunicationIdentityClient.from_connection_string( - connection_string) - user = identity_client.create_user() - - token_response = identity_client.issue_token(user, scopes=["chat"]) - - assert user.identifier is not None - assert token_response.token is not None - - @ResourceGroupPreparer(random_name_enabled=True) - @CommunicationServicePreparer() - def test_revoke_tokens_from_managed_identity(self, connection_string): - endpoint, access_key = parse_connection_str(connection_string) - from devtools_testutils import is_live - if not is_live(): - credential = FakeTokenCredential() - else: - credential = DefaultAzureCredential() - identity_client = CommunicationIdentityClient(endpoint, credential) - user = identity_client.create_user() - - token_response = identity_client.issue_token(user, scopes=["chat"]) - identity_client.revoke_tokens(user) - - assert user.identifier is not None - assert token_response.token is not None - - @ResourceGroupPreparer(random_name_enabled=True) - @CommunicationServicePreparer() - def test_revoke_tokens(self, connection_string): - identity_client = CommunicationIdentityClient.from_connection_string( - connection_string) - user = identity_client.create_user() - - token_response = identity_client.issue_token(user, scopes=["chat"]) - identity_client.revoke_tokens(user) - - assert user.identifier is not None - assert token_response.token is not None - - @ResourceGroupPreparer(random_name_enabled=True) - @CommunicationServicePreparer() - def test_delete_user_from_managed_identity(self, connection_string): - endpoint, access_key = parse_connection_str(connection_string) - from devtools_testutils import is_live - if not is_live(): - credential = FakeTokenCredential() - else: - credential = DefaultAzureCredential() - identity_client = CommunicationIdentityClient(endpoint, credential) - user = identity_client.create_user() - - identity_client.delete_user(user) - - assert user.identifier is not None - - @ResourceGroupPreparer(random_name_enabled=True) - @CommunicationServicePreparer() - def test_delete_user(self, connection_string): - identity_client = CommunicationIdentityClient.from_connection_string( - connection_string) - user = identity_client.create_user() - - identity_client.delete_user(user) - - assert user.identifier is not None diff --git a/sdk/communication/azure-communication-administration/tests/test_communication_identity_client_async.py b/sdk/communication/azure-communication-administration/tests/test_communication_identity_client_async.py deleted file mode 100644 index a01f92c618ed..000000000000 --- a/sdk/communication/azure-communication-administration/tests/test_communication_identity_client_async.py +++ /dev/null @@ -1,138 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -import pytest -from azure.core.credentials import AccessToken -from azure.communication.administration.aio import CommunicationIdentityClient -from azure.communication.administration._shared.utils import parse_connection_str -from azure_devtools.scenario_tests import RecordingProcessor -from devtools_testutils import ResourceGroupPreparer -from _shared.helper import URIIdentityReplacer -from _shared.asynctestcase import AsyncCommunicationTestCase -from _shared.testcase import BodyReplacerProcessor -from _shared.communication_service_preparer import CommunicationServicePreparer -from azure.identity import DefaultAzureCredential - -class FakeTokenCredential(object): - def __init__(self): - self.token = AccessToken("Fake Token", 0) - - def get_token(self, *args): - return self.token -class CommunicationIdentityClientTestAsync(AsyncCommunicationTestCase): - def setUp(self): - super(CommunicationIdentityClientTestAsync, self).setUp() - self.recording_processors.extend([ - BodyReplacerProcessor(keys=["id", "token"]), - URIIdentityReplacer()]) - - @ResourceGroupPreparer(random_name_enabled=True) - @CommunicationServicePreparer() - async def test_create_user_from_managed_identity(self, connection_string): - endpoint, access_key = parse_connection_str(connection_string) - from devtools_testutils import is_live - if not is_live(): - credential = FakeTokenCredential() - else: - credential = DefaultAzureCredential() - identity_client = CommunicationIdentityClient(endpoint, credential) - async with identity_client: - user = await identity_client.create_user() - - assert user.identifier is not None - - @ResourceGroupPreparer(random_name_enabled=True) - @CommunicationServicePreparer() - async def test_create_user(self, connection_string): - identity_client = CommunicationIdentityClient.from_connection_string(connection_string) - async with identity_client: - user = await identity_client.create_user() - - assert user.identifier is not None - - @ResourceGroupPreparer(random_name_enabled=True) - @CommunicationServicePreparer() - async def test_issue_token_from_managed_identity(self, connection_string): - endpoint, access_key = parse_connection_str(connection_string) - from devtools_testutils import is_live - if not is_live(): - credential = FakeTokenCredential() - else: - credential = DefaultAzureCredential() - identity_client = CommunicationIdentityClient(endpoint, credential) - async with identity_client: - user = await identity_client.create_user() - token_response = await identity_client.issue_token(user, scopes=["chat"]) - - assert user.identifier is not None - assert token_response.token is not None - - @ResourceGroupPreparer(random_name_enabled=True) - @CommunicationServicePreparer() - async def test_issue_token(self, connection_string): - identity_client = CommunicationIdentityClient.from_connection_string(connection_string) - async with identity_client: - user = await identity_client.create_user() - token_response = await identity_client.issue_token(user, scopes=["chat"]) - - assert user.identifier is not None - assert token_response.token is not None - - @ResourceGroupPreparer(random_name_enabled=True) - @CommunicationServicePreparer() - async def test_revoke_tokens_from_managed_identity(self, connection_string): - endpoint, access_key = parse_connection_str(connection_string) - from devtools_testutils import is_live - if not is_live(): - credential = FakeTokenCredential() - else: - credential = DefaultAzureCredential() - identity_client = CommunicationIdentityClient(endpoint, credential) - async with identity_client: - user = await identity_client.create_user() - token_response = await identity_client.issue_token(user, scopes=["chat"]) - await identity_client.revoke_tokens(user) - - assert user.identifier is not None - assert token_response.token is not None - - @ResourceGroupPreparer(random_name_enabled=True) - @CommunicationServicePreparer() - async def test_revoke_tokens(self, connection_string): - identity_client = CommunicationIdentityClient.from_connection_string(connection_string) - async with identity_client: - user = await identity_client.create_user() - token_response = await identity_client.issue_token(user, scopes=["chat"]) - await identity_client.revoke_tokens(user) - - assert user.identifier is not None - assert token_response.token is not None - - @ResourceGroupPreparer(random_name_enabled=True) - @CommunicationServicePreparer() - async def test_delete_user_from_managed_identity(self, connection_string): - endpoint, access_key = parse_connection_str(connection_string) - from devtools_testutils import is_live - if not is_live(): - credential = FakeTokenCredential() - else: - credential = DefaultAzureCredential() - identity_client = CommunicationIdentityClient(endpoint, credential) - async with identity_client: - user = await identity_client.create_user() - await identity_client.delete_user(user) - - assert user.identifier is not None - - @ResourceGroupPreparer(random_name_enabled=True) - @CommunicationServicePreparer() - async def test_delete_user(self, connection_string): - identity_client = CommunicationIdentityClient.from_connection_string(connection_string) - async with identity_client: - user = await identity_client.create_user() - await identity_client.delete_user(user) - - assert user.identifier is not None From 09b1d2987d1cceff6dd7bff61a81d799fa641c90 Mon Sep 17 00:00:00 2001 From: Bert Ong <823691+beltr0n@users.noreply.github.com> Date: Thu, 21 Jan 2021 17:23:50 -0800 Subject: [PATCH 13/33] Update admin readme --- .../README.md | 36 ++----------------- 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/sdk/communication/azure-communication-administration/README.md b/sdk/communication/azure-communication-administration/README.md index 9e926e7c2382..4e22a0500161 100644 --- a/sdk/communication/azure-communication-administration/README.md +++ b/sdk/communication/azure-communication-administration/README.md @@ -2,7 +2,7 @@ # Azure Communication Administration Package client library for Python -Azure Communication Administration client package is intended to be used to setup the basics for opening a way to use Azure Communication Service offerings. This package helps to create identities user tokens to be used by other client packages such as chat, calling, sms. +Azure Communication Administration client package is used to administer Phone Numbers. # Getting started ### Prerequisites @@ -17,31 +17,6 @@ pip install azure-communication-administration ``` # Key concepts -## CommunicationIdentityClient -`CommunicationIdentityClient` provides operations for: - -- Create/delete identities to be used in Azure Communication Services. Those identities can be used to make use of Azure Communication offerings and can be scoped to have limited abilities through token scopes. - -- Create/revoke scoped user access tokens to access services such as chat, calling, sms. Tokens are issued for a valid Azure Communication identity and can be revoked at any time. - -### Initializing Identity Client -```python -# You can find your endpoint and access token from your resource in the Azure Portal -import os -from azure.communication.administration import CommunicationIdentityClient -from azure.identity import DefaultAzureCredential - -connection_str = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') -endpoint = os.getenv('AZURE_COMMUNICATION_SERVICE_ENDPOINT') - -# To use Azure Active Directory Authentication (DefaultAzureCredential) make sure to have -# AZURE_TENANT_ID, AZURE_CLIENT_ID and AZURE_CLIENT_SECRET as env variables. -identity_client_managed_identity = CommunicationIdentityClient.(endpoint, DefaultAzureCredential()) - -#You can also authenticate using your connection string -identity_client = CommunicationIdentityClient.from_connection_string(connection_str) - -``` ## CommunicationPhoneNumberClient ### Initializing Phone Number Client @@ -70,10 +45,6 @@ Phone numbers can be assigned to a callback URL via the configure number API. As # Examples The following section provides several code snippets covering some of the most common Azure Communication Services tasks, including: -[Create/delete Azure Communication Service identities][identitysamples] - -[Create/revoke scoped user access tokens][identitysamples] - ## Communication Phone number ### Get Countries @@ -179,12 +150,12 @@ poller = phone_number_administration_client.begin_purchase_reservation( ``` # Troubleshooting -The Azure Communication Service Identity client will raise exceptions defined in [Azure Core][azure_core]. +The Phone Number Administration client will raise exceptions defined in [Azure Core][azure_core]. # Next steps ## More sample code -Please take a look at the [samples](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/communication/azure-communication-administration/samples) directory for detailed examples of how to use this library to manage identities and tokens. +Please take a look at the [samples](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/communication/azure-communication-administration/samples) directory for detailed examples of how to use this library. ## Provide Feedback @@ -201,5 +172,4 @@ This project has adopted the [Microsoft Open Source Code of Conduct](https://ope For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. -[identitysamples]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/communication/azure-communication-administration/samples/identity_samples.py [azure_core]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/README.md From b876e20f40007b3f3e65ae0b83199077c29d1a9c Mon Sep 17 00:00:00 2001 From: Bert Ong <823691+beltr0n@users.noreply.github.com> Date: Thu, 21 Jan 2021 17:37:29 -0800 Subject: [PATCH 14/33] add back version.py for wheel generation --- .../azure/communication/identity/_version.py | 9 +++++++++ .../azure/communication/identity/aio/_version.py | 9 +++++++++ 2 files changed, 18 insertions(+) create mode 100644 sdk/communication/azure-communication-identity/azure/communication/identity/_version.py create mode 100644 sdk/communication/azure-communication-identity/azure/communication/identity/aio/_version.py diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_version.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_version.py new file mode 100644 index 000000000000..a01196623d45 --- /dev/null +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_version.py @@ -0,0 +1,9 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b4" + +SDK_MONIKER = "communication-administration/{}".format(VERSION) # type: str diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_version.py b/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_version.py new file mode 100644 index 000000000000..a01196623d45 --- /dev/null +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_version.py @@ -0,0 +1,9 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b4" + +SDK_MONIKER = "communication-administration/{}".format(VERSION) # type: str From 5ab5308171e2ab7205f2eb3a9389d3b3bbab0b45 Mon Sep 17 00:00:00 2001 From: Lakshman Sundaralingam Date: Thu, 21 Jan 2021 17:40:56 -0800 Subject: [PATCH 15/33] Removed user credential test in admin package --- .../tests/user_credential_tests.py | 61 ------------------- 1 file changed, 61 deletions(-) delete mode 100644 sdk/communication/azure-communication-administration/tests/user_credential_tests.py diff --git a/sdk/communication/azure-communication-administration/tests/user_credential_tests.py b/sdk/communication/azure-communication-administration/tests/user_credential_tests.py deleted file mode 100644 index 127e89cd6e31..000000000000 --- a/sdk/communication/azure-communication-administration/tests/user_credential_tests.py +++ /dev/null @@ -1,61 +0,0 @@ -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- -from unittest import TestCase -from unittest.mock import MagicMock -from azure.communication.administration._shared.user_credential import CommunicationTokenCredential -from azure.communication.administration._shared.user_token_refresh_options import CommunicationTokenRefreshOptions -from azure.communication.administration._shared.utils import create_access_token - - -class TestCommunicationTokenCredential(TestCase): - sample_token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9."+\ - "eyJleHAiOjMyNTAzNjgwMDAwfQ.9i7FNNHHJT8cOzo-yrAUJyBSfJ-tPPk2emcHavOEpWc" - sample_token_expiry = 32503680000 - expired_token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9."+\ - "eyJleHAiOjEwMH0.1h_scYkNp-G98-O4cW6KvfJZwiz54uJMyeDACE4nypg" - - - def test_communicationtokencredential_decodes_token(self): - refresh_options = CommunicationTokenRefreshOptions(self.sample_token) - credential = CommunicationTokenCredential(refresh_options) - access_token = credential.get_token() - - self.assertEqual(access_token.token, self.sample_token) - - def test_communicationtokencredential_throws_if_invalid_token(self): - refresh_options = CommunicationTokenRefreshOptions("foo.bar.tar") - self.assertRaises(ValueError, lambda: CommunicationTokenCredential(refresh_options)) - - def test_communicationtokencredential_throws_if_nonstring_token(self): - refresh_options = CommunicationTokenRefreshOptions(454): - self.assertRaises(TypeError, lambda: CommunicationTokenCredential(refresh_options) - - def test_communicationtokencredential_static_token_returns_expired_token(self): - refresh_options = CommunicationTokenRefreshOptions(self.expired_token) - credential = CommunicationTokenCredential(refresh_options) - - self.assertEqual(credential.get_token().token, self.expired_token) - - def test_communicationtokencredential_token_expired_refresh_called(self): - refresher = MagicMock(return_value=self.sample_token) - refresh_options = CommunicationTokenRefreshOptions(self.sample_token, refresher) - access_token = CommunicationTokenCredential( - self.expired_token, - token_refresher=refresher).get_token() - refresher.assert_called_once() - self.assertEqual(access_token, self.sample_token) - - - def test_communicationtokencredential_token_expired_refresh_called_asnecessary(self): - refresher = MagicMock(return_value=create_access_token(self.expired_token)) - refresh_options = CommunicationTokenRefreshOptions(self.expired_token, refresher) - credential = CommunicationTokenCredential(refresh_options) - - credential.get_token() - access_token = credential.get_token() - - self.assertEqual(refresher.call_count, 2) - self.assertEqual(access_token.token, self.expired_token) From e8cec64a8da646cb35aabfad495209962147f94a Mon Sep 17 00:00:00 2001 From: Bert Ong <823691+beltr0n@users.noreply.github.com> Date: Thu, 21 Jan 2021 18:00:33 -0800 Subject: [PATCH 16/33] update _version.py --- .../azure/communication/identity/_version.py | 2 +- .../azure/communication/identity/aio/_version.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_version.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_version.py index a01196623d45..22f6d37839a7 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/_version.py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_version.py @@ -6,4 +6,4 @@ VERSION = "1.0.0b4" -SDK_MONIKER = "communication-administration/{}".format(VERSION) # type: str +SDK_MONIKER = "communication-identity/{}".format(VERSION) # type: str diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_version.py b/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_version.py index a01196623d45..22f6d37839a7 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_version.py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_version.py @@ -6,4 +6,4 @@ VERSION = "1.0.0b4" -SDK_MONIKER = "communication-administration/{}".format(VERSION) # type: str +SDK_MONIKER = "communication-identity/{}".format(VERSION) # type: str From 549c082927f8e673ee7fadf93b4dc623394ea798 Mon Sep 17 00:00:00 2001 From: Bert Ong <823691+beltr0n@users.noreply.github.com> Date: Thu, 21 Jan 2021 20:02:33 -0800 Subject: [PATCH 17/33] remove redundant files --- .../_communication_identity_client_async.py | 168 ------------------ .../communication/identity/aio/_version.py | 9 - 2 files changed, 177 deletions(-) delete mode 100644 sdk/communication/azure-communication-administration/azure/communication/administration/aio/_communication_identity_client_async.py delete mode 100644 sdk/communication/azure-communication-identity/azure/communication/identity/aio/_version.py diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/aio/_communication_identity_client_async.py b/sdk/communication/azure-communication-administration/azure/communication/administration/aio/_communication_identity_client_async.py deleted file mode 100644 index 4347edb7e3e8..000000000000 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/aio/_communication_identity_client_async.py +++ /dev/null @@ -1,168 +0,0 @@ -# coding=utf-8 -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ - -from azure.core.tracing.decorator_async import distributed_trace_async - -from .._identity._generated.aio._communication_identity_client\ - import CommunicationIdentityClient as CommunicationIdentityClientGen -from .._identity._generated.models import CommunicationIdentityToken - -from .._shared.utils import parse_connection_str, get_authentication_policy -from .._shared.models import CommunicationUserIdentifier -from .._version import SDK_MONIKER - - -class CommunicationIdentityClient: - """Azure Communication Services Identity client. - - :param str endpoint: - The endpoint url for Azure Communication Service resource. - :param credential: - The credentials with which to authenticate. The value is an account - shared access key - - .. admonition:: Example: - - .. literalinclude:: ../../samples/identity_samples_async.py - :language: python - :dedent: 8 - """ - def __init__( - self, - endpoint, # type: str - credential, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - try: - if not endpoint.lower().startswith('http'): - endpoint = "https://" + endpoint - except AttributeError: - raise ValueError("Account URL must be a string.") - - if not credential: - raise ValueError( - "You need to provide account shared key to authenticate.") - - self._endpoint = endpoint - self._identity_service_client = CommunicationIdentityClientGen( - self._endpoint, - authentication_policy=get_authentication_policy(endpoint, credential, is_async=True), - sdk_moniker=SDK_MONIKER, - **kwargs) - - @classmethod - def from_connection_string( - cls, conn_str, # type: str - **kwargs # type: Any - ): # type: (...) -> CommunicationIdentityClient - """Create CommunicationIdentityClient from a Connection String. - - :param str conn_str: - A connection string to an Azure Communication Service resource. - :returns: Instance of CommunicationIdentityClient. - :rtype: ~azure.communication.aio.CommunicationIdentityClient - - .. admonition:: Example: - - .. literalinclude:: ../samples/identity_samples.py - :start-after: [START auth_from_connection_string] - :end-before: [END auth_from_connection_string] - :language: python - :dedent: 8 - :caption: Creating the CommunicationIdentityClient from a connection string. - """ - endpoint, access_key = parse_connection_str(conn_str) - - return cls(endpoint, access_key, **kwargs) - - @distributed_trace_async - async def create_user(self, **kwargs): - # type: (...) -> CommunicationUserIdentifier - """create a single Communication user - - return: CommunicationUserIdentifier - rtype: ~azure.communication.administration.CommunicationUserIdentifier - """ - return await self._identity_service_client.communication_identity.create( - cls=lambda pr, u, e: CommunicationUserIdentifier(u.id), - **kwargs) - - @distributed_trace_async - async def delete_user( - self, - communication_user, # type: CommunicationUserIdentifier - **kwargs # type: Any - ): - # type: (...) -> None - """Triggers revocation event for user and deletes all its data. - - :param communication_user: - Azure Communication User to delete - :type communication_user: ~azure.communication.administration.CommunicationUserIdentifier - :return: None - :rtype: None - """ - await self._identity_service_client.communication_identity.delete( - communication_user.identifier, **kwargs) - - @distributed_trace_async - async def issue_token( - self, - user, # type: CommunicationUserIdentifier - scopes, # type: List[str] - **kwargs # type: Any - ): - # type: (...) -> CommunicationIdentityToken - """Generates a new token for an identity. - - :param user: Azure Communication User - :type user: ~azure.communication.administration.CommunicationUserIdentifier - :param scopes: - List of scopes to be added to the token. - :type scopes: list[str] - :return: CommunicationIdentityToken - :rtype: ~azure.communication.administration.CommunicationIdentityToken - """ - return await self._identity_service_client.communication_identity.issue_token( - user.identifier, - scopes, - **kwargs) - - @distributed_trace_async - async def revoke_tokens( - self, - user, # type: CommunicationUserIdentifier - issued_before=None, # type: Optional[datetime.datetime] - **kwargs # type: Any - ): - # type: (...) -> None - """Schedule revocation of all tokens of an identity. - - :param user: Azure Communication User. - :type user: ~azure.communication.administration.CommunicationUserIdentifier - :param issued_before: All tokens that are issued prior to this time should get revoked. - :type issued_before: ~datetime.datetime - :return: None - :rtype: None - """ - return await self._identity_service_client.communication_identity.update( - user.identifier if user else None, - tokens_valid_from=issued_before, - **kwargs) - - async def __aenter__(self) -> "CommunicationIdentityClient": - await self._identity_service_client.__aenter__() - return self - - async def __aexit__(self, *args: "Any") -> None: - await self.close() - - async def close(self) -> None: - """Close the :class: - `~azure.communication.administration.aio.CommunicationIdentityClient` session. - """ - await self._identity_service_client.__aexit__() diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_version.py b/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_version.py deleted file mode 100644 index 22f6d37839a7..000000000000 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- - -VERSION = "1.0.0b4" - -SDK_MONIKER = "communication-identity/{}".format(VERSION) # type: str From ea95e1e8617a992cd276435b99e607c01d9d4640 Mon Sep 17 00:00:00 2001 From: Bert Ong <823691+beltr0n@users.noreply.github.com> Date: Thu, 21 Jan 2021 20:06:51 -0800 Subject: [PATCH 18/33] fixed error with init file --- .../identity/{__init__ .py => __init__.py} | 11 +++++++++++ 1 file changed, 11 insertions(+) rename sdk/communication/azure-communication-identity/azure/communication/identity/{__init__ .py => __init__.py} (73%) diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/__init__ .py b/sdk/communication/azure-communication-identity/azure/communication/identity/__init__.py similarity index 73% rename from sdk/communication/azure-communication-identity/azure/communication/identity/__init__ .py rename to sdk/communication/azure-communication-identity/azure/communication/identity/__init__.py index 15d5752cae58..e868a8910894 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/__init__ .py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/__init__.py @@ -11,10 +11,21 @@ CommunicationIdentityToken ) +from ._shared.models import ( + CommunicationUserIdentifier, + PhoneNumberIdentifier, + UnknownIdentifier +) + __all__ = [ 'CommunicationIdentityClient', # from _identity 'CommunicationTokenRequest', 'CommunicationIdentityToken', + + # from _shared + 'CommunicationUserIdentifier', + 'PhoneNumberIdentifier', + 'UnknownIdentifier' ] \ No newline at end of file From 282204ce53ae565bcad5ef17d5238023c8b14c36 Mon Sep 17 00:00:00 2001 From: Bert Ong <823691+beltr0n@users.noreply.github.com> Date: Thu, 21 Jan 2021 20:10:31 -0800 Subject: [PATCH 19/33] minor naming fixes --- .../identity/_communication_identity_client.py | 10 +++++----- .../aio/_communication_identity_client_async.py | 10 +++++----- .../azure-communication-identity/sdk_packaging.toml | 2 +- .../azure-communication-identity/swagger/SWAGGER.md | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_communication_identity_client.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_communication_identity_client.py index 391a1572978a..bb3cb57fe258 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/_communication_identity_client.py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_communication_identity_client.py @@ -83,7 +83,7 @@ def create_user(self, **kwargs): """create a single Communication user return: CommunicationUserIdentifier - rtype: ~azure.communication.administration.CommunicationUserIdentifier + rtype: ~azure.communication.identity.CommunicationUserIdentifier """ return self._identity_service_client.communication_identity.create( cls=lambda pr, u, e: CommunicationUserIdentifier(u.id), @@ -100,7 +100,7 @@ def delete_user( :param communication_user: Azure Communication User to delete - :type communication_user: ~azure.communication.administration.CommunicationUserIdentifier + :type communication_user: ~azure.communication.identity.CommunicationUserIdentifier :return: None :rtype: None """ @@ -118,12 +118,12 @@ def issue_token( """Generates a new token for an identity. :param user: Azure Communication User - :type user: ~azure.communication.administration.CommunicationUserIdentifier + :type user: ~azure.communication.identity.CommunicationUserIdentifier :param scopes: List of scopes to be added to the token. :type scopes: list[str] :return: CommunicationIdentityToken - :rtype: ~azure.communication.administration.CommunicationIdentityToken + :rtype: ~azure.communication.identity.CommunicationIdentityToken """ return self._identity_service_client.communication_identity.issue_token( user.identifier, @@ -141,7 +141,7 @@ def revoke_tokens( """Schedule revocation of all tokens of an identity. :param user: Azure Communication User. - :type user: ~azure.communication.administration.CommunicationUserIdentifier. + :type user: ~azure.communication.identity.CommunicationUserIdentifier. :param issued_before: All tokens that are issued prior to this time should get revoked. :type issued_before: ~datetime.datetime. :return: None diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_communication_identity_client_async.py b/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_communication_identity_client_async.py index 8a9bc9523c1d..44cdf5a65e5f 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_communication_identity_client_async.py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_communication_identity_client_async.py @@ -85,7 +85,7 @@ async def create_user(self, **kwargs): """create a single Communication user return: CommunicationUserIdentifier - rtype: ~azure.communication.administration.CommunicationUserIdentifier + rtype: ~azure.communication.identity.CommunicationUserIdentifier """ return await self._identity_service_client.communication_identity.create( cls=lambda pr, u, e: CommunicationUserIdentifier(u.id), @@ -102,7 +102,7 @@ async def delete_user( :param communication_user: Azure Communication User to delete - :type communication_user: ~azure.communication.administration.CommunicationUserIdentifier + :type communication_user: ~azure.communication.identity.CommunicationUserIdentifier :return: None :rtype: None """ @@ -120,12 +120,12 @@ async def issue_token( """Generates a new token for an identity. :param user: Azure Communication User - :type user: ~azure.communication.administration.CommunicationUserIdentifier + :type user: ~azure.communication.identity.CommunicationUserIdentifier :param scopes: List of scopes to be added to the token. :type scopes: list[str] :return: CommunicationIdentityToken - :rtype: ~azure.communication.administration.CommunicationIdentityToken + :rtype: ~azure.communication.identity.CommunicationIdentityToken """ return await self._identity_service_client.communication_identity.issue_token( user.identifier, @@ -143,7 +143,7 @@ async def revoke_tokens( """Schedule revocation of all tokens of an identity. :param user: Azure Communication User. - :type user: ~azure.communication.administration.CommunicationUserIdentifier + :type user: ~azure.communication.identity.CommunicationUserIdentifier :param issued_before: All tokens that are issued prior to this time should get revoked. :type issued_before: ~datetime.datetime :return: None diff --git a/sdk/communication/azure-communication-identity/sdk_packaging.toml b/sdk/communication/azure-communication-identity/sdk_packaging.toml index 5d4170e7bda2..88dbadd37a99 100644 --- a/sdk/communication/azure-communication-identity/sdk_packaging.toml +++ b/sdk/communication/azure-communication-identity/sdk_packaging.toml @@ -1,7 +1,7 @@ [packaging] auto_update = false package_name = "azure-communication-identity" -package_pprint_name = "Communication Service" +package_pprint_name = "Communication Identity Service" package_doc_id = "" is_stable = false is_arm = false \ No newline at end of file diff --git a/sdk/communication/azure-communication-identity/swagger/SWAGGER.md b/sdk/communication/azure-communication-identity/swagger/SWAGGER.md index c44e83ad9eda..164f24e0e24d 100644 --- a/sdk/communication/azure-communication-identity/swagger/SWAGGER.md +++ b/sdk/communication/azure-communication-identity/swagger/SWAGGER.md @@ -1,4 +1,4 @@ -# Azure Communication Administration for Python +# Azure Communication Identity for Python > see https://aka.ms/autorest @@ -24,4 +24,4 @@ no-namespace-folders: true clear-output-folder: true v3: true python: true -``` \ No newline at end of file +``` From cdbac44bc7a0025aba68522bd34176f330b261cb Mon Sep 17 00:00:00 2001 From: Bert Ong <823691+beltr0n@users.noreply.github.com> Date: Fri, 22 Jan 2021 10:28:23 -0800 Subject: [PATCH 20/33] only expose required shared models --- .../azure/communication/identity/__init__.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/__init__.py b/sdk/communication/azure-communication-identity/azure/communication/identity/__init__.py index e868a8910894..302b88b2e35c 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/__init__.py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/__init__.py @@ -11,11 +11,8 @@ CommunicationIdentityToken ) -from ._shared.models import ( - CommunicationUserIdentifier, - PhoneNumberIdentifier, - UnknownIdentifier -) +from ._shared.models import CommunicationUserIdentifier + __all__ = [ 'CommunicationIdentityClient', @@ -25,7 +22,5 @@ 'CommunicationIdentityToken', # from _shared - 'CommunicationUserIdentifier', - 'PhoneNumberIdentifier', - 'UnknownIdentifier' + 'CommunicationUserIdentifier' ] \ No newline at end of file From 1f07e2bdcdd549ba1cfa8376b002c4f0bc9caf48 Mon Sep 17 00:00:00 2001 From: Bert Ong <823691+beltr0n@users.noreply.github.com> Date: Fri, 22 Jan 2021 13:39:08 -0800 Subject: [PATCH 21/33] Update chat to reference new identity package --- sdk/communication/azure-communication-chat/README.md | 8 ++++---- .../azure-communication-chat/dev_requirements.txt | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sdk/communication/azure-communication-chat/README.md b/sdk/communication/azure-communication-chat/README.md index 9f825335ffaa..b178c8bd0e48 100644 --- a/sdk/communication/azure-communication-chat/README.md +++ b/sdk/communication/azure-communication-chat/README.md @@ -22,14 +22,14 @@ pip install --pre azure-communication-chat ## User Access Tokens -User access tokens enable you to build client applications that directly authenticate to Azure Communication Services. You can generate these tokens with azure.communication.administration module, and then use them to initialize the Communication Services SDKs. Example of using azure.communication.administration: +User access tokens enable you to build client applications that directly authenticate to Azure Communication Services. You can generate these tokens with azure.communication.identity module, and then use them to initialize the Communication Services SDKs. Example of using azure.communication.identity: ```bash -pip install --pre azure-communication-administration +pip install --pre azure-communication-identity ``` ```python -from azure.communication.administration import CommunicationIdentityClient +from azure.communication.identity import CommunicationIdentityClient identity_client = CommunicationIdentityClient.from_connection_string("") user = identity_client.create_user() tokenresponse = identity_client.issue_token(user, scopes=["chat"]) @@ -374,7 +374,7 @@ to create a resource, then set some Environment Variables set AZURE_COMMUNICATION_SERVICE_ENDPOINT="https://.communcationservices.azure.com" set AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING="" -pip install azure-communication-administration +pip install azure-communication-identity python samples\chat_client_sample.py python samples\chat_client_sample_async.py diff --git a/sdk/communication/azure-communication-chat/dev_requirements.txt b/sdk/communication/azure-communication-chat/dev_requirements.txt index 1281667d25f3..b88483d99721 100644 --- a/sdk/communication/azure-communication-chat/dev_requirements.txt +++ b/sdk/communication/azure-communication-chat/dev_requirements.txt @@ -1,5 +1,5 @@ -e ../../../tools/azure-devtools -e ../../../tools/azure-sdk-tools ../azure-communication-nspkg --e ../azure-communication-administration +-e ../azure-communication-identity aiohttp>=3.0; python_version >= '3.5' \ No newline at end of file From 5741e0b2617bf4cd7c189ced62dbc01912649234 Mon Sep 17 00:00:00 2001 From: Lakshman Sundaralingam Date: Fri, 22 Jan 2021 13:59:30 -0800 Subject: [PATCH 22/33] Updated identity test recordings --- ...test_communication_identity_client.test_create_user.yaml | 2 +- ...ntity_client.test_create_user_from_managed_identity.yaml | 2 +- ...test_communication_identity_client.test_delete_user.yaml | 4 ++-- ...ntity_client.test_delete_user_from_managed_identity.yaml | 4 ++-- ...test_communication_identity_client.test_issue_token.yaml | 4 ++-- ...ntity_client.test_issue_token_from_managed_identity.yaml | 4 ++-- ...st_communication_identity_client.test_revoke_tokens.yaml | 6 +++--- ...ity_client.test_revoke_tokens_from_managed_identity.yaml | 6 +++--- ...ommunication_identity_client_async.test_create_user.yaml | 2 +- ...client_async.test_create_user_from_managed_identity.yaml | 2 +- ...ommunication_identity_client_async.test_delete_user.yaml | 4 ++-- ...client_async.test_delete_user_from_managed_identity.yaml | 4 ++-- ...ommunication_identity_client_async.test_issue_token.yaml | 4 ++-- ...client_async.test_issue_token_from_managed_identity.yaml | 4 ++-- ...munication_identity_client_async.test_revoke_tokens.yaml | 4 ++-- ...ient_async.test_revoke_tokens_from_managed_identity.yaml | 4 ++-- 16 files changed, 30 insertions(+), 30 deletions(-) diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_create_user.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_create_user.yaml index c2bc1d2d7dc8..1973cd353437 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_create_user.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_create_user.yaml @@ -13,7 +13,7 @@ interactions: Date: - Tue, 22 Dec 2020 18:26:56 GMT User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-return-client-request-id: - 'true' method: POST diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_create_user_from_managed_identity.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_create_user_from_managed_identity.yaml index f159cc5d3c7c..7ddd5c68dcc7 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_create_user_from_managed_identity.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_create_user_from_managed_identity.yaml @@ -11,7 +11,7 @@ interactions: Content-Length: - '0' User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) method: POST uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 response: diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_delete_user.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_delete_user.yaml index 392431b12f89..40564943ea37 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_delete_user.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_delete_user.yaml @@ -13,7 +13,7 @@ interactions: Date: - Tue, 22 Dec 2020 18:29:13 GMT User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-return-client-request-id: - 'true' method: POST @@ -53,7 +53,7 @@ interactions: Date: - Tue, 22 Dec 2020 18:29:14 GMT User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-return-client-request-id: - 'true' method: DELETE diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_delete_user_from_managed_identity.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_delete_user_from_managed_identity.yaml index e1b92837214b..7e794bd59a59 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_delete_user_from_managed_identity.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_delete_user_from_managed_identity.yaml @@ -11,7 +11,7 @@ interactions: Content-Length: - '0' User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) method: POST uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 response: @@ -47,7 +47,7 @@ interactions: Content-Length: - '0' User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) method: DELETE uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 response: diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_issue_token.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_issue_token.yaml index 76d30c8ff3e6..1645441b4fd6 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_issue_token.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_issue_token.yaml @@ -13,7 +13,7 @@ interactions: Date: - Tue, 22 Dec 2020 18:31:34 GMT User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-return-client-request-id: - 'true' method: POST @@ -55,7 +55,7 @@ interactions: Date: - Tue, 22 Dec 2020 18:31:34 GMT User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-return-client-request-id: - 'true' method: POST diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_issue_token_from_managed_identity.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_issue_token_from_managed_identity.yaml index 879ddee12d3c..bd088f82a792 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_issue_token_from_managed_identity.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_issue_token_from_managed_identity.yaml @@ -11,7 +11,7 @@ interactions: Content-Length: - '0' User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) method: POST uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 response: @@ -49,7 +49,7 @@ interactions: Content-Type: - application/json User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) method: POST uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 response: diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_revoke_tokens.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_revoke_tokens.yaml index 5e79664fa87f..99b3257388c8 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_revoke_tokens.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_revoke_tokens.yaml @@ -13,7 +13,7 @@ interactions: Date: - Tue, 22 Dec 2020 18:34:17 GMT User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-return-client-request-id: - 'true' method: POST @@ -55,7 +55,7 @@ interactions: Date: - Tue, 22 Dec 2020 18:34:18 GMT User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-return-client-request-id: - 'true' method: POST @@ -97,7 +97,7 @@ interactions: Date: - Tue, 22 Dec 2020 18:34:18 GMT User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-return-client-request-id: - 'true' method: PATCH diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_revoke_tokens_from_managed_identity.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_revoke_tokens_from_managed_identity.yaml index 853de6129c9d..d0fd1490c76e 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_revoke_tokens_from_managed_identity.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_revoke_tokens_from_managed_identity.yaml @@ -11,7 +11,7 @@ interactions: Content-Length: - '0' User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) method: POST uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 response: @@ -49,7 +49,7 @@ interactions: Content-Type: - application/json User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) method: POST uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 response: @@ -87,7 +87,7 @@ interactions: Content-Type: - application/merge-patch+json User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) method: PATCH uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 response: diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_create_user.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_create_user.yaml index 744fbd017292..1a9a4508d65a 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_create_user.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_create_user.yaml @@ -7,7 +7,7 @@ interactions: Date: - Tue, 22 Dec 2020 18:48:56 GMT User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-return-client-request-id: - 'true' method: POST diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_create_user_from_managed_identity.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_create_user_from_managed_identity.yaml index 883eb09da417..b723acbffebd 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_create_user_from_managed_identity.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_create_user_from_managed_identity.yaml @@ -5,7 +5,7 @@ interactions: Accept: - application/json User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) method: POST uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 response: diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_delete_user.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_delete_user.yaml index 46f6bc7da32e..d72ac521ab0f 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_delete_user.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_delete_user.yaml @@ -7,7 +7,7 @@ interactions: Date: - Tue, 22 Dec 2020 18:51:13 GMT User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-return-client-request-id: - 'true' method: POST @@ -33,7 +33,7 @@ interactions: Date: - Tue, 22 Dec 2020 18:51:14 GMT User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-return-client-request-id: - 'true' method: DELETE diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_delete_user_from_managed_identity.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_delete_user_from_managed_identity.yaml index 3d5253742e18..61f0f792823b 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_delete_user_from_managed_identity.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_delete_user_from_managed_identity.yaml @@ -5,7 +5,7 @@ interactions: Accept: - application/json User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) method: POST uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 response: @@ -27,7 +27,7 @@ interactions: body: null headers: User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) method: DELETE uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 response: diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_issue_token.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_issue_token.yaml index fce3ec17e7e1..3f080a769093 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_issue_token.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_issue_token.yaml @@ -7,7 +7,7 @@ interactions: Date: - Tue, 22 Dec 2020 18:53:37 GMT User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-return-client-request-id: - 'true' method: POST @@ -39,7 +39,7 @@ interactions: Date: - Tue, 22 Dec 2020 18:53:38 GMT User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-return-client-request-id: - 'true' method: POST diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_issue_token_from_managed_identity.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_issue_token_from_managed_identity.yaml index 44a889e13df3..1bb9bfee6b30 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_issue_token_from_managed_identity.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_issue_token_from_managed_identity.yaml @@ -5,7 +5,7 @@ interactions: Accept: - application/json User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) method: POST uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 response: @@ -33,7 +33,7 @@ interactions: Content-Type: - application/json User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) method: POST uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 response: diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_revoke_tokens.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_revoke_tokens.yaml index cefb985a000f..65852601867e 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_revoke_tokens.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_revoke_tokens.yaml @@ -7,7 +7,7 @@ interactions: Date: - Tue, 22 Dec 2020 18:55:56 GMT User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-return-client-request-id: - 'true' method: POST @@ -39,7 +39,7 @@ interactions: Date: - Tue, 22 Dec 2020 18:55:57 GMT User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-return-client-request-id: - 'true' method: POST diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_revoke_tokens_from_managed_identity.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_revoke_tokens_from_managed_identity.yaml index 23b4c57c9632..75a1a9851624 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_revoke_tokens_from_managed_identity.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_revoke_tokens_from_managed_identity.yaml @@ -5,7 +5,7 @@ interactions: Accept: - application/json User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) method: POST uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 response: @@ -33,7 +33,7 @@ interactions: Content-Type: - application/json User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) method: POST uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 response: From d459029abd329687c614f6fd3dd75ccbe1b4e13b Mon Sep 17 00:00:00 2001 From: Lakshman Sundaralingam Date: Fri, 22 Jan 2021 15:06:17 -0800 Subject: [PATCH 23/33] Added examples to identity README.md --- sdk/communication/azure-communication-identity/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sdk/communication/azure-communication-identity/README.md b/sdk/communication/azure-communication-identity/README.md index 42d1cbe4066c..bce44c94e482 100644 --- a/sdk/communication/azure-communication-identity/README.md +++ b/sdk/communication/azure-communication-identity/README.md @@ -43,6 +43,13 @@ identity_client = CommunicationIdentityClient.from_connection_string(connection_ ``` +# Examples +The following section provides several code snippets covering some of the most common Azure Communication Services tasks, including: + +[Create/delete Azure Communication Service identities][identitysamples] + +[Create/revoke scoped user access tokens][identitysamples] + # Troubleshooting The Azure Communication Service Identity client will raise exceptions defined in [Azure Core][azure_core]. From ab8c2b332f82328ed4113c28bb67ebcf95b81c53 Mon Sep 17 00:00:00 2001 From: Lakshman Sundaralingam Date: Fri, 22 Jan 2021 15:39:16 -0800 Subject: [PATCH 24/33] Updated dependencies in identity package --- sdk/communication/azure-communication-identity/setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/communication/azure-communication-identity/setup.py b/sdk/communication/azure-communication-identity/setup.py index 16d4f1a8f8f4..9efe558e6239 100644 --- a/sdk/communication/azure-communication-identity/setup.py +++ b/sdk/communication/azure-communication-identity/setup.py @@ -63,8 +63,8 @@ 'azure.communication' ]), install_requires=[ - "msrest>=0.6.0", - "azure-core<2.0.0,>=1.6.0", + 'msrest>=0.5.0', + "azure-core<2.0.0,>=1.2.2" ], extras_require={ ":python_version<'3.0'": ['azure-communication-nspkg'], From f52a08c2bd98440239ef3b71bc211ee4901cc5a4 Mon Sep 17 00:00:00 2001 From: Lakshman Sundaralingam Date: Fri, 22 Jan 2021 16:19:05 -0800 Subject: [PATCH 25/33] Updated code style to meet pylint requirements --- .../aio/_phone_number_administration_client_async.py | 2 +- .../azure/communication/identity/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/aio/_phone_number_administration_client_async.py b/sdk/communication/azure-communication-administration/azure/communication/administration/aio/_phone_number_administration_client_async.py index 28428b4f8e1c..dd18ec52f302 100644 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/aio/_phone_number_administration_client_async.py +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/aio/_phone_number_administration_client_async.py @@ -4,7 +4,7 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # ------------------------------------ -from typing import Dict, List +from typing import Dict from azure.communication.administration._phonenumber._generated.models import ReleaseStatus, CreateSearchOptions from azure.core.async_paging import AsyncItemPaged diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/__init__.py b/sdk/communication/azure-communication-identity/azure/communication/identity/__init__.py index 302b88b2e35c..77579e0b4d62 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/__init__.py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/__init__.py @@ -23,4 +23,4 @@ # from _shared 'CommunicationUserIdentifier' -] \ No newline at end of file +] From 4ecbdd0552620fe6715b5ea8e46d4d5ead01e1ee Mon Sep 17 00:00:00 2001 From: Bert Ong <823691+beltr0n@users.noreply.github.com> Date: Fri, 22 Jan 2021 17:15:29 -0800 Subject: [PATCH 26/33] update swagger + re-generate code --- .../_communication_identity_client.py | 2 +- .../identity/_generated/_configuration.py | 4 +- .../aio/_communication_identity_client.py | 2 +- .../identity/_generated/aio/_configuration.py | 4 +- .../_communication_identity_operations.py | 102 ++++++++--------- .../identity/_generated/models/__init__.py | 26 +++-- .../_communication_identity_client_enums.py | 34 ++++++ .../identity/_generated/models/_models.py | 91 +++++++++------ .../identity/_generated/models/_models_py3.py | 105 +++++++++++------- .../_communication_identity_operations.py | 102 ++++++++--------- .../swagger/SWAGGER.md | 19 +++- 11 files changed, 303 insertions(+), 188 deletions(-) create mode 100644 sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/_communication_identity_client_enums.py diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/_communication_identity_client.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/_communication_identity_client.py index 9e20523636c1..c8e80845ea47 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/_communication_identity_client.py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/_communication_identity_client.py @@ -25,7 +25,7 @@ class CommunicationIdentityClient(object): :ivar communication_identity: CommunicationIdentityOperations operations :vartype communication_identity: azure.communication.identity.operations.CommunicationIdentityOperations - :param endpoint: Auth and Identity endpoint. + :param endpoint: The communication resource, for example https://my-resource.communication.azure.com. :type endpoint: str """ diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/_configuration.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/_configuration.py index 079f98f2ffd0..68363ff6515f 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/_configuration.py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/_configuration.py @@ -23,7 +23,7 @@ class CommunicationIdentityClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param endpoint: Auth and Identity endpoint. + :param endpoint: The communication resource, for example https://my-resource.communication.azure.com. :type endpoint: str """ @@ -38,7 +38,7 @@ def __init__( super(CommunicationIdentityClientConfiguration, self).__init__(**kwargs) self.endpoint = endpoint - self.api_version = "2020-07-20-preview2" + self.api_version = "2021-03-07" kwargs.setdefault('sdk_moniker', 'communicationidentityclient/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/_communication_identity_client.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/_communication_identity_client.py index 998d60b4c35b..a9e14baadd75 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/_communication_identity_client.py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/_communication_identity_client.py @@ -21,7 +21,7 @@ class CommunicationIdentityClient(object): :ivar communication_identity: CommunicationIdentityOperations operations :vartype communication_identity: azure.communication.identity.aio.operations.CommunicationIdentityOperations - :param endpoint: Auth and Identity endpoint. + :param endpoint: The communication resource, for example https://my-resource.communication.azure.com. :type endpoint: str """ diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/_configuration.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/_configuration.py index 4b91da974fe0..ffd8616506db 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/_configuration.py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/_configuration.py @@ -19,7 +19,7 @@ class CommunicationIdentityClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param endpoint: Auth and Identity endpoint. + :param endpoint: The communication resource, for example https://my-resource.communication.azure.com. :type endpoint: str """ @@ -33,7 +33,7 @@ def __init__( super(CommunicationIdentityClientConfiguration, self).__init__(**kwargs) self.endpoint = endpoint - self.api_version = "2020-07-20-preview2" + self.api_version = "2021-03-07" kwargs.setdefault('sdk_moniker', 'communicationidentityclient/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/operations/_communication_identity_operations.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/operations/_communication_identity_operations.py index b1143a98ca01..3fc18bcd2858 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/operations/_communication_identity_operations.py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/operations/_communication_identity_operations.py @@ -5,8 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import datetime -from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar +from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -40,29 +39,35 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - async def create( + async def create_identity( self, + create_token_with_scopes: Optional[List[Union[str, "_models.CommunicationTokenScope"]]] = None, **kwargs - ) -> "_models.CommunicationIdentity": + ) -> "_models.CommunicationIdentityAccessTokenResult": """Create a new identity. Create a new identity. + :param create_token_with_scopes: Also create access token for the created identity. + :type create_token_with_scopes: list[str or ~azure.communication.identity.models.CommunicationTokenScope] :keyword callable cls: A custom type or function that will be passed the direct response - :return: CommunicationIdentity, or the result of cls(response) - :rtype: ~azure.communication.identity.models.CommunicationIdentity + :return: CommunicationIdentityAccessTokenResult, or the result of cls(response) + :rtype: ~azure.communication.identity.models.CommunicationIdentityAccessTokenResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunicationIdentity"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunicationIdentityAccessTokenResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview2" + + _body = _models.CommunicationIdentityCreateRequest(create_token_with_scopes=create_token_with_scopes) + api_version = "2021-03-07" + content_type = kwargs.pop("content_type", "application/json") accept = "application/json" # Construct URL - url = self.create.metadata['url'] # type: ignore + url = self.create_identity.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } @@ -74,9 +79,16 @@ async def create( # Construct headers header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - request = self._client.post(url, query_parameters, header_parameters) + body_content_kwargs = {} # type: Dict[str, Any] + if _body is not None: + body_content = self._serialize.body(_body, 'CommunicationIdentityCreateRequest') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -84,22 +96,22 @@ async def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - deserialized = self._deserialize('CommunicationIdentity', pipeline_response) + deserialized = self._deserialize('CommunicationIdentityAccessTokenResult', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/identities'} # type: ignore + create_identity.metadata = {'url': '/identities'} # type: ignore - async def delete( + async def delete_identity( self, id: str, **kwargs ) -> None: - """Delete the identity, revoke all tokens of the identity and delete all associated data. + """Delete the identity, revoke all tokens for the identity and delete all associated data. - Delete the identity, revoke all tokens of the identity and delete all associated data. + Delete the identity, revoke all tokens for the identity and delete all associated data. :param id: Identifier of the identity to be deleted. :type id: str @@ -113,10 +125,10 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview2" + api_version = "2021-03-07" # Construct URL - url = self.delete.metadata['url'] # type: ignore + url = self.delete_identity.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), 'id': self._serialize.url("id", id, 'str'), @@ -141,22 +153,19 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/identities/{id}'} # type: ignore + delete_identity.metadata = {'url': '/identities/{id}'} # type: ignore - async def update( + async def revoke_access_tokens( self, id: str, - tokens_valid_from: Optional[datetime.datetime] = None, **kwargs ) -> None: - """Update an Identity. + """Revoke all access tokens for the specific identity. - Update an Identity. + Revoke all access tokens for the specific identity. :param id: Identifier of the identity. :type id: str - :param tokens_valid_from: All tokens that are issued prior to this time will be revoked. - :type tokens_valid_from: ~datetime.datetime :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -167,13 +176,10 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - - _body = _models.CommunicationIdentityUpdateRequest(tokens_valid_from=tokens_valid_from) - api_version = "2020-07-20-preview2" - content_type = kwargs.pop("content_type", "application/merge-patch+json") + api_version = "2021-03-07" # Construct URL - url = self.update.metadata['url'] # type: ignore + url = self.revoke_access_tokens.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), 'id': self._serialize.url("id", id, 'str'), @@ -186,12 +192,8 @@ async def update( # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_body, 'CommunicationIdentityUpdateRequest') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -202,40 +204,40 @@ async def update( if cls: return cls(pipeline_response, None, {}) - update.metadata = {'url': '/identities/{id}'} # type: ignore + revoke_access_tokens.metadata = {'url': '/identities/{id}/:revokeAccessTokens'} # type: ignore - async def issue_token( + async def issue_access_token( self, id: str, - scopes: List[str], + scopes: List[Union[str, "_models.CommunicationTokenScope"]], **kwargs - ) -> "_models.CommunicationIdentityToken": - """Generate a new token for an identity. + ) -> "_models.CommunicationUserToken": + """Issue a new token for an identity. - Generate a new token for an identity. + Issue a new token for an identity. :param id: Identifier of the identity to issue token for. :type id: str :param scopes: List of scopes attached to the token. - :type scopes: list[str] + :type scopes: list[str or ~azure.communication.identity.models.CommunicationTokenScope] :keyword callable cls: A custom type or function that will be passed the direct response - :return: CommunicationIdentityToken, or the result of cls(response) - :rtype: ~azure.communication.identity.models.CommunicationIdentityToken + :return: CommunicationUserToken, or the result of cls(response) + :rtype: ~azure.communication.identity.models.CommunicationUserToken :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunicationIdentityToken"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunicationUserToken"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - _body = _models.CommunicationTokenRequest(scopes=scopes) - api_version = "2020-07-20-preview2" + _body = _models.CommunicationIdentityAccessTokenRequest(scopes=scopes) + api_version = "2021-03-07" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" # Construct URL - url = self.issue_token.metadata['url'] # type: ignore + url = self.issue_access_token.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), 'id': self._serialize.url("id", id, 'str'), @@ -252,7 +254,7 @@ async def issue_token( header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_body, 'CommunicationTokenRequest') + body_content = self._serialize.body(_body, 'CommunicationIdentityAccessTokenRequest') body_content_kwargs['content'] = body_content request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) @@ -262,10 +264,10 @@ async def issue_token( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - deserialized = self._deserialize('CommunicationIdentityToken', pipeline_response) + deserialized = self._deserialize('CommunicationUserToken', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - issue_token.metadata = {'url': '/identities/{id}/token'} # type: ignore + issue_access_token.metadata = {'url': '/identities/{id}/:issueAccessToken'} # type: ignore diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/__init__.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/__init__.py index 05dd3d4b6aab..74e19ba16a57 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/__init__.py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/__init__.py @@ -8,18 +8,26 @@ try: from ._models_py3 import CommunicationIdentity - from ._models_py3 import CommunicationIdentityToken - from ._models_py3 import CommunicationIdentityUpdateRequest - from ._models_py3 import CommunicationTokenRequest + from ._models_py3 import CommunicationIdentityAccessTokenRequest + from ._models_py3 import CommunicationIdentityAccessTokenResult + from ._models_py3 import CommunicationIdentityCreateRequest + from ._models_py3 import CommunicationUserToken except (SyntaxError, ImportError): from ._models import CommunicationIdentity # type: ignore - from ._models import CommunicationIdentityToken # type: ignore - from ._models import CommunicationIdentityUpdateRequest # type: ignore - from ._models import CommunicationTokenRequest # type: ignore + from ._models import CommunicationIdentityAccessTokenRequest # type: ignore + from ._models import CommunicationIdentityAccessTokenResult # type: ignore + from ._models import CommunicationIdentityCreateRequest # type: ignore + from ._models import CommunicationUserToken # type: ignore + +from ._communication_identity_client_enums import ( + CommunicationTokenScope, +) __all__ = [ 'CommunicationIdentity', - 'CommunicationIdentityToken', - 'CommunicationIdentityUpdateRequest', - 'CommunicationTokenRequest', + 'CommunicationIdentityAccessTokenRequest', + 'CommunicationIdentityAccessTokenResult', + 'CommunicationIdentityCreateRequest', + 'CommunicationUserToken', + 'CommunicationTokenScope', ] diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/_communication_identity_client_enums.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/_communication_identity_client_enums.py new file mode 100644 index 000000000000..fb650aac3d10 --- /dev/null +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/_communication_identity_client_enums.py @@ -0,0 +1,34 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum, EnumMeta +from six import with_metaclass + +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) + + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) + + +class CommunicationTokenScope(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """List of scopes for an access token. + """ + + CHAT = "chat" + VOIP = "voip" diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/_models.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/_models.py index ce2106c91807..3f78f63e247e 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/_models.py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/_models.py @@ -34,80 +34,105 @@ def __init__( self.id = kwargs['id'] -class CommunicationIdentityToken(msrest.serialization.Model): - """CommunicationIdentityToken. +class CommunicationIdentityAccessTokenRequest(msrest.serialization.Model): + """CommunicationIdentityAccessTokenRequest. All required parameters must be populated in order to send to Azure. - :param id: Required. Identifier of the identity owning the token. - :type id: str - :param token: Required. The token issued for the identity. - :type token: str - :param expires_on: Required. The expiry time of the token. - :type expires_on: ~datetime.datetime + :param scopes: Required. List of scopes attached to the token. + :type scopes: list[str or ~azure.communication.identity.models.CommunicationTokenScope] """ _validation = { - 'id': {'required': True}, - 'token': {'required': True}, - 'expires_on': {'required': True}, + 'scopes': {'required': True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'token': {'key': 'token', 'type': 'str'}, - 'expires_on': {'key': 'expiresOn', 'type': 'iso-8601'}, + 'scopes': {'key': 'scopes', 'type': '[str]'}, } def __init__( self, **kwargs ): - super(CommunicationIdentityToken, self).__init__(**kwargs) - self.id = kwargs['id'] - self.token = kwargs['token'] - self.expires_on = kwargs['expires_on'] + super(CommunicationIdentityAccessTokenRequest, self).__init__(**kwargs) + self.scopes = kwargs['scopes'] + +class CommunicationIdentityAccessTokenResult(msrest.serialization.Model): + """A communication identity with access token. -class CommunicationIdentityUpdateRequest(msrest.serialization.Model): - """CommunicationIdentityUpdateRequest. + All required parameters must be populated in order to send to Azure. - :param tokens_valid_from: All tokens that are issued prior to this time will be revoked. - :type tokens_valid_from: ~datetime.datetime + :param identity: Required. A communication identity. + :type identity: ~azure.communication.identity.models.CommunicationIdentity + :param access_token: An access token. + :type access_token: ~azure.communication.identity.models.CommunicationUserToken """ + _validation = { + 'identity': {'required': True}, + } + _attribute_map = { - 'tokens_valid_from': {'key': 'tokensValidFrom', 'type': 'iso-8601'}, + 'identity': {'key': 'identity', 'type': 'CommunicationIdentity'}, + 'access_token': {'key': 'accessToken', 'type': 'CommunicationUserToken'}, } def __init__( self, **kwargs ): - super(CommunicationIdentityUpdateRequest, self).__init__(**kwargs) - self.tokens_valid_from = kwargs.get('tokens_valid_from', None) + super(CommunicationIdentityAccessTokenResult, self).__init__(**kwargs) + self.identity = kwargs['identity'] + self.access_token = kwargs.get('access_token', None) + +class CommunicationIdentityCreateRequest(msrest.serialization.Model): + """CommunicationIdentityCreateRequest. -class CommunicationTokenRequest(msrest.serialization.Model): - """CommunicationTokenRequest. + :param create_token_with_scopes: Also create access token for the created identity. + :type create_token_with_scopes: list[str or + ~azure.communication.identity.models.CommunicationTokenScope] + """ + + _attribute_map = { + 'create_token_with_scopes': {'key': 'createTokenWithScopes', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + super(CommunicationIdentityCreateRequest, self).__init__(**kwargs) + self.create_token_with_scopes = kwargs.get('create_token_with_scopes', None) + + +class CommunicationUserToken(msrest.serialization.Model): + """An access token. All required parameters must be populated in order to send to Azure. - :param scopes: Required. List of scopes attached to the token. - :type scopes: list[str] + :param token: Required. The access token issued for the identity. + :type token: str + :param expires_on: Required. The expiry time of the token. + :type expires_on: ~datetime.datetime """ _validation = { - 'scopes': {'required': True}, + 'token': {'required': True}, + 'expires_on': {'required': True}, } _attribute_map = { - 'scopes': {'key': 'scopes', 'type': '[str]'}, + 'token': {'key': 'token', 'type': 'str'}, + 'expires_on': {'key': 'expiresOn', 'type': 'iso-8601'}, } def __init__( self, **kwargs ): - super(CommunicationTokenRequest, self).__init__(**kwargs) - self.scopes = kwargs['scopes'] + super(CommunicationUserToken, self).__init__(**kwargs) + self.token = kwargs['token'] + self.expires_on = kwargs['expires_on'] diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/_models_py3.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/_models_py3.py index ba3988b1589a..aee3deea484b 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/_models_py3.py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/_models_py3.py @@ -7,7 +7,7 @@ # -------------------------------------------------------------------------- import datetime -from typing import List, Optional +from typing import List, Optional, Union import msrest.serialization @@ -39,88 +39,115 @@ def __init__( self.id = id -class CommunicationIdentityToken(msrest.serialization.Model): - """CommunicationIdentityToken. +class CommunicationIdentityAccessTokenRequest(msrest.serialization.Model): + """CommunicationIdentityAccessTokenRequest. All required parameters must be populated in order to send to Azure. - :param id: Required. Identifier of the identity owning the token. - :type id: str - :param token: Required. The token issued for the identity. - :type token: str - :param expires_on: Required. The expiry time of the token. - :type expires_on: ~datetime.datetime + :param scopes: Required. List of scopes attached to the token. + :type scopes: list[str or ~azure.communication.identity.models.CommunicationTokenScope] """ _validation = { - 'id': {'required': True}, - 'token': {'required': True}, - 'expires_on': {'required': True}, + 'scopes': {'required': True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'token': {'key': 'token', 'type': 'str'}, - 'expires_on': {'key': 'expiresOn', 'type': 'iso-8601'}, + 'scopes': {'key': 'scopes', 'type': '[str]'}, } def __init__( self, *, - id: str, - token: str, - expires_on: datetime.datetime, + scopes: List[Union[str, "CommunicationTokenScope"]], **kwargs ): - super(CommunicationIdentityToken, self).__init__(**kwargs) - self.id = id - self.token = token - self.expires_on = expires_on + super(CommunicationIdentityAccessTokenRequest, self).__init__(**kwargs) + self.scopes = scopes -class CommunicationIdentityUpdateRequest(msrest.serialization.Model): - """CommunicationIdentityUpdateRequest. +class CommunicationIdentityAccessTokenResult(msrest.serialization.Model): + """A communication identity with access token. - :param tokens_valid_from: All tokens that are issued prior to this time will be revoked. - :type tokens_valid_from: ~datetime.datetime + All required parameters must be populated in order to send to Azure. + + :param identity: Required. A communication identity. + :type identity: ~azure.communication.identity.models.CommunicationIdentity + :param access_token: An access token. + :type access_token: ~azure.communication.identity.models.CommunicationUserToken """ + _validation = { + 'identity': {'required': True}, + } + _attribute_map = { - 'tokens_valid_from': {'key': 'tokensValidFrom', 'type': 'iso-8601'}, + 'identity': {'key': 'identity', 'type': 'CommunicationIdentity'}, + 'access_token': {'key': 'accessToken', 'type': 'CommunicationUserToken'}, } def __init__( self, *, - tokens_valid_from: Optional[datetime.datetime] = None, + identity: "CommunicationIdentity", + access_token: Optional["CommunicationUserToken"] = None, **kwargs ): - super(CommunicationIdentityUpdateRequest, self).__init__(**kwargs) - self.tokens_valid_from = tokens_valid_from + super(CommunicationIdentityAccessTokenResult, self).__init__(**kwargs) + self.identity = identity + self.access_token = access_token + +class CommunicationIdentityCreateRequest(msrest.serialization.Model): + """CommunicationIdentityCreateRequest. -class CommunicationTokenRequest(msrest.serialization.Model): - """CommunicationTokenRequest. + :param create_token_with_scopes: Also create access token for the created identity. + :type create_token_with_scopes: list[str or + ~azure.communication.identity.models.CommunicationTokenScope] + """ + + _attribute_map = { + 'create_token_with_scopes': {'key': 'createTokenWithScopes', 'type': '[str]'}, + } + + def __init__( + self, + *, + create_token_with_scopes: Optional[List[Union[str, "CommunicationTokenScope"]]] = None, + **kwargs + ): + super(CommunicationIdentityCreateRequest, self).__init__(**kwargs) + self.create_token_with_scopes = create_token_with_scopes + + +class CommunicationUserToken(msrest.serialization.Model): + """An access token. All required parameters must be populated in order to send to Azure. - :param scopes: Required. List of scopes attached to the token. - :type scopes: list[str] + :param token: Required. The access token issued for the identity. + :type token: str + :param expires_on: Required. The expiry time of the token. + :type expires_on: ~datetime.datetime """ _validation = { - 'scopes': {'required': True}, + 'token': {'required': True}, + 'expires_on': {'required': True}, } _attribute_map = { - 'scopes': {'key': 'scopes', 'type': '[str]'}, + 'token': {'key': 'token', 'type': 'str'}, + 'expires_on': {'key': 'expiresOn', 'type': 'iso-8601'}, } def __init__( self, *, - scopes: List[str], + token: str, + expires_on: datetime.datetime, **kwargs ): - super(CommunicationTokenRequest, self).__init__(**kwargs) - self.scopes = scopes + super(CommunicationUserToken, self).__init__(**kwargs) + self.token = token + self.expires_on = expires_on diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/operations/_communication_identity_operations.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/operations/_communication_identity_operations.py index 745b0e36a4f3..65ba6961ca89 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/operations/_communication_identity_operations.py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/operations/_communication_identity_operations.py @@ -5,7 +5,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import datetime from typing import TYPE_CHECKING import warnings @@ -17,7 +16,7 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar + from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,30 +43,36 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def create( + def create_identity( self, + create_token_with_scopes=None, # type: Optional[List[Union[str, "_models.CommunicationTokenScope"]]] **kwargs # type: Any ): - # type: (...) -> "_models.CommunicationIdentity" + # type: (...) -> "_models.CommunicationIdentityAccessTokenResult" """Create a new identity. Create a new identity. + :param create_token_with_scopes: Also create access token for the created identity. + :type create_token_with_scopes: list[str or ~azure.communication.identity.models.CommunicationTokenScope] :keyword callable cls: A custom type or function that will be passed the direct response - :return: CommunicationIdentity, or the result of cls(response) - :rtype: ~azure.communication.identity.models.CommunicationIdentity + :return: CommunicationIdentityAccessTokenResult, or the result of cls(response) + :rtype: ~azure.communication.identity.models.CommunicationIdentityAccessTokenResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunicationIdentity"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunicationIdentityAccessTokenResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview2" + + _body = _models.CommunicationIdentityCreateRequest(create_token_with_scopes=create_token_with_scopes) + api_version = "2021-03-07" + content_type = kwargs.pop("content_type", "application/json") accept = "application/json" # Construct URL - url = self.create.metadata['url'] # type: ignore + url = self.create_identity.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } @@ -79,9 +84,16 @@ def create( # Construct headers header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - request = self._client.post(url, query_parameters, header_parameters) + body_content_kwargs = {} # type: Dict[str, Any] + if _body is not None: + body_content = self._serialize.body(_body, 'CommunicationIdentityCreateRequest') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -89,23 +101,23 @@ def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - deserialized = self._deserialize('CommunicationIdentity', pipeline_response) + deserialized = self._deserialize('CommunicationIdentityAccessTokenResult', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/identities'} # type: ignore + create_identity.metadata = {'url': '/identities'} # type: ignore - def delete( + def delete_identity( self, id, # type: str **kwargs # type: Any ): # type: (...) -> None - """Delete the identity, revoke all tokens of the identity and delete all associated data. + """Delete the identity, revoke all tokens for the identity and delete all associated data. - Delete the identity, revoke all tokens of the identity and delete all associated data. + Delete the identity, revoke all tokens for the identity and delete all associated data. :param id: Identifier of the identity to be deleted. :type id: str @@ -119,10 +131,10 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-20-preview2" + api_version = "2021-03-07" # Construct URL - url = self.delete.metadata['url'] # type: ignore + url = self.delete_identity.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), 'id': self._serialize.url("id", id, 'str'), @@ -147,23 +159,20 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/identities/{id}'} # type: ignore + delete_identity.metadata = {'url': '/identities/{id}'} # type: ignore - def update( + def revoke_access_tokens( self, id, # type: str - tokens_valid_from=None, # type: Optional[datetime.datetime] **kwargs # type: Any ): # type: (...) -> None - """Update an Identity. + """Revoke all access tokens for the specific identity. - Update an Identity. + Revoke all access tokens for the specific identity. :param id: Identifier of the identity. :type id: str - :param tokens_valid_from: All tokens that are issued prior to this time will be revoked. - :type tokens_valid_from: ~datetime.datetime :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -174,13 +183,10 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - - _body = _models.CommunicationIdentityUpdateRequest(tokens_valid_from=tokens_valid_from) - api_version = "2020-07-20-preview2" - content_type = kwargs.pop("content_type", "application/merge-patch+json") + api_version = "2021-03-07" # Construct URL - url = self.update.metadata['url'] # type: ignore + url = self.revoke_access_tokens.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), 'id': self._serialize.url("id", id, 'str'), @@ -193,12 +199,8 @@ def update( # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_body, 'CommunicationIdentityUpdateRequest') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -209,41 +211,41 @@ def update( if cls: return cls(pipeline_response, None, {}) - update.metadata = {'url': '/identities/{id}'} # type: ignore + revoke_access_tokens.metadata = {'url': '/identities/{id}/:revokeAccessTokens'} # type: ignore - def issue_token( + def issue_access_token( self, id, # type: str - scopes, # type: List[str] + scopes, # type: List[Union[str, "_models.CommunicationTokenScope"]] **kwargs # type: Any ): - # type: (...) -> "_models.CommunicationIdentityToken" - """Generate a new token for an identity. + # type: (...) -> "_models.CommunicationUserToken" + """Issue a new token for an identity. - Generate a new token for an identity. + Issue a new token for an identity. :param id: Identifier of the identity to issue token for. :type id: str :param scopes: List of scopes attached to the token. - :type scopes: list[str] + :type scopes: list[str or ~azure.communication.identity.models.CommunicationTokenScope] :keyword callable cls: A custom type or function that will be passed the direct response - :return: CommunicationIdentityToken, or the result of cls(response) - :rtype: ~azure.communication.identity.models.CommunicationIdentityToken + :return: CommunicationUserToken, or the result of cls(response) + :rtype: ~azure.communication.identity.models.CommunicationUserToken :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunicationIdentityToken"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunicationUserToken"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - _body = _models.CommunicationTokenRequest(scopes=scopes) - api_version = "2020-07-20-preview2" + _body = _models.CommunicationIdentityAccessTokenRequest(scopes=scopes) + api_version = "2021-03-07" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" # Construct URL - url = self.issue_token.metadata['url'] # type: ignore + url = self.issue_access_token.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), 'id': self._serialize.url("id", id, 'str'), @@ -260,7 +262,7 @@ def issue_token( header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_body, 'CommunicationTokenRequest') + body_content = self._serialize.body(_body, 'CommunicationIdentityAccessTokenRequest') body_content_kwargs['content'] = body_content request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) @@ -270,10 +272,10 @@ def issue_token( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - deserialized = self._deserialize('CommunicationIdentityToken', pipeline_response) + deserialized = self._deserialize('CommunicationUserToken', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - issue_token.metadata = {'url': '/identities/{id}/token'} # type: ignore + issue_access_token.metadata = {'url': '/identities/{id}/:issueAccessToken'} # type: ignore diff --git a/sdk/communication/azure-communication-identity/swagger/SWAGGER.md b/sdk/communication/azure-communication-identity/swagger/SWAGGER.md index 164f24e0e24d..47b7472e1f82 100644 --- a/sdk/communication/azure-communication-identity/swagger/SWAGGER.md +++ b/sdk/communication/azure-communication-identity/swagger/SWAGGER.md @@ -15,7 +15,7 @@ autorest ./SWAGGER.md ### Settings ``` yaml -input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/8818a603b78a1355ba1647ab9cd4e3354cdc4b69/specification/communication/data-plane/Microsoft.CommunicationServicesIdentity/preview/2020-07-20-preview2/CommunicationIdentity.json +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/084de2711f77d12d644c7628b61cdd7634341ee8/specification/communication/data-plane/Microsoft.CommunicationServicesIdentity/stable/2021-03-07/CommunicationIdentity.json output-folder: ../azure/communication/identity/_generated/ namespace: azure.communication.identity license-header: MICROSOFT_MIT_NO_VERSION @@ -25,3 +25,20 @@ clear-output-folder: true v3: true python: true ``` + +### Rename CommunicationIdentityAccessToken to CommunicationUserToken + +``` yaml +directive: + - rename-model: + from: CommunicationIdentityAccessToken + to: CommunicationUserToken +``` + +### Rename CommunicationIdentityTokenScope to CommunicationTokenScope +```yaml +directive: + - from: swagger-document + where: $.definitions.CommunicationIdentityTokenScope + transform: > + $["x-ms-enum"].name = "CommunicationTokenScope"; \ No newline at end of file From 586f727219efe82f2b41d497e98e20c082c7437e Mon Sep 17 00:00:00 2001 From: Bert Ong <823691+beltr0n@users.noreply.github.com> Date: Fri, 22 Jan 2021 17:36:14 -0800 Subject: [PATCH 27/33] update with latest swagger and regen --- .../_communication_identity_operations.py | 30 ++++--- .../identity/_generated/models/__init__.py | 6 ++ .../identity/_generated/models/_models.py | 72 +++++++++++++++++ .../identity/_generated/models/_models_py3.py | 78 +++++++++++++++++++ .../_communication_identity_operations.py | 30 ++++--- .../swagger/SWAGGER.md | 2 +- 6 files changed, 195 insertions(+), 23 deletions(-) diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/operations/_communication_identity_operations.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/operations/_communication_identity_operations.py index 3fc18bcd2858..bf5d9fa4246b 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/operations/_communication_identity_operations.py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/aio/operations/_communication_identity_operations.py @@ -39,7 +39,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - async def create_identity( + async def create( self, create_token_with_scopes: Optional[List[Union[str, "_models.CommunicationTokenScope"]]] = None, **kwargs @@ -67,7 +67,7 @@ async def create_identity( accept = "application/json" # Construct URL - url = self.create_identity.metadata['url'] # type: ignore + url = self.create.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } @@ -92,9 +92,10 @@ async def create_identity( pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = self._deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) deserialized = self._deserialize('CommunicationIdentityAccessTokenResult', pipeline_response) @@ -102,9 +103,9 @@ async def create_identity( return cls(pipeline_response, deserialized, {}) return deserialized - create_identity.metadata = {'url': '/identities'} # type: ignore + create.metadata = {'url': '/identities'} # type: ignore - async def delete_identity( + async def delete( self, id: str, **kwargs @@ -126,9 +127,10 @@ async def delete_identity( } error_map.update(kwargs.pop('error_map', {})) api_version = "2021-03-07" + accept = "application/json" # Construct URL - url = self.delete_identity.metadata['url'] # type: ignore + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), 'id': self._serialize.url("id", id, 'str'), @@ -141,6 +143,7 @@ async def delete_identity( # Construct headers header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) @@ -148,12 +151,13 @@ async def delete_identity( if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = self._deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) if cls: return cls(pipeline_response, None, {}) - delete_identity.metadata = {'url': '/identities/{id}'} # type: ignore + delete.metadata = {'url': '/identities/{id}'} # type: ignore async def revoke_access_tokens( self, @@ -177,6 +181,7 @@ async def revoke_access_tokens( } error_map.update(kwargs.pop('error_map', {})) api_version = "2021-03-07" + accept = "application/json" # Construct URL url = self.revoke_access_tokens.metadata['url'] # type: ignore @@ -192,6 +197,7 @@ async def revoke_access_tokens( # Construct headers header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) @@ -199,7 +205,8 @@ async def revoke_access_tokens( if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = self._deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) if cls: return cls(pipeline_response, None, {}) @@ -262,7 +269,8 @@ async def issue_access_token( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = self._deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) deserialized = self._deserialize('CommunicationUserToken', pipeline_response) diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/__init__.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/__init__.py index 74e19ba16a57..4c6b3887ee2d 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/__init__.py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/__init__.py @@ -7,12 +7,16 @@ # -------------------------------------------------------------------------- try: + from ._models_py3 import CommunicationError + from ._models_py3 import CommunicationErrorResponse from ._models_py3 import CommunicationIdentity from ._models_py3 import CommunicationIdentityAccessTokenRequest from ._models_py3 import CommunicationIdentityAccessTokenResult from ._models_py3 import CommunicationIdentityCreateRequest from ._models_py3 import CommunicationUserToken except (SyntaxError, ImportError): + from ._models import CommunicationError # type: ignore + from ._models import CommunicationErrorResponse # type: ignore from ._models import CommunicationIdentity # type: ignore from ._models import CommunicationIdentityAccessTokenRequest # type: ignore from ._models import CommunicationIdentityAccessTokenResult # type: ignore @@ -24,6 +28,8 @@ ) __all__ = [ + 'CommunicationError', + 'CommunicationErrorResponse', 'CommunicationIdentity', 'CommunicationIdentityAccessTokenRequest', 'CommunicationIdentityAccessTokenResult', diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/_models.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/_models.py index 3f78f63e247e..e788acd2aa32 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/_models.py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/_models.py @@ -6,9 +6,81 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from azure.core.exceptions import HttpResponseError import msrest.serialization +class CommunicationError(msrest.serialization.Model): + """The Communication Services error. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. The error code. + :type code: str + :param message: Required. The error message. + :type message: str + :ivar target: The error target. + :vartype target: str + :ivar details: Further details about specific errors that led to this error. + :vartype details: list[~azure.communication.identity.models.CommunicationError] + :param inner_error: The Communication Services error. + :type inner_error: ~azure.communication.identity.models.CommunicationError + """ + + _validation = { + 'code': {'required': True}, + 'message': {'required': True}, + 'target': {'readonly': True}, + 'details': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[CommunicationError]'}, + 'inner_error': {'key': 'innerError', 'type': 'CommunicationError'}, + } + + def __init__( + self, + **kwargs + ): + super(CommunicationError, self).__init__(**kwargs) + self.code = kwargs['code'] + self.message = kwargs['message'] + self.target = None + self.details = None + self.inner_error = kwargs.get('inner_error', None) + + +class CommunicationErrorResponse(msrest.serialization.Model): + """The Communication Services error. + + All required parameters must be populated in order to send to Azure. + + :param error: Required. The Communication Services error. + :type error: ~azure.communication.identity.models.CommunicationError + """ + + _validation = { + 'error': {'required': True}, + } + + _attribute_map = { + 'error': {'key': 'error', 'type': 'CommunicationError'}, + } + + def __init__( + self, + **kwargs + ): + super(CommunicationErrorResponse, self).__init__(**kwargs) + self.error = kwargs['error'] + + class CommunicationIdentity(msrest.serialization.Model): """A communication identity. diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/_models_py3.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/_models_py3.py index aee3deea484b..b459227f23b4 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/_models_py3.py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/models/_models_py3.py @@ -9,9 +9,87 @@ import datetime from typing import List, Optional, Union +from azure.core.exceptions import HttpResponseError import msrest.serialization +class CommunicationError(msrest.serialization.Model): + """The Communication Services error. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. The error code. + :type code: str + :param message: Required. The error message. + :type message: str + :ivar target: The error target. + :vartype target: str + :ivar details: Further details about specific errors that led to this error. + :vartype details: list[~azure.communication.identity.models.CommunicationError] + :param inner_error: The Communication Services error. + :type inner_error: ~azure.communication.identity.models.CommunicationError + """ + + _validation = { + 'code': {'required': True}, + 'message': {'required': True}, + 'target': {'readonly': True}, + 'details': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[CommunicationError]'}, + 'inner_error': {'key': 'innerError', 'type': 'CommunicationError'}, + } + + def __init__( + self, + *, + code: str, + message: str, + inner_error: Optional["CommunicationError"] = None, + **kwargs + ): + super(CommunicationError, self).__init__(**kwargs) + self.code = code + self.message = message + self.target = None + self.details = None + self.inner_error = inner_error + + +class CommunicationErrorResponse(msrest.serialization.Model): + """The Communication Services error. + + All required parameters must be populated in order to send to Azure. + + :param error: Required. The Communication Services error. + :type error: ~azure.communication.identity.models.CommunicationError + """ + + _validation = { + 'error': {'required': True}, + } + + _attribute_map = { + 'error': {'key': 'error', 'type': 'CommunicationError'}, + } + + def __init__( + self, + *, + error: "CommunicationError", + **kwargs + ): + super(CommunicationErrorResponse, self).__init__(**kwargs) + self.error = error + + class CommunicationIdentity(msrest.serialization.Model): """A communication identity. diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/operations/_communication_identity_operations.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/operations/_communication_identity_operations.py index 65ba6961ca89..0c1d77b6e1cb 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/operations/_communication_identity_operations.py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_generated/operations/_communication_identity_operations.py @@ -43,7 +43,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def create_identity( + def create( self, create_token_with_scopes=None, # type: Optional[List[Union[str, "_models.CommunicationTokenScope"]]] **kwargs # type: Any @@ -72,7 +72,7 @@ def create_identity( accept = "application/json" # Construct URL - url = self.create_identity.metadata['url'] # type: ignore + url = self.create.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } @@ -97,9 +97,10 @@ def create_identity( pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = self._deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) deserialized = self._deserialize('CommunicationIdentityAccessTokenResult', pipeline_response) @@ -107,9 +108,9 @@ def create_identity( return cls(pipeline_response, deserialized, {}) return deserialized - create_identity.metadata = {'url': '/identities'} # type: ignore + create.metadata = {'url': '/identities'} # type: ignore - def delete_identity( + def delete( self, id, # type: str **kwargs # type: Any @@ -132,9 +133,10 @@ def delete_identity( } error_map.update(kwargs.pop('error_map', {})) api_version = "2021-03-07" + accept = "application/json" # Construct URL - url = self.delete_identity.metadata['url'] # type: ignore + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), 'id': self._serialize.url("id", id, 'str'), @@ -147,6 +149,7 @@ def delete_identity( # Construct headers header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) @@ -154,12 +157,13 @@ def delete_identity( if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = self._deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) if cls: return cls(pipeline_response, None, {}) - delete_identity.metadata = {'url': '/identities/{id}'} # type: ignore + delete.metadata = {'url': '/identities/{id}'} # type: ignore def revoke_access_tokens( self, @@ -184,6 +188,7 @@ def revoke_access_tokens( } error_map.update(kwargs.pop('error_map', {})) api_version = "2021-03-07" + accept = "application/json" # Construct URL url = self.revoke_access_tokens.metadata['url'] # type: ignore @@ -199,6 +204,7 @@ def revoke_access_tokens( # Construct headers header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) @@ -206,7 +212,8 @@ def revoke_access_tokens( if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = self._deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) if cls: return cls(pipeline_response, None, {}) @@ -270,7 +277,8 @@ def issue_access_token( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = self._deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) deserialized = self._deserialize('CommunicationUserToken', pipeline_response) diff --git a/sdk/communication/azure-communication-identity/swagger/SWAGGER.md b/sdk/communication/azure-communication-identity/swagger/SWAGGER.md index 47b7472e1f82..1c447dd7884c 100644 --- a/sdk/communication/azure-communication-identity/swagger/SWAGGER.md +++ b/sdk/communication/azure-communication-identity/swagger/SWAGGER.md @@ -15,7 +15,7 @@ autorest ./SWAGGER.md ### Settings ``` yaml -input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/084de2711f77d12d644c7628b61cdd7634341ee8/specification/communication/data-plane/Microsoft.CommunicationServicesIdentity/stable/2021-03-07/CommunicationIdentity.json +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/14bfbf5d0ff8f0dc1358e6e60362e99d0a649ba7/specification/communication/data-plane/Microsoft.CommunicationServicesIdentity/stable/2021-03-07/CommunicationIdentity.json output-folder: ../azure/communication/identity/_generated/ namespace: azure.communication.identity license-header: MICROSOFT_MIT_NO_VERSION From 563a9087cc78ba56334ea668b9186792aad5962a Mon Sep 17 00:00:00 2001 From: Bert Ong <823691+beltr0n@users.noreply.github.com> Date: Fri, 22 Jan 2021 17:56:05 -0800 Subject: [PATCH 28/33] async client changes for new api --- .../_communication_identity_client_async.py | 50 +++++++++++++------ 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_communication_identity_client_async.py b/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_communication_identity_client_async.py index 44cdf5a65e5f..0d621718aafd 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_communication_identity_client_async.py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_communication_identity_client_async.py @@ -8,7 +8,7 @@ from .._generated.aio._communication_identity_client\ import CommunicationIdentityClient as CommunicationIdentityClientGen -from .._generated.models import CommunicationIdentityToken +from .._generated.models import CommunicationUserToken from .._shared.utils import parse_connection_str, get_authentication_policy from .._shared.models import CommunicationUserIdentifier @@ -64,7 +64,7 @@ def from_connection_string( :param str conn_str: A connection string to an Azure Communication Service resource. :returns: Instance of CommunicationIdentityClient. - :rtype: ~azure.communication.aio.CommunicationIdentityClient + :rtype: ~azure.communication.identity.aio.CommunicationIdentityClient .. admonition:: Example: @@ -84,13 +84,34 @@ async def create_user(self, **kwargs): # type: (...) -> CommunicationUserIdentifier """create a single Communication user - return: CommunicationUserIdentifier - rtype: ~azure.communication.identity.CommunicationUserIdentifier + :return: CommunicationUserIdentifier + :rtype: ~azure.communication.identity.CommunicationUserIdentifier """ return await self._identity_service_client.communication_identity.create( cls=lambda pr, u, e: CommunicationUserIdentifier(u.id), **kwargs) + @distributed_trace_async + async def create_user_with_token( + self, + scopes, # type: List[Union[str, "_model.CommunicationTokenScope"]] + **kwargs + ): + # type: (...) -> Tuple[CommunicationUserIdentifier, CommunicationUserToken] + """create a single Communication user along with an Identity Token + + :param scopes: + List of scopes to be added to the token. + :type scopes: list[str or + ~azure.communication.identity.models.CommunicationTokenScope] + :return: A tuple of a CommunicationUserIdentifier and a CommunicationUserToken. + :rtype: tuple of (~azure.communication.identity.CommunicationUserIdentifier, ~azure.communication.identity.CommunicationUserToken) + """ + return await self._identity_service_client.communication_identity.create( + create_token_with_scopes=scopes, + cls=lambda pr, u, e: CommunicationUserIdentifier(u.id), + **kwargs) + @distributed_trace_async async def delete_user( self, @@ -113,21 +134,22 @@ async def delete_user( async def issue_token( self, user, # type: CommunicationUserIdentifier - scopes, # type: List[str] + scopes, # type: List[Union[str, "_model.CommunicationTokenScope"]] **kwargs # type: Any ): - # type: (...) -> CommunicationIdentityToken + # type: (...) -> CommunicationUserToken """Generates a new token for an identity. :param user: Azure Communication User :type user: ~azure.communication.identity.CommunicationUserIdentifier :param scopes: List of scopes to be added to the token. - :type scopes: list[str] - :return: CommunicationIdentityToken - :rtype: ~azure.communication.identity.CommunicationIdentityToken + :type scopes: list[str or + ~azure.communication.identity.models.CommunicationTokenScope] + :return: CommunicationUserToken + :rtype: ~azure.communication.identity.CommunicationUserToken """ - return await self._identity_service_client.communication_identity.issue_token( + return await self._identity_service_client.communication_identity.issue_access_token( user.identifier, scopes, **kwargs) @@ -136,7 +158,6 @@ async def issue_token( async def revoke_tokens( self, user, # type: CommunicationUserIdentifier - issued_before=None, # type: Optional[datetime.datetime] **kwargs # type: Any ): # type: (...) -> None @@ -144,14 +165,11 @@ async def revoke_tokens( :param user: Azure Communication User. :type user: ~azure.communication.identity.CommunicationUserIdentifier - :param issued_before: All tokens that are issued prior to this time should get revoked. - :type issued_before: ~datetime.datetime :return: None :rtype: None """ - return await self._identity_service_client.communication_identity.update( + return await self._identity_service_client.communication_identity.revoke_access_tokens( user.identifier if user else None, - tokens_valid_from=issued_before, **kwargs) async def __aenter__(self) -> "CommunicationIdentityClient": @@ -163,6 +181,6 @@ async def __aexit__(self, *args: "Any") -> None: async def close(self) -> None: """Close the :class: - `~azure.communication.administration.aio.CommunicationIdentityClient` session. + `~azure.communication.identity.aio.CommunicationIdentityClient` session. """ await self._identity_service_client.__aexit__() From bc1b2a269a06e1f99842ff63826f0ab91bb9129b Mon Sep 17 00:00:00 2001 From: Lakshman Sundaralingam Date: Fri, 22 Jan 2021 17:57:44 -0800 Subject: [PATCH 29/33] Updated sync identity client --- .../azure/communication/identity/__init__.py | 4 +- .../_communication_identity_client.py | 45 ++++++++++++------- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/__init__.py b/sdk/communication/azure-communication-identity/azure/communication/identity/__init__.py index 77579e0b4d62..7f5629b26591 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/__init__.py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/__init__.py @@ -8,7 +8,7 @@ from ._generated.models import ( CommunicationTokenRequest, - CommunicationIdentityToken + CommunicationUserToken ) from ._shared.models import CommunicationUserIdentifier @@ -19,7 +19,7 @@ # from _identity 'CommunicationTokenRequest', - 'CommunicationIdentityToken', + 'CommunicationUserToken', # from _shared 'CommunicationUserIdentifier' diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_communication_identity_client.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_communication_identity_client.py index bb3cb57fe258..ea1756236c4e 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/_communication_identity_client.py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_communication_identity_client.py @@ -8,7 +8,7 @@ from ._generated._communication_identity_client\ import CommunicationIdentityClient as CommunicationIdentityClientGen -from ._generated.models import CommunicationIdentityToken +from ._generated.models import CommunicationUserToken from ._shared.utils import parse_connection_str, get_authentication_policy from ._shared.models import CommunicationUserIdentifier from ._version import SDK_MONIKER @@ -62,7 +62,7 @@ def from_connection_string( :param str conn_str: A connection string to an Azure Communication Service resource. :returns: Instance of CommunicationIdentityClient. - :rtype: ~azure.communication.CommunicationIdentityClient + :rtype: ~azure.communication.identity.CommunicationIdentityClient .. admonition:: Example: @@ -82,12 +82,31 @@ def create_user(self, **kwargs): # type: (...) -> CommunicationUserIdentifier """create a single Communication user - return: CommunicationUserIdentifier - rtype: ~azure.communication.identity.CommunicationUserIdentifier + :return: CommunicationUserIdentifier + :rtype: ~azure.communication.identity.CommunicationUserIdentifier """ return self._identity_service_client.communication_identity.create( cls=lambda pr, u, e: CommunicationUserIdentifier(u.id), **kwargs) + + @distributed_trace + def create_user_with_token( + self, + scopes, # type: List[Union[str, "_model.CommunicationTokenScope"]] + **kwargs # type: Any + ): + # type: (...) -> Tuple[CommunicationUserIdentifier, CommunicationUserToken] + """create a single Communication user with an identity token. + :param scopes: + List of scopes to be added to the token. + :type scopes: list[str or ~azure.communication.identity.models.CommunicationTokenScope] + :return: A CommunicationUser and a CommunicationIdentityToken tuple. + :rtype: tuple of (~azure.communication.identity.CommunicationUser, ~azure.communication.identity.CommunicationIdentityToken) + """ + return self._identity_service_client.communication_identity.create( + cls=lambda pr, u, e: CommunicationUserIdentifier(u.id), + create_token_with_scopes=scopes, + **kwargs) @distributed_trace def delete_user( @@ -111,21 +130,21 @@ def delete_user( def issue_token( self, user, # type: CommunicationUserIdentifier - scopes, # type: List[str] + scopes, # List[Union[str, "_model.CommunicationTokenScope"]] **kwargs # type: Any ): - # type: (...) -> CommunicationIdentityToken + # type: (...) -> CommunicationUserToken """Generates a new token for an identity. :param user: Azure Communication User :type user: ~azure.communication.identity.CommunicationUserIdentifier :param scopes: List of scopes to be added to the token. - :type scopes: list[str] - :return: CommunicationIdentityToken - :rtype: ~azure.communication.identity.CommunicationIdentityToken + :type scopes: list[str or ~azure.communication.identity.models.CommunicationTokenScope] + :return: CommunicationUserToken + :rtype: ~azure.communication.identity.CommunicationUserToken """ - return self._identity_service_client.communication_identity.issue_token( + return self._identity_service_client.communication_identity.issue_access_token( user.identifier, scopes, **kwargs) @@ -134,7 +153,6 @@ def issue_token( def revoke_tokens( self, user, # type: CommunicationUserIdentifier - issued_before=None, # type: Optional[datetime.datetime] **kwargs # type: Any ): # type: (...) -> None @@ -142,12 +160,9 @@ def revoke_tokens( :param user: Azure Communication User. :type user: ~azure.communication.identity.CommunicationUserIdentifier. - :param issued_before: All tokens that are issued prior to this time should get revoked. - :type issued_before: ~datetime.datetime. :return: None :rtype: None """ - return self._identity_service_client.communication_identity.update( + return self._identity_service_client.communication_identity.revoke_access_tokens( user.identifier if user else None, - tokens_valid_from=issued_before, **kwargs) From f56c773700d6fdec2f118ebe49647b0e7bc9b20c Mon Sep 17 00:00:00 2001 From: Lakshman Sundaralingam Date: Mon, 25 Jan 2021 11:10:09 -0800 Subject: [PATCH 30/33] Updated CommunicationTokenRequest to CommunicationIdentityAccessTokenRequest --- .../azure/communication/identity/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/__init__.py b/sdk/communication/azure-communication-identity/azure/communication/identity/__init__.py index 7f5629b26591..8cf68fa76838 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/__init__.py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/__init__.py @@ -7,7 +7,7 @@ from ._communication_identity_client import CommunicationIdentityClient from ._generated.models import ( - CommunicationTokenRequest, + CommunicationIdentityAccessTokenRequest, CommunicationUserToken ) @@ -18,7 +18,7 @@ 'CommunicationIdentityClient', # from _identity - 'CommunicationTokenRequest', + 'CommunicationIdentityAccessTokenRequest', 'CommunicationUserToken', # from _shared From 02d2112890f3838b009dd0fb62fbf20546922fce Mon Sep 17 00:00:00 2001 From: Bert Ong <823691+beltr0n@users.noreply.github.com> Date: Mon, 25 Jan 2021 11:19:33 -0800 Subject: [PATCH 31/33] pylint fixes --- .../identity/_communication_identity_client.py | 3 ++- .../identity/aio/_communication_identity_client_async.py | 9 ++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_communication_identity_client.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_communication_identity_client.py index ea1756236c4e..0b2f0d88cd3a 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/_communication_identity_client.py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_communication_identity_client.py @@ -101,7 +101,8 @@ def create_user_with_token( List of scopes to be added to the token. :type scopes: list[str or ~azure.communication.identity.models.CommunicationTokenScope] :return: A CommunicationUser and a CommunicationIdentityToken tuple. - :rtype: tuple of (~azure.communication.identity.CommunicationUser, ~azure.communication.identity.CommunicationIdentityToken) + :rtype: tuple of (~azure.communication.identity.CommunicationUserIdentifier, + ~azure.communication.identity.CommunicationUserToken) """ return self._identity_service_client.communication_identity.create( cls=lambda pr, u, e: CommunicationUserIdentifier(u.id), diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_communication_identity_client_async.py b/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_communication_identity_client_async.py index 0d621718aafd..37489fb42548 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_communication_identity_client_async.py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_communication_identity_client_async.py @@ -102,10 +102,10 @@ async def create_user_with_token( :param scopes: List of scopes to be added to the token. - :type scopes: list[str or - ~azure.communication.identity.models.CommunicationTokenScope] + :type scopes: list[str or ~azure.communication.identity.models.CommunicationTokenScope] :return: A tuple of a CommunicationUserIdentifier and a CommunicationUserToken. - :rtype: tuple of (~azure.communication.identity.CommunicationUserIdentifier, ~azure.communication.identity.CommunicationUserToken) + :rtype: tuple of (~azure.communication.identity.CommunicationUserIdentifier, + ~azure.communication.identity.CommunicationUserToken) """ return await self._identity_service_client.communication_identity.create( create_token_with_scopes=scopes, @@ -144,8 +144,7 @@ async def issue_token( :type user: ~azure.communication.identity.CommunicationUserIdentifier :param scopes: List of scopes to be added to the token. - :type scopes: list[str or - ~azure.communication.identity.models.CommunicationTokenScope] + :type scopes: list[str or ~azure.communication.identity.models.CommunicationTokenScope] :return: CommunicationUserToken :rtype: ~azure.communication.identity.CommunicationUserToken """ From de04ea9e2b38bee6cd0beb7005e11a21d9978fd8 Mon Sep 17 00:00:00 2001 From: Lakshman Sundaralingam Date: Mon, 25 Jan 2021 15:24:18 -0800 Subject: [PATCH 32/33] Fixed pylint issues --- .../identity/_communication_identity_client.py | 5 +++-- .../identity/aio/_communication_identity_client_async.py | 9 ++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_communication_identity_client.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_communication_identity_client.py index ea1756236c4e..59cdc407b207 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/_communication_identity_client.py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_communication_identity_client.py @@ -88,7 +88,7 @@ def create_user(self, **kwargs): return self._identity_service_client.communication_identity.create( cls=lambda pr, u, e: CommunicationUserIdentifier(u.id), **kwargs) - + @distributed_trace def create_user_with_token( self, @@ -101,7 +101,8 @@ def create_user_with_token( List of scopes to be added to the token. :type scopes: list[str or ~azure.communication.identity.models.CommunicationTokenScope] :return: A CommunicationUser and a CommunicationIdentityToken tuple. - :rtype: tuple of (~azure.communication.identity.CommunicationUser, ~azure.communication.identity.CommunicationIdentityToken) + :rtype: tuple of (~azure.communication.identity.CommunicationUser, \ +~azure.communication.identity.CommunicationIdentityToken) """ return self._identity_service_client.communication_identity.create( cls=lambda pr, u, e: CommunicationUserIdentifier(u.id), diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_communication_identity_client_async.py b/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_communication_identity_client_async.py index 0d621718aafd..7b034e13bbf0 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_communication_identity_client_async.py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_communication_identity_client_async.py @@ -102,10 +102,10 @@ async def create_user_with_token( :param scopes: List of scopes to be added to the token. - :type scopes: list[str or - ~azure.communication.identity.models.CommunicationTokenScope] + :type scopes: list[str or ~azure.communication.identity.models.CommunicationTokenScope] :return: A tuple of a CommunicationUserIdentifier and a CommunicationUserToken. - :rtype: tuple of (~azure.communication.identity.CommunicationUserIdentifier, ~azure.communication.identity.CommunicationUserToken) + :rtype: tuple of (~azure.communication.identity.CommunicationUserIdentifier, \ +~azure.communication.identity.CommunicationUserToken) """ return await self._identity_service_client.communication_identity.create( create_token_with_scopes=scopes, @@ -144,8 +144,7 @@ async def issue_token( :type user: ~azure.communication.identity.CommunicationUserIdentifier :param scopes: List of scopes to be added to the token. - :type scopes: list[str or - ~azure.communication.identity.models.CommunicationTokenScope] + :type scopes: list[str or ~azure.communication.identity.models.CommunicationTokenScope] :return: CommunicationUserToken :rtype: ~azure.communication.identity.CommunicationUserToken """ From 5f262cc3b04ecf456dc0540b3b39eeecf18663c5 Mon Sep 17 00:00:00 2001 From: Lakshman Sundaralingam Date: Wed, 27 Jan 2021 16:14:48 -0800 Subject: [PATCH 33/33] Fixed create user method and updated test recordings --- .../_communication_identity_client.py | 4 +- .../_communication_identity_client_async.py | 4 +- ...tion_identity_client.test_create_user.yaml | 26 +++---- ...est_create_user_from_managed_identity.yaml | 24 ++++--- ...tion_identity_client.test_delete_user.yaml | 42 +++++------ ...est_delete_user_from_managed_identity.yaml | 38 +++++----- ...tion_identity_client.test_issue_token.yaml | 42 +++++------ ...est_issue_token_from_managed_identity.yaml | 38 +++++----- ...on_identity_client.test_revoke_tokens.yaml | 66 ++++++++--------- ...t_revoke_tokens_from_managed_identity.yaml | 60 ++++++++-------- ...dentity_client_async.test_create_user.yaml | 28 ++++---- ...est_create_user_from_managed_identity.yaml | 26 ++++--- ...dentity_client_async.test_delete_user.yaml | 46 ++++++------ ...est_delete_user_from_managed_identity.yaml | 42 ++++++----- ...dentity_client_async.test_issue_token.yaml | 46 ++++++------ ...est_issue_token_from_managed_identity.yaml | 42 ++++++----- ...ntity_client_async.test_revoke_tokens.yaml | 72 ++++++++++--------- ...t_revoke_tokens_from_managed_identity.yaml | 66 ++++++++--------- 18 files changed, 378 insertions(+), 334 deletions(-) diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/_communication_identity_client.py b/sdk/communication/azure-communication-identity/azure/communication/identity/_communication_identity_client.py index 0c1fdc1c3c54..43444467aa2c 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/_communication_identity_client.py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/_communication_identity_client.py @@ -86,7 +86,7 @@ def create_user(self, **kwargs): :rtype: ~azure.communication.identity.CommunicationUserIdentifier """ return self._identity_service_client.communication_identity.create( - cls=lambda pr, u, e: CommunicationUserIdentifier(u.id), + cls=lambda pr, u, e: CommunicationUserIdentifier(u.identity.id), **kwargs) @distributed_trace @@ -105,7 +105,7 @@ def create_user_with_token( ~azure.communication.identity.CommunicationUserToken) """ return self._identity_service_client.communication_identity.create( - cls=lambda pr, u, e: CommunicationUserIdentifier(u.id), + cls=lambda pr, u, e: CommunicationUserIdentifier(u.identity.id), create_token_with_scopes=scopes, **kwargs) diff --git a/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_communication_identity_client_async.py b/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_communication_identity_client_async.py index 7b034e13bbf0..9db27f05aeb1 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_communication_identity_client_async.py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_communication_identity_client_async.py @@ -88,7 +88,7 @@ async def create_user(self, **kwargs): :rtype: ~azure.communication.identity.CommunicationUserIdentifier """ return await self._identity_service_client.communication_identity.create( - cls=lambda pr, u, e: CommunicationUserIdentifier(u.id), + cls=lambda pr, u, e: CommunicationUserIdentifier(u.identity.id), **kwargs) @distributed_trace_async @@ -109,7 +109,7 @@ async def create_user_with_token( """ return await self._identity_service_client.communication_identity.create( create_token_with_scopes=scopes, - cls=lambda pr, u, e: CommunicationUserIdentifier(u.id), + cls=lambda pr, u, e: CommunicationUserIdentifier(u.identity.id), **kwargs) @distributed_trace_async diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_create_user.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_create_user.yaml index 1973cd353437..bc64aafcef68 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_create_user.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_create_user.yaml @@ -1,6 +1,6 @@ interactions: - request: - body: null + body: '{}' headers: Accept: - application/json @@ -9,34 +9,36 @@ interactions: Connection: - keep-alive Content-Length: - - '0' + - '2' + Content-Type: + - application/json Date: - - Tue, 22 Dec 2020 18:26:56 GMT + - Wed, 27 Jan 2021 23:54:39 GMT User-Agent: - - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) x-ms-return-client-request-id: - 'true' method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2021-03-07 response: body: - string: '{"id": "sanitized"}' + string: '{"identity": {"id": "8:acs:713bd27c-3c73-4c55-a3d2-11c120d32fa8_00000007-e626-e90a-6216-1f3a0d003bb4"}}' headers: api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + - 2020-07-20-preview2, 2021-03-07 content-type: - application/json; charset=utf-8 date: - - Tue, 22 Dec 2020 18:26:55 GMT + - Wed, 27 Jan 2021 23:54:40 GMT ms-cv: - - 4whAoum970WIzePHLz1Ujg.0 + - V3Rpav/bY0WZnu7vMclLog.0 strict-transport-security: - max-age=2592000 transfer-encoding: - chunked x-processing-time: - - 18ms + - 229ms status: - code: 200 - message: OK + code: 201 + message: Created version: 1 diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_create_user_from_managed_identity.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_create_user_from_managed_identity.yaml index 7ddd5c68dcc7..67a09dedbd90 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_create_user_from_managed_identity.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_create_user_from_managed_identity.yaml @@ -1,6 +1,6 @@ interactions: - request: - body: null + body: '{}' headers: Accept: - application/json @@ -9,30 +9,32 @@ interactions: Connection: - keep-alive Content-Length: - - '0' + - '2' + Content-Type: + - application/json User-Agent: - - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2021-03-07 response: body: - string: '{"id": "sanitized"}' + string: '{"identity": {"id": "8:acs:3de2c19f-8f12-45ac-a978-5fe327284a35_00000007-e627-f129-ac00-343a0d00b106"}}' headers: api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + - 2020-07-20-preview2, 2021-03-07 content-type: - application/json; charset=utf-8 date: - - Tue, 22 Dec 2020 18:28:04 GMT + - Wed, 27 Jan 2021 23:55:48 GMT ms-cv: - - /4JsXqUuEkmQ1v304iaBTw.0 + - iocVB67Og0KRosYwvJnZlg.0 strict-transport-security: - max-age=2592000 transfer-encoding: - chunked x-processing-time: - - 635ms + - 183ms status: - code: 200 - message: OK + code: 201 + message: Created version: 1 diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_delete_user.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_delete_user.yaml index 40564943ea37..1feba48bb56c 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_delete_user.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_delete_user.yaml @@ -1,6 +1,6 @@ interactions: - request: - body: null + body: '{}' headers: Accept: - application/json @@ -9,41 +9,43 @@ interactions: Connection: - keep-alive Content-Length: - - '0' + - '2' + Content-Type: + - application/json Date: - - Tue, 22 Dec 2020 18:29:13 GMT + - Wed, 27 Jan 2021 23:56:55 GMT User-Agent: - - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) x-ms-return-client-request-id: - 'true' method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2021-03-07 response: body: - string: '{"id": "sanitized"}' + string: '{"identity": {"id": "8:acs:b040bbd1-fb13-465b-a547-44c5ff20b980_00000007-e628-f9f8-3ef0-8b3a0d003d3d"}}' headers: api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + - 2020-07-20-preview2, 2021-03-07 content-type: - application/json; charset=utf-8 date: - - Tue, 22 Dec 2020 18:29:12 GMT + - Wed, 27 Jan 2021 23:56:55 GMT ms-cv: - - UzbbWyNM6Ee4hx1Ym7MwSA.0 + - lv7eyX3+o0SgYHigmvhZNw.0 strict-transport-security: - max-age=2592000 transfer-encoding: - chunked x-processing-time: - - 19ms + - 214ms status: - code: 200 - message: OK + code: 201 + message: Created - request: body: null headers: Accept: - - '*/*' + - application/json Accept-Encoding: - gzip, deflate Connection: @@ -51,27 +53,27 @@ interactions: Content-Length: - '0' Date: - - Tue, 22 Dec 2020 18:29:14 GMT + - Wed, 27 Jan 2021 23:56:55 GMT User-Agent: - - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) x-ms-return-client-request-id: - 'true' method: DELETE - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2021-03-07 response: body: string: '' headers: api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + - 2020-07-20-preview2, 2021-03-07 date: - - Tue, 22 Dec 2020 18:29:13 GMT + - Wed, 27 Jan 2021 23:56:56 GMT ms-cv: - - bD8oBIuNQEWXEaluFwupbA.0 + - sVJZF/hnPUiFLBDEQt3jnQ.0 strict-transport-security: - max-age=2592000 x-processing-time: - - 764ms + - 777ms status: code: 204 message: No Content diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_delete_user_from_managed_identity.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_delete_user_from_managed_identity.yaml index 7e794bd59a59..ed23307fa951 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_delete_user_from_managed_identity.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_delete_user_from_managed_identity.yaml @@ -1,6 +1,6 @@ interactions: - request: - body: null + body: '{}' headers: Accept: - application/json @@ -9,37 +9,39 @@ interactions: Connection: - keep-alive Content-Length: - - '0' + - '2' + Content-Type: + - application/json User-Agent: - - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2021-03-07 response: body: - string: '{"id": "sanitized"}' + string: '{"identity": {"id": "8:acs:f050eca7-6baa-4427-966b-21841aa36a78_00000007-e62a-1f3f-8337-3b3a0d009555"}}' headers: api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + - 2020-07-20-preview2, 2021-03-07 content-type: - application/json; charset=utf-8 date: - - Tue, 22 Dec 2020 18:30:23 GMT + - Wed, 27 Jan 2021 23:58:10 GMT ms-cv: - - eSMH8ZATxUWO5OamG49Wdg.0 + - RivzvSMrYUCxdpIjJOqXeA.0 strict-transport-security: - max-age=2592000 transfer-encoding: - chunked x-processing-time: - - 811ms + - 193ms status: - code: 200 - message: OK + code: 201 + message: Created - request: body: null headers: Accept: - - '*/*' + - application/json Accept-Encoding: - gzip, deflate Connection: @@ -47,23 +49,23 @@ interactions: Content-Length: - '0' User-Agent: - - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) method: DELETE - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2021-03-07 response: body: string: '' headers: api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + - 2020-07-20-preview2, 2021-03-07 date: - - Tue, 22 Dec 2020 18:30:24 GMT + - Wed, 27 Jan 2021 23:58:12 GMT ms-cv: - - 91lJNqPMP0+hZnY0ay0tXA.0 + - akcIQiMeskOt/X1QZdhizg.0 strict-transport-security: - max-age=2592000 x-processing-time: - - 741ms + - 1936ms status: code: 204 message: No Content diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_issue_token.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_issue_token.yaml index 1645441b4fd6..dc7bd3bffa92 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_issue_token.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_issue_token.yaml @@ -1,6 +1,6 @@ interactions: - request: - body: null + body: '{}' headers: Accept: - application/json @@ -9,36 +9,38 @@ interactions: Connection: - keep-alive Content-Length: - - '0' + - '2' + Content-Type: + - application/json Date: - - Tue, 22 Dec 2020 18:31:34 GMT + - Wed, 27 Jan 2021 23:59:18 GMT User-Agent: - - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) x-ms-return-client-request-id: - 'true' method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2021-03-07 response: body: - string: '{"id": "sanitized"}' + string: '{"identity": {"id": "8:acs:8b7cf66e-98a2-4dc9-b44e-902ad4bd2a83_00000007-e62b-2a03-8d33-3b3a0d00aab4"}}' headers: api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + - 2020-07-20-preview2, 2021-03-07 content-type: - application/json; charset=utf-8 date: - - Tue, 22 Dec 2020 18:31:32 GMT + - Wed, 27 Jan 2021 23:59:19 GMT ms-cv: - - OXm+S4D9ak+t0Y4jKA3bFA.0 + - svjbdAEx+0CIrvFNZfZTNA.0 strict-transport-security: - max-age=2592000 transfer-encoding: - chunked x-processing-time: - - 24ms + - 20ms status: - code: 200 - message: OK + code: 201 + message: Created - request: body: '{"scopes": ["chat"]}' headers: @@ -53,31 +55,31 @@ interactions: Content-Type: - application/json Date: - - Tue, 22 Dec 2020 18:31:34 GMT + - Wed, 27 Jan 2021 23:59:19 GMT User-Agent: - - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) x-ms-return-client-request-id: - 'true' method: POST - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/:issueAccessToken?api-version=2021-03-07 response: body: - string: '{"id": "sanitized", "token": "sanitized", "expiresOn": "2020-12-23T18:31:32.3009076+00:00"}' + string: '{"token": "sanitized", "expiresOn": "2021-01-28T23:59:19.164577+00:00"}' headers: api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + - 2020-07-20-preview2, 2021-03-07 content-type: - application/json; charset=utf-8 date: - - Tue, 22 Dec 2020 18:31:32 GMT + - Wed, 27 Jan 2021 23:59:20 GMT ms-cv: - - EArcgkwtPkCU38ZbLjwJEQ.0 + - q/mt/g2JeUiXEsC0OhWXNQ.0 strict-transport-security: - max-age=2592000 transfer-encoding: - chunked x-processing-time: - - 24ms + - 284ms status: code: 200 message: OK diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_issue_token_from_managed_identity.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_issue_token_from_managed_identity.yaml index bd088f82a792..cbcb125440c8 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_issue_token_from_managed_identity.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_issue_token_from_managed_identity.yaml @@ -1,6 +1,6 @@ interactions: - request: - body: null + body: '{}' headers: Accept: - application/json @@ -9,32 +9,34 @@ interactions: Connection: - keep-alive Content-Length: - - '0' + - '2' + Content-Type: + - application/json User-Agent: - - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2021-03-07 response: body: - string: '{"id": "sanitized"}' + string: '{"identity": {"id": "8:acs:31fd4348-e9dd-4222-ae65-a61c9953759c_00000007-e62c-414b-0e04-343a0d00a745"}}' headers: api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + - 2020-07-20-preview2, 2021-03-07 content-type: - application/json; charset=utf-8 date: - - Tue, 22 Dec 2020 18:32:41 GMT + - Thu, 28 Jan 2021 00:00:30 GMT ms-cv: - - NcQPodkL5UOzC+AtKJcXvw.0 + - BndpwMRlKkSHkEuCPG7OOw.0 strict-transport-security: - max-age=2592000 transfer-encoding: - chunked x-processing-time: - - 501ms + - 198ms status: - code: 200 - message: OK + code: 201 + message: Created - request: body: '{"scopes": ["chat"]}' headers: @@ -49,27 +51,27 @@ interactions: Content-Type: - application/json User-Agent: - - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) method: POST - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/:issueAccessToken?api-version=2021-03-07 response: body: - string: '{"id": "sanitized", "token": "sanitized", "expiresOn": "2020-12-23T18:32:41.3736569+00:00"}' + string: '{"token": "sanitized", "expiresOn": "2021-01-29T00:00:30.7153587+00:00"}' headers: api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + - 2020-07-20-preview2, 2021-03-07 content-type: - application/json; charset=utf-8 date: - - Tue, 22 Dec 2020 18:32:41 GMT + - Thu, 28 Jan 2021 00:00:31 GMT ms-cv: - - W4rjQkxkvUSQqyJk5dUwCA.0 + - Ka0JSro0U0mjBhf0UNLzSg.0 strict-transport-security: - max-age=2592000 transfer-encoding: - chunked x-processing-time: - - 27ms + - 328ms status: code: 200 message: OK diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_revoke_tokens.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_revoke_tokens.yaml index 99b3257388c8..ecc9db7c4710 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_revoke_tokens.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_revoke_tokens.yaml @@ -1,6 +1,6 @@ interactions: - request: - body: null + body: '{}' headers: Accept: - application/json @@ -9,36 +9,38 @@ interactions: Connection: - keep-alive Content-Length: - - '0' + - '2' + Content-Type: + - application/json Date: - - Tue, 22 Dec 2020 18:34:17 GMT + - Thu, 28 Jan 2021 00:01:37 GMT User-Agent: - - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) x-ms-return-client-request-id: - 'true' method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2021-03-07 response: body: - string: '{"id": "sanitized"}' + string: '{"identity": {"id": "8:acs:a83346e4-c8aa-4a33-8993-ef56f44076ba_00000007-e62d-4910-1000-343a0d00b028"}}' headers: api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + - 2020-07-20-preview2, 2021-03-07 content-type: - application/json; charset=utf-8 date: - - Tue, 22 Dec 2020 18:34:16 GMT + - Thu, 28 Jan 2021 00:01:38 GMT ms-cv: - - ZDSP6Prb6UGYOTBLvb6AdQ.0 + - 3EE+zJXF4kyYK65z0u5AnQ.0 strict-transport-security: - max-age=2592000 transfer-encoding: - chunked x-processing-time: - - 23ms + - 18ms status: - code: 200 - message: OK + code: 201 + message: Created - request: body: '{"scopes": ["chat"]}' headers: @@ -53,69 +55,67 @@ interactions: Content-Type: - application/json Date: - - Tue, 22 Dec 2020 18:34:18 GMT + - Thu, 28 Jan 2021 00:01:38 GMT User-Agent: - - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) x-ms-return-client-request-id: - 'true' method: POST - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/:issueAccessToken?api-version=2021-03-07 response: body: - string: '{"id": "sanitized", "token": "sanitized", "expiresOn": "2020-12-23T18:34:15.7537392+00:00"}' + string: '{"token": "sanitized", "expiresOn": "2021-01-29T00:01:38.1765422+00:00"}' headers: api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + - 2020-07-20-preview2, 2021-03-07 content-type: - application/json; charset=utf-8 date: - - Tue, 22 Dec 2020 18:34:16 GMT + - Thu, 28 Jan 2021 00:01:39 GMT ms-cv: - - Hmv1R+jifUSsezIU2yJU8Q.0 + - wkhlq8Sb0ES4lAV8LpBBpw.0 strict-transport-security: - max-age=2592000 transfer-encoding: - chunked x-processing-time: - - 31ms + - 277ms status: code: 200 message: OK - request: - body: '{}' + body: null headers: Accept: - - '*/*' + - application/json Accept-Encoding: - gzip, deflate Connection: - keep-alive Content-Length: - - '2' - Content-Type: - - application/merge-patch+json + - '0' Date: - - Tue, 22 Dec 2020 18:34:18 GMT + - Thu, 28 Jan 2021 00:01:38 GMT User-Agent: - - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) x-ms-return-client-request-id: - 'true' - method: PATCH - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 + method: POST + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/:revokeAccessTokens?api-version=2021-03-07 response: body: string: '' headers: api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + - 2020-07-20-preview2, 2021-03-07 date: - - Tue, 22 Dec 2020 18:34:16 GMT + - Thu, 28 Jan 2021 00:01:39 GMT ms-cv: - - vwznKj2MY0qO9HTJ9YWIRw.0 + - 3+8Tl9kzVUSYp1fxZqKkSA.0 strict-transport-security: - max-age=2592000 x-processing-time: - - 11ms + - 231ms status: code: 204 message: No Content diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_revoke_tokens_from_managed_identity.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_revoke_tokens_from_managed_identity.yaml index d0fd1490c76e..25b2208d7edd 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_revoke_tokens_from_managed_identity.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_revoke_tokens_from_managed_identity.yaml @@ -1,6 +1,6 @@ interactions: - request: - body: null + body: '{}' headers: Accept: - application/json @@ -9,32 +9,34 @@ interactions: Connection: - keep-alive Content-Length: - - '0' + - '2' + Content-Type: + - application/json User-Agent: - - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2021-03-07 response: body: - string: '{"id": "sanitized"}' + string: '{"identity": {"id": "8:acs:ae743ca9-44ad-417b-9f52-cd0f7714f7f8_00000007-e62e-559c-defd-8b3a0d0026b9"}}' headers: api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + - 2020-07-20-preview2, 2021-03-07 content-type: - application/json; charset=utf-8 date: - - Tue, 22 Dec 2020 18:35:27 GMT + - Thu, 28 Jan 2021 00:02:47 GMT ms-cv: - - QmngflWD+EOVXH7i/FS+iw.0 + - 6bho3IvVN0KiuXQIQuaY4A.0 strict-transport-security: - max-age=2592000 transfer-encoding: - chunked x-processing-time: - - 792ms + - 351ms status: - code: 200 - message: OK + code: 201 + message: Created - request: body: '{"scopes": ["chat"]}' headers: @@ -49,61 +51,59 @@ interactions: Content-Type: - application/json User-Agent: - - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) method: POST - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/:issueAccessToken?api-version=2021-03-07 response: body: - string: '{"id": "sanitized", "token": "sanitized", "expiresOn": "2020-12-23T18:35:27.28321+00:00"}' + string: '{"token": "sanitized", "expiresOn": "2021-01-29T00:02:46.9228559+00:00"}' headers: api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + - 2020-07-20-preview2, 2021-03-07 content-type: - application/json; charset=utf-8 date: - - Tue, 22 Dec 2020 18:35:27 GMT + - Thu, 28 Jan 2021 00:02:47 GMT ms-cv: - - PRIzOxRVQkycMUEl6WNjHw.0 + - IaJHFvPdF0mpl2c2JVYIzw.0 strict-transport-security: - max-age=2592000 transfer-encoding: - chunked x-processing-time: - - 30ms + - 419ms status: code: 200 message: OK - request: - body: '{}' + body: null headers: Accept: - - '*/*' + - application/json Accept-Encoding: - gzip, deflate Connection: - keep-alive Content-Length: - - '2' - Content-Type: - - application/merge-patch+json + - '0' User-Agent: - - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - method: PATCH - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/:revokeAccessTokens?api-version=2021-03-07 response: body: string: '' headers: api-supported-versions: - - 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + - 2020-07-20-preview2, 2021-03-07 date: - - Tue, 22 Dec 2020 18:35:27 GMT + - Thu, 28 Jan 2021 00:02:48 GMT ms-cv: - - mUk2cNSJI0e/Nz7J7yCGYg.0 + - sw69Gh9HzkGQWmbSHeePvQ.0 strict-transport-security: - max-age=2592000 x-processing-time: - - 11ms + - 800ms status: code: 204 message: No Content diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_create_user.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_create_user.yaml index 1a9a4508d65a..f6e055603649 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_create_user.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_create_user.yaml @@ -1,30 +1,34 @@ interactions: - request: - body: '' + body: '{}' headers: Accept: - application/json + Content-Length: + - '2' + Content-Type: + - application/json Date: - - Tue, 22 Dec 2020 18:48:56 GMT + - Thu, 28 Jan 2021 00:03:54 GMT User-Agent: - - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) x-ms-return-client-request-id: - 'true' method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2021-03-07 response: body: - string: '{"id": "sanitized"}' + string: '{"identity": {"id": "8:acs:739796df-dcea-4106-b003-57a6e6d2b610_00000007-e62f-6079-defd-8b3a0d0026c2"}}' headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + api-supported-versions: 2020-07-20-preview2, 2021-03-07 content-type: application/json; charset=utf-8 - date: Tue, 22 Dec 2020 18:48:54 GMT - ms-cv: vfIkgQk+J0OWSV4P3J1i0w.0 + date: Thu, 28 Jan 2021 00:03:55 GMT + ms-cv: PttWnGmR6EmJpoysdPDsDA.0 strict-transport-security: max-age=2592000 transfer-encoding: chunked - x-processing-time: 22ms + x-processing-time: 240ms status: - code: 200 - message: OK - url: https://communicationtrnhzmurqrr.communication.azure.com/identities?api-version=2020-07-20-preview2 + code: 201 + message: Created + url: https://communicationx3clgzus2tf.communication.azure.com/identities?api-version=2021-03-07 version: 1 diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_create_user_from_managed_identity.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_create_user_from_managed_identity.yaml index b723acbffebd..41b643c8f1d4 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_create_user_from_managed_identity.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_create_user_from_managed_identity.yaml @@ -1,26 +1,30 @@ interactions: - request: - body: null + body: '{}' headers: Accept: - application/json + Content-Length: + - '2' + Content-Type: + - application/json User-Agent: - - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2021-03-07 response: body: - string: '{"id": "sanitized"}' + string: '{"identity": {"id": "8:acs:9c350207-bcd5-45a4-82d3-894441d61f3b_00000007-e630-69b0-a1ab-1d3a0d002d3b"}}' headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + api-supported-versions: 2020-07-20-preview2, 2021-03-07 content-type: application/json; charset=utf-8 - date: Tue, 22 Dec 2020 18:50:04 GMT - ms-cv: fj3guox5CUSvTCDG5gI0YA.0 + date: Thu, 28 Jan 2021 00:05:02 GMT + ms-cv: gGztHo5tZ0S0/LUla6RpUA.0 strict-transport-security: max-age=2592000 transfer-encoding: chunked - x-processing-time: 534ms + x-processing-time: 310ms status: - code: 200 - message: OK - url: https://communicationr7rdwwqs74n.communication.azure.com/identities?api-version=2020-07-20-preview2 + code: 201 + message: Created + url: https://communication7ne7szyxrek.communication.azure.com/identities?api-version=2021-03-07 version: 1 diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_delete_user.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_delete_user.yaml index d72ac521ab0f..0f3b5ea70644 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_delete_user.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_delete_user.yaml @@ -1,54 +1,60 @@ interactions: - request: - body: '' + body: '{}' headers: Accept: - application/json + Content-Length: + - '2' + Content-Type: + - application/json Date: - - Tue, 22 Dec 2020 18:51:13 GMT + - Thu, 28 Jan 2021 00:06:09 GMT User-Agent: - - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) x-ms-return-client-request-id: - 'true' method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2021-03-07 response: body: - string: '{"id": "sanitized"}' + string: '{"identity": {"id": "8:acs:0f760253-1d8c-4ac0-b43b-df2d1c43e136_00000007-e631-705c-92fd-8b3a0d004c1d"}}' headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + api-supported-versions: 2020-07-20-preview2, 2021-03-07 content-type: application/json; charset=utf-8 - date: Tue, 22 Dec 2020 18:51:12 GMT - ms-cv: dHk7/E5BhUSf+g3Bkg94YQ.0 + date: Thu, 28 Jan 2021 00:06:10 GMT + ms-cv: CP51xT5ofU2Qf4/8quyvHA.0 strict-transport-security: max-age=2592000 transfer-encoding: chunked - x-processing-time: 22ms + x-processing-time: 207ms status: - code: 200 - message: OK - url: https://communication42hz4pfbosr.communication.azure.com/identities?api-version=2020-07-20-preview2 + code: 201 + message: Created + url: https://communicationjr4rcjud6dy.communication.azure.com/identities?api-version=2021-03-07 - request: body: '' headers: + Accept: + - application/json Date: - - Tue, 22 Dec 2020 18:51:14 GMT + - Thu, 28 Jan 2021 00:06:10 GMT User-Agent: - - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) x-ms-return-client-request-id: - 'true' method: DELETE - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2021-03-07 response: body: string: '' headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - date: Tue, 22 Dec 2020 18:51:12 GMT - ms-cv: 3DnY9x3jNUGrGnsi3LP0SA.0 + api-supported-versions: 2020-07-20-preview2, 2021-03-07 + date: Thu, 28 Jan 2021 00:06:11 GMT + ms-cv: PvIFy0Tb7UmwNq2Se6oJhg.0 strict-transport-security: max-age=2592000 - x-processing-time: 440ms + x-processing-time: 843ms status: code: 204 message: No Content - url: https://communication42hz4pfbosr.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 + url: https://communicationjr4rcjud6dy.communication.azure.com/identities/sanitized?api-version=2021-03-07 version: 1 diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_delete_user_from_managed_identity.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_delete_user_from_managed_identity.yaml index 61f0f792823b..9e48141e976d 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_delete_user_from_managed_identity.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_delete_user_from_managed_identity.yaml @@ -1,46 +1,52 @@ interactions: - request: - body: null + body: '{}' headers: Accept: - application/json + Content-Length: + - '2' + Content-Type: + - application/json User-Agent: - - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2021-03-07 response: body: - string: '{"id": "sanitized"}' + string: '{"identity": {"id": "8:acs:a24497f3-efec-4740-a3b5-1fa011bcf80c_00000007-e632-7b36-6032-3b3a0d009e24"}}' headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + api-supported-versions: 2020-07-20-preview2, 2021-03-07 content-type: application/json; charset=utf-8 - date: Tue, 22 Dec 2020 18:52:27 GMT - ms-cv: ww9tz7CpG0SXqqYPyV70Cw.0 + date: Thu, 28 Jan 2021 00:07:18 GMT + ms-cv: S8lcY4P4/0ufU/ttufqb9A.0 strict-transport-security: max-age=2592000 transfer-encoding: chunked - x-processing-time: 192ms + x-processing-time: 223ms status: - code: 200 - message: OK - url: https://communicationrscjfarclwr.communication.azure.com/identities?api-version=2020-07-20-preview2 + code: 201 + message: Created + url: https://communicationmp7h7ovhgeo.communication.azure.com/identities?api-version=2021-03-07 - request: body: null headers: + Accept: + - application/json User-Agent: - - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) method: DELETE - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2021-03-07 response: body: string: '' headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - date: Tue, 22 Dec 2020 18:52:28 GMT - ms-cv: baDrTbu3H0qpWj2TJSno0A.0 + api-supported-versions: 2020-07-20-preview2, 2021-03-07 + date: Thu, 28 Jan 2021 00:07:19 GMT + ms-cv: kATCJqiKOUCRhfHBvexmcA.0 strict-transport-security: max-age=2592000 - x-processing-time: 864ms + x-processing-time: 432ms status: code: 204 message: No Content - url: https://communicationrscjfarclwr.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 + url: https://communicationmp7h7ovhgeo.communication.azure.com/identities/sanitized?api-version=2021-03-07 version: 1 diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_issue_token.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_issue_token.yaml index 3f080a769093..0c17f57a3b1b 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_issue_token.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_issue_token.yaml @@ -1,32 +1,36 @@ interactions: - request: - body: '' + body: '{}' headers: Accept: - application/json + Content-Length: + - '2' + Content-Type: + - application/json Date: - - Tue, 22 Dec 2020 18:53:37 GMT + - Thu, 28 Jan 2021 00:08:25 GMT User-Agent: - - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) x-ms-return-client-request-id: - 'true' method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2021-03-07 response: body: - string: '{"id": "sanitized"}' + string: '{"identity": {"id": "8:acs:26a61a0d-7568-4668-b4af-a50d5e31a3c2_00000007-e633-80ba-8337-3b3a0d00957f"}}' headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + api-supported-versions: 2020-07-20-preview2, 2021-03-07 content-type: application/json; charset=utf-8 - date: Tue, 22 Dec 2020 18:53:36 GMT - ms-cv: Agl32miSq0CTEladXG7lbw.0 + date: Thu, 28 Jan 2021 00:08:25 GMT + ms-cv: bgD+YH+iyUq2DCmb3A8xpA.0 strict-transport-security: max-age=2592000 transfer-encoding: chunked - x-processing-time: 20ms + x-processing-time: 18ms status: - code: 200 - message: OK - url: https://communicatione77tfh7y2ht.communication.azure.com/identities?api-version=2020-07-20-preview2 + code: 201 + message: Created + url: https://communicationc76ebhgedjy.communication.azure.com/identities?api-version=2021-03-07 - request: body: '{"scopes": ["chat"]}' headers: @@ -37,26 +41,26 @@ interactions: Content-Type: - application/json Date: - - Tue, 22 Dec 2020 18:53:38 GMT + - Thu, 28 Jan 2021 00:08:25 GMT User-Agent: - - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) x-ms-return-client-request-id: - 'true' method: POST - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/:issueAccessToken?api-version=2021-03-07 response: body: - string: '{"id": "sanitized", "token": "sanitized", "expiresOn": "2020-12-23T18:53:35.7585148+00:00"}' + string: '{"token": "sanitized", "expiresOn": "2021-01-29T00:08:25.6307952+00:00"}' headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + api-supported-versions: 2020-07-20-preview2, 2021-03-07 content-type: application/json; charset=utf-8 - date: Tue, 22 Dec 2020 18:53:36 GMT - ms-cv: P3rSrWhwykmJcOW+Yb8Q2w.0 + date: Thu, 28 Jan 2021 00:08:25 GMT + ms-cv: zvXlhCo5B0q+t7sBNEliuQ.0 strict-transport-security: max-age=2592000 transfer-encoding: chunked - x-processing-time: 26ms + x-processing-time: 271ms status: code: 200 message: OK - url: https://communicatione77tfh7y2ht.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 + url: https://communicationc76ebhgedjy.communication.azure.com/identities/sanitized/:issueAccessToken?api-version=2021-03-07 version: 1 diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_issue_token_from_managed_identity.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_issue_token_from_managed_identity.yaml index 1bb9bfee6b30..f7ce02fdc730 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_issue_token_from_managed_identity.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_issue_token_from_managed_identity.yaml @@ -1,28 +1,32 @@ interactions: - request: - body: null + body: '{}' headers: Accept: - application/json + Content-Length: + - '2' + Content-Type: + - application/json User-Agent: - - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2021-03-07 response: body: - string: '{"id": "sanitized"}' + string: '{"identity": {"id": "8:acs:eb4d4339-97ec-4d4d-838f-3535e5be22fb_00000007-e634-8c53-1000-343a0d00b05d"}}' headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + api-supported-versions: 2020-07-20-preview2, 2021-03-07 content-type: application/json; charset=utf-8 - date: Tue, 22 Dec 2020 18:54:45 GMT - ms-cv: UywF8dbxrkyYXGTozRnuIw.0 + date: Thu, 28 Jan 2021 00:09:33 GMT + ms-cv: aYXgrkUYzkCqrvW6aCFoJg.0 strict-transport-security: max-age=2592000 transfer-encoding: chunked - x-processing-time: 773ms + x-processing-time: 203ms status: - code: 200 - message: OK - url: https://communicationztg2acjbipc.communication.azure.com/identities?api-version=2020-07-20-preview2 + code: 201 + message: Created + url: https://communicationbro23o5lt3y.communication.azure.com/identities?api-version=2021-03-07 - request: body: '{"scopes": ["chat"]}' headers: @@ -33,22 +37,22 @@ interactions: Content-Type: - application/json User-Agent: - - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) method: POST - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/:issueAccessToken?api-version=2021-03-07 response: body: - string: '{"id": "sanitized", "token": "sanitized", "expiresOn": "2020-12-23T18:54:45.1115885+00:00"}' + string: '{"token": "sanitized", "expiresOn": "2021-01-29T00:09:34.3804866+00:00"}' headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + api-supported-versions: 2020-07-20-preview2, 2021-03-07 content-type: application/json; charset=utf-8 - date: Tue, 22 Dec 2020 18:54:45 GMT - ms-cv: ywaIOOtf9EiQs6pibQmCwg.0 + date: Thu, 28 Jan 2021 00:09:34 GMT + ms-cv: 1xmX6Mokj06NM2PVg6ZuqQ.0 strict-transport-security: max-age=2592000 transfer-encoding: chunked - x-processing-time: 25ms + x-processing-time: 522ms status: code: 200 message: OK - url: https://communicationztg2acjbipc.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 + url: https://communicationbro23o5lt3y.communication.azure.com/identities/sanitized/:issueAccessToken?api-version=2021-03-07 version: 1 diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_revoke_tokens.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_revoke_tokens.yaml index 65852601867e..a75ac24c472c 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_revoke_tokens.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_revoke_tokens.yaml @@ -1,32 +1,36 @@ interactions: - request: - body: '' + body: '{}' headers: Accept: - application/json + Content-Length: + - '2' + Content-Type: + - application/json Date: - - Tue, 22 Dec 2020 18:55:56 GMT + - Thu, 28 Jan 2021 00:10:41 GMT User-Agent: - - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) x-ms-return-client-request-id: - 'true' method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2021-03-07 response: body: - string: '{"id": "sanitized"}' + string: '{"identity": {"id": "8:acs:dfd067fd-fca6-4b13-ab29-9942ccef42de_00000007-e635-948a-0338-3b3a0d00a0b2"}}' headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + api-supported-versions: 2020-07-20-preview2, 2021-03-07 content-type: application/json; charset=utf-8 - date: Tue, 22 Dec 2020 18:55:55 GMT - ms-cv: M9b8kGAz8UGwsoZe2mFLCA.0 + date: Thu, 28 Jan 2021 00:10:42 GMT + ms-cv: MQOB7hTyHUWG20LRH6jl4A.0 strict-transport-security: max-age=2592000 transfer-encoding: chunked - x-processing-time: 29ms + x-processing-time: 19ms status: - code: 200 - message: OK - url: https://communicationngn6p2kywhg.communication.azure.com/identities?api-version=2020-07-20-preview2 + code: 201 + message: Created + url: https://communication2rjlrpnsekt.communication.azure.com/identities?api-version=2021-03-07 - request: body: '{"scopes": ["chat"]}' headers: @@ -37,54 +41,52 @@ interactions: Content-Type: - application/json Date: - - Tue, 22 Dec 2020 18:55:57 GMT + - Thu, 28 Jan 2021 00:10:41 GMT User-Agent: - - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) x-ms-return-client-request-id: - 'true' method: POST - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/:issueAccessToken?api-version=2021-03-07 response: body: - string: '{"id": "sanitized", "token": "sanitized", "expiresOn": "2020-12-23T18:55:54.788117+00:00"}' + string: '{"token": "sanitized", "expiresOn": "2021-01-29T00:10:41.2727745+00:00"}' headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + api-supported-versions: 2020-07-20-preview2, 2021-03-07 content-type: application/json; charset=utf-8 - date: Tue, 22 Dec 2020 18:55:55 GMT - ms-cv: MBCUlMoRBECvCLmV00eWXw.0 + date: Thu, 28 Jan 2021 00:10:42 GMT + ms-cv: ewu+XAda5EKtcLG/IUVAqg.0 strict-transport-security: max-age=2592000 transfer-encoding: chunked - x-processing-time: 27ms + x-processing-time: 34ms status: code: 200 message: OK - url: https://communicationngn6p2kywhg.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 + url: https://communication2rjlrpnsekt.communication.azure.com/identities/sanitized/:issueAccessToken?api-version=2021-03-07 - request: - body: '{}' + body: '' headers: - Content-Length: - - '2' - Content-Type: - - application/merge-patch+json + Accept: + - application/json Date: - - Tue, 22 Dec 2020 18:55:57 GMT + - Thu, 28 Jan 2021 00:10:41 GMT User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) x-ms-return-client-request-id: - 'true' - method: PATCH - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 + method: POST + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/:revokeAccessTokens?api-version=2021-03-07 response: body: string: '' headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - date: Tue, 22 Dec 2020 18:55:55 GMT - ms-cv: MVgoSrOVSkiU0c+teqMDZQ.0 + api-supported-versions: 2020-07-20-preview2, 2021-03-07 + date: Thu, 28 Jan 2021 00:10:42 GMT + ms-cv: 73SrLh8Gu0qRA7HwJHhzPA.0 strict-transport-security: max-age=2592000 - x-processing-time: 10ms + x-processing-time: 326ms status: code: 204 message: No Content - url: https://communicationngn6p2kywhg.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 + url: https://communication2rjlrpnsekt.communication.azure.com/identities/sanitized/:revokeAccessTokens?api-version=2021-03-07 version: 1 diff --git a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_revoke_tokens_from_managed_identity.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_revoke_tokens_from_managed_identity.yaml index 75a1a9851624..a2e7c57b3452 100644 --- a/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_revoke_tokens_from_managed_identity.yaml +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_revoke_tokens_from_managed_identity.yaml @@ -1,28 +1,32 @@ interactions: - request: - body: null + body: '{}' headers: Accept: - application/json + Content-Length: + - '2' + Content-Type: + - application/json User-Agent: - - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) method: POST - uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2020-07-20-preview2 + uri: https://communicationegrcrs.communication.azure.com/identities?api-version=2021-03-07 response: body: - string: '{"id": "sanitized"}' + string: '{"identity": {"id": "8:acs:27e29eed-ad97-4eb3-a1ce-754ac5f661e3_00000007-e636-9f5d-a1ab-1d3a0d002d81"}}' headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + api-supported-versions: 2020-07-20-preview2, 2021-03-07 content-type: application/json; charset=utf-8 - date: Tue, 22 Dec 2020 18:57:03 GMT - ms-cv: a9v8/cRgN0uyuQQUguwkGA.0 + date: Thu, 28 Jan 2021 00:11:49 GMT + ms-cv: ai+7GFVaeEKhVOAHICW3uw.0 strict-transport-security: max-age=2592000 transfer-encoding: chunked - x-processing-time: 195ms + x-processing-time: 498ms status: - code: 200 - message: OK - url: https://communicationxheui257vce.communication.azure.com/identities?api-version=2020-07-20-preview2 + code: 201 + message: Created + url: https://communicationrfbn6jmio5t.communication.azure.com/identities?api-version=2021-03-07 - request: body: '{"scopes": ["chat"]}' headers: @@ -33,46 +37,44 @@ interactions: Content-Type: - application/json User-Agent: - - azsdk-python-communication-identity/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) method: POST - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/:issueAccessToken?api-version=2021-03-07 response: body: - string: '{"id": "sanitized", "token": "sanitized", "expiresOn": "2020-12-23T18:57:03.4428768+00:00"}' + string: '{"token": "sanitized", "expiresOn": "2021-01-29T00:11:49.9423938+00:00"}' headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 + api-supported-versions: 2020-07-20-preview2, 2021-03-07 content-type: application/json; charset=utf-8 - date: Tue, 22 Dec 2020 18:57:03 GMT - ms-cv: Oc9n/N0oA0mLVBlk8UaTpw.0 + date: Thu, 28 Jan 2021 00:11:50 GMT + ms-cv: V32cSH7R6k+Js2HFOK2/0g.0 strict-transport-security: max-age=2592000 transfer-encoding: chunked - x-processing-time: 24ms + x-processing-time: 277ms status: code: 200 message: OK - url: https://communicationxheui257vce.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 + url: https://communicationrfbn6jmio5t.communication.azure.com/identities/sanitized/:issueAccessToken?api-version=2021-03-07 - request: - body: '{}' + body: null headers: - Content-Length: - - '2' - Content-Type: - - application/merge-patch+json + Accept: + - application/json User-Agent: - - azsdk-python-communication-administration/1.0.0b4 Python/3.8.5 (Windows-10-10.0.19041-SP0) - method: PATCH - uri: https://communicationegrcrs.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 + - azsdk-python-communication-identity/1.0.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://communicationegrcrs.communication.azure.com/identities/sanitized/:revokeAccessTokens?api-version=2021-03-07 response: body: string: '' headers: - api-supported-versions: 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2 - date: Tue, 22 Dec 2020 18:57:03 GMT - ms-cv: lBOoIDU5lUe2vbpjz5+Gkg.0 + api-supported-versions: 2020-07-20-preview2, 2021-03-07 + date: Thu, 28 Jan 2021 00:11:50 GMT + ms-cv: 9cuEcfUT3EG/iFHPRteC3Q.0 strict-transport-security: max-age=2592000 - x-processing-time: 11ms + x-processing-time: 412ms status: code: 204 message: No Content - url: https://communicationxheui257vce.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 + url: https://communicationrfbn6jmio5t.communication.azure.com/identities/sanitized/:revokeAccessTokens?api-version=2021-03-07 version: 1