mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 19:01:15 +00:00
Merge pull request #454 from mattjmorrison/add-team-repo-permissions
Add ability to set permission for team repo
This commit is contained in:
@@ -149,6 +149,23 @@ class Team(github.GithubObject.CompletableGithubObject):
|
||||
self.url + "/repos/" + repo._identity
|
||||
)
|
||||
|
||||
def set_repo_permission(self, repo, permission):
|
||||
"""
|
||||
:calls: `PUT /teams/:id/repos/:org/:repo <http://developer.github.com/v3/orgs/teams>`_
|
||||
:param repo: :class:`github.Repository.Repository`
|
||||
:param permission: string
|
||||
:rtype: None
|
||||
"""
|
||||
assert isinstance(repo, github.Repository.Repository), repo
|
||||
put_parameters = {
|
||||
"permission": permission,
|
||||
}
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PUT",
|
||||
self.url + "/repos/" + repo._identity,
|
||||
input=put_parameters
|
||||
)
|
||||
|
||||
def delete(self):
|
||||
"""
|
||||
:calls: `DELETE /teams/:id <http://developer.github.com/v3/orgs/teams>`_
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
https
|
||||
GET
|
||||
api.github.com
|
||||
None
|
||||
/repos/BeaverSoftware/FatherBeaver
|
||||
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
null
|
||||
200
|
||||
[('status', '200 OK'), ('x-ratelimit-remaining', '4963'), ('content-length', '1431'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"c9b98209a51840e6710aa96cb2e4eb56"'), ('date', 'Sat, 26 May 2012 21:12:35 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
{"organization":{"url":"https://api.github.com/users/BeaverSoftware","avatar_url":"https://secure.gravatar.com/avatar/d563e337cac2fdc644e2aaaad1e23266?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-orgs.png","gravatar_id":"d563e337cac2fdc644e2aaaad1e23266","login":"BeaverSoftware","id":1424031},"clone_url":"https://github.com/BeaverSoftware/FatherBeaver.git","mirror_url":null,"has_downloads":true,"watchers":2,"updated_at":"2012-02-16T21:51:15Z","permissions":{"pull":true,"admin":true,"push":true},"homepage":"","url":"https://api.github.com/repos/BeaverSoftware/FatherBeaver","has_wiki":true,"has_issues":true,"fork":false,"forks":1,"size":0,"private":false,"open_issues":0,"svn_url":"https://github.com/BeaverSoftware/FatherBeaver","git_url":"git://github.com/BeaverSoftware/FatherBeaver.git","owner":{"url":"https://api.github.com/users/BeaverSoftware","avatar_url":"https://secure.gravatar.com/avatar/d563e337cac2fdc644e2aaaad1e23266?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-orgs.png","gravatar_id":"d563e337cac2fdc644e2aaaad1e23266","login":"BeaverSoftware","id":1424031},"name":"FatherBeaver","language":null,"description":"","ssh_url":"git@github.com:BeaverSoftware/FatherBeaver.git","pushed_at":null,"created_at":"2012-02-09T19:32:21Z","id":3400397,"html_url":"https://github.com/BeaverSoftware/FatherBeaver","full_name":"BeaverSoftware/FatherBeaver"}
|
||||
|
||||
https
|
||||
PUT
|
||||
api.github.com
|
||||
None
|
||||
/teams/189850/repos/BeaverSoftware/FatherBeaver
|
||||
{"Authorization": "Basic login_and_password_removed", "Content-Type": "application/json", "User-Agent": "PyGithub/Python"}
|
||||
{"permission": "admin"}
|
||||
204
|
||||
[]
|
||||
{}
|
||||
@@ -55,6 +55,10 @@ class Team(Framework.TestCase):
|
||||
self.assertListKeyEqual(self.team.get_members(), None, [])
|
||||
self.assertFalse(self.team.has_in_members(user))
|
||||
|
||||
def testRepoPermission(self):
|
||||
repo = self.org.get_repo("FatherBeaver")
|
||||
self.team.set_repo_permission(repo, "admin")
|
||||
|
||||
def testRepos(self):
|
||||
repo = self.org.get_repo("FatherBeaver")
|
||||
self.assertListKeyEqual(self.team.get_repos(), None, [])
|
||||
|
||||
Reference in New Issue
Block a user