PyGithub-asyncio 3.0.0b1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. githubasyncio/AccessToken.py +159 -0
  2. githubasyncio/AdvisoryBase.py +163 -0
  3. githubasyncio/AdvisoryCredit.py +131 -0
  4. githubasyncio/AdvisoryCreditDetailed.py +110 -0
  5. githubasyncio/AdvisoryVulnerability.py +191 -0
  6. githubasyncio/AdvisoryVulnerabilityPackage.py +93 -0
  7. githubasyncio/AppAuthentication.py +58 -0
  8. githubasyncio/ApplicationOAuth.py +200 -0
  9. githubasyncio/Artifact.py +183 -0
  10. githubasyncio/Auth.py +560 -0
  11. githubasyncio/AuthenticatedUser.py +1251 -0
  12. githubasyncio/Authorization.py +192 -0
  13. githubasyncio/AuthorizationApplication.py +73 -0
  14. githubasyncio/Autolink.py +104 -0
  15. githubasyncio/Branch.py +689 -0
  16. githubasyncio/BranchProtection.py +224 -0
  17. githubasyncio/CVSS.py +83 -0
  18. githubasyncio/CWE.py +75 -0
  19. githubasyncio/CheckRun.py +315 -0
  20. githubasyncio/CheckRunAnnotation.py +134 -0
  21. githubasyncio/CheckRunOutput.py +108 -0
  22. githubasyncio/CheckSuite.py +319 -0
  23. githubasyncio/Clones.py +97 -0
  24. githubasyncio/CodeScanAlert.py +215 -0
  25. githubasyncio/CodeScanAlertInstance.py +134 -0
  26. githubasyncio/CodeScanAlertInstanceLocation.py +102 -0
  27. githubasyncio/CodeScanRule.py +134 -0
  28. githubasyncio/CodeScanTool.py +94 -0
  29. githubasyncio/CodeSecurityConfig.py +301 -0
  30. githubasyncio/CodeSecurityConfigRepository.py +70 -0
  31. githubasyncio/Commit.py +442 -0
  32. githubasyncio/CommitCombinedStatus.py +126 -0
  33. githubasyncio/CommitComment.py +270 -0
  34. githubasyncio/CommitStats.py +78 -0
  35. githubasyncio/CommitStatus.py +169 -0
  36. githubasyncio/Comparison.py +219 -0
  37. githubasyncio/Consts.py +197 -0
  38. githubasyncio/ContentFile.py +304 -0
  39. githubasyncio/Copilot.py +97 -0
  40. githubasyncio/CopilotSeat.py +132 -0
  41. githubasyncio/DefaultCodeSecurityConfig.py +93 -0
  42. githubasyncio/DependabotAlert.py +184 -0
  43. githubasyncio/DependabotAlertAdvisory.py +82 -0
  44. githubasyncio/DependabotAlertDependency.py +100 -0
  45. githubasyncio/DependabotAlertVulnerability.py +85 -0
  46. githubasyncio/Deployment.py +314 -0
  47. githubasyncio/DeploymentBranchPolicy.py +102 -0
  48. githubasyncio/DeploymentStatus.py +201 -0
  49. githubasyncio/DiscussionBase.py +140 -0
  50. githubasyncio/DiscussionCommentBase.py +140 -0
  51. githubasyncio/Download.py +256 -0
  52. githubasyncio/Enterprise.py +175 -0
  53. githubasyncio/EnterpriseConsumedLicenses.py +138 -0
  54. githubasyncio/Environment.py +354 -0
  55. githubasyncio/EnvironmentDeploymentBranchPolicy.py +87 -0
  56. githubasyncio/EnvironmentProtectionRule.py +117 -0
  57. githubasyncio/EnvironmentProtectionRuleReviewer.py +110 -0
  58. githubasyncio/Event.py +134 -0
  59. githubasyncio/File.py +142 -0
  60. githubasyncio/GeneratedReleaseNotes.py +68 -0
  61. githubasyncio/Gist.py +373 -0
  62. githubasyncio/GistComment.py +162 -0
  63. githubasyncio/GistFile.py +106 -0
  64. githubasyncio/GistHistoryState.py +245 -0
  65. githubasyncio/GitAuthor.py +94 -0
  66. githubasyncio/GitBlob.py +123 -0
  67. githubasyncio/GitCommit.py +208 -0
  68. githubasyncio/GitCommitVerification.py +103 -0
  69. githubasyncio/GitObject.py +84 -0
  70. githubasyncio/GitRef.py +122 -0
  71. githubasyncio/GitRelease.py +476 -0
  72. githubasyncio/GitReleaseAsset.py +232 -0
  73. githubasyncio/GitTag.py +143 -0
  74. githubasyncio/GitTree.py +113 -0
  75. githubasyncio/GitTreeElement.py +104 -0
  76. githubasyncio/GithubApp.py +236 -0
  77. githubasyncio/GithubException.py +226 -0
  78. githubasyncio/GithubIntegration.py +365 -0
  79. githubasyncio/GithubObject.py +910 -0
  80. githubasyncio/GithubRetry.py +253 -0
  81. githubasyncio/GitignoreTemplate.py +88 -0
  82. githubasyncio/GlobalAdvisory.py +141 -0
  83. githubasyncio/Hook.py +238 -0
  84. githubasyncio/HookDelivery.py +243 -0
  85. githubasyncio/HookDescription.py +85 -0
  86. githubasyncio/HookResponse.py +83 -0
  87. githubasyncio/InputFileContent.py +63 -0
  88. githubasyncio/InputGitAuthor.py +71 -0
  89. githubasyncio/InputGitTreeElement.py +79 -0
  90. githubasyncio/Installation.py +298 -0
  91. githubasyncio/InstallationAuthorization.py +138 -0
  92. githubasyncio/Invitation.py +171 -0
  93. githubasyncio/Issue.py +955 -0
  94. githubasyncio/IssueComment.py +309 -0
  95. githubasyncio/IssueDependenciesSummary.py +77 -0
  96. githubasyncio/IssueEvent.py +296 -0
  97. githubasyncio/IssuePullRequest.py +97 -0
  98. githubasyncio/IssueType.py +123 -0
  99. githubasyncio/Label.py +186 -0
  100. githubasyncio/License.py +169 -0
  101. githubasyncio/MainClass.py +1142 -0
  102. githubasyncio/Membership.py +154 -0
  103. githubasyncio/MergedUpstream.py +71 -0
  104. githubasyncio/Migration.py +281 -0
  105. githubasyncio/Milestone.py +255 -0
  106. githubasyncio/NamedEnterpriseUser.py +207 -0
  107. githubasyncio/NamedUser.py +841 -0
  108. githubasyncio/Notification.py +182 -0
  109. githubasyncio/NotificationSubject.py +96 -0
  110. githubasyncio/Organization.py +2462 -0
  111. githubasyncio/OrganizationCodeScanAlert.py +65 -0
  112. githubasyncio/OrganizationCustomProperty.py +215 -0
  113. githubasyncio/OrganizationDependabotAlert.py +75 -0
  114. githubasyncio/OrganizationSecret.py +191 -0
  115. githubasyncio/OrganizationSecretScanAlert.py +112 -0
  116. githubasyncio/OrganizationVariable.py +141 -0
  117. githubasyncio/PaginatedList.py +652 -0
  118. githubasyncio/Path.py +102 -0
  119. githubasyncio/Permissions.py +113 -0
  120. githubasyncio/Plan.py +108 -0
  121. githubasyncio/Project.py +286 -0
  122. githubasyncio/ProjectCard.py +257 -0
  123. githubasyncio/ProjectColumn.py +227 -0
  124. githubasyncio/PublicKey.py +138 -0
  125. githubasyncio/PullRequest.py +1202 -0
  126. githubasyncio/PullRequestComment.py +401 -0
  127. githubasyncio/PullRequestMergeStatus.py +89 -0
  128. githubasyncio/PullRequestPart.py +110 -0
  129. githubasyncio/PullRequestReview.py +214 -0
  130. githubasyncio/Rate.py +123 -0
  131. githubasyncio/RateLimit.py +210 -0
  132. githubasyncio/RateLimitOverview.py +104 -0
  133. githubasyncio/Reaction.py +128 -0
  134. githubasyncio/Referrer.py +94 -0
  135. githubasyncio/RepoCodeSecurityConfig.py +93 -0
  136. githubasyncio/Repository.py +5211 -0
  137. githubasyncio/RepositoryAdvisory.py +431 -0
  138. githubasyncio/RepositoryDiscussion.py +221 -0
  139. githubasyncio/RepositoryDiscussionCategory.py +150 -0
  140. githubasyncio/RepositoryDiscussionComment.py +159 -0
  141. githubasyncio/RepositoryKey.py +166 -0
  142. githubasyncio/RepositoryPreferences.py +82 -0
  143. githubasyncio/RepositoryRulesetBypassActor.py +75 -0
  144. githubasyncio/Requester.py +1518 -0
  145. githubasyncio/RequiredPullRequestReviews.py +269 -0
  146. githubasyncio/RequiredStatusChecks.py +153 -0
  147. githubasyncio/Rule.py +134 -0
  148. githubasyncio/Ruleset.py +292 -0
  149. githubasyncio/Secret.py +139 -0
  150. githubasyncio/SecretScanAlert.py +317 -0
  151. githubasyncio/SecretScanAlertInstance.py +128 -0
  152. githubasyncio/SecurityAndAnalysis.py +188 -0
  153. githubasyncio/SecurityAndAnalysisFeature.py +79 -0
  154. githubasyncio/SelfHostedActionsRunner.py +129 -0
  155. githubasyncio/SelfHostedActionsRunnerApplication.py +92 -0
  156. githubasyncio/SelfHostedActionsRunnerJitConfig.py +74 -0
  157. githubasyncio/SelfHostedActionsRunnerToken.py +118 -0
  158. githubasyncio/SourceImport.py +260 -0
  159. githubasyncio/Stargazer.py +88 -0
  160. githubasyncio/StatsCodeFrequency.py +81 -0
  161. githubasyncio/StatsCommitActivity.py +86 -0
  162. githubasyncio/StatsContributor.py +138 -0
  163. githubasyncio/StatsParticipation.py +78 -0
  164. githubasyncio/StatsPunchCard.py +76 -0
  165. githubasyncio/SubIssueSummary.py +70 -0
  166. githubasyncio/Tag.py +108 -0
  167. githubasyncio/Team.py +618 -0
  168. githubasyncio/TeamDiscussion.py +137 -0
  169. githubasyncio/TimelineEvent.py +164 -0
  170. githubasyncio/TimelineEventSource.py +81 -0
  171. githubasyncio/Topic.py +177 -0
  172. githubasyncio/Traffic.py +95 -0
  173. githubasyncio/UserKey.py +141 -0
  174. githubasyncio/Variable.py +155 -0
  175. githubasyncio/View.py +97 -0
  176. githubasyncio/Workflow.py +335 -0
  177. githubasyncio/WorkflowJob.py +253 -0
  178. githubasyncio/WorkflowRun.py +480 -0
  179. githubasyncio/WorkflowStep.py +118 -0
  180. githubasyncio/__init__.py +38 -0
  181. githubasyncio/compat/__init__.py +52 -0
  182. githubasyncio/requestlib/__init__.py +29 -0
  183. pygithub_asyncio-3.0.0b1.dist-info/METADATA +102 -0
  184. pygithub_asyncio-3.0.0b1.dist-info/RECORD +188 -0
  185. pygithub_asyncio-3.0.0b1.dist-info/WHEEL +5 -0
  186. pygithub_asyncio-3.0.0b1.dist-info/licenses/COPYING +674 -0
  187. pygithub_asyncio-3.0.0b1.dist-info/licenses/COPYING.LESSER +165 -0
  188. pygithub_asyncio-3.0.0b1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,365 @@
1
+ # FILE AUTO GENERATED DO NOT TOUCH
2
+ ############################ Copyrights and license ############################
3
+ # #
4
+ # Copyright 2023 Denis Blanchette <dblanchette@coveo.com> #
5
+ # Copyright 2023 Enrico Minack <github@enrico.minack.dev> #
6
+ # Copyright 2023 Hemslo Wang <hemslo.wang@gmail.com> #
7
+ # Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> #
8
+ # Copyright 2023 Mark Amery <markamery@btinternet.com> #
9
+ # Copyright 2023 Trim21 <trim21.me@gmail.com> #
10
+ # Copyright 2023 chantra <chantra@users.noreply.github.com> #
11
+ # Copyright 2024 Enrico Minack <github@enrico.minack.dev> #
12
+ # Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> #
13
+ # Copyright 2024 Min RK <benjaminrk@gmail.com> #
14
+ # Copyright 2025 Aidan McNay <acm289@cornell.edu> #
15
+ # Copyright 2025 Christoph Reiter <reiter.christoph@gmail.com> #
16
+ # Copyright 2025 Enrico Minack <github@enrico.minack.dev> #
17
+ # Copyright 2025 xmo-odoo <xmo@odoo.com> #
18
+ # Copyright 2026 Enrico Minack <github@enrico.minack.dev> #
19
+ # #
20
+ # This file is part of PyGithub. #
21
+ # http://pygithub.readthedocs.io/ #
22
+ # #
23
+ # PyGithub is free software: you can redistribute it and/or modify it under #
24
+ # the terms of the GNU Lesser General Public License as published by the Free #
25
+ # Software Foundation, either version 3 of the License, or (at your option) #
26
+ # any later version. #
27
+ # #
28
+ # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
29
+ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
30
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
31
+ # details. #
32
+ # #
33
+ # You should have received a copy of the GNU Lesser General Public License #
34
+ # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
35
+ # #
36
+ ################################################################################
37
+
38
+ from __future__ import annotations
39
+
40
+ import urllib.parse
41
+ import warnings
42
+ from typing import Any
43
+
44
+ import githubasyncio
45
+ from githubasyncio import Consts
46
+ from githubasyncio.Auth import AppAuth
47
+ from githubasyncio.compat import deprecated
48
+ from githubasyncio.GithubApp import GithubApp
49
+ from githubasyncio.GithubException import GithubException
50
+ from githubasyncio.Installation import Installation
51
+ from githubasyncio.InstallationAuthorization import InstallationAuthorization
52
+ from githubasyncio.PaginatedList import PaginatedList
53
+ from githubasyncio.RateLimitOverview import RateLimitOverview
54
+ from githubasyncio.Requester import Requester
55
+ from githubasyncio.requestlib import Retry
56
+
57
+
58
+ class GithubIntegration:
59
+ """
60
+ Main class to obtain tokens for a GitHub integration.
61
+ """
62
+
63
+ # keep non-deprecated arguments in-sync with Requester
64
+ # v3: remove integration_id, private_key, jwt_expiry, jwt_issued_at and jwt_algorithm
65
+ # v3: move auth to the front of arguments
66
+ # v3: move * before first argument so all arguments must be named,
67
+ # allows to reorder / add new arguments / remove deprecated arguments without breaking user code
68
+ # added here to force named parameters because new parameters have been added
69
+ auth: AppAuth
70
+ base_url: str
71
+ __requester: Requester
72
+
73
+ def __init__(
74
+ self,
75
+ integration_id: int | str | None = None,
76
+ private_key: str | None = None,
77
+ base_url: str = Consts.DEFAULT_BASE_URL,
78
+ *,
79
+ timeout: int = Consts.DEFAULT_TIMEOUT,
80
+ user_agent: str = Consts.DEFAULT_USER_AGENT,
81
+ per_page: int = Consts.DEFAULT_PER_PAGE,
82
+ verify: bool | str = True,
83
+ retry: int | Retry | None = None,
84
+ pool_size: int | None = None,
85
+ seconds_between_requests: float | None = Consts.DEFAULT_SECONDS_BETWEEN_REQUESTS,
86
+ seconds_between_writes: float | None = Consts.DEFAULT_SECONDS_BETWEEN_WRITES,
87
+ jwt_expiry: int = Consts.DEFAULT_JWT_EXPIRY,
88
+ jwt_issued_at: int = Consts.DEFAULT_JWT_ISSUED_AT,
89
+ jwt_algorithm: str = Consts.DEFAULT_JWT_ALGORITHM,
90
+ auth: AppAuth | None = None,
91
+ # v3: set lazy = True as the default
92
+ lazy: bool = False,
93
+ api_version: str | None = None,
94
+ ) -> None:
95
+ """
96
+ :param integration_id: int deprecated, use auth=githubasyncio.Auth.AppAuth(...) instead
97
+ :param private_key: string deprecated, use auth=githubasyncio.Auth.AppAuth(...) instead
98
+ :param base_url: string
99
+ :param timeout: integer
100
+ :param user_agent: string
101
+ :param per_page: int
102
+ :param verify: boolean or string
103
+ :param retry: int or urllib3.util.retry.Retry object
104
+ :param pool_size: int
105
+ :param seconds_between_requests: float
106
+ :param seconds_between_writes: float
107
+ :param jwt_expiry: int deprecated, use auth=githubasyncio.Auth.AppAuth(...) instead
108
+ :param jwt_issued_at: int deprecated, use auth=githubasyncio.Auth.AppAuth(...) instead
109
+ :param jwt_algorithm: string deprecated, use auth=githubasyncio.Auth.AppAuth(...) instead
110
+ :param auth: authentication method
111
+ :param lazy: completable objects created from this instance are lazy,
112
+ as well as completable objects created from those, and so on
113
+ :param api_version: string, GitHub API version to use (see https://docs.github.com/en/rest/about-the-rest-api/api-versions).
114
+ Note that some PyGithub methods might downgrade this version if it is not supported by the implementation.
115
+ Set to None to not specify any version
116
+ """
117
+ if integration_id is not None:
118
+ assert isinstance(integration_id, (int, str)), integration_id
119
+ if private_key is not None:
120
+ assert isinstance(private_key, str), "supplied private key should be a string"
121
+ assert isinstance(base_url, str), base_url
122
+ assert isinstance(timeout, int), timeout
123
+ assert user_agent is None or isinstance(user_agent, str), user_agent
124
+ assert isinstance(per_page, int), per_page
125
+ assert isinstance(verify, (bool, str)), verify
126
+ assert retry is None or isinstance(retry, int) or isinstance(retry, Retry), retry
127
+ assert pool_size is None or isinstance(pool_size, int), pool_size
128
+ assert seconds_between_requests is None or seconds_between_requests >= 0
129
+ assert seconds_between_writes is None or seconds_between_writes >= 0
130
+ assert isinstance(jwt_expiry, int), jwt_expiry
131
+ assert Consts.MIN_JWT_EXPIRY <= jwt_expiry <= Consts.MAX_JWT_EXPIRY, jwt_expiry
132
+ assert isinstance(jwt_issued_at, int)
133
+ assert isinstance(lazy, bool), lazy
134
+ assert api_version is None or isinstance(api_version, str), api_version
135
+
136
+ self.base_url = base_url
137
+
138
+ if (
139
+ integration_id is not None
140
+ or private_key is not None
141
+ or jwt_expiry != Consts.DEFAULT_JWT_EXPIRY
142
+ or jwt_issued_at != Consts.DEFAULT_JWT_ISSUED_AT
143
+ or jwt_algorithm != Consts.DEFAULT_JWT_ALGORITHM
144
+ ):
145
+ warnings.warn(
146
+ "Arguments integration_id, private_key, jwt_expiry, jwt_issued_at and jwt_algorithm are deprecated, "
147
+ "please use auth=githubasyncio.Auth.AppAuth(...) instead",
148
+ category=DeprecationWarning,
149
+ stacklevel=2,
150
+ )
151
+ if jwt_algorithm != Consts.DEFAULT_JWT_ALGORITHM:
152
+ auth = AppAuth(
153
+ integration_id, # type: ignore
154
+ private_key=None, # type: ignore
155
+ sign_func=AppAuth.create_jwt_sign(private_key, jwt_algorithm), # type: ignore
156
+ jwt_expiry=jwt_expiry,
157
+ jwt_issued_at=jwt_issued_at,
158
+ )
159
+ else:
160
+ auth = AppAuth(
161
+ integration_id, # type: ignore
162
+ private_key, # type: ignore
163
+ jwt_expiry=jwt_expiry,
164
+ jwt_issued_at=jwt_issued_at,
165
+ )
166
+
167
+ assert isinstance(auth, AppAuth), (
168
+ f"GithubIntegration requires githubasyncio.Auth.AppAuth authentication, not {type(auth)}"
169
+ )
170
+
171
+ self.auth = auth
172
+
173
+ self.__requester = Requester(
174
+ auth=auth,
175
+ base_url=self.base_url,
176
+ timeout=timeout,
177
+ user_agent=user_agent,
178
+ per_page=per_page,
179
+ verify=verify,
180
+ retry=retry,
181
+ pool_size=pool_size,
182
+ seconds_between_requests=seconds_between_requests,
183
+ seconds_between_writes=seconds_between_writes,
184
+ lazy=lazy,
185
+ api_version=api_version,
186
+ )
187
+
188
+ def withLazy(self, lazy: bool) -> GithubIntegration:
189
+ """
190
+ Create a GithubIntegration instance with identical configuration but the given lazy setting.
191
+
192
+ :param lazy: completable objects created from this instance are lazy, as well as completable objects created
193
+ from those, and so on
194
+ :return: new Github instance
195
+
196
+ """
197
+ kwargs = self.__requester.kwargs
198
+ kwargs.update(lazy=lazy)
199
+ integration = GithubIntegration(**kwargs)
200
+ integration.requester.useCurrentRateLimits(self.__requester)
201
+ return integration
202
+
203
+ async def close(self) -> None:
204
+ """
205
+ Close connections to the server. Alternatively, use the
206
+ GithubIntegration object as a context manager:
207
+
208
+ .. code-block:: python
209
+
210
+ with GithubIntegration(...) as gi:
211
+ # do something
212
+ """
213
+ await self.__requester.close()
214
+
215
+ async def __aenter__(self) -> GithubIntegration:
216
+ return self
217
+
218
+ async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
219
+ await self.close()
220
+
221
+ def get_github_for_installation(
222
+ self, installation_id: int, token_permissions: dict[str, str] | None = None
223
+ ) -> githubasyncio.Github:
224
+ # The installation has to authenticate as an installation, not an app
225
+ auth = self.auth.get_installation_auth(installation_id, token_permissions, self.__requester)
226
+ return githubasyncio.Github(**self.__requester.withAuth(auth).kwargs)
227
+
228
+ @property
229
+ def current_rate_limits(self) -> RateLimitOverview:
230
+ """
231
+ Latest rate limits known to the requester of this instance, per resource. This does not send any request.
232
+
233
+ Values come from the response headers of requests made through the requester of this instance.
234
+ Attributes of ``resources`` are ``None`` until values for that resource are known or if the resource is unknown
235
+ to :class:`githubasyncio.RateLimit.RateLimit`. Use :meth:`githubasyncio.RateLimitOverview.RateLimitOverview.update` to fetch latest values.
236
+
237
+ """
238
+ return self.__requester.current_rate_limits
239
+
240
+ @property
241
+ def requester(self) -> Requester:
242
+ """
243
+ Return my Requester object.
244
+
245
+ For example, to make requests to API endpoints not yet supported by PyGitHub.
246
+
247
+ """
248
+ return self.__requester
249
+
250
+ def _get_headers(self) -> dict[str, str]:
251
+ """
252
+ Get headers for the requests.
253
+ """
254
+ return {
255
+ "Accept": Consts.mediaTypeIntegrationPreview,
256
+ }
257
+
258
+ async def _get_installed_app(self, url: str) -> Installation:
259
+ """
260
+ Get installation for the given URL.
261
+ """
262
+ headers, response = await self.__requester.requestJsonAndCheck("GET", url, headers=self._get_headers())
263
+
264
+ return Installation(
265
+ requester=self.__requester,
266
+ headers=headers,
267
+ attributes=response,
268
+ )
269
+
270
+ @deprecated(
271
+ "Use githubasyncio.Github(auth=githubasyncio.Auth.AppAuth), githubasyncio.Auth.AppAuth.token or githubasyncio.Auth.AppAuth.create_jwt(expiration) instead"
272
+ )
273
+ def create_jwt(self, expiration: int | None = None) -> str:
274
+ """
275
+ Create a signed JWT
276
+ https://docs.github.com/en/developers/apps/building-github-apps/authenticating-with-github-apps#authenticating-as-a-github-app
277
+ """
278
+ return self.auth.create_jwt(expiration)
279
+
280
+ async def get_access_token(
281
+ self, installation_id: int, permissions: dict[str, str] | None = None
282
+ ) -> InstallationAuthorization:
283
+ """
284
+ :calls: `POST /app/installations/{installation_id}/access_tokens <https://docs.github.com/en/rest/apps/apps#create-an-installation-access-token-for-an-app>`
285
+ """
286
+ if permissions is None:
287
+ permissions = {}
288
+
289
+ if not isinstance(permissions, dict):
290
+ raise GithubException(status=400, data={"message": "Invalid permissions"}, headers=None)
291
+
292
+ body = {"permissions": permissions}
293
+ headers, response = await self.__requester.requestJsonAndCheck(
294
+ "POST",
295
+ f"/app/installations/{installation_id}/access_tokens",
296
+ headers=self._get_headers(),
297
+ input=body,
298
+ )
299
+
300
+ return InstallationAuthorization(
301
+ requester=self.__requester,
302
+ headers=headers,
303
+ attributes=response,
304
+ )
305
+
306
+ @deprecated("Use get_repo_installation")
307
+ async def get_installation(self, owner: str, repo: str) -> Installation:
308
+ """
309
+ Deprecated by get_repo_installation.
310
+
311
+ :calls: `GET /repos/{owner}/{repo}/installation <https://docs.github.com/en/rest/reference/apps#get-a-repository-
312
+ installation-for-the-authenticated-app>`
313
+
314
+ """
315
+ owner = urllib.parse.quote(owner)
316
+ repo = urllib.parse.quote(repo)
317
+ return await self._get_installed_app(url=f"/repos/{owner}/{repo}/installation")
318
+
319
+ def get_installations(self) -> PaginatedList[Installation]:
320
+ """
321
+ :calls: GET /app/installations <https://docs.github.com/en/rest/reference/apps#list-installations-for-the-authenticated-app>
322
+ """
323
+ return PaginatedList(
324
+ contentClass=Installation,
325
+ requester=self.__requester,
326
+ firstUrl="/app/installations",
327
+ firstParams=None,
328
+ headers=self._get_headers(),
329
+ list_item="installations",
330
+ )
331
+
332
+ async def get_org_installation(self, org: str) -> Installation:
333
+ """
334
+ :calls: `GET /orgs/{org}/installation <https://docs.github.com/en/rest/apps/apps#get-an-organization-installation-for-the-authenticated-app>`
335
+ """
336
+ org = urllib.parse.quote(org, safe="")
337
+ return await self._get_installed_app(url=f"/orgs/{org}/installation")
338
+
339
+ async def get_repo_installation(self, owner: str, repo: str) -> Installation:
340
+ """
341
+ :calls: `GET /repos/{owner}/{repo}/installation <https://docs.github.com/en/rest/reference/apps#get-a-repository-installation-for-the-authenticated-app>`
342
+ """
343
+ owner = urllib.parse.quote(owner)
344
+ repo = urllib.parse.quote(repo)
345
+ return await self._get_installed_app(url=f"/repos/{owner}/{repo}/installation")
346
+
347
+ async def get_user_installation(self, username: str) -> Installation:
348
+ """
349
+ :calls: `GET /users/{username}/installation <https://docs.github.com/en/rest/apps/apps#get-a-user-installation-for-the-authenticated-app>`
350
+ """
351
+ username = urllib.parse.quote(username)
352
+ return await self._get_installed_app(url=f"/users/{username}/installation")
353
+
354
+ async def get_app_installation(self, installation_id: int) -> Installation:
355
+ """
356
+ :calls: `GET /app/installations/{installation_id} <https://docs.github.com/en/rest/apps/apps#get-an-installation-for-the-authenticated-app>`
357
+ """
358
+ return await self._get_installed_app(url=f"/app/installations/{installation_id}")
359
+
360
+ async def get_app(self) -> GithubApp:
361
+ """
362
+ :calls: `GET /app <https://docs.github.com/en/rest/reference/apps#get-the-authenticated-app>`_
363
+ """
364
+ headers, data = await self.__requester.requestJsonAndCheck("GET", "/app", headers=self._get_headers())
365
+ return GithubApp(requester=self.__requester, headers=headers, attributes=data, completed=True)