diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_shared/user_credential.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_shared/user_credential.py index c27a32369185..73b494b8ccf3 100644 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_shared/user_credential.py +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/_shared/user_credential.py @@ -13,7 +13,7 @@ from msrest.serialization import TZ_UTC from .utils import create_access_token -class CommunicationUserCredential(object): +class CommunicationTokenCredential(object): """Credential type used for authenticating to an Azure Communication service. :param str token: The token used to authenticate to an Azure Communication service :raises: TypeError diff --git a/sdk/communication/azure-communication-administration/azure/communication/administration/_shared/user_credential_async.py b/sdk/communication/azure-communication-administration/azure/communication/administration/_shared/user_credential_async.py index 1c9b2318aa09..710c9948c839 100644 --- a/sdk/communication/azure-communication-administration/azure/communication/administration/_shared/user_credential_async.py +++ b/sdk/communication/azure-communication-administration/azure/communication/administration/_shared/user_credential_async.py @@ -13,7 +13,7 @@ from msrest.serialization import TZ_UTC from .utils import create_access_token -class CommunicationUserCredential(object): +class CommunicationTokenCredential(object): """Credential type used for authenticating to an Azure Communication service. :param str token: The token used to authenticate to an Azure Communication service :raises: TypeError diff --git a/sdk/communication/azure-communication-administration/tests/user_credential_tests.py b/sdk/communication/azure-communication-administration/tests/user_credential_tests.py index d6a8c28998cd..c63cfcd1434e 100644 --- a/sdk/communication/azure-communication-administration/tests/user_credential_tests.py +++ b/sdk/communication/azure-communication-administration/tests/user_credential_tests.py @@ -5,11 +5,11 @@ # -------------------------------------------------------------------------- from unittest import TestCase from unittest.mock import MagicMock -from azure.communication.administration._shared.user_credential import CommunicationUserCredential +from azure.communication.administration._shared.user_credential import CommunicationTokenCredential from azure.communication.administration._shared.utils import create_access_token -class TestCommunicationUserCredential(TestCase): +class TestCommunicationTokenCredential(TestCase): sample_token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9."+\ "eyJleHAiOjMyNTAzNjgwMDAwfQ.9i7FNNHHJT8cOzo-yrAUJyBSfJ-tPPk2emcHavOEpWc" sample_token_expiry = 32503680000 @@ -17,35 +17,35 @@ class TestCommunicationUserCredential(TestCase): "eyJleHAiOjEwMH0.1h_scYkNp-G98-O4cW6KvfJZwiz54uJMyeDACE4nypg" - def test_communicationusercredential_decodes_token(self): - credential = CommunicationUserCredential(self.sample_token) + def test_communicationtokencredential_decodes_token(self): + credential = CommunicationTokenCredential(self.sample_token) access_token = credential.get_token() self.assertEqual(access_token.token, self.sample_token) - def test_communicationusercredential_throws_if_invalid_token(self): - self.assertRaises(ValueError, lambda: CommunicationUserCredential("foo.bar.tar")) + def test_communicationtokencredential_throws_if_invalid_token(self): + self.assertRaises(ValueError, lambda: CommunicationTokenCredential("foo.bar.tar")) - def test_communicationusercredential_throws_if_nonstring_token(self): - self.assertRaises(TypeError, lambda: CommunicationUserCredential(454)) + def test_communicationtokencredential_throws_if_nonstring_token(self): + self.assertRaises(TypeError, lambda: CommunicationTokenCredential(454)) - def test_communicationusercredential_static_token_returns_expired_token(self): - credential = CommunicationUserCredential(self.expired_token) + def test_communicationtokencredential_static_token_returns_expired_token(self): + credential = CommunicationTokenCredential(self.expired_token) self.assertEqual(credential.get_token().token, self.expired_token) - def test_communicationusercredential_token_expired_refresh_called(self): + def test_communicationtokencredential_token_expired_refresh_called(self): refresher = MagicMock(return_value=self.sample_token) - access_token = CommunicationUserCredential( + access_token = CommunicationTokenCredential( self.expired_token, token_refresher=refresher).get_token() refresher.assert_called_once() self.assertEqual(access_token, self.sample_token) - def test_communicationusercredential_token_expired_refresh_called_asnecessary(self): + def test_communicationtokencredential_token_expired_refresh_called_asnecessary(self): refresher = MagicMock(return_value=create_access_token(self.expired_token)) - credential = CommunicationUserCredential( + credential = CommunicationTokenCredential( self.expired_token, token_refresher=refresher) diff --git a/sdk/communication/azure-communication-chat/README.md b/sdk/communication/azure-communication-chat/README.md index 5aa1df81ef87..4fa675911338 100644 --- a/sdk/communication/azure-communication-chat/README.md +++ b/sdk/communication/azure-communication-chat/README.md @@ -44,11 +44,11 @@ it with this token. It is because the initiator of the create request must be in This will allow you to create, get, list or delete chat threads. ```python -from azure.communication.chat import ChatClient, CommunicationUserCredential +from azure.communication.chat import ChatClient, CommunicationTokenCredential # Your unique Azure Communication service endpoint endpoint = "https://.communcationservices.azure.com" token = "" -chat_client = ChatClient(endpoint, CommunicationUserCredential(token)) +chat_client = ChatClient(endpoint, CommunicationTokenCredential(token)) ``` ## Create Chat Thread Client diff --git a/sdk/communication/azure-communication-chat/azure/communication/chat/__init__.py b/sdk/communication/azure-communication-chat/azure/communication/chat/__init__.py index 2b15029c6a7f..78575fcb80c7 100644 --- a/sdk/communication/azure-communication-chat/azure/communication/chat/__init__.py +++ b/sdk/communication/azure-communication-chat/azure/communication/chat/__init__.py @@ -6,7 +6,7 @@ SendChatMessageResult, ChatThreadInfo, ) -from ._shared.user_credential import CommunicationUserCredential +from ._shared.user_credential import CommunicationTokenCredential from ._models import ( ChatThreadMember, ChatMessage, @@ -24,7 +24,7 @@ 'SendChatMessageResult', 'ChatThread', 'ChatThreadInfo', - 'CommunicationUserCredential', + 'CommunicationTokenCredential', 'ChatThreadMember', 'CommunicationUserIdentifier', ] diff --git a/sdk/communication/azure-communication-chat/azure/communication/chat/_chat_client.py b/sdk/communication/azure-communication-chat/azure/communication/chat/_chat_client.py index cf7c0047b22f..096e31311fd0 100644 --- a/sdk/communication/azure-communication-chat/azure/communication/chat/_chat_client.py +++ b/sdk/communication/azure-communication-chat/azure/communication/chat/_chat_client.py @@ -15,7 +15,7 @@ from azure.core.pipeline.policies import BearerTokenCredentialPolicy from ._chat_thread_client import ChatThreadClient -from ._shared.user_credential import CommunicationUserCredential +from ._shared.user_credential import CommunicationTokenCredential from ._generated import AzureCommunicationChatService from ._generated.models import CreateChatThreadRequest from ._models import ChatThread @@ -37,7 +37,7 @@ class ChatClient(object): :param str endpoint: The endpoint of the Azure Communication resource. - :param CommunicationUserCredential credential: + :param CommunicationTokenCredential credential: The credentials with which to authenticate. .. admonition:: Example: @@ -53,7 +53,7 @@ class ChatClient(object): def __init__( self, endpoint, # type: str - credential, # type: CommunicationUserCredential + credential, # type: CommunicationTokenCredential **kwargs # type: Any ): # type: (...) -> None diff --git a/sdk/communication/azure-communication-chat/azure/communication/chat/_chat_thread_client.py b/sdk/communication/azure-communication-chat/azure/communication/chat/_chat_thread_client.py index 3a3e3af776ad..8da49613ae01 100644 --- a/sdk/communication/azure-communication-chat/azure/communication/chat/_chat_thread_client.py +++ b/sdk/communication/azure-communication-chat/azure/communication/chat/_chat_thread_client.py @@ -13,7 +13,7 @@ from azure.core.tracing.decorator import distributed_trace from azure.core.pipeline.policies import BearerTokenCredentialPolicy -from ._shared.user_credential import CommunicationUserCredential +from ._shared.user_credential import CommunicationTokenCredential from ._generated import AzureCommunicationChatService from ._generated.models import ( AddChatThreadMembersRequest, @@ -51,7 +51,7 @@ class ChatThreadClient(object): :param str endpoint: The endpoint of the Azure Communication resource. - :param CommunicationUserCredential credential: + :param CommunicationTokenCredential credential: The credentials with which to authenticate. The value contains a User Access Token :param str thread_id: @@ -70,7 +70,7 @@ class ChatThreadClient(object): def __init__( self, endpoint, # type: str - credential, # type: CommunicationUserCredential + credential, # type: CommunicationTokenCredential thread_id, # type: str **kwargs # type: Any ): diff --git a/sdk/communication/azure-communication-chat/azure/communication/chat/_shared/user_credential.py b/sdk/communication/azure-communication-chat/azure/communication/chat/_shared/user_credential.py index f922d9cba5b9..a197b98ab620 100644 --- a/sdk/communication/azure-communication-chat/azure/communication/chat/_shared/user_credential.py +++ b/sdk/communication/azure-communication-chat/azure/communication/chat/_shared/user_credential.py @@ -14,7 +14,7 @@ from msrest.serialization import TZ_UTC from .utils import create_access_token -class CommunicationUserCredential(object): +class CommunicationTokenCredential(object): """Credential type used for authenticating to an Azure Communication service. :param str token: The token used to authenticate to an Azure Communication service :raises: TypeError diff --git a/sdk/communication/azure-communication-chat/azure/communication/chat/_shared/user_credential_async.py b/sdk/communication/azure-communication-chat/azure/communication/chat/_shared/user_credential_async.py index a88d9966f8ff..ad12c37e3450 100644 --- a/sdk/communication/azure-communication-chat/azure/communication/chat/_shared/user_credential_async.py +++ b/sdk/communication/azure-communication-chat/azure/communication/chat/_shared/user_credential_async.py @@ -15,7 +15,7 @@ from msrest.serialization import TZ_UTC from .utils import create_access_token -class CommunicationUserCredential(object): +class CommunicationTokenCredential(object): """Credential type used for authenticating to an Azure Communication service. :param str token: The token used to authenticate to an Azure Communication service :raises: TypeError diff --git a/sdk/communication/azure-communication-chat/azure/communication/chat/aio/__init__.py b/sdk/communication/azure-communication-chat/azure/communication/chat/aio/__init__.py index 9b93a55ac4e1..dfda78b4aafd 100644 --- a/sdk/communication/azure-communication-chat/azure/communication/chat/aio/__init__.py +++ b/sdk/communication/azure-communication-chat/azure/communication/chat/aio/__init__.py @@ -4,10 +4,10 @@ # ------------------------------------ from ._chat_client_async import ChatClient from ._chat_thread_client_async import ChatThreadClient -from .._shared.user_credential_async import CommunicationUserCredential +from .._shared.user_credential_async import CommunicationTokenCredential __all__ = [ "ChatClient", "ChatThreadClient", - "CommunicationUserCredential" + "CommunicationTokenCredential" ] diff --git a/sdk/communication/azure-communication-chat/azure/communication/chat/aio/_chat_client_async.py b/sdk/communication/azure-communication-chat/azure/communication/chat/aio/_chat_client_async.py index c3390c7178fe..62f6969ec87f 100644 --- a/sdk/communication/azure-communication-chat/azure/communication/chat/aio/_chat_client_async.py +++ b/sdk/communication/azure-communication-chat/azure/communication/chat/aio/_chat_client_async.py @@ -20,7 +20,7 @@ from azure.core.async_paging import AsyncItemPaged from ._chat_thread_client_async import ChatThreadClient -from .._shared.user_credential_async import CommunicationUserCredential +from .._shared.user_credential_async import CommunicationTokenCredential from .._generated.aio import AzureCommunicationChatService from .._generated.models import ( CreateChatThreadRequest, @@ -42,7 +42,7 @@ class ChatClient(object): :param str endpoint: The endpoint of the Azure Communication resource. - :param CommunicationUserCredential credential: + :param CommunicationTokenCredential credential: The credentials with which to authenticate. .. admonition:: Example: @@ -57,7 +57,7 @@ class ChatClient(object): def __init__( self, endpoint: str, - credential: CommunicationUserCredential, + credential: CommunicationTokenCredential, **kwargs ) -> None: if not credential: diff --git a/sdk/communication/azure-communication-chat/azure/communication/chat/aio/_chat_thread_client_async.py b/sdk/communication/azure-communication-chat/azure/communication/chat/aio/_chat_thread_client_async.py index 7a7bf74b5572..597c0f7b39d4 100644 --- a/sdk/communication/azure-communication-chat/azure/communication/chat/aio/_chat_thread_client_async.py +++ b/sdk/communication/azure-communication-chat/azure/communication/chat/aio/_chat_thread_client_async.py @@ -18,7 +18,7 @@ from azure.core.pipeline.policies import BearerTokenCredentialPolicy from azure.core.async_paging import AsyncItemPaged -from .._shared.user_credential_async import CommunicationUserCredential +from .._shared.user_credential_async import CommunicationTokenCredential from .._generated.aio import AzureCommunicationChatService from .._generated.models import ( AddChatThreadMembersRequest, @@ -51,7 +51,7 @@ class ChatThreadClient(object): :param str endpoint: The endpoint of the Azure Communication resource. - :param CommunicationUserCredential credential: + :param CommunicationTokenCredential credential: The credentials with which to authenticate. The value contains a User Access Token :param str thread_id: @@ -70,7 +70,7 @@ class ChatThreadClient(object): def __init__( self, endpoint: str, - credential: CommunicationUserCredential, + credential: CommunicationTokenCredential, thread_id: str, **kwargs ) -> None: diff --git a/sdk/communication/azure-communication-chat/samples/chat_client_sample.py b/sdk/communication/azure-communication-chat/samples/chat_client_sample.py index 0cc8be8009ff..9bb0a44ae62f 100644 --- a/sdk/communication/azure-communication-chat/samples/chat_client_sample.py +++ b/sdk/communication/azure-communication-chat/samples/chat_client_sample.py @@ -45,8 +45,8 @@ class ChatClientSamples(object): def create_chat_client(self): # [START create_chat_client] - from azure.communication.chat import ChatClient, CommunicationUserCredential - chat_client = ChatClient(self.endpoint, CommunicationUserCredential(self.token)) + from azure.communication.chat import ChatClient, CommunicationTokenCredential + chat_client = ChatClient(self.endpoint, CommunicationTokenCredential(self.token)) # [END create_chat_client] def create_thread(self): @@ -56,10 +56,10 @@ def create_thread(self): ChatClient, ChatThreadMember, CommunicationUserIdentifier, - CommunicationUserCredential + CommunicationTokenCredential ) - chat_client = ChatClient(self.endpoint, CommunicationUserCredential(self.token)) + chat_client = ChatClient(self.endpoint, CommunicationTokenCredential(self.token)) topic = "test topic" members = [ChatThreadMember( @@ -75,9 +75,9 @@ def create_thread(self): def get_chat_thread_client(self): # [START get_chat_thread_client] - from azure.communication.chat import ChatClient, CommunicationUserCredential + from azure.communication.chat import ChatClient, CommunicationTokenCredential - chat_client = ChatClient(self.endpoint, CommunicationUserCredential(self.token)) + chat_client = ChatClient(self.endpoint, CommunicationTokenCredential(self.token)) chat_thread_client = chat_client.get_chat_thread_client(self._thread_id) # [END get_chat_thread_client] @@ -85,9 +85,9 @@ def get_chat_thread_client(self): def get_thread(self): # [START get_thread] - from azure.communication.chat import ChatClient, CommunicationUserCredential + from azure.communication.chat import ChatClient, CommunicationTokenCredential - chat_client = ChatClient(self.endpoint, CommunicationUserCredential(self.token)) + chat_client = ChatClient(self.endpoint, CommunicationTokenCredential(self.token)) chat_thread = chat_client.get_chat_thread(self._thread_id) # [END get_thread] @@ -95,11 +95,11 @@ def get_thread(self): def list_threads(self): # [START list_threads] - from azure.communication.chat import ChatClient, CommunicationUserCredential + from azure.communication.chat import ChatClient, CommunicationTokenCredential from datetime import datetime, timedelta import pytz - chat_client = ChatClient(self.endpoint, CommunicationUserCredential(self.token)) + chat_client = ChatClient(self.endpoint, CommunicationTokenCredential(self.token)) start_time = datetime.utcnow() - timedelta(days=2) start_time = start_time.replace(tzinfo=pytz.utc) chat_thread_infos = chat_client.list_chat_threads(results_per_page=5, start_time=start_time) @@ -111,9 +111,9 @@ def list_threads(self): def delete_thread(self): # [START delete_thread] - from azure.communication.chat import ChatClient, CommunicationUserCredential + from azure.communication.chat import ChatClient, CommunicationTokenCredential - chat_client = ChatClient(self.endpoint, CommunicationUserCredential(self.token)) + chat_client = ChatClient(self.endpoint, CommunicationTokenCredential(self.token)) chat_client.delete_chat_thread(self._thread_id) # [END delete_thread] diff --git a/sdk/communication/azure-communication-chat/samples/chat_client_sample_async.py b/sdk/communication/azure-communication-chat/samples/chat_client_sample_async.py index 15e046bf3fcb..fe1135ebfd40 100644 --- a/sdk/communication/azure-communication-chat/samples/chat_client_sample_async.py +++ b/sdk/communication/azure-communication-chat/samples/chat_client_sample_async.py @@ -45,17 +45,17 @@ class ChatClientSamplesAsync(object): def create_chat_client(self): # [START create_chat_client] - from azure.communication.chat.aio import ChatClient, CommunicationUserCredential - chat_client = ChatClient(self.endpoint, CommunicationUserCredential(self.token)) + from azure.communication.chat.aio import ChatClient, CommunicationTokenCredential + chat_client = ChatClient(self.endpoint, CommunicationTokenCredential(self.token)) # [END create_chat_client] print("chat_client created") async def create_thread_async(self): from datetime import datetime - from azure.communication.chat.aio import ChatClient, CommunicationUserCredential + from azure.communication.chat.aio import ChatClient, CommunicationTokenCredential from azure.communication.chat import ChatThreadMember, CommunicationUser - chat_client = ChatClient(self.endpoint, CommunicationUserCredential(self.token)) + chat_client = ChatClient(self.endpoint, CommunicationTokenCredential(self.token)) async with chat_client: # [START create_thread] topic = "test topic" @@ -72,18 +72,18 @@ async def create_thread_async(self): def get_chat_thread_client(self): # [START get_chat_thread_client] - from azure.communication.chat.aio import ChatClient, CommunicationUserCredential + from azure.communication.chat.aio import ChatClient, CommunicationTokenCredential - chat_client = ChatClient(self.endpoint, CommunicationUserCredential(self.token)) + chat_client = ChatClient(self.endpoint, CommunicationTokenCredential(self.token)) chat_thread_client = chat_client.get_chat_thread_client(self._thread_id) # [END get_chat_thread_client] print("chat_thread_client created with thread id: ", chat_thread_client.thread_id) async def get_thread_async(self): - from azure.communication.chat.aio import ChatClient, CommunicationUserCredential + from azure.communication.chat.aio import ChatClient, CommunicationTokenCredential - chat_client = ChatClient(self.endpoint, CommunicationUserCredential(self.token)) + chat_client = ChatClient(self.endpoint, CommunicationTokenCredential(self.token)) async with chat_client: # [START get_thread] chat_thread = await chat_client.get_chat_thread(self._thread_id) @@ -91,9 +91,9 @@ async def get_thread_async(self): print("get_thread succeeded, thread id: " + chat_thread.id + ", thread topic: " + chat_thread.topic) async def list_threads_async(self): - from azure.communication.chat.aio import ChatClient, CommunicationUserCredential + from azure.communication.chat.aio import ChatClient, CommunicationTokenCredential - chat_client = ChatClient(self.endpoint, CommunicationUserCredential(self.token)) + chat_client = ChatClient(self.endpoint, CommunicationTokenCredential(self.token)) async with chat_client: # [START list_threads] from datetime import datetime, timedelta @@ -107,9 +107,9 @@ async def list_threads_async(self): # [END list_threads] async def delete_thread_async(self): - from azure.communication.chat.aio import ChatClient, CommunicationUserCredential + from azure.communication.chat.aio import ChatClient, CommunicationTokenCredential - chat_client = ChatClient(self.endpoint, CommunicationUserCredential(self.token)) + chat_client = ChatClient(self.endpoint, CommunicationTokenCredential(self.token)) async with chat_client: # [START delete_thread] await chat_client.delete_chat_thread(self._thread_id) diff --git a/sdk/communication/azure-communication-chat/samples/chat_thread_client_sample.py b/sdk/communication/azure-communication-chat/samples/chat_thread_client_sample.py index 62858f841aad..b80a4ed63cde 100644 --- a/sdk/communication/azure-communication-chat/samples/chat_thread_client_sample.py +++ b/sdk/communication/azure-communication-chat/samples/chat_thread_client_sample.py @@ -52,9 +52,9 @@ def create_chat_thread_client(self): ChatClient, ChatThreadMember, CommunicationUserIdentifier, - CommunicationUserCredential + CommunicationTokenCredential ) - chat_client = ChatClient(self.endpoint, CommunicationUserCredential(self.token)) + chat_client = ChatClient(self.endpoint, CommunicationTokenCredential(self.token)) topic = "test topic" members = [ChatThreadMember( user=self.user, @@ -68,8 +68,8 @@ def create_chat_thread_client(self): def update_thread(self): from azure.communication.chat import ChatThreadClient - from azure.communication.chat import CommunicationUserCredential - chat_thread_client = ChatThreadClient(self.endpoint, CommunicationUserCredential(self.token), self._thread_id) + from azure.communication.chat import CommunicationTokenCredential + chat_thread_client = ChatThreadClient(self.endpoint, CommunicationTokenCredential(self.token), self._thread_id) # [START update_thread] topic = "updated thread topic" chat_thread_client.update_thread(topic=topic) @@ -79,8 +79,8 @@ def update_thread(self): def send_message(self): from azure.communication.chat import ChatThreadClient - from azure.communication.chat import CommunicationUserCredential - chat_thread_client = ChatThreadClient(self.endpoint, CommunicationUserCredential(self.token), self._thread_id) + from azure.communication.chat import CommunicationTokenCredential + chat_thread_client = ChatThreadClient(self.endpoint, CommunicationTokenCredential(self.token), self._thread_id) # [START send_message] from azure.communication.chat import ChatMessagePriority @@ -99,8 +99,8 @@ def send_message(self): def get_message(self): from azure.communication.chat import ChatThreadClient - from azure.communication.chat import CommunicationUserCredential - chat_thread_client = ChatThreadClient(self.endpoint, CommunicationUserCredential(self.token), self._thread_id) + from azure.communication.chat import CommunicationTokenCredential + chat_thread_client = ChatThreadClient(self.endpoint, CommunicationTokenCredential(self.token), self._thread_id) # [START get_message] chat_message = chat_thread_client.get_message(self._message_id) # [END get_message] @@ -110,8 +110,8 @@ def get_message(self): def list_messages(self): from azure.communication.chat import ChatThreadClient - from azure.communication.chat import CommunicationUserCredential - chat_thread_client = ChatThreadClient(self.endpoint, CommunicationUserCredential(self.token), self._thread_id) + from azure.communication.chat import CommunicationTokenCredential + chat_thread_client = ChatThreadClient(self.endpoint, CommunicationTokenCredential(self.token), self._thread_id) # [START list_messages] from datetime import datetime, timedelta start_time = datetime.utcnow() - timedelta(days=1) @@ -125,8 +125,8 @@ def list_messages(self): def update_message(self): from azure.communication.chat import ChatThreadClient - from azure.communication.chat import CommunicationUserCredential - chat_thread_client = ChatThreadClient(self.endpoint, CommunicationUserCredential(self.token), self._thread_id) + from azure.communication.chat import CommunicationTokenCredential + chat_thread_client = ChatThreadClient(self.endpoint, CommunicationTokenCredential(self.token), self._thread_id) # [START update_message] content = "updated content" chat_thread_client.update_message(self._message_id, content=content) @@ -136,8 +136,8 @@ def update_message(self): def send_read_receipt(self): from azure.communication.chat import ChatThreadClient - from azure.communication.chat import CommunicationUserCredential - chat_thread_client = ChatThreadClient(self.endpoint, CommunicationUserCredential(self.token), self._thread_id) + from azure.communication.chat import CommunicationTokenCredential + chat_thread_client = ChatThreadClient(self.endpoint, CommunicationTokenCredential(self.token), self._thread_id) # [START send_read_receipt] chat_thread_client.send_read_receipt(self._message_id) # [END send_read_receipt] @@ -146,8 +146,8 @@ def send_read_receipt(self): def list_read_receipts(self): from azure.communication.chat import ChatThreadClient - from azure.communication.chat import CommunicationUserCredential - chat_thread_client = ChatThreadClient(self.endpoint, CommunicationUserCredential(self.token), self._thread_id) + from azure.communication.chat import CommunicationTokenCredential + chat_thread_client = ChatThreadClient(self.endpoint, CommunicationTokenCredential(self.token), self._thread_id) # [START list_read_receipts] read_receipts = chat_thread_client.list_read_receipts() print("list_read_receipts succeeded, receipts:") @@ -157,8 +157,8 @@ def list_read_receipts(self): def delete_message(self): from azure.communication.chat import ChatThreadClient - from azure.communication.chat import CommunicationUserCredential - chat_thread_client = ChatThreadClient(self.endpoint, CommunicationUserCredential(self.token), self._thread_id) + from azure.communication.chat import CommunicationTokenCredential + chat_thread_client = ChatThreadClient(self.endpoint, CommunicationTokenCredential(self.token), self._thread_id) # [START delete_message] chat_thread_client.delete_message(self._message_id) # [END delete_message] @@ -166,8 +166,8 @@ def delete_message(self): def list_members(self): from azure.communication.chat import ChatThreadClient - from azure.communication.chat import CommunicationUserCredential - chat_thread_client = ChatThreadClient(self.endpoint, CommunicationUserCredential(self.token), self._thread_id) + from azure.communication.chat import CommunicationTokenCredential + chat_thread_client = ChatThreadClient(self.endpoint, CommunicationTokenCredential(self.token), self._thread_id) # [START list_members] chat_thread_members = chat_thread_client.list_members() print("list_chat_members succeeded, members: ") @@ -176,8 +176,8 @@ def list_members(self): # [END list_members] def add_members(self): - from azure.communication.chat import ChatThreadClient, CommunicationUserCredential - chat_thread_client = ChatThreadClient(self.endpoint, CommunicationUserCredential(self.token), self._thread_id) + from azure.communication.chat import ChatThreadClient, CommunicationTokenCredential + chat_thread_client = ChatThreadClient(self.endpoint, CommunicationTokenCredential(self.token), self._thread_id) # [START add_members] from azure.communication.chat import ChatThreadMember @@ -193,8 +193,8 @@ def add_members(self): def remove_member(self): from azure.communication.chat import ChatThreadClient - from azure.communication.chat import CommunicationUserCredential, CommunicationUser - chat_thread_client = ChatThreadClient(self.endpoint, CommunicationUserCredential(self.token), self._thread_id) + from azure.communication.chat import CommunicationTokenCredential, CommunicationUser + chat_thread_client = ChatThreadClient(self.endpoint, CommunicationTokenCredential(self.token), self._thread_id) # [START remove_member] chat_thread_client.remove_member(self.new_user) @@ -203,8 +203,8 @@ def remove_member(self): print("remove_chat_member succeeded") def send_typing_notification(self): - from azure.communication.chat import ChatThreadClient, CommunicationUserCredential - chat_thread_client = ChatThreadClient(self.endpoint, CommunicationUserCredential(self.token), self._thread_id) + from azure.communication.chat import ChatThreadClient, CommunicationTokenCredential + chat_thread_client = ChatThreadClient(self.endpoint, CommunicationTokenCredential(self.token), self._thread_id) # [START send_typing_notification] chat_thread_client.send_typing_notification() # [END send_typing_notification] diff --git a/sdk/communication/azure-communication-chat/samples/chat_thread_client_sample_async.py b/sdk/communication/azure-communication-chat/samples/chat_thread_client_sample_async.py index 0333e0427e38..1dec7847314c 100644 --- a/sdk/communication/azure-communication-chat/samples/chat_thread_client_sample_async.py +++ b/sdk/communication/azure-communication-chat/samples/chat_thread_client_sample_async.py @@ -49,10 +49,10 @@ class ChatThreadClientSamplesAsync(object): async def create_chat_thread_client_async(self): # [START create_chat_thread_client] from datetime import datetime - from azure.communication.chat.aio import ChatClient, CommunicationUserCredential + from azure.communication.chat.aio import ChatClient, CommunicationTokenCredential from azure.communication.chat import ChatThreadMember, CommunicationUserIdentifier - chat_client = ChatClient(self.endpoint, CommunicationUserCredential(self.token)) + chat_client = ChatClient(self.endpoint, CommunicationTokenCredential(self.token)) async with chat_client: topic = "test topic" @@ -68,8 +68,8 @@ async def create_chat_thread_client_async(self): print("thread created, id: " + self._thread_id) async def update_thread_async(self): - from azure.communication.chat.aio import ChatThreadClient, CommunicationUserCredential - chat_thread_client = ChatThreadClient(self.endpoint, CommunicationUserCredential(self.token), self._thread_id) + from azure.communication.chat.aio import ChatThreadClient, CommunicationTokenCredential + chat_thread_client = ChatThreadClient(self.endpoint, CommunicationTokenCredential(self.token), self._thread_id) async with chat_thread_client: # [START update_thread] @@ -80,8 +80,8 @@ async def update_thread_async(self): print("update_thread succeeded") async def send_message_async(self): - from azure.communication.chat.aio import ChatThreadClient, CommunicationUserCredential - chat_thread_client = ChatThreadClient(self.endpoint, CommunicationUserCredential(self.token), self._thread_id) + from azure.communication.chat.aio import ChatThreadClient, CommunicationTokenCredential + chat_thread_client = ChatThreadClient(self.endpoint, CommunicationTokenCredential(self.token), self._thread_id) async with chat_thread_client: # [START send_message] @@ -100,8 +100,8 @@ async def send_message_async(self): print("send_message succeeded, message id:", self._message_id) async def get_message_async(self): - from azure.communication.chat.aio import ChatThreadClient, CommunicationUserCredential - chat_thread_client = ChatThreadClient(self.endpoint, CommunicationUserCredential(self.token), self._thread_id) + from azure.communication.chat.aio import ChatThreadClient, CommunicationTokenCredential + chat_thread_client = ChatThreadClient(self.endpoint, CommunicationTokenCredential(self.token), self._thread_id) async with chat_thread_client: # [START get_message] @@ -111,8 +111,8 @@ async def get_message_async(self): "content: ", chat_message.content) async def list_messages_async(self): - from azure.communication.chat.aio import ChatThreadClient, CommunicationUserCredential - chat_thread_client = ChatThreadClient(self.endpoint, CommunicationUserCredential(self.token), self._thread_id) + from azure.communication.chat.aio import ChatThreadClient, CommunicationTokenCredential + chat_thread_client = ChatThreadClient(self.endpoint, CommunicationTokenCredential(self.token), self._thread_id) async with chat_thread_client: # [START list_messages] @@ -126,8 +126,8 @@ async def list_messages_async(self): # [END list_messages] async def update_message_async(self): - from azure.communication.chat.aio import ChatThreadClient, CommunicationUserCredential - chat_thread_client = ChatThreadClient(self.endpoint, CommunicationUserCredential(self.token), self._thread_id) + from azure.communication.chat.aio import ChatThreadClient, CommunicationTokenCredential + chat_thread_client = ChatThreadClient(self.endpoint, CommunicationTokenCredential(self.token), self._thread_id) async with chat_thread_client: # [START update_message] @@ -137,8 +137,8 @@ async def update_message_async(self): print("update_message succeeded") async def send_read_receipt_async(self): - from azure.communication.chat.aio import ChatThreadClient, CommunicationUserCredential - chat_thread_client = ChatThreadClient(self.endpoint, CommunicationUserCredential(self.token), self._thread_id) + from azure.communication.chat.aio import ChatThreadClient, CommunicationTokenCredential + chat_thread_client = ChatThreadClient(self.endpoint, CommunicationTokenCredential(self.token), self._thread_id) async with chat_thread_client: # [START send_read_receipt] @@ -148,8 +148,8 @@ async def send_read_receipt_async(self): print("send_read_receipt succeeded") async def list_read_receipts_async(self): - from azure.communication.chat.aio import ChatThreadClient, CommunicationUserCredential - chat_thread_client = ChatThreadClient(self.endpoint, CommunicationUserCredential(self.token), self._thread_id) + from azure.communication.chat.aio import ChatThreadClient, CommunicationTokenCredential + chat_thread_client = ChatThreadClient(self.endpoint, CommunicationTokenCredential(self.token), self._thread_id) async with chat_thread_client: # [START list_read_receipts] @@ -160,8 +160,8 @@ async def list_read_receipts_async(self): print(read_receipt) async def delete_message_async(self): - from azure.communication.chat.aio import ChatThreadClient, CommunicationUserCredential - chat_thread_client = ChatThreadClient(self.endpoint, CommunicationUserCredential(self.token), self._thread_id) + from azure.communication.chat.aio import ChatThreadClient, CommunicationTokenCredential + chat_thread_client = ChatThreadClient(self.endpoint, CommunicationTokenCredential(self.token), self._thread_id) async with chat_thread_client: # [START delete_message] @@ -170,8 +170,8 @@ async def delete_message_async(self): print("delete_message succeeded") async def list_members_async(self): - from azure.communication.chat.aio import ChatThreadClient, CommunicationUserCredential - chat_thread_client = ChatThreadClient(self.endpoint, CommunicationUserCredential(self.token), self._thread_id) + from azure.communication.chat.aio import ChatThreadClient, CommunicationTokenCredential + chat_thread_client = ChatThreadClient(self.endpoint, CommunicationTokenCredential(self.token), self._thread_id) async with chat_thread_client: # [START list_members] @@ -182,8 +182,8 @@ async def list_members_async(self): # [END list_members] async def add_members_async(self): - from azure.communication.chat.aio import ChatThreadClient, CommunicationUserCredential - chat_thread_client = ChatThreadClient(self.endpoint, CommunicationUserCredential(self.token), self._thread_id) + from azure.communication.chat.aio import ChatThreadClient, CommunicationTokenCredential + chat_thread_client = ChatThreadClient(self.endpoint, CommunicationTokenCredential(self.token), self._thread_id) async with chat_thread_client: # [START add_members] @@ -199,8 +199,8 @@ async def add_members_async(self): print("add_members succeeded") async def remove_member_async(self): - from azure.communication.chat.aio import ChatThreadClient, CommunicationUserCredential - chat_thread_client = ChatThreadClient(self.endpoint, CommunicationUserCredential(self.token), self._thread_id) + from azure.communication.chat.aio import ChatThreadClient, CommunicationTokenCredential + chat_thread_client = ChatThreadClient(self.endpoint, CommunicationTokenCredential(self.token), self._thread_id) async with chat_thread_client: # [START remove_member] @@ -209,8 +209,8 @@ async def remove_member_async(self): print("remove_member_async succeeded") async def send_typing_notification_async(self): - from azure.communication.chat.aio import ChatThreadClient, CommunicationUserCredential - chat_thread_client = ChatThreadClient(self.endpoint, CommunicationUserCredential(self.token), self._thread_id) + from azure.communication.chat.aio import ChatThreadClient, CommunicationTokenCredential + chat_thread_client = ChatThreadClient(self.endpoint, CommunicationTokenCredential(self.token), self._thread_id) async with chat_thread_client: # [START send_typing_notification] diff --git a/sdk/communication/azure-communication-chat/tests/test_chat_client.py b/sdk/communication/azure-communication-chat/tests/test_chat_client.py index cc84ce3fdab9..b38c1936aace 100644 --- a/sdk/communication/azure-communication-chat/tests/test_chat_client.py +++ b/sdk/communication/azure-communication-chat/tests/test_chat_client.py @@ -13,7 +13,7 @@ ChatClient, ChatThreadMember, CommunicationUserIdentifier, - CommunicationUserCredential + CommunicationTokenCredential ) from unittest_helpers import mock_response from datetime import datetime @@ -26,7 +26,7 @@ class TestChatClient(unittest.TestCase): @classmethod - @patch('azure.communication.chat.CommunicationUserCredential') + @patch('azure.communication.chat.CommunicationTokenCredential') def setUpClass(cls, credential): credential.get_token = Mock(return_value=AccessToken("some_token", datetime.now().replace(tzinfo=TZ_UTC))) TestChatClient.credential = credential diff --git a/sdk/communication/azure-communication-chat/tests/test_chat_client_async.py b/sdk/communication/azure-communication-chat/tests/test_chat_client_async.py index edcd76ac9e62..2a409042748f 100644 --- a/sdk/communication/azure-communication-chat/tests/test_chat_client_async.py +++ b/sdk/communication/azure-communication-chat/tests/test_chat_client_async.py @@ -6,7 +6,7 @@ from azure.core.credentials import AccessToken from azure.communication.chat.aio import ( ChatClient, - CommunicationUserCredential + CommunicationTokenCredential ) from azure.communication.chat import ( ChatThreadMember, diff --git a/sdk/communication/azure-communication-chat/tests/test_chat_client_e2e.py b/sdk/communication/azure-communication-chat/tests/test_chat_client_e2e.py index 194878492270..57970249e001 100644 --- a/sdk/communication/azure-communication-chat/tests/test_chat_client_e2e.py +++ b/sdk/communication/azure-communication-chat/tests/test_chat_client_e2e.py @@ -13,7 +13,7 @@ from azure.communication.administration import CommunicationIdentityClient from azure.communication.chat import ( ChatClient, - CommunicationUserCredential, + CommunicationTokenCredential, ChatThreadMember ) from azure.communication.chat._shared.utils import parse_connection_str @@ -48,7 +48,7 @@ def setUp(self): self.token = tokenresponse.token # create ChatClient - self.chat_client = ChatClient(self.endpoint, CommunicationUserCredential(self.token)) + self.chat_client = ChatClient(self.endpoint, CommunicationTokenCredential(self.token)) def tearDown(self): super(ChatClientTest, self).tearDown() diff --git a/sdk/communication/azure-communication-chat/tests/test_chat_client_e2e_async.py b/sdk/communication/azure-communication-chat/tests/test_chat_client_e2e_async.py index 289998c7a290..1fdc7590a2ed 100644 --- a/sdk/communication/azure-communication-chat/tests/test_chat_client_e2e_async.py +++ b/sdk/communication/azure-communication-chat/tests/test_chat_client_e2e_async.py @@ -12,7 +12,7 @@ from azure.communication.administration import CommunicationIdentityClient from azure.communication.chat.aio import ( ChatClient, - CommunicationUserCredential + CommunicationTokenCredential ) from azure.communication.chat import ( ChatThreadMember @@ -46,7 +46,7 @@ def setUp(self): self.token = token_response.token # create ChatClient - self.chat_client = ChatClient(self.endpoint, CommunicationUserCredential(self.token)) + self.chat_client = ChatClient(self.endpoint, CommunicationTokenCredential(self.token)) def tearDown(self): super(ChatClientTestAsync, self).tearDown() diff --git a/sdk/communication/azure-communication-chat/tests/test_chat_thread_client.py b/sdk/communication/azure-communication-chat/tests/test_chat_thread_client.py index 1a349a7ebaf3..b3cc8f3b4dfd 100644 --- a/sdk/communication/azure-communication-chat/tests/test_chat_thread_client.py +++ b/sdk/communication/azure-communication-chat/tests/test_chat_thread_client.py @@ -14,7 +14,7 @@ ChatMessagePriority, ChatThreadMember, CommunicationUserIdentifier, - CommunicationUserCredential + CommunicationTokenCredential ) from unittest_helpers import mock_response @@ -25,7 +25,7 @@ class TestChatThreadClient(unittest.TestCase): @classmethod - @patch('azure.communication.chat.CommunicationUserCredential') + @patch('azure.communication.chat.CommunicationTokenCredential') def setUpClass(cls, credential): credential.get_token = Mock(return_value=AccessToken("some_token", datetime.now().replace(tzinfo=TZ_UTC))) TestChatThreadClient.credential = credential diff --git a/sdk/communication/azure-communication-chat/tests/test_chat_thread_client_e2e.py b/sdk/communication/azure-communication-chat/tests/test_chat_thread_client_e2e.py index afe9b51b7594..87a1a797da29 100644 --- a/sdk/communication/azure-communication-chat/tests/test_chat_thread_client_e2e.py +++ b/sdk/communication/azure-communication-chat/tests/test_chat_thread_client_e2e.py @@ -13,7 +13,7 @@ from azure.communication.administration import CommunicationIdentityClient from azure.communication.chat import ( ChatClient, - CommunicationUserCredential, + CommunicationTokenCredential, ChatThreadMember, ChatMessagePriority ) @@ -51,7 +51,7 @@ def setUp(self): self.new_user = self.identity_client.create_user() # create ChatClient - self.chat_client = ChatClient(self.endpoint, CommunicationUserCredential(self.token)) + self.chat_client = ChatClient(self.endpoint, CommunicationTokenCredential(self.token)) def tearDown(self): super(ChatThreadClientTest, self).tearDown() diff --git a/sdk/communication/azure-communication-chat/tests/test_chat_thread_client_e2e_async.py b/sdk/communication/azure-communication-chat/tests/test_chat_thread_client_e2e_async.py index fb23f51bf83d..a4cf235bfae0 100644 --- a/sdk/communication/azure-communication-chat/tests/test_chat_thread_client_e2e_async.py +++ b/sdk/communication/azure-communication-chat/tests/test_chat_thread_client_e2e_async.py @@ -12,7 +12,7 @@ from azure.communication.administration import CommunicationIdentityClient from azure.communication.chat.aio import ( ChatClient, - CommunicationUserCredential + CommunicationTokenCredential ) from azure.communication.chat import ( ChatThreadMember, @@ -50,7 +50,7 @@ def setUp(self): self.new_user = self.identity_client.create_user() # create ChatClient - self.chat_client = ChatClient(self.endpoint, CommunicationUserCredential(self.token)) + self.chat_client = ChatClient(self.endpoint, CommunicationTokenCredential(self.token)) def tearDown(self): super(ChatThreadClientTestAsync, self).tearDown() diff --git a/sdk/communication/azure-communication-sms/azure/communication/sms/_shared/user_credential.py b/sdk/communication/azure-communication-sms/azure/communication/sms/_shared/user_credential.py index c27a32369185..73b494b8ccf3 100644 --- a/sdk/communication/azure-communication-sms/azure/communication/sms/_shared/user_credential.py +++ b/sdk/communication/azure-communication-sms/azure/communication/sms/_shared/user_credential.py @@ -13,7 +13,7 @@ from msrest.serialization import TZ_UTC from .utils import create_access_token -class CommunicationUserCredential(object): +class CommunicationTokenCredential(object): """Credential type used for authenticating to an Azure Communication service. :param str token: The token used to authenticate to an Azure Communication service :raises: TypeError diff --git a/sdk/communication/azure-communication-sms/azure/communication/sms/_shared/user_credential_async.py b/sdk/communication/azure-communication-sms/azure/communication/sms/_shared/user_credential_async.py index 1c9b2318aa09..710c9948c839 100644 --- a/sdk/communication/azure-communication-sms/azure/communication/sms/_shared/user_credential_async.py +++ b/sdk/communication/azure-communication-sms/azure/communication/sms/_shared/user_credential_async.py @@ -13,7 +13,7 @@ from msrest.serialization import TZ_UTC from .utils import create_access_token -class CommunicationUserCredential(object): +class CommunicationTokenCredential(object): """Credential type used for authenticating to an Azure Communication service. :param str token: The token used to authenticate to an Azure Communication service :raises: TypeError