@@ -118,13 +118,16 @@ def _create_pull(self, data):
118
118
return self ._instance_or_null (pulls .ShortPullRequest , json )
119
119
120
120
@decorators .requires_auth
121
- def add_collaborator (self , username ):
121
+ def add_collaborator (self , username , permission = None ):
122
122
"""Add ``username`` as a collaborator to a repository.
123
123
124
124
:param username:
125
125
(required), username of the user
126
126
:type username:
127
127
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.
128
131
:returns:
129
132
True if successful, False otherwise
130
133
:rtype:
@@ -134,7 +137,12 @@ def add_collaborator(self, username):
134
137
url = self ._build_url (
135
138
"collaborators" , str (username ), base_url = self ._api
136
139
)
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 )
138
146
139
147
def archive (self , format , path = "" , ref = "master" ):
140
148
"""Get the tarball or zipball archive for this repo at ref.
0 commit comments