Adds docstrings for permission api data interface
This commit is contained in:
parent
a68ec6966e
commit
6528c1f3bc
2 changed files with 107 additions and 13 deletions
|
@ -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
|
||||
"""
|
||||
|
||||
Args:
|
||||
team_name: string
|
||||
namespace_name: string
|
||||
repository_name: string
|
||||
|
||||
Returns:
|
||||
TeamPermission
|
||||
|
||||
Raises:
|
||||
DeleteException
|
||||
"""
|
|
@ -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()
|
||||
pre_oci_model = PreOCIModel()
|
||||
|
|
Reference in a new issue