mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-02 03:41:08 +00:00
Add support for get_app() with App authentication (#2549)
Moves `Github.get_app()` called without `slug` parameter into `GithubIntegration`, because it needs an `AppAuth`, and we collect all such endpoints there. Calling `Github.get_app()` without `slug` parameter is now deprecated. Replaces `datetime.utcnow()` with `datetime.now(timezone.utc)`, as it is deprecated in Python 3.12.
This commit is contained in:
@@ -4,6 +4,7 @@ import deprecated
|
||||
|
||||
from github import Consts
|
||||
from github.Auth import AppAuth
|
||||
from github.GithubApp import GithubApp
|
||||
from github.GithubException import GithubException
|
||||
from github.Installation import Installation
|
||||
from github.InstallationAuthorization import InstallationAuthorization
|
||||
@@ -71,7 +72,10 @@ class GithubIntegration:
|
||||
jwt_algorithm=jwt_algorithm,
|
||||
)
|
||||
|
||||
assert auth is not None
|
||||
assert isinstance(
|
||||
auth, AppAuth
|
||||
), f"GithubIntegration requires github.Auth.AppAuth authentication, not {type(auth)}"
|
||||
|
||||
self.auth = auth
|
||||
|
||||
self.__requester = Requester(
|
||||
@@ -213,3 +217,16 @@ class GithubIntegration:
|
||||
:rtype: :class:`github.Installation.Installation`
|
||||
"""
|
||||
return self._get_installed_app(url=f"/app/installations/{installation_id}")
|
||||
|
||||
def get_app(self):
|
||||
"""
|
||||
:calls: `GET /app <https://docs.github.com/en/rest/reference/apps#get-the-authenticated-app>`_
|
||||
:rtype: :class:`github.GithubApp.GithubApp`
|
||||
"""
|
||||
|
||||
headers, data = self.__requester.requestJsonAndCheck(
|
||||
"GET", "/app", headers=self._get_headers()
|
||||
)
|
||||
return GithubApp(
|
||||
requester=self.__requester, headers=headers, attributes=data, completed=True
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user