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:
Steve Kowalik
2018-08-27 13:23:03 +08:00
committed by Wan Liuyang
parent 6732517c1d
commit 7b099c9800
4 changed files with 48 additions and 0 deletions
+15
View File
@@ -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>`_