Skip to content

Commit 3dd990c

Browse files
committed
add "permission" param to repo.add_collaborator
1 parent c4b1ee9 commit 3dd990c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/github3/repos/repo.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,16 @@ def _create_pull(self, data):
118118
return self._instance_or_null(pulls.ShortPullRequest, json)
119119

120120
@decorators.requires_auth
121-
def add_collaborator(self, username):
121+
def add_collaborator(self, username, permission=None):
122122
"""Add ``username`` as a collaborator to a repository.
123123
124124
:param username:
125125
(required), username of the user
126126
:type username:
127127
str or :class:`~github3.users.User`
128+
:param str permission:
129+
(optional), permission to grant the collaborator, valid on organization repositories only
130+
Can be 'pull', 'triage', 'push', 'maintain', 'admin' or an organization-defined custom role name.
128131
:returns:
129132
True if successful, False otherwise
130133
:rtype:
@@ -134,7 +137,12 @@ def add_collaborator(self, username):
134137
url = self._build_url(
135138
"collaborators", str(username), base_url=self._api
136139
)
137-
return self._boolean(self._put(url), 201, 404)
140+
if permission:
141+
data = {"permission": permission}
142+
resp = self._put(url, data=jsonlib.dumps(data))
143+
else:
144+
resp = self._put(url)
145+
return self._boolean(resp, 201, 404)
138146

139147
def archive(self, format, path="", ref="master"):
140148
"""Get the tarball or zipball archive for this repo at ref.

0 commit comments

Comments
 (0)