mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-02 03:41:08 +00:00
Implement Repository.get_collaborator_permission (#881)
Add a method to Repository, collaborator_permission that allows users with push access to repositories to query the permission level of collaborators. Fixes #722
This commit is contained in:
committed by
Wan Liuyang
parent
6732517c1d
commit
7b099c9800
@@ -788,6 +788,21 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
return github.Invitation.Invitation(self._requester, headers, data, completed=True) if \
|
||||
data is not None else None
|
||||
|
||||
def get_collaborator_permission(self, collaborator):
|
||||
"""
|
||||
:calls: `GET /repos/:owner/:repo/collaborators/:username/permission <http://developer.github.com/v3/repos/collaborators>`_
|
||||
:param collaborator: string or :class:`github.NamedUser.NamedUser`
|
||||
:rtype: string
|
||||
"""
|
||||
assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance(collaborator, (str, unicode)), collaborator
|
||||
if isinstance(collaborator, github.NamedUser.NamedUser):
|
||||
collaborator = collaborator._identity
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self.url + "/collaborators/" + collaborator + "/permission",
|
||||
)
|
||||
return data["permission"]
|
||||
|
||||
def compare(self, base, head):
|
||||
"""
|
||||
:calls: `GET /repos/:owner/:repo/compare/:base...:head <http://developer.github.com/v3/repos/commits>`_
|
||||
|
||||
Reference in New Issue
Block a user