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/__init__ .py b/sdk/communication/azure-communication-identity/azure/communication/identity/__init__.py similarity index 84% 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..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,10 +11,16 @@ CommunicationIdentityToken ) +from ._shared.models import CommunicationUserIdentifier + + __all__ = [ 'CommunicationIdentityClient', # from _identity 'CommunicationTokenRequest', 'CommunicationIdentityToken', + + # from _shared + 'CommunicationUserIdentifier' ] \ 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 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/_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/_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/azure/communication/identity/aio/_version.py b/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_version.py deleted file mode 100644 index a01196623d45..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-administration/{}".format(VERSION) # type: str 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 +```