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,191 @@
1
+ # FILE AUTO GENERATED DO NOT TOUCH
2
+ ############################ Copyrights and license ############################
3
+ # #
4
+ # Copyright 2023 Enrico Minack <github@enrico.minack.dev> #
5
+ # Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> #
6
+ # Copyright 2023 Jonathan Leitschuh <jonathan.leitschuh@gmail.com> #
7
+ # Copyright 2023 Joseph Henrich <crimsonknave@gmail.com> #
8
+ # Copyright 2023 Trim21 <trim21.me@gmail.com> #
9
+ # Copyright 2024 Enrico Minack <github@enrico.minack.dev> #
10
+ # Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> #
11
+ # Copyright 2025 Enrico Minack <github@enrico.minack.dev> #
12
+ # #
13
+ # This file is part of PyGithub. #
14
+ # http://pygithub.readthedocs.io/ #
15
+ # #
16
+ # PyGithub is free software: you can redistribute it and/or modify it under #
17
+ # the terms of the GNU Lesser General Public License as published by the Free #
18
+ # Software Foundation, either version 3 of the License, or (at your option) #
19
+ # any later version. #
20
+ # #
21
+ # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
22
+ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
23
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
24
+ # details. #
25
+ # #
26
+ # You should have received a copy of the GNU Lesser General Public License #
27
+ # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
28
+ # #
29
+ ################################################################################
30
+
31
+ from __future__ import annotations
32
+
33
+ from typing import TYPE_CHECKING, Any, Union
34
+
35
+ import githubasyncio.AdvisoryVulnerabilityPackage
36
+ from githubasyncio.compat import TypedDict
37
+ from githubasyncio.GithubObject import Attribute, NonCompletableGithubObject, NotSet
38
+
39
+ if TYPE_CHECKING:
40
+ from githubasyncio.AdvisoryVulnerabilityPackage import AdvisoryVulnerabilityPackage
41
+
42
+
43
+ class SimpleAdvisoryVulnerabilityPackage(TypedDict):
44
+ """
45
+ A simple package in an advisory.
46
+ """
47
+
48
+ ecosystem: str
49
+ name: str | None
50
+
51
+
52
+ class SimpleAdvisoryVulnerability(TypedDict):
53
+ """
54
+ A simple vulnerability in a security advisory.
55
+ """
56
+
57
+ package: SimpleAdvisoryVulnerabilityPackage
58
+ patched_versions: str | None
59
+ vulnerable_functions: list[str] | None
60
+ vulnerable_version_range: str | None
61
+
62
+
63
+ AdvisoryVulnerabilityInput = Union[SimpleAdvisoryVulnerability, "AdvisoryVulnerability"]
64
+
65
+
66
+ class AdvisoryVulnerability(NonCompletableGithubObject):
67
+ """
68
+ This class represents a package that is vulnerable to a parent SecurityAdvisory.
69
+
70
+ The reference can be found here
71
+ https://docs.github.com/en/rest/security-advisories/repository-advisories
72
+
73
+ The OpenAPI schema can be found at
74
+
75
+ - /components/schemas/repository-advisory-vulnerability
76
+ - /components/schemas/vulnerability
77
+
78
+ """
79
+
80
+ def _initAttributes(self) -> None:
81
+ self._first_patched_version: Attribute[str] = NotSet
82
+ self._package: Attribute[AdvisoryVulnerabilityPackage] = NotSet
83
+ self._patched_versions: Attribute[str] = NotSet
84
+ self._vulnerable_functions: Attribute[list[str]] = NotSet
85
+ self._vulnerable_version_range: Attribute[str] = NotSet
86
+
87
+ def __repr__(self) -> str:
88
+ return self.get__repr__({"package": self.package})
89
+
90
+ @property
91
+ def first_patched_version(self) -> str:
92
+ return self._first_patched_version.value
93
+
94
+ @property
95
+ def package(
96
+ self,
97
+ ) -> AdvisoryVulnerabilityPackage:
98
+ """
99
+ :type: :class:`AdvisoryVulnerability`
100
+ """
101
+ return self._package.value
102
+
103
+ @property
104
+ def patched_versions(self) -> str:
105
+ """
106
+ :type: string
107
+ """
108
+ return self._patched_versions.value
109
+
110
+ @property
111
+ def vulnerable_functions(self) -> list[str] | None:
112
+ """
113
+ :type: list of string
114
+ """
115
+ return self._vulnerable_functions.value
116
+
117
+ @property
118
+ def vulnerable_version_range(self) -> str | None:
119
+ """
120
+ :type: string
121
+ """
122
+ return self._vulnerable_version_range.value
123
+
124
+ @classmethod
125
+ def _validate_vulnerability(cls, vulnerability: AdvisoryVulnerabilityInput) -> None:
126
+ assert isinstance(vulnerability, (dict, cls)), vulnerability
127
+ if isinstance(vulnerability, dict):
128
+ assert "package" in vulnerability, vulnerability
129
+ package: SimpleAdvisoryVulnerabilityPackage = vulnerability["package"]
130
+ assert isinstance(package, dict), package
131
+ assert "ecosystem" in package, package
132
+ assert isinstance(package["ecosystem"], str), package
133
+ assert "name" in package, package
134
+ assert isinstance(package["name"], (str, type(None))), package
135
+ assert "patched_versions" in vulnerability, vulnerability
136
+ assert isinstance(vulnerability["patched_versions"], (str, type(None))), vulnerability
137
+ assert "vulnerable_functions" in vulnerability, vulnerability
138
+ assert isinstance(vulnerability["vulnerable_functions"], (list, type(None))), vulnerability
139
+ assert "vulnerable_functions" in vulnerability, vulnerability
140
+ assert (
141
+ all(isinstance(vf, str) for vf in vulnerability["vulnerable_functions"])
142
+ if vulnerability["vulnerable_functions"] is not None
143
+ else True
144
+ ), vulnerability
145
+ assert "vulnerable_version_range" in vulnerability, vulnerability
146
+ assert isinstance(vulnerability["vulnerable_version_range"], (str, type(None))), vulnerability
147
+
148
+ else:
149
+ assert vulnerability.package is githubasyncio.AdvisoryVulnerabilityPackage.AdvisoryVulnerabilityPackage, (
150
+ vulnerability
151
+ )
152
+
153
+ @staticmethod
154
+ def _to_github_dict(
155
+ vulnerability: AdvisoryVulnerabilityInput,
156
+ ) -> SimpleAdvisoryVulnerability:
157
+ if isinstance(vulnerability, dict):
158
+ vulnerability_package: SimpleAdvisoryVulnerabilityPackage = vulnerability["package"]
159
+ return {
160
+ "package": {
161
+ "ecosystem": vulnerability_package["ecosystem"],
162
+ "name": vulnerability_package["name"],
163
+ },
164
+ "patched_versions": vulnerability["patched_versions"],
165
+ "vulnerable_functions": vulnerability["vulnerable_functions"],
166
+ "vulnerable_version_range": vulnerability["vulnerable_version_range"],
167
+ }
168
+ return {
169
+ "package": {
170
+ "ecosystem": vulnerability.package.ecosystem,
171
+ "name": vulnerability.package.name,
172
+ },
173
+ "patched_versions": vulnerability.patched_versions,
174
+ "vulnerable_functions": vulnerability.vulnerable_functions,
175
+ "vulnerable_version_range": vulnerability.vulnerable_version_range,
176
+ }
177
+
178
+ def _useAttributes(self, attributes: dict[str, Any]) -> None:
179
+ if "first_patched_version" in attributes: # pragma no branch
180
+ self._first_patched_version = self._makeStringAttribute(attributes["first_patched_version"])
181
+ if "package" in attributes: # pragma no branch
182
+ self._package = self._makeClassAttribute(
183
+ githubasyncio.AdvisoryVulnerabilityPackage.AdvisoryVulnerabilityPackage,
184
+ attributes["package"],
185
+ )
186
+ if "patched_versions" in attributes: # pragma no branch
187
+ self._patched_versions = self._makeStringAttribute(attributes["patched_versions"])
188
+ if "vulnerable_functions" in attributes: # pragma no branch
189
+ self._vulnerable_functions = self._makeListOfStringsAttribute(attributes["vulnerable_functions"])
190
+ if "vulnerable_version_range" in attributes: # pragma no branch
191
+ self._vulnerable_version_range = self._makeStringAttribute(attributes["vulnerable_version_range"])
@@ -0,0 +1,93 @@
1
+ # FILE AUTO GENERATED DO NOT TOUCH
2
+ ############################ Copyrights and license ############################
3
+ # #
4
+ # Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
5
+ # Copyright 2012 Zearin <zearin@gonk.net> #
6
+ # Copyright 2013 AKFish <akfish@gmail.com> #
7
+ # Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
8
+ # Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net> #
9
+ # Copyright 2016 Jannis Gebauer <ja.geb@me.com> #
10
+ # Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com> #
11
+ # Copyright 2018 Wan Liuyang <tsfdye@gmail.com> #
12
+ # Copyright 2018 sfdye <tsfdye@gmail.com> #
13
+ # Copyright 2019 Steve Kowalik <steven@wedontsleep.org> #
14
+ # Copyright 2019 Wan Liuyang <tsfdye@gmail.com> #
15
+ # Copyright 2020 Steve Kowalik <steven@wedontsleep.org> #
16
+ # Copyright 2021 Steve Kowalik <steven@wedontsleep.org> #
17
+ # Copyright 2022 Eric Nieuwland <eric.nieuwland@gmail.com> #
18
+ # Copyright 2023 Enrico Minack <github@enrico.minack.dev> #
19
+ # Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> #
20
+ # Copyright 2023 Jonathan Leitschuh <jonathan.leitschuh@gmail.com> #
21
+ # Copyright 2023 Joseph Henrich <crimsonknave@gmail.com> #
22
+ # Copyright 2023 Trim21 <trim21.me@gmail.com> #
23
+ # Copyright 2024 Enrico Minack <github@enrico.minack.dev> #
24
+ # Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> #
25
+ # Copyright 2024 Thomas Cooper <coopernetes@proton.me> #
26
+ # Copyright 2025 Enrico Minack <github@enrico.minack.dev> #
27
+ # #
28
+ # This file is part of PyGithub. #
29
+ # http://pygithub.readthedocs.io/ #
30
+ # #
31
+ # PyGithub is free software: you can redistribute it and/or modify it under #
32
+ # the terms of the GNU Lesser General Public License as published by the Free #
33
+ # Software Foundation, either version 3 of the License, or (at your option) #
34
+ # any later version. #
35
+ # #
36
+ # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
37
+ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
38
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
39
+ # details. #
40
+ # #
41
+ # You should have received a copy of the GNU Lesser General Public License #
42
+ # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
43
+ # #
44
+ ################################################################################
45
+
46
+ from __future__ import annotations
47
+
48
+ from typing import Any
49
+
50
+ from githubasyncio.GithubObject import Attribute, NonCompletableGithubObject, NotSet
51
+
52
+
53
+ class AdvisoryVulnerabilityPackage(NonCompletableGithubObject):
54
+ """
55
+ This class represents an identifier for a package that is vulnerable to a parent SecurityAdvisory.
56
+
57
+ The reference can be found here
58
+ https://docs.github.com/en/rest/security-advisories/repository-advisories
59
+
60
+ The OpenAPI schema can be found at
61
+
62
+ - /components/schemas/dependabot-alert-package
63
+ - /components/schemas/repository-advisory-vulnerability/properties/package
64
+ - /components/schemas/vulnerability/properties/package
65
+
66
+ """
67
+
68
+ def _initAttributes(self) -> None:
69
+ self._ecosystem: Attribute[str] = NotSet
70
+ self._name: Attribute[str | None] = NotSet
71
+
72
+ def __repr__(self) -> str:
73
+ return self.get__repr__({"name": self._name.value})
74
+
75
+ @property
76
+ def ecosystem(self) -> str:
77
+ """
78
+ :type: string
79
+ """
80
+ return self._ecosystem.value
81
+
82
+ @property
83
+ def name(self) -> str | None:
84
+ """
85
+ :type: string or None
86
+ """
87
+ return self._name.value
88
+
89
+ def _useAttributes(self, attributes: dict[str, Any]) -> None:
90
+ if "ecosystem" in attributes: # pragma no branch
91
+ self._ecosystem = self._makeStringAttribute(attributes["ecosystem"])
92
+ if "name" in attributes: # pragma no branch
93
+ self._name = self._makeStringAttribute(attributes["name"])
@@ -0,0 +1,58 @@
1
+ # FILE AUTO GENERATED DO NOT TOUCH
2
+ ############################ Copyrights and license ############################
3
+ # #
4
+ # Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
5
+ # Copyright 2012 Zearin <zearin@gonk.net> #
6
+ # Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
7
+ # Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net> #
8
+ # Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com> #
9
+ # Copyright 2018 sfdye <tsfdye@gmail.com> #
10
+ # Copyright 2019 Steve Kowalik <steven@wedontsleep.org> #
11
+ # Copyright 2019 TechnicalPirate <35609336+TechnicalPirate@users.noreply.github.com>#
12
+ # Copyright 2019 Wan Liuyang <tsfdye@gmail.com> #
13
+ # Copyright 2020 Steve Kowalik <steven@wedontsleep.org> #
14
+ # Copyright 2022 Eric Nieuwland <eric.nieuwland@gmail.com> #
15
+ # Copyright 2023 Denis Blanchette <dblanchette@coveo.com> #
16
+ # Copyright 2023 Enrico Minack <github@enrico.minack.dev> #
17
+ # Copyright 2023 Trim21 <trim21.me@gmail.com> #
18
+ # Copyright 2025 Christoph Reiter <reiter.christoph@gmail.com> #
19
+ # Copyright 2025 Enrico Minack <github@enrico.minack.dev> #
20
+ # #
21
+ # This file is part of PyGithub. #
22
+ # http://pygithub.readthedocs.io/ #
23
+ # #
24
+ # PyGithub is free software: you can redistribute it and/or modify it under #
25
+ # the terms of the GNU Lesser General Public License as published by the Free #
26
+ # Software Foundation, either version 3 of the License, or (at your option) #
27
+ # any later version. #
28
+ # #
29
+ # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
30
+ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
31
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
32
+ # details. #
33
+ # #
34
+ # You should have received a copy of the GNU Lesser General Public License #
35
+ # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
36
+ # #
37
+ ################################################################################
38
+
39
+ from __future__ import annotations
40
+
41
+ from githubasyncio.Auth import AppAuth, AppInstallationAuth
42
+ from githubasyncio.compat import deprecated
43
+
44
+
45
+ @deprecated("Use githubasyncio.Auth.AppInstallationAuth instead")
46
+ class AppAuthentication(AppInstallationAuth):
47
+ def __init__(
48
+ self,
49
+ app_id: int | str,
50
+ private_key: str,
51
+ installation_id: int,
52
+ token_permissions: dict[str, str] | None = None,
53
+ ):
54
+ super().__init__(
55
+ app_auth=AppAuth(app_id, private_key),
56
+ installation_id=installation_id,
57
+ token_permissions=token_permissions,
58
+ )
@@ -0,0 +1,200 @@
1
+ # FILE AUTO GENERATED DO NOT TOUCH
2
+ ############################ Copyrights and license ############################
3
+ # #
4
+ # Copyright 2019 Rigas Papathanasopoulos <rigaspapas@gmail.com> #
5
+ # Copyright 2020 Steve Kowalik <steven@wedontsleep.org> #
6
+ # Copyright 2021 Mark Walker <mark.walker@realbuzz.com> #
7
+ # Copyright 2021 Steve Kowalik <steven@wedontsleep.org> #
8
+ # Copyright 2023 Enrico Minack <github@enrico.minack.dev> #
9
+ # Copyright 2023 Trim21 <trim21.me@gmail.com> #
10
+ # Copyright 2024 Enrico Minack <github@enrico.minack.dev> #
11
+ # Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> #
12
+ # Copyright 2025 Enrico Minack <github@enrico.minack.dev> #
13
+ # Copyright 2026 Théo Goudout <TheoGoudout@users.noreply.github.com> #
14
+ # #
15
+ # This file is part of PyGithub. #
16
+ # http://pygithub.readthedocs.io/ #
17
+ # #
18
+ # PyGithub is free software: you can redistribute it and/or modify it under #
19
+ # the terms of the GNU Lesser General Public License as published by the Free #
20
+ # Software Foundation, either version 3 of the License, or (at your option) #
21
+ # any later version. #
22
+ # #
23
+ # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
24
+ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
25
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
26
+ # details. #
27
+ # #
28
+ # You should have received a copy of the GNU Lesser General Public License #
29
+ # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
30
+ # #
31
+ ################################################################################
32
+
33
+ from __future__ import annotations
34
+
35
+ import urllib.parse
36
+ from typing import TYPE_CHECKING, Any
37
+
38
+ import githubasyncio.AccessToken
39
+ import githubasyncio.Auth
40
+ from githubasyncio.Consts import DEFAULT_BASE_URL, DEFAULT_OAUTH_URL
41
+ from githubasyncio.GithubException import BadCredentialsException, GithubException
42
+ from githubasyncio.GithubObject import Attribute, NonCompletableGithubObject, NotSet
43
+ from githubasyncio.Requester import Requester
44
+
45
+ if TYPE_CHECKING:
46
+ from githubasyncio.AccessToken import AccessToken
47
+ from githubasyncio.Auth import AppUserAuth
48
+
49
+
50
+ class ApplicationOAuth(NonCompletableGithubObject):
51
+ """
52
+ This class is used for identifying and authorizing users for Github Apps.
53
+
54
+ The reference can be found at
55
+ https://docs.github.com/en/developers/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps
56
+
57
+ """
58
+
59
+ def __init__(
60
+ self,
61
+ requester: Requester,
62
+ headers: dict[str, Any],
63
+ attributes: Any,
64
+ ) -> None:
65
+ # this object requires a request without authentication
66
+ requester = requester.withAuth(auth=None)
67
+ super().__init__(requester, headers, attributes)
68
+
69
+ def _initAttributes(self) -> None:
70
+ self._client_id: Attribute[str] = NotSet
71
+ self._client_secret: Attribute[str] = NotSet
72
+
73
+ def __repr__(self) -> str:
74
+ return self.get__repr__({"client_id": self._client_id.value})
75
+
76
+ @property
77
+ def client_id(self) -> str:
78
+ return self._client_id.value
79
+
80
+ @property
81
+ def client_secret(self) -> str:
82
+ return self._client_secret.value
83
+
84
+ def get_oauth_url(self, path: str) -> str:
85
+ if not path.startswith("/"):
86
+ path = f"/{path}"
87
+
88
+ if self._requester.base_url == DEFAULT_BASE_URL:
89
+ base_url = DEFAULT_OAUTH_URL
90
+ else:
91
+ base_url = f"{self._requester.scheme}://{self._requester.hostname_and_port}/login/oauth"
92
+ return f"{base_url}{path}"
93
+
94
+ def get_login_url(
95
+ self,
96
+ redirect_uri: str | None = None,
97
+ state: str | None = None,
98
+ login: str | None = None,
99
+ ) -> str:
100
+ """
101
+ Return the URL you need to redirect a user to in order to authorize your App.
102
+ """
103
+ parameters = {"client_id": self.client_id}
104
+ if redirect_uri is not None:
105
+ assert isinstance(redirect_uri, str), redirect_uri
106
+ parameters["redirect_uri"] = redirect_uri
107
+ if state is not None:
108
+ assert isinstance(state, str), state
109
+ parameters["state"] = state
110
+ if login is not None:
111
+ assert isinstance(login, str), login
112
+ parameters["login"] = login
113
+
114
+ query = urllib.parse.urlencode(parameters)
115
+
116
+ return self.get_oauth_url(f"/authorize?{query}")
117
+
118
+ async def get_access_token(self, code: str, code_verifier: str | None = None) -> AccessToken:
119
+ """
120
+ :calls: `POST /login/oauth/access_token <https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-user-access-token-for-a-github-app#using-the-web-application-flow-to-generate-a-user-access-token>`_
121
+ """
122
+ assert isinstance(code, str), code
123
+ post_parameters = {
124
+ "code": code,
125
+ "client_id": self.client_id,
126
+ "client_secret": self.client_secret,
127
+ }
128
+
129
+ if code_verifier is not None:
130
+ post_parameters["code_verifier"] = code_verifier
131
+
132
+ headers, data = self._checkError(
133
+ *await self._requester.requestJsonAndCheck(
134
+ "POST",
135
+ self.get_oauth_url("/access_token"),
136
+ headers={"Accept": "application/json"},
137
+ input=post_parameters,
138
+ )
139
+ )
140
+
141
+ return githubasyncio.AccessToken.AccessToken(
142
+ requester=self._requester,
143
+ headers=headers,
144
+ attributes=data,
145
+ )
146
+
147
+ def get_app_user_auth(self, token: AccessToken) -> AppUserAuth:
148
+ return githubasyncio.Auth.AppUserAuth(
149
+ client_id=self.client_id,
150
+ client_secret=self.client_secret,
151
+ token=token.token,
152
+ token_type=token.type,
153
+ expires_at=token.expires_at,
154
+ refresh_token=token.refresh_token,
155
+ refresh_expires_at=token.refresh_expires_at,
156
+ requester=self._requester,
157
+ )
158
+
159
+ async def refresh_access_token(self, refresh_token: str) -> AccessToken:
160
+ """
161
+ :calls: `POST /login/oauth/access_token <https://docs.github.com/en/developers/apps/identifying-and-authorizing-users-for-github-apps>`_
162
+ :param refresh_token: string
163
+ """
164
+ assert isinstance(refresh_token, str)
165
+ post_parameters = {
166
+ "client_id": self.client_id,
167
+ "client_secret": self.client_secret,
168
+ "grant_type": "refresh_token",
169
+ "refresh_token": refresh_token,
170
+ }
171
+
172
+ headers, data = self._checkError(
173
+ *await self._requester.requestJsonAndCheck(
174
+ "POST",
175
+ self.get_oauth_url("/access_token"),
176
+ headers={"Accept": "application/json"},
177
+ input=post_parameters,
178
+ )
179
+ )
180
+
181
+ return githubasyncio.AccessToken.AccessToken(
182
+ requester=self._requester,
183
+ headers=headers,
184
+ attributes=data,
185
+ )
186
+
187
+ @staticmethod
188
+ def _checkError(headers: dict[str, Any], data: Any) -> tuple[dict[str, Any], Any]:
189
+ if isinstance(data, dict) and "error" in data:
190
+ if data["error"] == "bad_verification_code":
191
+ raise BadCredentialsException(200, data, headers)
192
+ raise GithubException(200, data, headers)
193
+
194
+ return headers, data
195
+
196
+ def _useAttributes(self, attributes: dict[str, Any]) -> None:
197
+ if "client_id" in attributes: # pragma no branch
198
+ self._client_id = self._makeStringAttribute(attributes["client_id"])
199
+ if "client_secret" in attributes: # pragma no branch
200
+ self._client_secret = self._makeStringAttribute(attributes["client_secret"])