From 4832523e1a50cb9648e6ea4fb5ac556d14be9bb5 Mon Sep 17 00:00:00 2001 From: unknown <1014422757@qq.com> Date: Sat, 25 Apr 2020 12:15:47 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=88=9B=E5=BB=BAapps=E5=92=8Cinstallation?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/apps/apps.py | 21 +++++++++++++++++++++ api/apps/installactions.py | 21 +++++++++++++++++++++ github.py | 4 +++- 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 api/apps/apps.py create mode 100644 api/apps/installactions.py diff --git a/api/apps/apps.py b/api/apps/apps.py new file mode 100644 index 0000000..a0fb921 --- /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 + """ + header = {'Accept': 'application/vnd.github.machine-man-preview+json'} + return self.get("/users/{}/installation".format(username), **kwargs) diff --git a/api/apps/installactions.py b/api/apps/installactions.py new file mode 100644 index 0000000..50a7c76 --- /dev/null +++ b/api/apps/installactions.py @@ -0,0 +1,21 @@ +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: + """ + header = {'Accept': 'application/vnd.github.machine-man-preview+json'} + return self.get("/installation/repositories", headers=header, **kwargs) + + def list_installations_for_a_user(self, **kwargs): + """ + https://developer.github.com/v3/apps/installations/#list-installations-for-a-user + :param kwargs: + :return: + """ + header = {'Accept': 'application/vnd.github.machine-man-preview+json'} + return self.get("/user/installations", headers=header, **kwargs) \ No newline at end of file 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) + From ef39a604e04d1c0e8a6b7d0b48b44c6debad88e9 Mon Sep 17 00:00:00 2001 From: unknown <1014422757@qq.com> Date: Sat, 25 Apr 2020 12:37:00 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9apps.py=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/apps/apps.py | 4 ++-- api/apps/installactions.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/api/apps/apps.py b/api/apps/apps.py index a0fb921..da3a787 100644 --- a/api/apps/apps.py +++ b/api/apps/apps.py @@ -17,5 +17,5 @@ def get_a_user_installation(self, username, **kwargs): """ https://developer.github.com/v3/apps/#get-a-user-installation """ - header = {'Accept': 'application/vnd.github.machine-man-preview+json'} - return self.get("/users/{}/installation".format(username), **kwargs) + 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 index 50a7c76..9cbc497 100644 --- a/api/apps/installactions.py +++ b/api/apps/installactions.py @@ -8,8 +8,8 @@ def list_repositories(self, **kwargs): :param kwargs: :return: """ - header = {'Accept': 'application/vnd.github.machine-man-preview+json'} - return self.get("/installation/repositories", headers=header, **kwargs) + 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): """ @@ -17,5 +17,5 @@ def list_installations_for_a_user(self, **kwargs): :param kwargs: :return: """ - header = {'Accept': 'application/vnd.github.machine-man-preview+json'} - return self.get("/user/installations", headers=header, **kwargs) \ No newline at end of file + headers = {'Accept': 'application/vnd.github.machine-man-preview+json'} + return self.get("/user/installations", headers=headers, **kwargs) \ No newline at end of file From c8c184abf1c991fe88f284ce6dc1643320862879 Mon Sep 17 00:00:00 2001 From: unknown <1014422757@qq.com> Date: Sat, 25 Apr 2020 22:33:51 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=AE=8C=E6=88=90#563=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/apps/installactions.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/api/apps/installactions.py b/api/apps/installactions.py index 9cbc497..a039858 100644 --- a/api/apps/installactions.py +++ b/api/apps/installactions.py @@ -18,4 +18,12 @@ def list_installations_for_a_user(self, **kwargs): :return: """ headers = {'Accept': 'application/vnd.github.machine-man-preview+json'} - return self.get("/user/installations", headers=headers, **kwargs) \ No newline at end of file + 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) + From 5b2f7217a8fd5010655183c5114d0b203b480f22 Mon Sep 17 00:00:00 2001 From: namelaowang <1014422757@qq.com> Date: Sun, 26 Apr 2020 14:41:38 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=9C=80=E6=B1=82502?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/issues/issues.py | 9 +++++++++ 1 file changed, 9 insertions(+) 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) + + From e00ea436efdbba9999b98b61af6070b559ff042a Mon Sep 17 00:00:00 2001 From: namelaowang <1014422757@qq.com> Date: Thu, 30 Apr 2020 16:36:24 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=9C=80=E6=B1=82#131?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/repositories/repositories.py | 6 ++++++ 1 file changed, 6 insertions(+) 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) +