mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 19:01:15 +00:00
* Add new Team.update_team_repository() * Mark Team.set_repo_permission() as deprecated Fixes #1507
This commit is contained in:
@@ -41,6 +41,8 @@
|
||||
# #
|
||||
################################################################################
|
||||
|
||||
from deprecated import deprecated
|
||||
|
||||
import github.GithubObject
|
||||
import github.NamedUser
|
||||
import github.Organization
|
||||
@@ -252,6 +254,11 @@ class Team(github.GithubObject.CompletableGithubObject):
|
||||
except UnknownObjectException:
|
||||
return None
|
||||
|
||||
@deprecated(
|
||||
reason="""
|
||||
Team.set_repo_permission() is deprecated, use Team.update_team_repository() instead.
|
||||
"""
|
||||
)
|
||||
def set_repo_permission(self, repo, permission):
|
||||
"""
|
||||
:calls: `PUT /teams/:id/repos/:org/:repo <http://developer.github.com/v3/orgs/teams>`_
|
||||
@@ -259,6 +266,7 @@ class Team(github.GithubObject.CompletableGithubObject):
|
||||
:param permission: string
|
||||
:rtype: None
|
||||
"""
|
||||
|
||||
assert isinstance(repo, github.Repository.Repository), repo
|
||||
put_parameters = {
|
||||
"permission": permission,
|
||||
@@ -267,6 +275,30 @@ class Team(github.GithubObject.CompletableGithubObject):
|
||||
"PUT", self.url + "/repos/" + repo._identity, input=put_parameters
|
||||
)
|
||||
|
||||
def update_team_repository(self, repo, permission):
|
||||
"""
|
||||
:calls: `PUT /orgs/:org/teams/:team_slug/repos/:owner/:repo <https://developer.github.com/v3/teams/#add-or-update-team-repository-permissions>`_
|
||||
:param repo: string or :class:`github.Repository.Repository`
|
||||
:param permission: string
|
||||
:rtype: bool
|
||||
"""
|
||||
assert isinstance(repo, github.Repository.Repository) or isinstance(
|
||||
repo, str
|
||||
), repo
|
||||
assert isinstance(permission, str), permission
|
||||
repo_url_param = repo
|
||||
if isinstance(repo, github.Repository.Repository):
|
||||
repo_url_param = repo._identity
|
||||
put_parameters = {
|
||||
"permission": permission,
|
||||
}
|
||||
status, _, _ = self._requester.requestJson(
|
||||
"PUT",
|
||||
self.organization.url + "/teams/" + self.slug + "/repos/" + repo_url_param,
|
||||
input=put_parameters,
|
||||
)
|
||||
return status == 204
|
||||
|
||||
def delete(self):
|
||||
"""
|
||||
:calls: `DELETE /teams/:id <http://developer.github.com/v3/orgs/teams>`_
|
||||
|
||||
@@ -18,5 +18,5 @@ None
|
||||
None
|
||||
200
|
||||
[('status', '200 OK'), ('x-ratelimit-remaining', '4975'), ('content-length', '145'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"03555a65309084f36bcf959063a39d35"'), ('date', 'Sat, 26 May 2012 21:09:52 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
{"repos_count":0,"url":"https://api.github.com/teams/189850","members_count":0,"name":"Team created by PyGithub","privacy":"closed","permission":"pull","id":189850,"organization":{"login":"BeaverSoftware","id":1424031,"url":"https://api.github.com/orgs/BeaverSoftware"}}
|
||||
{"repos_count":0,"url":"https://api.github.com/teams/189850","members_count":0,"name":"Team created by PyGithub","slug": "pygithub","privacy":"closed","permission":"pull","id":189850,"organization":{"login":"BeaverSoftware","id":1424031,"url":"https://api.github.com/orgs/BeaverSoftware"}}
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
https
|
||||
GET
|
||||
api.github.com
|
||||
None
|
||||
/repos/BeaverSoftware/FatherBeaver
|
||||
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
None
|
||||
200
|
||||
[('Date', 'Thu, 07 May 2020 12:39:27 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Server', 'GitHub.com'), ('Status', '200 OK'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4971'), ('X-RateLimit-Reset', '1588858091'), ('Cache-Control', 'private, max-age=60, s-maxage=60'), ('Vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With'), ('ETag', 'W/"d0c102425dbcce281d1fec14c70d888d"'), ('Last-Modified', 'Thu, 07 May 2020 12:25:17 GMT'), ('X-OAuth-Scopes', 'admin:org, repo'), ('X-Accepted-OAuth-Scopes', 'repo'), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '1; mode=block'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Content-Encoding', 'gzip')]
|
||||
{"name":"FatherBeaver","full_name":"BeaverSoftware/FatherBeaver","private":false,"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},"html_url":"https://github.com/BeaverSoftware/FatherBeaver","description":"","fork":false,"url":"https://api.github.com/repos/BeaverSoftware/FatherBeaver","created_at":"2012-02-09T19:32:21Z","updated_at":"2012-02-16T21:51:15Z","svn_url":"https://github.com/BeaverSoftware/FatherBeaver","git_url":"git://github.com/BeaverSoftware/FatherBeaver.git","ssh_url":"git@github.com:BeaverSoftware/FatherBeaver.git","clone_url":"https://github.com/BeaverSoftware/FatherBeaver.git","homepage":"","size":0,"mirror_url":null,"has_downloads":true,"watchers":2,"permissions":{"pull":true,"admin":true,"push":true},"has_wiki":true,"has_issues":true,"forks":1,"open_issues":0,"language":null,"pushed_at":null,"id":3400397,"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}}
|
||||
|
||||
https
|
||||
PUT
|
||||
api.github.com
|
||||
None
|
||||
/orgs/BeaverSoftware/teams/pygithub/repos/BeaverSoftware/FatherBeaver
|
||||
{"Authorization": "Basic login_and_password_removed", "Content-Type": "application/json", "User-Agent": "PyGithub/Python"}
|
||||
{"permission": "admin"}
|
||||
204
|
||||
[]
|
||||
@@ -123,6 +123,10 @@ class Team(Framework.TestCase):
|
||||
repo = self.org.get_repo("FatherBeaver")
|
||||
self.team.set_repo_permission(repo, "admin")
|
||||
|
||||
def testUpdateTeamRepository(self):
|
||||
repo = self.org.get_repo("FatherBeaver")
|
||||
self.assertTrue(self.team.update_team_repository(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