Skip to content

Feature namelaowang #750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions api/apps/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from core.rest_client import RestClient
from api.apps.installactions import Installation


class Apps(RestClient):
def __init__(self, api_root_url, **kwargs):
super(Apps, self).__init__(api_root_url, **kwargs)
self.installaction = Installation(self.api_root_url, **kwargs)

def create_gitHub_app_from_a_manifest(self, code, **kwargs):
"""
https://developer.github.com/v3/apps/#create-a-github-app-from-a-manifest
"""
return self.post("/app-manifests/{}/conversions".format(code), **kwargs)

def get_a_user_installation(self, username, **kwargs):
"""
https://developer.github.com/v3/apps/#get-a-user-installation
"""
headers = {'Accept': 'application/vnd.github.machine-man-preview+json'}
return self.get("/users/{}/installation".format(username), headers=headers, **kwargs)
29 changes: 29 additions & 0 deletions api/apps/installactions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from core.rest_client import RestClient


class Installation(RestClient):
def list_repositories(self, **kwargs):
"""
https://developer.github.com/v3/apps/installations/#list-repositories
:param kwargs:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

要么不写param,要么写全,写个参数名字不加解释是不对的。

:return:
"""
headers = {'Accept': 'application/vnd.github.machine-man-preview+json'}
return self.get("/installation/repositories", headers=headers, **kwargs)

def list_installations_for_a_user(self, **kwargs):
"""
https://developer.github.com/v3/apps/installations/#list-installations-for-a-user
:param kwargs:
:return:
"""
headers = {'Accept': 'application/vnd.github.machine-man-preview+json'}
return self.get("/user/installations", headers=headers, **kwargs)

def add_repository_to_installation(self, installation_id, repository_id, **kwargs):
"""
https://developer.github.com/v3/apps/installations/#add-repository-to-installation
"""
headers = {'Accept': 'application/vnd.github.machine-man-preview+json'}
return self.put("/user/installations/{}/repositories/{}".format(installation_id, repository_id), headers = headers, **kwargs)

9 changes: 9 additions & 0 deletions api/issues/issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,12 @@ def create_issue(self, owner, repo, **kwargs):
https://developer.github.com/v3/issues/#create-an-issue
"""
return self.post("/repos/{}/{}/issues".format(owner, repo), **kwargs)

def list_issue(self, **kwargs):
"""
https://developer.github.com/v3/issues/#list-issues
"""
header = {'Accept': 'application/vnd.github.machine-man-preview'}
return self.get("/issues", headers=header, **kwargs)


6 changes: 6 additions & 0 deletions api/repositories/repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ def transfer_a_repository(self, owner, repo, **kwargs):
headers = {'Accept':'application/vnd.github.nightshade-preview+json'}
return self.delete('/repos/{}/{}/transfer'.format(owner, repo), headers = headers ,**kwargs)

def list_teams(self, owner, repo, **kwargs):
"""
https://developer.github.com/v3/repos/#list-teams
"""
return self.get("/repos/{}/{}/teams".format(owner, repo), **kwargs)




Expand Down
4 changes: 3 additions & 1 deletion github.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from api.issues.issues import Issues
from api.checks.checks import Checks
from api.interactions.interactions import Interactions

from api.apps.apps import Apps

class Github():
def __init__(self, **kwargs):
Expand All @@ -11,3 +11,5 @@ def __init__(self, **kwargs):
self.issues = Issues(self.api_root_url, **kwargs)
self.checks = Checks(self.api_root_url, **kwargs)
self.interactions = Interactions(self.api_root_url, **kwargs)
self.apps = Apps(self.api_root_url, **kwargs)