diff --git a/api/apps/apps.py b/api/apps/apps.py new file mode 100644 index 0000000..da3a787 --- /dev/null +++ b/api/apps/apps.py @@ -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) diff --git a/api/apps/installactions.py b/api/apps/installactions.py new file mode 100644 index 0000000..a039858 --- /dev/null +++ b/api/apps/installactions.py @@ -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: + :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) + diff --git a/api/issues/issues.py b/api/issues/issues.py index 892e955..59470de 100644 --- a/api/issues/issues.py +++ b/api/issues/issues.py @@ -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) + + diff --git a/api/repositories/repositories.py b/api/repositories/repositories.py index 31c735e..ce09f96 100644 --- a/api/repositories/repositories.py +++ b/api/repositories/repositories.py @@ -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) + diff --git a/github.py b/github.py index edb7c1c..d64abc3 100644 --- a/github.py +++ b/github.py @@ -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): @@ -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) +