From e32d4800a66751aa2e51a023af43ed71fbb31087 Mon Sep 17 00:00:00 2001 From: RTa-technology Date: Fri, 10 Jun 2022 11:46:39 +0900 Subject: [PATCH 1/7] add: Github Actions --- .github/workflows/python-publish.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/python-publish.yml diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml new file mode 100644 index 0000000..6bf16a9 --- /dev/null +++ b/.github/workflows/python-publish.yml @@ -0,0 +1,28 @@ +# https://github.com/kentaroy47/ODA-Object-Detection-ttA/blob/main/.github/workflows/python-publish.yml +name: Upload Python Package + +on: + release: + types: [created] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + # ソース配布型 + python setup.py sdist bdist_wheel + twine upload dist/* \ No newline at end of file From 9ad7ae0d04d82a18bcd09607607f905ca00ff7c5 Mon Sep 17 00:00:00 2001 From: RTa <57354947+RTa-technology@users.noreply.github.com> Date: Sat, 11 Jun 2022 10:28:33 +0900 Subject: [PATCH 2/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9c52da8..daf89fe 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![GitHub stars](https://img.shields.io/github/stars/RTa-technology/githubapps.py)](https://github.com/RTa-technology/githubapps.py/stargazers) [![PyPI version](https://badge.fury.io/py/githubapps.py.svg)](https://badge.fury.io/py/githubapps.py) [![Python Versions](https://img.shields.io/pypi/pyversions/githubapps.py.svg)](https://pypi.org/project/githubapps.py/) -[![Downloads](https://pepy.tech/badge/githubapps-py?period=total&units=international_system&left_color=grey&right_color=orange&left_text=Downloads)](https://pepy.tech/project/githubapps-py) +[![Downloads](https://pepy.tech/badge/githubapps-py)](https://pepy.tech/project/githubapps-py) A Python wrapper for the Github Apps API From 15a70834ecc45b0ce14ae92f770ff4826c61088e Mon Sep 17 00:00:00 2001 From: RTa <57354947+RTa-technology@users.noreply.github.com> Date: Sun, 12 Jun 2022 16:32:32 +0900 Subject: [PATCH 3/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index daf89fe..6b6915e 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![GitHub stars](https://img.shields.io/github/stars/RTa-technology/githubapps.py)](https://github.com/RTa-technology/githubapps.py/stargazers) [![PyPI version](https://badge.fury.io/py/githubapps.py.svg)](https://badge.fury.io/py/githubapps.py) [![Python Versions](https://img.shields.io/pypi/pyversions/githubapps.py.svg)](https://pypi.org/project/githubapps.py/) -[![Downloads](https://pepy.tech/badge/githubapps-py)](https://pepy.tech/project/githubapps-py) +[![Downloads](https://static.pepy.tech/personalized-badge/githubapps-py?period=total&units=abbreviation&left_color=grey&right_color=blue&left_text=Downloads)](https://pepy.tech/project/githubapps-py) A Python wrapper for the Github Apps API From 9fced6002eb6b04bd7a92a1f7de6f3214ec318f9 Mon Sep 17 00:00:00 2001 From: RTa <57354947+RTa-technology@users.noreply.github.com> Date: Tue, 14 Jun 2022 11:48:39 +0900 Subject: [PATCH 4/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6b6915e..20d7b85 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![GitHub stars](https://img.shields.io/github/stars/RTa-technology/githubapps.py)](https://github.com/RTa-technology/githubapps.py/stargazers) [![PyPI version](https://badge.fury.io/py/githubapps.py.svg)](https://badge.fury.io/py/githubapps.py) [![Python Versions](https://img.shields.io/pypi/pyversions/githubapps.py.svg)](https://pypi.org/project/githubapps.py/) -[![Downloads](https://static.pepy.tech/personalized-badge/githubapps-py?period=total&units=abbreviation&left_color=grey&right_color=blue&left_text=Downloads)](https://pepy.tech/project/githubapps-py) +[![Downloads](https://pepy.tech/badge/githubapps-py)](https://pepy.tech/project/githubapps-py?period=total) A Python wrapper for the Github Apps API From 3484129d81225783ad012fbc0cbbe761ed048593 Mon Sep 17 00:00:00 2001 From: RTa <57354947+RTa-technology@users.noreply.github.com> Date: Tue, 14 Jun 2022 12:01:27 +0900 Subject: [PATCH 5/7] Create dependabot.yml --- .github/dependabot.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..35a0200 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "daily" + From ae1cfa1da5e21ce81122e24b1375ed9bcacb8810 Mon Sep 17 00:00:00 2001 From: RTa <57354947+RTa-technology@users.noreply.github.com> Date: Tue, 14 Jun 2022 12:02:52 +0900 Subject: [PATCH 6/7] Update dependabot.yml --- .github/dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 35a0200..2cbc359 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,7 +5,7 @@ version: 2 updates: - - package-ecosystem: "" # See documentation for possible values + - package-ecosystem: "pip" # See documentation for possible values directory: "/" # Location of package manifests schedule: interval: "daily" From b7317feb923ac75bc67c75a1c432d42e095ae109 Mon Sep 17 00:00:00 2001 From: RTa-technology Date: Thu, 23 Jun 2022 14:32:06 +0900 Subject: [PATCH 7/7] add: get installation_id --- githubapps/adapter.py | 73 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 3 deletions(-) diff --git a/githubapps/adapter.py b/githubapps/adapter.py index 90a69e0..98076b5 100644 --- a/githubapps/adapter.py +++ b/githubapps/adapter.py @@ -321,11 +321,43 @@ def get_access_token(self, *, access_token_response: Optional[Union[list, dict]] access_token_response = self.get_access_token_response() return access_token_response["token"] - def get_usage(self) -> None: - return None + def get_installation_id(self, *, _jwt: bytes = None, perPage:int = None, page:int=None, since: datetime=None, outdated: str=None, **kwargs) -> Optional[Union[list, dict]]: + + installation_id_endpoint = "https://api.github.com/app/installations" + if _jwt is None: + _jwt = self.gen_jwt() + endpointparsed = urllib.urlparse(installation_id_endpoint) + endpointquery = urllib.parse.parse_qs(endpointparsed.query) + + if perPage is not None: + endpointquery["per_page"] = perPage + if page is not None: + endpointquery["page"] = page + if since is not None: + endpointquery["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ") + if outdated is not None: + endpointquery["outdated"] = outdated + endpointencoded = urllib.parse.urlencode(endpointquery, doseq=True) + endpoint = urllib.parse.ParseResult(endpointparsed.scheme, endpointparsed.netloc, endpointparsed.path, endpointparsed.params, endpointencoded, endpointparsed.fragment).geturl() + + headers = { + 'Accept': 'application/vnd.github.v3+json', + 'Authorization': 'Bearer {}'.format(_jwt), + } + + req_access_token = requests.get( + url=endpoint, headers=headers) + try: + data = req_access_token.json() + except json.JSONDecodeError: + print(req_access_token.content) + return data + def get_usage(self) -> None: + return None + class AiohttpAuth(Authentication): """Researchmap authentication interface. @@ -567,5 +599,40 @@ async def get_access_token(self, *, access_token_response: Optional[Union[list, access_token_response = await self.get_access_token_response() return access_token_response["token"] + + async def get_installation_id(self, *, _jwt: bytes = None, perPage:int = None, page:int=None, since: datetime=None, outdated: str=None, **kwargs) -> Optional[Union[list, dict]]: + + installation_id_endpoint = "https://api.github.com/app/installations" + if _jwt is None: + _jwt = self.gen_jwt() + + endpointparsed = urllib.urlparse(installation_id_endpoint) + endpointquery = urllib.parse.parse_qs(endpointparsed.query) + + if perPage is not None: + endpointquery["per_page"] = perPage + if page is not None: + endpointquery["page"] = page + if since is not None: + endpointquery["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ") + if outdated is not None: + endpointquery["outdated"] = outdated + endpointencoded = urllib.parse.urlencode(endpointquery, doseq=True) + endpoint = urllib.parse.ParseResult(endpointparsed.scheme, endpointparsed.netloc, endpointparsed.path, endpointparsed.params, endpointencoded, endpointparsed.fragment).geturl() + + headers = { + 'Accept': 'application/vnd.github.v3+json', + 'Authorization': 'Bearer {}'.format(_jwt), + } + + async with httpx.AsyncClient() as client: + req_access_token = await client.get( + url=endpoint, headers=headers) + try: + data = req_access_token.json() + except json.JSONDecodeError: + print(req_access_token.content) + return data + def get_usage(self) -> None: - return None + return None \ No newline at end of file