diff --git a/endpoints/api/permission_models_interface.py b/endpoints/api/permission_models_interface.py index 40bba3039..1e541d2a5 100644 --- a/endpoints/api/permission_models_interface.py +++ b/endpoints/api/permission_models_interface.py @@ -74,38 +74,135 @@ class TeamPermission(namedtuple('TeamPermission', [ @add_metaclass(ABCMeta) class PermissionDataInterface(object): + """ + Data interface used by permissions API + """ + @abstractmethod def get_repo_permissions_by_user(self, namespace_name, repository_name): - pass + """ + + Args: + namespace_name: string + repository_name: string + + Returns: + list(UserPermission) + """ @abstractmethod def get_repo_roles(self, username, namespace_name, repository_name): - pass + """ + + Args: + username: string + namespace_name: string + repository_name: string + + Returns: + list(Role) or None + """ @abstractmethod def get_repo_permission_for_user(self, username, namespace_name, repository_name): - pass + """ + + Args: + username: string + namespace_name: string + repository_name: string + + Returns: + UserPermission + """ @abstractmethod def set_repo_permission_for_user(self, username, namespace_name, repository_name, role_name): - pass + """ + + Args: + username: string + namespace_name: string + repository_name: string + role_name: string + + Returns: + UserPermission + + Raises: + SaveException + """ @abstractmethod def delete_repo_permission_for_user(self, username, namespace_name, repository_name): - pass + """ + + Args: + username: string + namespace_name: string + repository_name: string + + Returns: + void + + Raises: + DeleteException + """ @abstractmethod def get_repo_permissions_by_team(self, namespace_name, repository_name): - pass + """ + + Args: + namespace_name: string + repository_name: string + + Returns: + list(TeamPermission) + """ @abstractmethod def get_repo_role_for_team(self, team_name, namespace_name, repository_name): - pass + """ + + Args: + team_name: string + namespace_name: string + repository_name: string + + Returns: + Role + """ @abstractmethod def set_repo_permission_for_team(self, team_name, namespace_name, repository_name, permission): - pass + """ + + Args: + team_name: string + namespace_name: string + repository_name: string + permission: string + + Returns: + TeamPermission + + Raises: + SaveException + """ @abstractmethod def delete_repo_permission_for_team(self, team_name, namespace_name, repository_name): - pass \ No newline at end of file + """ + + Args: + team_name: string + namespace_name: string + repository_name: string + + Returns: + TeamPermission + + Raises: + DeleteException + """ \ No newline at end of file diff --git a/endpoints/api/permission_models_pre_oci.py b/endpoints/api/permission_models_pre_oci.py index 07cee95ef..1f19cad10 100644 --- a/endpoints/api/permission_models_pre_oci.py +++ b/endpoints/api/permission_models_pre_oci.py @@ -30,10 +30,8 @@ class PreOCIModel(PermissionDataInterface): return user.robot or user.username in org_members - return [self._user_permission(perm, org is not None, is_org_member(perm.user)) for perm in repo_perms] - def get_repo_roles(self, username, namespace_name, repository_name): user = model.user.get_user(username) if not user: @@ -98,7 +96,6 @@ class PreOCIModel(PermissionDataInterface): except model.DataModelException as ex: raise DeleteException(ex) - def _role(self, permission_obj): return Role(role_name=permission_obj.role.name) @@ -115,4 +112,4 @@ class PreOCIModel(PermissionDataInterface): team_name=permission_obj.team.name, avatar=avatar.get_data_for_team(permission_obj.team)) -pre_oci_model = PreOCIModel() \ No newline at end of file +pre_oci_model = PreOCIModel()