Skip to content

Conversation

@sarkar-rajarshi
Copy link
Member

No description provided.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The snippets will need a bit more context than this (and this applies to other existing snippets in the readme).
The goal is that a user should be able to copy+paste the code and use it right away.
So something more like:

client = ChatClient(...)
thread = client.get_chat_thread_client(...)
thread.get_properties(...)

Given that this applies to multiple snippets throughout the readme - I'm happy if you want to open a github issue to address it in a subsequent PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will update the README and the samples in a separate PR

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add_participants should be a no-op if passed an empty list, so a user should be able to do:

chat_thread_client.add_participants([p for p, error in create_chat_thread_result.errors if decide_to_retry(error)])

Additionally, if you need to check that a list has 0 elements, you can just do this in python:

need_to_retry = [p for p, error in create_chat_thread_result.errors if decide_to_retry(error)]
if need_to_retry:
    chat_thread_client.add_participants(need_to_retry)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add_participants has been updated to be no-op if passed empty list. Will update the README and the samples in a separate PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe "Gets the properties of the chat thread."?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under what circumstances is ValueError raised? Unless it's something specific that users need to be aware of and code for, we can just remove this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a miss. It does not throw ValueError in any scenario. This sneaked in when transferring the method from chat_client :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the typehint should be something like:

from typing import List, Tuple
List[Tuple[ChatThreadParticipant, ChatError]]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this is what you already had in the docstring :return: value :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It used to show up as a flag in apiview before. Have refactored this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is a bug in autorest or swagger spec - but I think this should be returning an Iterable["_models.ChatThreadItem"].
It doesn't really matter in the generated code, so long as we've confirmed that the hand-written layer over the top is doing the right thing :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an autorest thing. It is exposed as ItemPaged[ChatThreadItem] to the outside world.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we refactored out this CommunicationTokenRefreshOptions object

Copy link
Member Author

@sarkar-rajarshi sarkar-rajarshi Mar 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. The changes were in a dangling state in a separate PR #17178 . It's been merged.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The credentials objects should just be imported from azure.communication.chat now right?

Copy link
Member Author

@sarkar-rajarshi sarkar-rajarshi Mar 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. The changes were in a dangling state in a separate PR #17178 . It's been merged.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this marked live test only?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to use mock responses here? Is there some reason the recording wont work?

@sarkar-rajarshi
Copy link
Member Author

/azp run python - communication - tests

@azure-pipelines
Copy link

Azure Pipelines could not run because the pipeline triggers exclude this branch/path.

@sarkar-rajarshi sarkar-rajarshi changed the base branch from feature/communication-chat-preview5 to master March 18, 2021 19:43
@sarkar-rajarshi
Copy link
Member Author

/azp run python - communication - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

* make CommunicationUserIdentifierSerializer private

* CommunicationTokenCredential + AccessToken fix
- Initialize CommunicationTokenCredential with token and not with CommunicationTokenRefreshOptions
- Convert AccessToken.expires_on to int as compared to datetime

* add token_refresher to CommunicationTokenCredential

* update docstring

* Identifier fields renaming _ credential import fixes in sample code
- CommunicationError renamed to ChatError
- Rename method
- Move get_properties from ChatClient to ChatThreadClient
- Change method signature - remove parameter thread_id
- Modify unit and e2e tests - move tests from chat_thread_* to chat_thread_client_*
- Update README.md
- Changes made due to flattening of CreateChatThreadResult and AddChatParticipantsResult
@sarkar-rajarshi
Copy link
Member Author

/azp run python - communication - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@juancamilor juancamilor enabled auto-merge (squash) March 19, 2021 00:08
@juancamilor juancamilor merged commit 388beb9 into Azure:master Mar 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants