Skip to content

[SYNPY-1633] Add membership_status to Team model and Deprecate Old Method - #1235

Merged
linglp merged 17 commits into
developfrom
synpy-1633
Aug 25, 2025
Merged

linglp merged 17 commits into
developfrom
synpy-1633

Conversation

@linglp

@linglp linglp commented Aug 18, 2025

Copy link
Copy Markdown
Contributor

Problem:

This method here needs to be deprecated: synapsePythonClient/synapseclient/client.py at 02d3b38d2a0f043811637064f61ae8b537e4253b · Sage-Bionetworks/synapsePythonClient

Solution:

Added a new method called get_user_membership_status under team

Testing:

  • Ensured that the example in the docstring works
  • Surfaced the new function in documentation
  • Added test

@linglp
linglp requested a review from a team as a code owner August 18, 2025 18:48
Comment thread synapseclient/models/team.py Outdated
Comment on lines +377 to +386
Returns:
A dictionary of TeamMembershipStatus
"""
from synapseclient import Synapse

client = Synapse.get_client(synapse_client=synapse_client)
status = await get_membership_status(
user_id=user_id, team=team, synapse_client=client
)
return status

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since users will call this, can we convert the response from the API call (https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/TeamMembershipStatus.html) into a Dataclass (Similar to what we did with TeamMembers

class TeamMember:
"""
Contains information about a user's membership in a Team.
In practice the constructor is not called directly by the client.
Attributes:
team_id: The ID of the team
member: An object of type [org.sagebionetworks.repo.model.UserGroupHeader](https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/UserGroupHeader.html)
describing the member
is_admin: Whether the given member is an administrator of the team
"""
team_id: Optional[int] = None
"""The ID of the team"""
member: Optional[UserGroupHeader] = None
"""An object of type [org.sagebionetworks.repo.model.UserGroupHeader](https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/UserGroupHeader.html)"""
is_admin: Optional[bool] = None
"""Whether the given member is an administrator of the team"""
def fill_from_dict(
self, synapse_team_member: Union[Synapse_TeamMember, Dict[str, str]]
) -> "TeamMember":
self.team_id = (
int(synapse_team_member.get("teamId", None))
if synapse_team_member.get("teamId", None)
else None
)
self.member = UserGroupHeader().fill_from_dict(
synapse_team_member.get("member", None)
)
self.is_admin = synapse_team_member.get("isAdmin", None)
return self
)

This will ensure that anyone calling this Method knows exactly what to expect from both the mkdocs page AND within the IDE via the hoverdocs.

Comment thread synapseclient/client.py Outdated

@BryanFauble BryanFauble left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Swap to Dataclass for return from method for better user experience

Comment thread synapseclient/client.py Outdated
@linglp
linglp requested a review from BryanFauble August 21, 2025 21:19
Comment thread synapseclient/models/team.py
Comment thread synapseclient/models/team.py
Comment thread synapseclient/models/team.py
Comment thread synapseclient/client.py Outdated

@BryanFauble BryanFauble left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is great! I had a few comments, but nothing that changes the functionality of what was proposed.

@linglp
linglp merged commit 5a5f989 into develop Aug 25, 2025
37 of 45 checks passed
@linglp
linglp deleted the synpy-1633 branch August 25, 2025 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants