diff --git a/sdk/communication/azure-communication-identity/CHANGELOG.md b/sdk/communication/azure-communication-identity/CHANGELOG.md index 28774e65f045..cbe5dc3d14b3 100644 --- a/sdk/communication/azure-communication-identity/CHANGELOG.md +++ b/sdk/communication/azure-communication-identity/CHANGELOG.md @@ -4,6 +4,11 @@ ### Added - Added CommunicationIdentityClient (originally was part of the azure.communication.administration package). +- Added ability to create a user and issue token for it at the same time. + +### Breaking +- CommunicationIdentityClient.revoke_tokens now revoke all the currently issued tokens instead of revoking tokens issued prior to a given time. +- CommunicationIdentityClient.issue_tokens returns an instance of `azure.core.credentials.AccessToken` instead of `CommunicationUserToken`. [read_me]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/communication/azure-communication-identity/README.md diff --git a/sdk/communication/azure-communication-identity/README.md b/sdk/communication/azure-communication-identity/README.md index bce44c94e482..e1193e980f06 100644 --- a/sdk/communication/azure-communication-identity/README.md +++ b/sdk/communication/azure-communication-identity/README.md @@ -36,19 +36,58 @@ 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()) +identity_client_managed_identity = CommunicationIdentityClient(endpoint, DefaultAzureCredential()) #You can also authenticate using your connection string identity_client = CommunicationIdentityClient.from_connection_string(connection_str) ``` -# Examples +## 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] +### Creating a new user -[Create/revoke scoped user access tokens][identitysamples] +Use the `create_user` method to create a new user. +```python +user = identity_client.create_user() +print("User created with id:" + user.identifier) +``` + +Alternatively, use the `create_user_with_token` method to create a new user and issue a token for it.\ +For this option, a list of `CommunicationTokenScope` must be defined (see "Issuing an access token" for more information) + +```python +user, tokenresponse = identity_client.create_user_with_token(scopes=[CommunicationTokenScope.CHAT]) +print("User id:" + user.identifier) +print("Token issued with value: " + tokenresponse.token) +``` + +### Issuing or Refreshing an access token for a user + +Use the `issue_token` method to issue or refresh a scoped access token for the user. \ +Pass in the user object as a parameter, and a list of `CommunicationTokenScope`. Scope options are: +- `CHAT` (Chat) +- `VOIP` (VoIP) + +```python +tokenresponse = identity_client.issue_token(user, scopes=[CommunicationTokenScope.CHAT]) +print("Token issued with value: " + tokenresponse.token) +``` + +### Revoking a user's access tokens + +Use `revoke_tokens` to revoke all access tokens for a user. Pass in the user object as a parameter +```python +identity_client.revoke_tokens(user) +``` + +### Deleting a user + +Use the `delete_user` method to delete a user. Pass in the user object as a parameter +```python +identity_client.delete_user(user) +``` # Troubleshooting The Azure Communication Service Identity client will raise exceptions defined in [Azure Core][azure_core]. @@ -73,5 +112,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-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/azure/communication/identity/__init__.py b/sdk/communication/azure-communication-identity/azure/communication/identity/__init__.py index 77579e0b4d62..1921a8e3e522 100644 --- a/sdk/communication/azure-communication-identity/azure/communication/identity/__init__.py +++ b/sdk/communication/azure-communication-identity/azure/communication/identity/__init__.py @@ -7,19 +7,16 @@ from ._communication_identity_client import CommunicationIdentityClient from ._generated.models import ( - CommunicationTokenRequest, - CommunicationIdentityToken + CommunicationTokenScope ) from ._shared.models import CommunicationUserIdentifier - __all__ = [ 'CommunicationIdentityClient', # from _identity - 'CommunicationTokenRequest', - 'CommunicationIdentityToken', + 'CommunicationTokenScope', # 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..595762303739 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 @@ -5,10 +5,10 @@ # ------------------------------------ from azure.core.tracing.decorator import distributed_trace +from azure.core.credentials import AccessToken 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 @@ -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,11 +82,32 @@ 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), + cls=lambda pr, u, e: CommunicationUserIdentifier(u.identity.id), + **kwargs) + + @distributed_trace + def create_user_with_token( + self, + scopes, # type: List[Union[str, "_model.CommunicationTokenScope"]] + **kwargs # type: Any + ): + # type: (...) -> Tuple[CommunicationUserIdentifier, AccessToken] + """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 tuple of a CommunicationUserIdentifier and a AccessToken. + :rtype: + tuple of (~azure.communication.identity.CommunicationUserIdentifier, ~azure.core.credentials.AccessToken) + """ + return self._identity_service_client.communication_identity.create( + cls=lambda pr, u, e: (CommunicationUserIdentifier(u.identity.id), + AccessToken(u.access_token.token, u.access_token.expires_on)), + create_token_with_scopes=scopes, **kwargs) @distributed_trace @@ -111,30 +132,30 @@ 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: (...) -> AccessToken """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: AccessToken + :rtype: ~azure.core.credentials.AccessToken """ - return self._identity_service_client.communication_identity.issue_token( + return self._identity_service_client.communication_identity.issue_access_token( user.identifier, scopes, + cls=lambda pr, u, e: AccessToken(u.token, u.expires_on), **kwargs) @distributed_trace def revoke_tokens( self, user, # type: CommunicationUserIdentifier - issued_before=None, # type: Optional[datetime.datetime] **kwargs # type: Any ): # type: (...) -> None @@ -142,12 +163,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) 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..4e970ee1869a 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 """ @@ -41,6 +41,7 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) self.communication_identity = CommunicationIdentityOperations( 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..99c76d0c7fc7 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 """ @@ -36,6 +36,7 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) self.communication_identity = CommunicationIdentityOperations( 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..804305f349e2 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 @@ -42,23 +41,29 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def create( 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 @@ -74,17 +79,25 @@ 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 - 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.failsafe_deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) - deserialized = self._deserialize('CommunicationIdentity', pipeline_response) + deserialized = self._deserialize('CommunicationIdentityAccessTokenResult', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -97,9 +110,9 @@ async def delete( 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,7 +126,8 @@ 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" + accept = "application/json" # Construct URL url = self.delete.metadata['url'] # type: ignore @@ -129,6 +143,7 @@ async def delete( # 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) @@ -136,27 +151,25 @@ async def delete( 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.failsafe_deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) if cls: return cls(pipeline_response, None, {}) delete.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 +180,11 @@ 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" + accept = "application/json" # 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,56 +197,54 @@ async def update( # 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, '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 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.failsafe_deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) 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.CommunicationIdentityAccessToken": + """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: CommunicationIdentityAccessToken, or the result of cls(response) + :rtype: ~azure.communication.identity.models.CommunicationIdentityAccessToken :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunicationIdentityToken"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunicationIdentityAccessToken"] 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 +261,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) @@ -260,12 +269,13 @@ async def issue_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.failsafe_deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) - deserialized = self._deserialize('CommunicationIdentityToken', pipeline_response) + deserialized = self._deserialize('CommunicationIdentityAccessToken', 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..c5df5a066788 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,19 +7,33 @@ # -------------------------------------------------------------------------- try: + from ._models_py3 import CommunicationError + from ._models_py3 import CommunicationErrorResponse from ._models_py3 import CommunicationIdentity - from ._models_py3 import CommunicationIdentityToken - from ._models_py3 import CommunicationIdentityUpdateRequest - from ._models_py3 import CommunicationTokenRequest + from ._models_py3 import CommunicationIdentityAccessToken + from ._models_py3 import CommunicationIdentityAccessTokenRequest + from ._models_py3 import CommunicationIdentityAccessTokenResult + from ._models_py3 import CommunicationIdentityCreateRequest except (SyntaxError, ImportError): + from ._models import CommunicationError # type: ignore + from ._models import CommunicationErrorResponse # type: ignore 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 CommunicationIdentityAccessToken # type: ignore + from ._models import CommunicationIdentityAccessTokenRequest # type: ignore + from ._models import CommunicationIdentityAccessTokenResult # type: ignore + from ._models import CommunicationIdentityCreateRequest # type: ignore + +from ._communication_identity_client_enums import ( + CommunicationTokenScope, +) __all__ = [ + 'CommunicationError', + 'CommunicationErrorResponse', 'CommunicationIdentity', - 'CommunicationIdentityToken', - 'CommunicationIdentityUpdateRequest', - 'CommunicationTokenRequest', + 'CommunicationIdentityAccessToken', + 'CommunicationIdentityAccessTokenRequest', + 'CommunicationIdentityAccessTokenResult', + 'CommunicationIdentityCreateRequest', + '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..b69cad65181d 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. @@ -34,27 +106,23 @@ def __init__( self.id = kwargs['id'] -class CommunicationIdentityToken(msrest.serialization.Model): - """CommunicationIdentityToken. +class CommunicationIdentityAccessToken(msrest.serialization.Model): + """An access token. 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. + :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 = { - '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'}, } @@ -63,51 +131,80 @@ def __init__( self, **kwargs ): - super(CommunicationIdentityToken, self).__init__(**kwargs) - self.id = kwargs['id'] + super(CommunicationIdentityAccessToken, self).__init__(**kwargs) self.token = kwargs['token'] self.expires_on = kwargs['expires_on'] -class CommunicationIdentityUpdateRequest(msrest.serialization.Model): - """CommunicationIdentityUpdateRequest. +class CommunicationIdentityAccessTokenRequest(msrest.serialization.Model): + """CommunicationIdentityAccessTokenRequest. + + 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 scopes: Required. List of scopes attached to the token. + :type scopes: list[str or ~azure.communication.identity.models.CommunicationTokenScope] """ + _validation = { + 'scopes': {'required': True}, + } + _attribute_map = { - 'tokens_valid_from': {'key': 'tokensValidFrom', 'type': 'iso-8601'}, + 'scopes': {'key': 'scopes', 'type': '[str]'}, } def __init__( self, **kwargs ): - super(CommunicationIdentityUpdateRequest, self).__init__(**kwargs) - self.tokens_valid_from = kwargs.get('tokens_valid_from', None) + super(CommunicationIdentityAccessTokenRequest, self).__init__(**kwargs) + self.scopes = kwargs['scopes'] -class CommunicationTokenRequest(msrest.serialization.Model): - """CommunicationTokenRequest. +class CommunicationIdentityAccessTokenResult(msrest.serialization.Model): + """A communication identity with 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 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.CommunicationIdentityAccessToken """ _validation = { - 'scopes': {'required': True}, + 'identity': {'required': True}, } _attribute_map = { - 'scopes': {'key': 'scopes', 'type': '[str]'}, + 'identity': {'key': 'identity', 'type': 'CommunicationIdentity'}, + 'access_token': {'key': 'accessToken', 'type': 'CommunicationIdentityAccessToken'}, } def __init__( self, **kwargs ): - super(CommunicationTokenRequest, self).__init__(**kwargs) - self.scopes = kwargs['scopes'] + super(CommunicationIdentityAccessTokenResult, self).__init__(**kwargs) + self.identity = kwargs['identity'] + self.access_token = kwargs.get('access_token', None) + + +class CommunicationIdentityCreateRequest(msrest.serialization.Model): + """CommunicationIdentityCreateRequest. + + :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) 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..6cd91adc9de6 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,11 +7,89 @@ # -------------------------------------------------------------------------- import datetime -from typing import List, Optional +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. @@ -39,27 +117,23 @@ def __init__( self.id = id -class CommunicationIdentityToken(msrest.serialization.Model): - """CommunicationIdentityToken. +class CommunicationIdentityAccessToken(msrest.serialization.Model): + """An access token. 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. + :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 = { - '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'}, } @@ -67,60 +141,91 @@ class CommunicationIdentityToken(msrest.serialization.Model): def __init__( self, *, - id: str, token: str, expires_on: datetime.datetime, **kwargs ): - super(CommunicationIdentityToken, self).__init__(**kwargs) - self.id = id + super(CommunicationIdentityAccessToken, self).__init__(**kwargs) self.token = token self.expires_on = expires_on -class CommunicationIdentityUpdateRequest(msrest.serialization.Model): - """CommunicationIdentityUpdateRequest. +class CommunicationIdentityAccessTokenRequest(msrest.serialization.Model): + """CommunicationIdentityAccessTokenRequest. - :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 scopes: Required. List of scopes attached to the token. + :type scopes: list[str or ~azure.communication.identity.models.CommunicationTokenScope] """ + _validation = { + 'scopes': {'required': True}, + } + _attribute_map = { - 'tokens_valid_from': {'key': 'tokensValidFrom', 'type': 'iso-8601'}, + 'scopes': {'key': 'scopes', 'type': '[str]'}, } def __init__( self, *, - tokens_valid_from: Optional[datetime.datetime] = None, + scopes: List[Union[str, "CommunicationTokenScope"]], **kwargs ): - super(CommunicationIdentityUpdateRequest, self).__init__(**kwargs) - self.tokens_valid_from = tokens_valid_from + super(CommunicationIdentityAccessTokenRequest, self).__init__(**kwargs) + self.scopes = scopes -class CommunicationTokenRequest(msrest.serialization.Model): - """CommunicationTokenRequest. +class CommunicationIdentityAccessTokenResult(msrest.serialization.Model): + """A communication identity with 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 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.CommunicationIdentityAccessToken """ _validation = { - 'scopes': {'required': True}, + 'identity': {'required': True}, } _attribute_map = { - 'scopes': {'key': 'scopes', 'type': '[str]'}, + 'identity': {'key': 'identity', 'type': 'CommunicationIdentity'}, + 'access_token': {'key': 'accessToken', 'type': 'CommunicationIdentityAccessToken'}, } def __init__( self, *, - scopes: List[str], + identity: "CommunicationIdentity", + access_token: Optional["CommunicationIdentityAccessToken"] = None, **kwargs ): - super(CommunicationTokenRequest, self).__init__(**kwargs) - self.scopes = scopes + super(CommunicationIdentityAccessTokenResult, self).__init__(**kwargs) + self.identity = identity + self.access_token = access_token + + +class CommunicationIdentityCreateRequest(msrest.serialization.Model): + """CommunicationIdentityCreateRequest. + + :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 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..507b932cb689 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]] @@ -46,24 +45,30 @@ def __init__(self, client, config, serializer, deserializer): def create( 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 @@ -79,17 +84,25 @@ 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 - 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.failsafe_deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) - deserialized = self._deserialize('CommunicationIdentity', pipeline_response) + deserialized = self._deserialize('CommunicationIdentityAccessTokenResult', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -103,9 +116,9 @@ def delete( **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,7 +132,8 @@ 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" + accept = "application/json" # Construct URL url = self.delete.metadata['url'] # type: ignore @@ -135,6 +149,7 @@ def delete( # 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) @@ -142,28 +157,26 @@ def delete( 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.failsafe_deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) if cls: return cls(pipeline_response, None, {}) delete.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 +187,11 @@ 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" + accept = "application/json" # 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,57 +204,55 @@ def update( # 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, '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 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.failsafe_deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) 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.CommunicationIdentityAccessToken" + """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: CommunicationIdentityAccessToken, or the result of cls(response) + :rtype: ~azure.communication.identity.models.CommunicationIdentityAccessToken :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunicationIdentityToken"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunicationIdentityAccessToken"] 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 +269,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) @@ -268,12 +277,13 @@ def issue_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.failsafe_deserialize(_models.CommunicationErrorResponse, response) + raise HttpResponseError(response=response, model=error) - deserialized = self._deserialize('CommunicationIdentityToken', pipeline_response) + deserialized = self._deserialize('CommunicationIdentityAccessToken', 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/aio/_communication_identity_client_async.py b/sdk/communication/azure-communication-identity/azure/communication/identity/aio/_communication_identity_client_async.py index 44cdf5a65e5f..c75d6d937c1a 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 @@ -5,11 +5,10 @@ # ------------------------------------ from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.credentials import AccessToken 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 @@ -64,7 +63,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,11 +83,32 @@ 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.identity.id), + **kwargs) + + @distributed_trace_async + async def create_user_with_token( + self, + scopes, # type: List[Union[str, "_model.CommunicationTokenScope"]] + **kwargs # type: Any + ): + # type: (...) -> Tuple[CommunicationUserIdentifier, AccessToken] + """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 tuple of a CommunicationUserIdentifier and a AccessToken. + :rtype: + tuple of (~azure.communication.identity.CommunicationUserIdentifier, ~azure.core.credentials.AccessToken) """ return await self._identity_service_client.communication_identity.create( - cls=lambda pr, u, e: CommunicationUserIdentifier(u.id), + create_token_with_scopes=scopes, + cls=lambda pr, u, e: (CommunicationUserIdentifier(u.identity.id), + AccessToken(u.access_token.token, u.access_token.expires_on)), **kwargs) @distributed_trace_async @@ -113,30 +133,30 @@ 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: (...) -> AccessToken """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: AccessToken + :rtype: ~azure.core.credentials.AccessToken """ - return await self._identity_service_client.communication_identity.issue_token( + return await self._identity_service_client.communication_identity.issue_access_token( user.identifier, scopes, + cls=lambda pr, u, e: AccessToken(u.token, u.expires_on), **kwargs) @distributed_trace_async async def revoke_tokens( self, user, # type: CommunicationUserIdentifier - issued_before=None, # type: Optional[datetime.datetime] **kwargs # type: Any ): # type: (...) -> None @@ -144,14 +164,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 +180,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__() diff --git a/sdk/communication/azure-communication-identity/samples/identity_samples.py b/sdk/communication/azure-communication-identity/samples/identity_samples.py index cf28e9fe18e8..5279fbdecf09 100644 --- a/sdk/communication/azure-communication-identity/samples/identity_samples.py +++ b/sdk/communication/azure-communication-identity/samples/identity_samples.py @@ -9,11 +9,13 @@ """ FILE: identity_sample.py DESCRIPTION: - These samples demonstrate identity client samples. + These samples demonstrate creating a user, issuing a token, revoking a token and deleting a user. ///authenticating a client via a connection string USAGE: python identity_samples.py + Set the environment variables with your own values before running the sample: + 1) AZURE_COMMUNICATION_SERVICE_ENDPOINT - Communication Service endpoint url """ import os @@ -24,10 +26,13 @@ def __init__(self): 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') + self.tenant_id = os.getenv('AZURE_TENANT_ID') def issue_token(self): - from azure.communication.identity import CommunicationIdentityClient + from azure.communication.identity import ( + CommunicationIdentityClient, + CommunicationTokenScope + ) 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 @@ -35,11 +40,15 @@ def issue_token(self): 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) - + print("Issuing token for: " + user.identifier) + tokenresponse = identity_client.issue_token(user, scopes=[CommunicationTokenScope.CHAT]) + print("Token issued with value: " + tokenresponse.token) + def revoke_tokens(self): - from azure.communication.identity import CommunicationIdentityClient + from azure.communication.identity import ( + CommunicationIdentityClient, + CommunicationTokenScope + ) 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 @@ -47,9 +56,10 @@ def revoke_tokens(self): else: identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) user = identity_client.create_user() - tokenresponse = identity_client.issue_token(user, scopes=["chat"]) + tokenresponse = identity_client.issue_token(user, scopes=[CommunicationTokenScope.CHAT]) + print("Revoking token: " + tokenresponse.token) identity_client.revoke_tokens(user) - print(tokenresponse) + print(tokenresponse.token + " revoked successfully") def create_user(self): from azure.communication.identity import CommunicationIdentityClient @@ -59,9 +69,25 @@ def create_user(self): identity_client = CommunicationIdentityClient(self.endpoint, DefaultAzureCredential()) else: identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) + print("Creating new user") user = identity_client.create_user() - print(user.identifier) - + print("User created with id:" + user.identifier) + + def create_user_with_token(self): + from azure.communication.identity import ( + CommunicationIdentityClient, + CommunicationTokenScope + ) + 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) + print("Creating new user with token") + user, tokenresponse = identity_client.create_user_with_token(scopes=[CommunicationTokenScope.CHAT]) + print("User created with id:" + user.identifier) + print("Token issued with value: " + tokenresponse.token) + def delete_user(self): from azure.communication.identity import CommunicationIdentityClient @@ -71,11 +97,14 @@ def delete_user(self): else: identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) user = identity_client.create_user() + print("Deleting user: " + user.identifier) identity_client.delete_user(user) + print(user.identifier + " deleted") if __name__ == '__main__': sample = CommunicationIdentityClientSamples() sample.create_user() - sample.delete_user() + sample.create_user_with_token() sample.issue_token() sample.revoke_tokens() + sample.delete_user() diff --git a/sdk/communication/azure-communication-identity/samples/identity_samples_async.py b/sdk/communication/azure-communication-identity/samples/identity_samples_async.py index 2b2b8e17b992..9bf2561b9a29 100644 --- a/sdk/communication/azure-communication-identity/samples/identity_samples_async.py +++ b/sdk/communication/azure-communication-identity/samples/identity_samples_async.py @@ -9,11 +9,13 @@ """ FILE: identity_sample_async.py DESCRIPTION: - These samples demonstrate async identity client samples. + These async samples demonstrate creating a user, issuing a token, revoking a token and deleting a user. ///authenticating a client via a connection string USAGE: python identity_samples_async.py + Set the environment variables with your own values before running the sample: + 1) AZURE_COMMUNICATION_SERVICE_ENDPOINT - Communication Service endpoint url """ import asyncio @@ -27,10 +29,11 @@ def __init__(self): 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') + self.tenant_id = os.getenv('AZURE_TENANT_ID') async def issue_token(self): from azure.communication.identity.aio import CommunicationIdentityClient + from azure.communication.identity import CommunicationTokenScope 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()) @@ -39,12 +42,13 @@ async def issue_token(self): async with identity_client: user = await identity_client.create_user() - print(user.identifier) - tokenresponse = await identity_client.issue_token(user, scopes=["chat"]) - print(tokenresponse) - + print("Issuing token for: " + user.identifier) + tokenresponse = await identity_client.issue_token(user, scopes=[CommunicationTokenScope.CHAT]) + print("Token issued with value: " + tokenresponse.token) + async def revoke_tokens(self): from azure.communication.identity.aio import CommunicationIdentityClient + from azure.communication.identity import CommunicationTokenScope 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()) @@ -53,9 +57,10 @@ async def revoke_tokens(self): async with identity_client: user = await identity_client.create_user() - tokenresponse = await identity_client.issue_token(user, scopes=["chat"]) + tokenresponse = await identity_client.issue_token(user, scopes=[CommunicationTokenScope.CHAT]) + print("Revoking token: " + tokenresponse.token) await identity_client.revoke_tokens(user) - print(tokenresponse) + print(tokenresponse.token + " revoked successfully") async def create_user(self): from azure.communication.identity.aio import CommunicationIdentityClient @@ -66,8 +71,24 @@ async def create_user(self): identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) async with identity_client: + print("Creating new user") user = await identity_client.create_user() - print(user.identifier) + print("User created with id:" + user.identifier) + + async def create_user_with_token(self): + from azure.communication.identity.aio import CommunicationIdentityClient + from azure.communication.identity import CommunicationTokenScope + 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: + print("Creating new user with token") + user, tokenresponse = await identity_client.create_user_with_token(scopes=[CommunicationTokenScope.CHAT]) + print("User created with id:" + user.identifier) + print("Token issued with value: " + tokenresponse.token) async def delete_user(self): from azure.communication.identity.aio import CommunicationIdentityClient @@ -79,14 +100,17 @@ async def delete_user(self): async with identity_client: user = await identity_client.create_user() + print("Deleting user: " + user.identifier) await identity_client.delete_user(user) + print(user.identifier + " deleted") async def main(): sample = CommunicationIdentityClientSamples() await sample.create_user() - await sample.delete_user() + await sample.create_user_with_token() await sample.issue_token() await sample.revoke_tokens() + await sample.delete_user() if __name__ == '__main__': loop = asyncio.get_event_loop() diff --git a/sdk/communication/azure-communication-identity/swagger/SWAGGER.md b/sdk/communication/azure-communication-identity/swagger/SWAGGER.md index 164f24e0e24d..5e9b9b82510e 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/5b19c6e69cd2bb9dbe4e5c1237b2c5a175d90ca5/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,11 @@ clear-output-folder: true v3: true python: true ``` + +### Rename CommunicationIdentityTokenScope to CommunicationTokenScope +```yaml +directive: + - from: swagger-document + where: $.definitions.CommunicationIdentityTokenScope + transform: > + $["x-ms-enum"].name = "CommunicationTokenScope"; \ 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 index f56f17e56a46..c06c0bf5b1a5 100644 --- a/sdk/communication/azure-communication-identity/tests/_shared/testcase.py +++ b/sdk/communication/azure-communication-identity/tests/_shared/testcase.py @@ -48,14 +48,21 @@ def process_response(self, response): response['body']['string'] = self._replace_keys(response['body']['string']) return response - + def _replace_keys(self, body): + def _replace_recursively(dictionary): + if type(dictionary) != dict: + return + for key in dictionary: + if key in self._keys: + dictionary[key] = self._replacement + else: + _replace_recursively(dictionary[key]) + import json try: body = json.loads(body) - for key in self._keys: - if key in body: - body[key] = self._replacement + _replace_recursively(body) except (KeyError, ValueError): return body 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..a5bc813701dc 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 + - Fri, 29 Jan 2021 22:48:30 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": "sanitized"}}' 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 + - Fri, 29 Jan 2021 22:48:29 GMT ms-cv: - - 4whAoum970WIzePHLz1Ujg.0 + - 8tfK3/iTvEmwjYUYlPn7Qg.0 strict-transport-security: - max-age=2592000 transfer-encoding: - chunked x-processing-time: - - 18ms + - 209ms 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..2a6a22b80e6b 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": "sanitized"}}' 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 + - Fri, 29 Jan 2021 22:21:01 GMT ms-cv: - - /4JsXqUuEkmQ1v304iaBTw.0 + - T/Hx9aJuMka5ZSLjy1uvxA.0 strict-transport-security: - max-age=2592000 transfer-encoding: - chunked x-processing-time: - - 635ms + - 247ms 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_with_token.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_create_user_with_token.yaml new file mode 100644 index 000000000000..d0e3e6b7a986 --- /dev/null +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client.test_create_user_with_token.yaml @@ -0,0 +1,45 @@ +interactions: +- request: + body: '{"createTokenWithScopes": ["chat"]}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '35' + Content-Type: + - application/json + Date: + - Fri, 29 Jan 2021 22:50:21 GMT + User-Agent: + - 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=2021-03-07 + response: + body: + string: '{"identity": {"id": "sanitized"}, "accessToken": {"token": "sanitized", + "expiresOn": "2021-01-30T22:50:20.3668737+00:00"}}' + headers: + api-supported-versions: + - 2020-07-20-preview2, 2021-03-07 + content-type: + - application/json; charset=utf-8 + date: + - Fri, 29 Jan 2021 22:50:20 GMT + ms-cv: + - 4wYYchxOnEay3S80a4tugw.0 + strict-transport-security: + - max-age=2592000 + transfer-encoding: + - chunked + x-processing-time: + - 38ms + status: + 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..4bce56996e55 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 + - Fri, 29 Jan 2021 22:23:15 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": "sanitized"}}' 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 + - Fri, 29 Jan 2021 22:23:14 GMT ms-cv: - - UzbbWyNM6Ee4hx1Ym7MwSA.0 + - TgHUTqnyBk+TTGrk+qGYCg.0 strict-transport-security: - max-age=2592000 transfer-encoding: - chunked x-processing-time: - - 19ms + - 22ms 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 + - Fri, 29 Jan 2021 22:23:15 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 + - Fri, 29 Jan 2021 22:23:14 GMT ms-cv: - - bD8oBIuNQEWXEaluFwupbA.0 + - phAKzopa7kCat9napbUQGQ.0 strict-transport-security: - max-age=2592000 x-processing-time: - - 764ms + - 245ms 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..ecf04ae480d1 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": "sanitized"}}' 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 + - Fri, 29 Jan 2021 22:24:21 GMT ms-cv: - - eSMH8ZATxUWO5OamG49Wdg.0 + - 8Dz7rbKlnUyC0X9hMkHkGg.0 strict-transport-security: - max-age=2592000 transfer-encoding: - chunked x-processing-time: - - 811ms + - 203ms 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 + - Fri, 29 Jan 2021 22:24:21 GMT ms-cv: - - 91lJNqPMP0+hZnY0ay0tXA.0 + - 573z+Dhr+UOuJm8r75diNA.0 strict-transport-security: - max-age=2592000 x-processing-time: - - 741ms + - 479ms 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..78e4af9e7e07 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 + - Fri, 29 Jan 2021 22:25:29 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": "sanitized"}}' 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 + - Fri, 29 Jan 2021 22:25:28 GMT ms-cv: - - OXm+S4D9ak+t0Y4jKA3bFA.0 + - izpRZUdB/kyDNywz7m1KQQ.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 + - Fri, 29 Jan 2021 22:25:29 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-30T22:25:27.9464673+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 + - Fri, 29 Jan 2021 22:25:28 GMT ms-cv: - - EArcgkwtPkCU38ZbLjwJEQ.0 + - p2Kp9U6Jek6X2zToYblIHA.0 strict-transport-security: - max-age=2592000 transfer-encoding: - chunked x-processing-time: - - 24ms + - 26ms 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..e08c29cde49b 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": "sanitized"}}' 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 + - Fri, 29 Jan 2021 22:26:36 GMT ms-cv: - - NcQPodkL5UOzC+AtKJcXvw.0 + - sIImdgIO6kSSfNEh18vBHQ.0 strict-transport-security: - max-age=2592000 transfer-encoding: - chunked x-processing-time: - - 501ms + - 203ms 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-30T22:26:35.9312051+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 + - Fri, 29 Jan 2021 22:26:36 GMT ms-cv: - - W4rjQkxkvUSQqyJk5dUwCA.0 + - JPBOQWSIBUWpPLVKMVZSTw.0 strict-transport-security: - max-age=2592000 transfer-encoding: - chunked x-processing-time: - - 27ms + - 30ms 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..1f520f645a24 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 + - Fri, 29 Jan 2021 22:27:44 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": "sanitized"}}' 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 + - Fri, 29 Jan 2021 22:27:43 GMT ms-cv: - - ZDSP6Prb6UGYOTBLvb6AdQ.0 + - xE21Gmx5h0mpZbTaV4qWcA.0 strict-transport-security: - max-age=2592000 transfer-encoding: - chunked x-processing-time: - - 23ms + - 20ms 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 + - Fri, 29 Jan 2021 22:27:44 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-30T22:27:42.9428277+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 + - Fri, 29 Jan 2021 22:27:43 GMT ms-cv: - - Hmv1R+jifUSsezIU2yJU8Q.0 + - q5Uz363zF0aE4eQEN8C8Ng.0 strict-transport-security: - max-age=2592000 transfer-encoding: - chunked x-processing-time: - - 31ms + - 26ms 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 + - Fri, 29 Jan 2021 22:27:44 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 + - Fri, 29 Jan 2021 22:27:43 GMT ms-cv: - - vwznKj2MY0qO9HTJ9YWIRw.0 + - IZVgWwmBk06K7QlAXuz7LQ.0 strict-transport-security: - max-age=2592000 x-processing-time: - - 11ms + - 178ms 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..433cabb9de4f 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": "sanitized"}}' 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 + - Fri, 29 Jan 2021 22:28:50 GMT ms-cv: - - QmngflWD+EOVXH7i/FS+iw.0 + - VDeJxLCpwEiwT+0DkDgQ/w.0 strict-transport-security: - max-age=2592000 transfer-encoding: - chunked x-processing-time: - - 792ms + - 258ms 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-30T22:28:50.160399+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 + - Fri, 29 Jan 2021 22:28:50 GMT ms-cv: - - PRIzOxRVQkycMUEl6WNjHw.0 + - qGOKcdu3m0Cwmnn0J3k7Tw.0 strict-transport-security: - max-age=2592000 transfer-encoding: - chunked x-processing-time: - - 30ms + - 32ms 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 + - Fri, 29 Jan 2021 22:28:51 GMT ms-cv: - - mUk2cNSJI0e/Nz7J7yCGYg.0 + - GGw7vBUa70CbJs5Df0aTSw.0 strict-transport-security: - max-age=2592000 x-processing-time: - - 11ms + - 581ms 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..fda7a5c22f39 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 + - Fri, 29 Jan 2021 22:29:58 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": "sanitized"}}' 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: Fri, 29 Jan 2021 22:29:57 GMT + ms-cv: 1YYCfhRcFkym4hrqBRGZFQ.0 strict-transport-security: max-age=2592000 transfer-encoding: chunked - x-processing-time: 22ms + x-processing-time: 19ms status: - code: 200 - message: OK - url: https://communicationtrnhzmurqrr.communication.azure.com/identities?api-version=2020-07-20-preview2 + code: 201 + message: Created + url: https://communicationasqoly6jb4x.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..1e2fd2003d1f 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": "sanitized"}}' 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: Fri, 29 Jan 2021 22:31:04 GMT + ms-cv: z+LL7RQr+U+x/tyygix5Fg.0 strict-transport-security: max-age=2592000 transfer-encoding: chunked - x-processing-time: 534ms + x-processing-time: 183ms status: - code: 200 - message: OK - url: https://communicationr7rdwwqs74n.communication.azure.com/identities?api-version=2020-07-20-preview2 + code: 201 + message: Created + url: https://communication3ijwjphimwr.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_with_token.yaml b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_create_user_with_token.yaml new file mode 100644 index 000000000000..a1f51269e36a --- /dev/null +++ b/sdk/communication/azure-communication-identity/tests/recordings/test_communication_identity_client_async.test_create_user_with_token.yaml @@ -0,0 +1,35 @@ +interactions: +- request: + body: '{"createTokenWithScopes": ["chat"]}' + headers: + Accept: + - application/json + Content-Length: + - '35' + Content-Type: + - application/json + Date: + - Fri, 29 Jan 2021 22:32:18 GMT + User-Agent: + - 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=2021-03-07 + response: + body: + string: '{"identity": {"id": "sanitized"}, "accessToken": {"token": "sanitized", + "expiresOn": "2021-01-30T22:32:16.9405213+00:00"}}' + headers: + api-supported-versions: 2020-07-20-preview2, 2021-03-07 + content-type: application/json; charset=utf-8 + date: Fri, 29 Jan 2021 22:32:17 GMT + ms-cv: W1T1PVQFlEWIXcgu0EeooA.0 + strict-transport-security: max-age=2592000 + transfer-encoding: chunked + x-processing-time: 35ms + status: + code: 201 + message: Created + url: https://communication6l4km7ph3zj.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..0b2eab2624c7 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 + - Fri, 29 Jan 2021 22:33: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": "sanitized"}}' 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: Fri, 29 Jan 2021 22:33:24 GMT + ms-cv: E+HUdaa+gE+cpD1TJJKNSg.0 strict-transport-security: max-age=2592000 transfer-encoding: chunked - x-processing-time: 22ms + x-processing-time: 19ms status: - code: 200 - message: OK - url: https://communication42hz4pfbosr.communication.azure.com/identities?api-version=2020-07-20-preview2 + code: 201 + message: Created + url: https://communicationzgvvggklwoa.communication.azure.com/identities?api-version=2021-03-07 - request: body: '' headers: + Accept: + - application/json Date: - - Tue, 22 Dec 2020 18:51:14 GMT + - Fri, 29 Jan 2021 22:33: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: 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: Fri, 29 Jan 2021 22:33:25 GMT + ms-cv: q02XjOHx2EKny82QMeoybA.0 strict-transport-security: max-age=2592000 - x-processing-time: 440ms + x-processing-time: 854ms status: code: 204 message: No Content - url: https://communication42hz4pfbosr.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 + url: https://communicationzgvvggklwoa.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..a5f8633cb199 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": "sanitized"}}' 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: Fri, 29 Jan 2021 22:34:32 GMT + ms-cv: M4o3j8QviU6dfW/2cZS4ug.0 strict-transport-security: max-age=2592000 transfer-encoding: chunked - x-processing-time: 192ms + x-processing-time: 242ms status: - code: 200 - message: OK - url: https://communicationrscjfarclwr.communication.azure.com/identities?api-version=2020-07-20-preview2 + code: 201 + message: Created + url: https://communicationvfxjz4kgs5q.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: Fri, 29 Jan 2021 22:34:33 GMT + ms-cv: 4NslPsnjL0iQ1CODgbz7TA.0 strict-transport-security: max-age=2592000 - x-processing-time: 864ms + x-processing-time: 676ms status: code: 204 message: No Content - url: https://communicationrscjfarclwr.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 + url: https://communicationvfxjz4kgs5q.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..32210dc46be7 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 + - Fri, 29 Jan 2021 22:35:42 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": "sanitized"}}' 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: Fri, 29 Jan 2021 22:35:41 GMT + ms-cv: d5Ncfb9TeEWiZ8EGWkToTw.0 strict-transport-security: max-age=2592000 transfer-encoding: chunked - x-processing-time: 20ms + x-processing-time: 205ms status: - code: 200 - message: OK - url: https://communicatione77tfh7y2ht.communication.azure.com/identities?api-version=2020-07-20-preview2 + code: 201 + message: Created + url: https://communicationdo2ohmwsm52.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 + - Fri, 29 Jan 2021 22:35:42 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-30T22:35:41.2292482+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: Fri, 29 Jan 2021 22:35:42 GMT + ms-cv: DoX6Mm/9pkqFtpHOKzWiAg.0 strict-transport-security: max-age=2592000 transfer-encoding: chunked - x-processing-time: 26ms + x-processing-time: 215ms status: code: 200 message: OK - url: https://communicatione77tfh7y2ht.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 + url: https://communicationdo2ohmwsm52.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..e70320714b8b 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": "sanitized"}}' 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: Fri, 29 Jan 2021 22:36:49 GMT + ms-cv: cUzRyy4LbUigYrZ7lbi4wA.0 strict-transport-security: max-age=2592000 transfer-encoding: chunked - x-processing-time: 773ms + x-processing-time: 238ms status: - code: 200 - message: OK - url: https://communicationztg2acjbipc.communication.azure.com/identities?api-version=2020-07-20-preview2 + code: 201 + message: Created + url: https://communication5brewzlj3te.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-30T22:36:48.7283566+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: Fri, 29 Jan 2021 22:36:49 GMT + ms-cv: bFRoAJk3ikGgv2ot2Vwh4A.0 strict-transport-security: max-age=2592000 transfer-encoding: chunked - x-processing-time: 25ms + x-processing-time: 26ms status: code: 200 message: OK - url: https://communicationztg2acjbipc.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 + url: https://communication5brewzlj3te.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..7b6b2c57a1fe 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 + - Fri, 29 Jan 2021 22:37:56 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": "sanitized"}}' 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: Fri, 29 Jan 2021 22:37:55 GMT + ms-cv: vJReSgsEzEC1EVRdWZnCWA.0 strict-transport-security: max-age=2592000 transfer-encoding: chunked - x-processing-time: 29ms + x-processing-time: 22ms status: - code: 200 - message: OK - url: https://communicationngn6p2kywhg.communication.azure.com/identities?api-version=2020-07-20-preview2 + code: 201 + message: Created + url: https://communication2xbng6lk65f.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 + - Fri, 29 Jan 2021 22:37:56 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-30T22:37:54.9493083+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: Fri, 29 Jan 2021 22:37:55 GMT + ms-cv: nQk1/zvYyEiAvNDwqRdZAg.0 strict-transport-security: max-age=2592000 transfer-encoding: chunked - x-processing-time: 27ms + x-processing-time: 28ms status: code: 200 message: OK - url: https://communicationngn6p2kywhg.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 + url: https://communication2xbng6lk65f.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 + - Fri, 29 Jan 2021 22:37: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.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: Fri, 29 Jan 2021 22:37:55 GMT + ms-cv: Bf9FLiU9kkm2bE7qs4H8Yw.0 strict-transport-security: max-age=2592000 - x-processing-time: 10ms + x-processing-time: 674ms status: code: 204 message: No Content - url: https://communicationngn6p2kywhg.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 + url: https://communication2xbng6lk65f.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..ff0c50a514a8 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": "sanitized"}}' 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: Fri, 29 Jan 2021 22:39:03 GMT + ms-cv: /SEx2qFrG0afGsUyQ/WtaQ.0 strict-transport-security: max-age=2592000 transfer-encoding: chunked - x-processing-time: 195ms + x-processing-time: 325ms status: - code: 200 - message: OK - url: https://communicationxheui257vce.communication.azure.com/identities?api-version=2020-07-20-preview2 + code: 201 + message: Created + url: https://communicationztcvutdsdqx.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-30T22:39:02.9481803+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: Fri, 29 Jan 2021 22:39:03 GMT + ms-cv: ZzKd7QU4k0Or4Bt/g0hClg.0 strict-transport-security: max-age=2592000 transfer-encoding: chunked - x-processing-time: 24ms + x-processing-time: 25ms status: code: 200 message: OK - url: https://communicationxheui257vce.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2 + url: https://communicationztcvutdsdqx.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: Fri, 29 Jan 2021 22:39:03 GMT + ms-cv: F8O7efYC2EWG7TZ3/dJFpA.0 strict-transport-security: max-age=2592000 - x-processing-time: 11ms + x-processing-time: 616ms status: code: 204 message: No Content - url: https://communicationxheui257vce.communication.azure.com/identities/sanitized?api-version=2020-07-20-preview2 + url: https://communicationztcvutdsdqx.communication.azure.com/identities/sanitized/:revokeAccessTokens?api-version=2021-03-07 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 index 9fc58152be3c..dbbda4811a89 100644 --- a/sdk/communication/azure-communication-identity/tests/test_communication_identity_client.py +++ b/sdk/communication/azure-communication-identity/tests/test_communication_identity_client.py @@ -6,6 +6,7 @@ # -------------------------------------------------------------------------- import pytest from azure.communication.identity import CommunicationIdentityClient +from azure.communication.identity import CommunicationTokenScope from azure.core.credentials import AccessToken from _shared.helper import URIIdentityReplacer from _shared.testcase import ( @@ -53,6 +54,15 @@ def test_create_user(self, connection_string): assert user.identifier is not None + @ResourceGroupPreparer(random_name_enabled=True) + @CommunicationServicePreparer() + def test_create_user_with_token(self, connection_string): + identity_client = CommunicationIdentityClient.from_connection_string(connection_string) + user, token_response = identity_client.create_user_with_token(scopes=[CommunicationTokenScope.CHAT]) + + assert user.identifier is not None + assert token_response.token is not None + @ResourceGroupPreparer(random_name_enabled=True) @CommunicationServicePreparer() def test_issue_token_from_managed_identity(self, connection_string): @@ -65,7 +75,7 @@ def test_issue_token_from_managed_identity(self, connection_string): identity_client = CommunicationIdentityClient(endpoint, credential) user = identity_client.create_user() - token_response = identity_client.issue_token(user, scopes=["chat"]) + token_response = identity_client.issue_token(user, scopes=[CommunicationTokenScope.CHAT]) assert user.identifier is not None assert token_response.token is not None @@ -77,7 +87,7 @@ def test_issue_token(self, connection_string): connection_string) user = identity_client.create_user() - token_response = identity_client.issue_token(user, scopes=["chat"]) + token_response = identity_client.issue_token(user, scopes=[CommunicationTokenScope.CHAT]) assert user.identifier is not None assert token_response.token is not None @@ -94,7 +104,7 @@ def test_revoke_tokens_from_managed_identity(self, connection_string): identity_client = CommunicationIdentityClient(endpoint, credential) user = identity_client.create_user() - token_response = identity_client.issue_token(user, scopes=["chat"]) + token_response = identity_client.issue_token(user, scopes=[CommunicationTokenScope.CHAT]) identity_client.revoke_tokens(user) assert user.identifier is not None @@ -107,7 +117,7 @@ def test_revoke_tokens(self, connection_string): connection_string) user = identity_client.create_user() - token_response = identity_client.issue_token(user, scopes=["chat"]) + token_response = identity_client.issue_token(user, scopes=[CommunicationTokenScope.CHAT]) identity_client.revoke_tokens(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 index 0dafc2b5b76c..eba81941ccb2 100644 --- 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 @@ -7,6 +7,7 @@ import pytest from azure.core.credentials import AccessToken from azure.communication.identity.aio import CommunicationIdentityClient +from azure.communication.identity import CommunicationTokenScope from azure.communication.identity._shared.utils import parse_connection_str from azure_devtools.scenario_tests import RecordingProcessor from devtools_testutils import ResourceGroupPreparer @@ -53,6 +54,16 @@ async def test_create_user(self, connection_string): assert user.identifier is not None + @ResourceGroupPreparer(random_name_enabled=True) + @CommunicationServicePreparer() + async def test_create_user_with_token(self, connection_string): + identity_client = CommunicationIdentityClient.from_connection_string(connection_string) + async with identity_client: + user, token_response = await identity_client.create_user_with_token(scopes=[CommunicationTokenScope.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_from_managed_identity(self, connection_string): @@ -65,7 +76,7 @@ async def test_issue_token_from_managed_identity(self, connection_string): 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"]) + token_response = await identity_client.issue_token(user, scopes=[CommunicationTokenScope.CHAT]) assert user.identifier is not None assert token_response.token is not None @@ -76,7 +87,7 @@ 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"]) + token_response = await identity_client.issue_token(user, scopes=[CommunicationTokenScope.CHAT]) assert user.identifier is not None assert token_response.token is not None @@ -93,7 +104,7 @@ async def test_revoke_tokens_from_managed_identity(self, connection_string): 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"]) + token_response = await identity_client.issue_token(user, scopes=[CommunicationTokenScope.CHAT]) await identity_client.revoke_tokens(user) assert user.identifier is not None @@ -105,7 +116,7 @@ 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"]) + token_response = await identity_client.issue_token(user, scopes=[CommunicationTokenScope.CHAT]) await identity_client.revoke_tokens(user) assert user.identifier is not None