-
Notifications
You must be signed in to change notification settings - Fork 68
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
[SYNPY-1302] add method to implement get entity permission api #1026
[SYNPY-1302] add method to implement get entity permission api #1026
Conversation
Hello @danlu1! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
|
is_entity_open_data: bool = None | ||
"""(Read Only) Returns true if the Entity's DateType equals 'OPEN_DATA', indicating that the data is safe to be released to the public.""" | ||
|
||
def __init__(self, data: dict): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is how we should create an instance of this class. The reason is that if you are overriding the init dunder method than it prevent you from creating a Permissions instance like:
my_other_permissions = Permissions(can_view=True)
print(my_other_permissions)
This might make more sense:
@classmethod
def from_dict(cls, data: dict) -> "Permissions":
"""
Convert a data dictory to an instance of this dataclass.
"""
return cls(
can_view=data["canView"],
can_edit=data["canEdit"],
can_move=data["canMove"],
can_add_child=data["canAddChild"],
can_certified_user_edit=data["canCertifiedUserEdit"],
can_certified_user_add_child=data["canCertifiedUserAddChild"],
is_certified_user=data["isCertifiedUser"],
can_change_permissions=data["canChangePermissions"],
can_change_settings=data["canChangeSettings"],
can_delete=data["canDelete"],
can_download=data["canDownload"],
can_upload=data["canUpload"],
can_enable_inheritance=data["canEnableInheritance"],
owner_principal_id=data["ownerPrincipalId"],
can_public_read=data["canPublicRead"],
can_moderate=data["canModerate"],
is_certification_required=data["isCertificationRequired"],
is_entity_open_data=data["isEntityOpenData"],
)
In the get_permissions
function:
return Permissions.from_dict(data)
Thoughts?
Quality Gate passedThe SonarCloud Quality Gate passed, but some issues were introduced. 24 New issues |
@danlu1 Something for when you are back in the office after the holidays. I had missed this originally, but since this is running on the fork of the main Please raise a PR from within the main repo instead of a fork. I'll be working to update our documentation to mention these changes. This does not change external collaborators who are still required to work from a fork. |
What do you all think about completing these changes here first due to all the comments that have been made? Then create a feature branch in SYNPY to merge this branch into which can then be merged into develop. |
Great plan! Let's keep the changes and discussion here and move it over when it's ready so we can see all the pre-merge checks. |
Closed in favor of new PR. |
Problem:
The original
getPermission
method uses /acl endpoint only that shows inconsistent behavior in the case of publicly downloadable content from Synapse.Solution:
create a
get_permissions
method that implements GET /entity/{id}/permissions API. These API factors in the entity's ACL and the user's group membership when determining the caller's permission to the entity.Example:
Testing:
Unit tests and integration tests are included in the PR.