Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor doc updates #17546

Merged
merged 2 commits into from
Mar 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions sdk/communication/azure-communication-chat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def decide_to_retry(error, **kwargs):
return True

retry = [thread_participant for thread_participant, error in create_chat_thread_result.errors if decide_to_retry(error)]
if len(retry) > 0:
if retry:
chat_thread_client.add_participants(retry)
```

Expand All @@ -263,10 +263,8 @@ An iterator of `[ChatThreadItem]` is the response returned from listing threads

```python
from datetime import datetime, timedelta
import pytz

start_time = datetime.utcnow() - timedelta(days=2)
start_time = start_time.replace(tzinfo=pytz.utc)

chat_threads = chat_client.list_chat_threads(results_per_page=5, start_time=start_time)
for chat_thread_item_page in chat_threads.by_page():
Expand Down Expand Up @@ -358,10 +356,8 @@ An iterator of `[ChatMessage]` is the response returned from listing messages

```Python
from datetime import datetime, timedelta
import pytz

start_time = datetime.utcnow() - timedelta(days=1)
start_time = start_time.replace(tzinfo=pytz.utc)

chat_messages = chat_thread_client.list_messages(results_per_page=1, start_time=start_time)
for chat_message_page in chat_messages.by_page():
Expand Down Expand Up @@ -464,7 +460,8 @@ def decide_to_retry(error, **kwargs):
# verify if all users has been successfully added or not
# in case of partial failures, you can retry to add all the failed participants
retry = [p for p, e in response if decide_to_retry(e)]
chat_thread_client.add_participants(retry)
if retry:
chat_thread_client.add_participants(retry)
```

### Remove thread participant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ChatClient(object):
"""A client to interact with the AzureCommunicationService Chat gateway.

This client provides operations to create chat thread, delete chat thread,
get chat thread by id, list chat threads, create chat thread client.
get chat thread client by thread id, list chat threads.

:param str endpoint:
The endpoint of the Azure Communication resource.
Expand Down Expand Up @@ -108,7 +108,7 @@ def get_chat_thread_client(
:end-before: [END get_chat_thread_client]
:language: python
:dedent: 8
:caption: Creating the ChatThreadClient from an existing chat thread id.
:caption: Retrieving the ChatThreadClient from an existing chat thread id.
"""
if not thread_id:
raise ValueError("thread_id cannot be None.")
Expand All @@ -133,9 +133,9 @@ def create_chat_thread(
:keyword thread_participants: Optional. Participants to be added to the thread.
:paramtype thread_participants: List[~azure.communication.chat.ChatThreadParticipant]
:keyword idempotency_token: Optional. If specified, the client directs that the request is
repeatable; that is, that the client can make the request multiple times with the same
Repeatability-Request-ID and get back an appropriate response without the server executing the
request multiple times. The value of the Repeatability-Request-ID is an opaque string
repeatable; that is, the client can make the request multiple times with the same
Idempotency_Token and get back an appropriate response without the server executing the
request multiple times. The value of the Idempotency_Token is an opaque string
representing a client-generated, globally unique for all time, identifier for the request. If not
specified, a new unique id would be generated.
:paramtype idempotency_token: str
Expand All @@ -150,7 +150,7 @@ def create_chat_thread(
:end-before: [END create_thread]
:language: python
:dedent: 8
:caption: Creating ChatThread by creating a new chat thread.
:caption: Creating a new chat thread.
"""
if not topic:
raise ValueError("topic cannot be None.")
Expand Down Expand Up @@ -211,7 +211,7 @@ def list_chat_threads(
:end-before: [END list_threads]
:language: python
:dedent: 8
:caption: listing chat threads.
:caption: Listing chat threads.
"""
results_per_page = kwargs.pop("results_per_page", None)
start_time = kwargs.pop("start_time", None)
Expand All @@ -228,7 +228,7 @@ def delete_chat_thread(
**kwargs # type: Any
):
# type: (...) -> None
"""Deletes a thread.
"""Deletes a chat thread.

:param thread_id: Required. Thread id to delete.
:type thread_id: str
Expand All @@ -243,7 +243,7 @@ def delete_chat_thread(
:end-before: [END delete_thread]
:language: python
:dedent: 8
:caption: deleting chat thread.
:caption: Deleting a chat thread.
"""
if not thread_id:
raise ValueError("thread_id cannot be None.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@

class ChatThreadClient(object):
"""A client to interact with the AzureCommunicationService Chat gateway.
Instances of this class is normally created by ChatClient.create_chat_thread()
Instances of this class is normally retrieved by ChatClient.get_chat_thread_client()

This client provides operations to add participant to chat thread, remove participant from
This client provides operations to add participant(s) to chat thread, remove participant from
chat thread, send message, delete message, update message, send typing notifications,
send and list read receipt

Expand Down Expand Up @@ -138,7 +138,7 @@ def get_properties(
:end-before: [END get_thread]
:language: python
:dedent: 8
:caption: Getting a chat thread by thread id.
:caption: Retrieving chat thread properties by chat thread id.
"""

chat_thread = self._client.chat_thread.get_chat_thread_properties(self._thread_id, **kwargs)
Expand All @@ -154,7 +154,7 @@ def update_topic(
# type: (...) -> None
"""Updates a thread's properties.

:param topic: Thread topic. If topic is not specified, the update will succeeded but
:param topic: Thread topic. If topic is not specified, the update will succeed but
chat thread properties will not be changed.
:type topic: str
:return: None
Expand Down Expand Up @@ -184,7 +184,7 @@ def send_read_receipt(
**kwargs # type: Any
):
# type: (...) -> None
"""Posts a read receipt event to a thread, on behalf of a user.
"""Posts a read receipt event to a chat thread, on behalf of a user.

:param message_id: Required. Id of the latest message read by current user.
:type message_id: str
Expand Down Expand Up @@ -262,7 +262,7 @@ def send_typing_notification(
:end-before: [END send_typing_notification]
:language: python
:dedent: 8
:caption: Sending typing notification.
:caption: Send typing notification.
"""
return self._client.chat_thread.send_typing_notification(self._thread_id, **kwargs)

Expand All @@ -277,11 +277,11 @@ def send_message(

:param content: Required. Chat message content.
:type content: str
:keyword chat_message_type: The chat message type. Possible values include: "text", "html".
Default: ChatMessageType.TEXT
:keyword chat_message_type:
The chat message type. Possible values include: "text", "html". Default: ChatMessageType.TEXT
:paramtype chat_message_type: Union[str, ~azure.communication.chat.ChatMessageType]
:keyword str sender_display_name: The display name of the message sender. This property is used to
populate sender name for push notifications.
populate sender name for push notifications.
:return: SendChatMessageResult
:rtype: ~azure.communication.chat.SendChatMessageResult
:raises: ~azure.core.exceptions.HttpResponseError, ValueError
Expand Down Expand Up @@ -348,7 +348,7 @@ def get_message(
:end-before: [END get_message]
:language: python
:dedent: 8
:caption: Getting a message by message id.
:caption: Retrieving a message by message id.
"""
if not message_id:
raise ValueError("message_id cannot be None.")
Expand Down Expand Up @@ -416,7 +416,7 @@ def update_message(
:end-before: [END update_message]
:language: python
:dedent: 8
:caption: Updating a sent messages.
:caption: Updating an already sent message.
"""
if not message_id:
raise ValueError("message_id cannot be None.")
Expand Down Expand Up @@ -451,7 +451,7 @@ def delete_message(
:end-before: [END delete_message]
:language: python
:dedent: 8
:caption: Deleting a messages.
:caption: Deleting a message.
"""
if not message_id:
raise ValueError("message_id cannot be None.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
class ChatClient(object):
"""A client to interact with the AzureCommunicationService Chat gateway.

This client provides operations to create a chat thread, delete a chat thread,
get chat thread by id, list chat threads.
This client provides operations to create chat thread, delete chat thread,
get chat thread client by thread id, list chat threads.

:param str endpoint:
The endpoint of the Azure Communication resource.
Expand Down Expand Up @@ -113,7 +113,7 @@ def get_chat_thread_client(
:end-before: [END get_chat_thread_client]
:language: python
:dedent: 8
:caption: Creating the ChatThreadClient from an existing chat thread id.
:caption: Retrieving the ChatThreadClient from an existing chat thread id.
"""
if not thread_id:
raise ValueError("thread_id cannot be None.")
Expand All @@ -140,9 +140,9 @@ async def create_chat_thread(
:keyword thread_participants: Optional. Participants to be added to the thread.
:paramtype thread_participants: List[~azure.communication.chat.ChatThreadParticipant]
:keyword idempotency_token: Optional. If specified, the client directs that the request is
repeatable; that is, that the client can make the request multiple times with the same
Repeatability-Request-ID and get back an appropriate response without the server executing the
request multiple times. The value of the Repeatability-Request-ID is an opaque string
repeatable; that is, the client can make the request multiple times with the same
Idempotency_Token and get back an appropriate response without the server executing the
request multiple times. The value of the Idempotency_Token is an opaque string
representing a client-generated, globally unique for all time, identifier for the request. If not
specified, a new unique id would be generated.
:paramtype idempotency_token: str
Expand All @@ -157,7 +157,7 @@ async def create_chat_thread(
:end-before: [END create_thread]
:language: python
:dedent: 12
:caption: Creating ChatThreadClient by creating a new chat thread.
:caption: Creating a new chat thread.
"""
if not topic:
raise ValueError("topic cannot be None.")
Expand Down Expand Up @@ -218,7 +218,7 @@ def list_chat_threads(
:end-before: [END list_threads]
:language: python
:dedent: 12
:caption: listing chat threads.
:caption: Listing chat threads.
"""
results_per_page = kwargs.pop("results_per_page", None)
start_time = kwargs.pop("start_time", None)
Expand All @@ -234,7 +234,7 @@ async def delete_chat_thread(
thread_id: str,
**kwargs
) -> None:
"""Deletes a thread.
"""Deletes a chat thread.

:param thread_id: Required. Thread id to delete.
:type thread_id: str
Expand All @@ -249,7 +249,7 @@ async def delete_chat_thread(
:end-before: [END delete_thread]
:language: python
:dedent: 12
:caption: deleting chat thread.
:caption: Deleting a chat thread.
"""
if not thread_id:
raise ValueError("thread_id cannot be None.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@

class ChatThreadClient(object):
"""A client to interact with the AzureCommunicationService Chat gateway.
Instances of this class is normally created by ChatClient.create_chat_thread()
Instances of this class is normally retrieved by ChatClient.get_chat_thread_client()

This client provides operations to add participant to chat thread, remove participant from
This client provides operations to add participant(s) to chat thread, remove participant from
chat thread, send message, delete message, update message, send typing notifications,
send and list read receipt

Expand Down Expand Up @@ -136,7 +136,7 @@ async def get_properties(
:end-before: [END get_thread]
:language: python
:dedent: 12
:caption: Getting a chat thread by thread id.
:caption: Retrieving chat thread properties by chat thread id.
"""

chat_thread = await self._client.chat_thread.get_chat_thread_properties(self._thread_id, **kwargs)
Expand All @@ -151,7 +151,7 @@ async def update_topic(
) -> None:
"""Updates a thread's properties.

:param topic: Thread topic. If topic is not specified, the update will succeeded but
:param topic: Thread topic. If topic is not specified, the update will succeed but
chat thread properties will not be changed.
:type topic: str
:return: None
Expand Down Expand Up @@ -180,7 +180,7 @@ async def send_read_receipt(
message_id: str,
**kwargs
) -> None:
"""Posts a read receipt event to a thread, on behalf of a user.
"""Posts a read receipt event to a chat thread, on behalf of a user.

:param message_id: Required. Id of the latest message read by current user.
:type message_id: str
Expand Down Expand Up @@ -256,7 +256,7 @@ async def send_typing_notification(
:end-before: [END send_typing_notification]
:language: python
:dedent: 12
:caption: Sending typing notification.
:caption: Send typing notification.
"""
return await self._client.chat_thread.send_typing_notification(self._thread_id, **kwargs)

Expand All @@ -270,11 +270,11 @@ async def send_message(

:param content: Required. Chat message content.
:type content: str
:keyword chat_message_type: The chat message type. Possible values include: "text", "html".
Default: ChatMessageType.TEXT
:keyword chat_message_type:
The chat message type. Possible values include: "text", "html". Default: ChatMessageType.TEXT
:paramtype chat_message_type: Union[str, ~azure.communication.chat.ChatMessageType]
:keyword str sender_display_name: The display name of the message sender. This property is used to
populate sender name for push notifications.
populate sender name for push notifications.
:return: SendChatMessageResult
:rtype: ~azure.communication.chat.SendChatMessageResult
:raises: ~azure.core.exceptions.HttpResponseError, ValueError
Expand Down Expand Up @@ -340,7 +340,7 @@ async def get_message(
:end-before: [END get_message]
:language: python
:dedent: 12
:caption: Getting a message by message id.
:caption: Retrieving a message by message id.
"""
if not message_id:
raise ValueError("message_id cannot be None.")
Expand Down Expand Up @@ -404,7 +404,7 @@ async def update_message(
:end-before: [END update_message]
:language: python
:dedent: 12
:caption: Updating a sent messages.
:caption: Updating an already sent message.
"""
if not message_id:
raise ValueError("message_id cannot be None.")
Expand Down Expand Up @@ -438,7 +438,7 @@ async def delete_message(
:end-before: [END delete_message]
:language: python
:dedent: 12
:caption: Deleting a messages.
:caption: Deleting a message.
"""
if not message_id:
raise ValueError("message_id cannot be None.")
Expand Down
Loading