Skip to content

Commit cf690e3

Browse files
authored
Merge pull request #742 from Gunnine/task_543
完成8.Interactions接口#543-#549
2 parents fe0878b + c98df9a commit cf690e3

File tree

4 files changed

+73
-0
lines changed

4 files changed

+73
-0
lines changed

api/interactions/interactions.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from core.rest_client import RestClient
2+
from api.interactions.orgs import Orgs
3+
from api.interactions.repos import Repos
4+
5+
6+
class Interactions(RestClient):
7+
"""
8+
https://developer.github.com/v3/interactions/#interactions
9+
"""
10+
11+
def __init__(self, api_root_url, **kwargs):
12+
super(Interactions, self).__init__(api_root_url, **kwargs)
13+
self.orgs = Orgs(self.api_root_url, **kwargs)
14+
self.repos = Repos(self.api_root_url, **kwargs)

api/interactions/orgs.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from core.rest_client import RestClient
2+
3+
4+
class Orgs(RestClient):
5+
def __init__(self):
6+
self.headers = {'Accept': 'application/vnd.github.sombra-preview'}
7+
8+
def get_interactions_limits_for_org(self, org, **kwargs):
9+
"""
10+
https://developer.github.com/v3/interactions/orgs/#get-interaction-restrictions-for-an-organization
11+
:param org: organization name
12+
"""
13+
return self.get('/orgs/{}/interaction-limits'.format(org), headers=self.headers, **kwargs)
14+
15+
def update_interactions_limits_for_org(self, org, **kwargs):
16+
"""
17+
https://developer.github.com/v3/interactions/orgs#add-or-update-interaction-restrictions-for-an-organization
18+
:param org: organization name
19+
"""
20+
return self.put('/orgs/{}/interaction-limits'.format(org), headers=self.headers, **kwargs)
21+
22+
def remove_interaction_restrictions_for_org(self, org, **kwargs):
23+
"""
24+
https://developer.github.com/v3/interactions/orgs#remove-interaction-restrictions-for-an-organization
25+
:param org: organization name
26+
"""
27+
return self.delete('/orgs/{}/interaction-limits'.format(org), headers=self.headers, **kwargs)

api/interactions/repos.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from core.rest_client import RestClient
2+
3+
4+
class Repos(RestClient):
5+
def __init__(self):
6+
self.headers = {'Accept': 'application/vnd.github.sombra-preview'}
7+
8+
def get_interaction_restrictions_for_repo(self, owner, **kwargs):
9+
"""
10+
https://developer.github.com/v3/interactions/repos#get-interaction-restrictions-for-a-repository
11+
:param owner: organization owner
12+
"""
13+
return self.get('/repos/{}/:repo/interaction-limits'.format(owner), headers=self.headers, **kwargs)
14+
15+
def update_interaction_restrictions_for_repo(self, owner, repo, **kwargs):
16+
"""
17+
https://developer.github.com/v3/interactions/repos/#add-or-update-interaction-restrictions-for-a-repository
18+
:param owner: organization owner
19+
:param repo: repository
20+
"""
21+
return self.put('/repos/{}/{}/interaction-limits'.format(owner, repo), headers=self.headers, **kwargs)
22+
23+
def remove_interaction_restrictions_for_repo(self, owner, repo, **kwargs):
24+
"""
25+
https://developer.github.com/v3/interactions/repos/#remove-interaction-restrictions-for-a-repository
26+
:param owner: organization owner
27+
:param repo: repository
28+
"""
29+
return self.delete('/repos/{}/{}/interaction-limits'.format(owner, repo), header=self.headers, **kwargs)

github.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
from api.repositories.repos import Repos
22
from api.issues.issues import Issues
33
from api.checks.checks import Checks
4+
from api.interactions.interactions import Interactions
5+
46

57
class Github():
68
def __init__(self, **kwargs):
79
self.api_root_url = "https://api.github.com"
810
self.repos = Repos(self.api_root_url, **kwargs)
911
self.issues = Issues(self.api_root_url, **kwargs)
1012
self.checks = Checks(self.api_root_url, **kwargs)
13+
self.interactions = Interactions(self.api_root_url, **kwargs)

0 commit comments

Comments
 (0)