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,431 @@
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 2024 Thomas Cooper <coopernetes@proton.me> #
12
+ # Copyright 2025 Enrico Minack <github@enrico.minack.dev> #
13
+ # Copyright 2025 Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> #
14
+ # Copyright 2026 Enrico Minack <github@enrico.minack.dev> #
15
+ # #
16
+ # This file is part of PyGithub. #
17
+ # http://pygithub.readthedocs.io/ #
18
+ # #
19
+ # PyGithub is free software: you can redistribute it and/or modify it under #
20
+ # the terms of the GNU Lesser General Public License as published by the Free #
21
+ # Software Foundation, either version 3 of the License, or (at your option) #
22
+ # any later version. #
23
+ # #
24
+ # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
25
+ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
26
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
27
+ # details. #
28
+ # #
29
+ # You should have received a copy of the GNU Lesser General Public License #
30
+ # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
31
+ # #
32
+ ################################################################################
33
+
34
+ from __future__ import annotations
35
+
36
+ from collections.abc import Iterable
37
+ from datetime import datetime
38
+ from typing import TYPE_CHECKING, Any
39
+
40
+ import githubasyncio.AdvisoryCredit
41
+ import githubasyncio.AdvisoryCreditDetailed
42
+ import githubasyncio.AdvisoryVulnerability
43
+ import githubasyncio.NamedUser
44
+ import githubasyncio.Repository
45
+ import githubasyncio.Team
46
+ from githubasyncio.AdvisoryBase import AdvisoryBase
47
+ from githubasyncio.GithubObject import Attribute, NotSet, Opt, is_defined, is_undefined
48
+
49
+ if TYPE_CHECKING:
50
+ from githubasyncio.AdvisoryCredit import AdvisoryCredit, Credit
51
+ from githubasyncio.AdvisoryCreditDetailed import AdvisoryCreditDetailed
52
+ from githubasyncio.AdvisoryVulnerability import AdvisoryVulnerability, AdvisoryVulnerabilityInput
53
+ from githubasyncio.NamedUser import NamedUser
54
+ from githubasyncio.Repository import Repository
55
+ from githubasyncio.Team import Team
56
+
57
+
58
+ class RepositoryAdvisory(AdvisoryBase):
59
+ """
60
+ This class represents a RepositoryAdvisory.
61
+
62
+ The reference can be found here
63
+ https://docs.github.com/en/rest/security-advisories/repository-advisories
64
+
65
+ The OpenAPI schema can be found at
66
+
67
+ - /components/schemas/repository-advisory
68
+
69
+ """
70
+
71
+ def _initAttributes(self) -> None:
72
+ super()._initAttributes()
73
+ self._author: Attribute[NamedUser] = NotSet
74
+ self._closed_at: Attribute[datetime] = NotSet
75
+ self._collaborating_teams: Attribute[list[Team]] = NotSet
76
+ self._collaborating_users: Attribute[list[NamedUser]] = NotSet
77
+ self._created_at: Attribute[datetime] = NotSet
78
+ self._credits: Attribute[list[AdvisoryCredit]] = NotSet
79
+ self._credits_detailed: Attribute[list[AdvisoryCreditDetailed]] = NotSet
80
+ self._cwe_ids: Attribute[list[str]] = NotSet
81
+ self._private_fork: Attribute[Repository] = NotSet
82
+ self._publisher: Attribute[NamedUser] = NotSet
83
+ self._state: Attribute[str] = NotSet
84
+ self._submission: Attribute[dict[str, Any]] = NotSet
85
+ self._vulnerabilities: Attribute[list[AdvisoryVulnerability]] = NotSet
86
+ super()._initAttributes()
87
+
88
+ @property
89
+ def author(self) -> NamedUser:
90
+ return self._author.value
91
+
92
+ @property
93
+ def closed_at(self) -> datetime:
94
+ return self._closed_at.value
95
+
96
+ @property
97
+ def collaborating_teams(self) -> list[Team]:
98
+ return self._collaborating_teams.value
99
+
100
+ @property
101
+ def collaborating_users(self) -> list[NamedUser]:
102
+ return self._collaborating_users.value
103
+
104
+ @property
105
+ def created_at(self) -> datetime:
106
+ return self._created_at.value
107
+
108
+ @property
109
+ def credits(
110
+ self,
111
+ ) -> list[AdvisoryCredit]:
112
+ return self._credits.value
113
+
114
+ @property
115
+ def credits_detailed(
116
+ self,
117
+ ) -> list[AdvisoryCreditDetailed]:
118
+ return self._credits_detailed.value
119
+
120
+ @property
121
+ def cwe_ids(self) -> list[str]:
122
+ return self._cwe_ids.value
123
+
124
+ @property
125
+ def private_fork(self) -> Repository:
126
+ return self._private_fork.value
127
+
128
+ @property
129
+ def publisher(self) -> NamedUser:
130
+ return self._publisher.value
131
+
132
+ @property
133
+ def state(self) -> str:
134
+ return self._state.value
135
+
136
+ @property
137
+ def submission(self) -> dict[str, Any]:
138
+ return self._submission.value
139
+
140
+ @property
141
+ def vulnerabilities(self) -> list[AdvisoryVulnerability]:
142
+ return self._vulnerabilities.value
143
+
144
+ async def add_vulnerability(
145
+ self,
146
+ ecosystem: str,
147
+ package_name: str | None = None,
148
+ vulnerable_version_range: str | None = None,
149
+ patched_versions: str | None = None,
150
+ vulnerable_functions: list[str] | None = None,
151
+ ) -> None:
152
+ """
153
+ :calls: `PATCH /repos/{owner}/{repo}/security-advisories/{ghsa_id} <https://docs.github.com/en/rest/security-advisories/repository-advisories>`\
154
+ """
155
+ return await self.add_vulnerabilities(
156
+ [
157
+ {
158
+ "package": {
159
+ "ecosystem": ecosystem,
160
+ "name": package_name,
161
+ },
162
+ "vulnerable_version_range": vulnerable_version_range,
163
+ "patched_versions": patched_versions,
164
+ "vulnerable_functions": vulnerable_functions,
165
+ }
166
+ ]
167
+ )
168
+
169
+ async def add_vulnerabilities(self, vulnerabilities: Iterable[AdvisoryVulnerabilityInput]) -> None:
170
+ """
171
+ :calls: `PATCH /repos/{owner}/{repo}/security-advisories/{ghsa_id} <https://docs.github.com/en/rest/security-advisories/repository-advisories>`
172
+ """
173
+ assert isinstance(vulnerabilities, Iterable), vulnerabilities
174
+ for vulnerability in vulnerabilities:
175
+ githubasyncio.AdvisoryVulnerability.AdvisoryVulnerability._validate_vulnerability(vulnerability)
176
+
177
+ post_parameters = {
178
+ "vulnerabilities": [
179
+ githubasyncio.AdvisoryVulnerability.AdvisoryVulnerability._to_github_dict(vulnerability)
180
+ for vulnerability in (self.vulnerabilities + list(vulnerabilities))
181
+ ]
182
+ }
183
+ headers, data = await self._requester.requestJsonAndCheck(
184
+ "PATCH",
185
+ self.url,
186
+ input=post_parameters,
187
+ )
188
+ self._useAttributes(data)
189
+
190
+ async def offer_credit(
191
+ self,
192
+ login_or_user: str | NamedUser,
193
+ credit_type: str,
194
+ ) -> None:
195
+ """
196
+ Offers credit to a user for a vulnerability in a repository.
197
+
198
+ Unless you are giving credit to yourself, the user having credit offered will need to explicitly accept the credit.
199
+ :calls: `PATCH /repos/{owner}/{repo}/security-advisories/{ghsa_id} <https://docs.github.com/en/rest/security-advisories/repository-advisories>`
200
+
201
+ """
202
+ await self.offer_credits([{"login": login_or_user, "type": credit_type}])
203
+
204
+ async def offer_credits(
205
+ self,
206
+ credited: Iterable[Credit],
207
+ ) -> None:
208
+ """
209
+ Offers credit to a list of users for a vulnerability in a repository.
210
+
211
+ Unless you are giving credit to yourself, the user having credit offered will need to explicitly accept the credit.
212
+ :calls: `PATCH /repos/{owner}/{repo}/security-advisories/{ghsa_id} <https://docs.github.com/en/rest/security-advisories/repository-advisories>`
213
+ :param credited: iterable of dict with keys "login" and "type"
214
+
215
+ """
216
+ assert isinstance(credited, Iterable), credited
217
+ for credit in credited:
218
+ githubasyncio.AdvisoryCredit.AdvisoryCredit._validate_credit(credit)
219
+
220
+ patch_parameters = {
221
+ "credits": [
222
+ await githubasyncio.AdvisoryCredit.AdvisoryCredit._to_github_dict(credit)
223
+ for credit in (self.credits + list(credited))
224
+ ]
225
+ }
226
+ headers, data = await self._requester.requestJsonAndCheck(
227
+ "PATCH",
228
+ self.url,
229
+ input=patch_parameters,
230
+ )
231
+ self._useAttributes(data)
232
+
233
+ async def revoke_credit(self, login_or_user: str | NamedUser) -> None:
234
+ """
235
+ :calls: `PATCH /repos/{owner}/{repo}/security-advisories/{ghsa_id} <https://docs.github.com/en/rest/security-advisories/repository-advisories>`_
236
+ """
237
+ assert isinstance(login_or_user, (str, githubasyncio.NamedUser.NamedUser)), login_or_user
238
+ if isinstance(login_or_user, githubasyncio.NamedUser.NamedUser):
239
+ login_or_user = await login_or_user.login
240
+ patch_parameters = {
241
+ "credits": [
242
+ dict(login=credit.login, type=credit.type) for credit in self.credits if credit.login != login_or_user
243
+ ]
244
+ }
245
+ headers, data = await self._requester.requestJsonAndCheck(
246
+ "PATCH",
247
+ self.url,
248
+ input=patch_parameters,
249
+ )
250
+ self._useAttributes(data)
251
+
252
+ async def clear_credits(self) -> None:
253
+ """
254
+ :calls: `PATCH /repos/{owner}/{repo}/security-advisories/{ghsa_id} <https://docs.github.com/en/rest/security-advisories/repository-advisories>`_
255
+ """
256
+ patch_parameters: dict[str, Any] = {"credits": []}
257
+ headers, data = await self._requester.requestJsonAndCheck(
258
+ "PATCH",
259
+ self.url,
260
+ input=patch_parameters,
261
+ )
262
+ self._useAttributes(data)
263
+
264
+ async def edit(
265
+ self,
266
+ summary: Opt[str] = NotSet,
267
+ description: Opt[str] = NotSet,
268
+ severity_or_cvss_vector_string: Opt[str] = NotSet,
269
+ cve_id: Opt[str] = NotSet,
270
+ vulnerabilities: Opt[Iterable[AdvisoryVulnerabilityInput]] = NotSet,
271
+ cwe_ids: Opt[Iterable[str]] = NotSet,
272
+ credits: Opt[Iterable[Credit]] = NotSet,
273
+ state: Opt[str] = NotSet,
274
+ ) -> RepositoryAdvisory:
275
+ """
276
+ :calls: `PATCH /repos/{owner}/{repo}/security-advisories/{ghsa_id} <https://docs.github.com/en/rest/security-advisories/repository-advisories>`_
277
+ """
278
+ assert is_undefined(summary) or isinstance(summary, str), summary
279
+ assert is_undefined(description) or isinstance(description, str), description
280
+ assert is_undefined(severity_or_cvss_vector_string) or isinstance(severity_or_cvss_vector_string, str), (
281
+ severity_or_cvss_vector_string
282
+ )
283
+ assert is_undefined(cve_id) or isinstance(cve_id, str), cve_id
284
+ assert is_undefined(vulnerabilities) or isinstance(vulnerabilities, Iterable), vulnerabilities
285
+ if isinstance(vulnerabilities, Iterable):
286
+ for vulnerability in vulnerabilities:
287
+ githubasyncio.AdvisoryVulnerability.AdvisoryVulnerability._validate_vulnerability(vulnerability)
288
+ assert is_undefined(cwe_ids) or (
289
+ isinstance(cwe_ids, Iterable) and all(isinstance(element, str) for element in cwe_ids)
290
+ ), cwe_ids
291
+ if isinstance(credits, Iterable):
292
+ for credit in credits:
293
+ githubasyncio.AdvisoryCredit.AdvisoryCredit._validate_credit(credit)
294
+ assert is_undefined(state) or isinstance(state, str), state
295
+ patch_parameters: dict[str, Any] = {}
296
+ if is_defined(summary):
297
+ patch_parameters["summary"] = summary
298
+ if is_defined(description):
299
+ patch_parameters["description"] = description
300
+ if isinstance(severity_or_cvss_vector_string, str):
301
+ if severity_or_cvss_vector_string.startswith("CVSS:"):
302
+ patch_parameters["cvss_vector_string"] = severity_or_cvss_vector_string
303
+ else:
304
+ patch_parameters["severity"] = severity_or_cvss_vector_string
305
+ if is_defined(cve_id):
306
+ patch_parameters["cve_id"] = cve_id
307
+ if isinstance(vulnerabilities, Iterable):
308
+ patch_parameters["vulnerabilities"] = [
309
+ githubasyncio.AdvisoryVulnerability.AdvisoryVulnerability._to_github_dict(vulnerability)
310
+ for vulnerability in vulnerabilities
311
+ ]
312
+ if isinstance(cwe_ids, Iterable):
313
+ patch_parameters["cwe_ids"] = list(cwe_ids)
314
+ if isinstance(credits, Iterable):
315
+ patch_parameters["credits"] = [
316
+ await githubasyncio.AdvisoryCredit.AdvisoryCredit._to_github_dict(credit) for credit in credits
317
+ ]
318
+ if is_defined(state):
319
+ patch_parameters["state"] = state
320
+ headers, data = await self._requester.requestJsonAndCheck(
321
+ "PATCH",
322
+ self.url,
323
+ input=patch_parameters,
324
+ )
325
+ self._useAttributes(data)
326
+ return self
327
+
328
+ async def accept_report(self) -> None:
329
+ """
330
+ Accepts the advisory reported from an external reporter via private vulnerability reporting.
331
+
332
+ :calls: `PATCH /repos/{owner}/{repo}/security-advisories/{ghsa_id} <https://docs.github.com/en/rest/security-advisories/repository-advisories>`
333
+
334
+ """
335
+ patch_parameters = {"state": "draft"}
336
+ headers, data = await self._requester.requestJsonAndCheck(
337
+ "PATCH",
338
+ self.url,
339
+ input=patch_parameters,
340
+ )
341
+ self._useAttributes(data)
342
+
343
+ async def publish(self) -> None:
344
+ """
345
+ Publishes the advisory.
346
+
347
+ :calls: `PATCH /repos/{owner}/{repo}/security-advisories/{ghsa_id} <https://docs.github.com/en/rest/security-advisories/repository-advisories>`
348
+
349
+ """
350
+ patch_parameters = {"state": "published"}
351
+ headers, data = await self._requester.requestJsonAndCheck(
352
+ "PATCH",
353
+ self.url,
354
+ input=patch_parameters,
355
+ )
356
+ self._useAttributes(data)
357
+
358
+ async def request_cve(self) -> None:
359
+ """
360
+ Requests a CVE for the advisory.
361
+
362
+ :calls: `POST /repos/{owner}/{repo}/security-advisories/{ghsa_id}/cve <https://docs.github.com/en/rest/security-advisories/repository-advisories#request-a-cve-for-a-repository-security-advisory>`_
363
+
364
+ """
365
+ await self._requester.requestJsonAndCheck(
366
+ "POST",
367
+ self.url + "/cve",
368
+ )
369
+
370
+ async def close(self) -> None:
371
+ """
372
+ Closes the advisory.
373
+
374
+ :calls: `PATCH /repos/{owner}/{repo}/security-advisories/{ghsa_id} <https://docs.github.com/en/rest/security-advisories/repository-advisories>`
375
+
376
+ """
377
+ patch_parameters = {"state": "closed"}
378
+ headers, data = await self._requester.requestJsonAndCheck(
379
+ "PATCH",
380
+ self.url,
381
+ input=patch_parameters,
382
+ )
383
+ self._useAttributes(data)
384
+
385
+ def _useAttributes(self, attributes: dict[str, Any]) -> None:
386
+ if "author" in attributes: # pragma no branch
387
+ self._author = self._makeClassAttribute(githubasyncio.NamedUser.NamedUser, attributes["author"])
388
+ if "closed_at" in attributes: # pragma no branch
389
+ assert attributes["closed_at"] is None or isinstance(attributes["closed_at"], str), attributes["closed_at"]
390
+ self._closed_at = self._makeDatetimeAttribute(attributes["closed_at"])
391
+ if "collaborating_teams" in attributes: # pragma no branch
392
+ self._collaborating_teams = self._makeListOfClassesAttribute(
393
+ githubasyncio.Team.Team, attributes["collaborating_teams"]
394
+ )
395
+ if "collaborating_users" in attributes: # pragma no branch
396
+ self._collaborating_users = self._makeListOfClassesAttribute(
397
+ githubasyncio.NamedUser.NamedUser, attributes["collaborating_users"]
398
+ )
399
+ if "created_at" in attributes: # pragma no branch
400
+ assert attributes["created_at"] is None or isinstance(attributes["created_at"], str), attributes[
401
+ "created_at"
402
+ ]
403
+ self._created_at = self._makeDatetimeAttribute(attributes["created_at"])
404
+ if "credits" in attributes: # pragma no branch
405
+ self._credits = self._makeListOfClassesAttribute(
406
+ githubasyncio.AdvisoryCredit.AdvisoryCredit,
407
+ attributes["credits"],
408
+ )
409
+ if "credits_detailed" in attributes: # pragma no branch
410
+ self._credits_detailed = self._makeListOfClassesAttribute(
411
+ githubasyncio.AdvisoryCreditDetailed.AdvisoryCreditDetailed,
412
+ attributes["credits_detailed"],
413
+ )
414
+ if "cwe_ids" in attributes: # pragma no branch
415
+ self._cwe_ids = self._makeListOfStringsAttribute(attributes["cwe_ids"])
416
+ if "private_fork" in attributes: # pragma no branch
417
+ self._private_fork = self._makeClassAttribute(
418
+ githubasyncio.Repository.Repository, attributes["private_fork"]
419
+ )
420
+ if "publisher" in attributes: # pragma no branch
421
+ self._publisher = self._makeClassAttribute(githubasyncio.NamedUser.NamedUser, attributes["publisher"])
422
+ if "state" in attributes: # pragma no branch
423
+ self._state = self._makeStringAttribute(attributes["state"])
424
+ if "submission" in attributes: # pragma no branch
425
+ self._submission = self._makeDictAttribute(attributes["submission"])
426
+ if "vulnerabilities" in attributes:
427
+ self._vulnerabilities = self._makeListOfClassesAttribute(
428
+ githubasyncio.AdvisoryVulnerability.AdvisoryVulnerability,
429
+ attributes["vulnerabilities"],
430
+ )
431
+ super()._useAttributes(attributes)
@@ -0,0 +1,221 @@
1
+ # FILE AUTO GENERATED DO NOT TOUCH
2
+ ############################ Copyrights and license ############################
3
+ # #
4
+ # Copyright 2024 Enrico Minack <github@enrico.minack.dev> #
5
+ # #
6
+ # This file is part of PyGithub. #
7
+ # http://pygithub.readthedocs.io/ #
8
+ # #
9
+ # PyGithub is free software: you can redistribute it and/or modify it under #
10
+ # the terms of the GNU Lesser General Public License as published by the Free #
11
+ # Software Foundation, either version 3 of the License, or (at your option) #
12
+ # any later version. #
13
+ # #
14
+ # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
15
+ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
16
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
17
+ # details. #
18
+ # #
19
+ # You should have received a copy of the GNU Lesser General Public License #
20
+ # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
21
+ # #
22
+ ################################################################################
23
+
24
+ from __future__ import annotations
25
+
26
+ from typing import TYPE_CHECKING, Any
27
+
28
+ import githubasyncio.Label
29
+ import githubasyncio.NamedUser
30
+ import githubasyncio.Reaction
31
+ import githubasyncio.Repository
32
+ import githubasyncio.RepositoryDiscussionCategory
33
+ import githubasyncio.RepositoryDiscussionComment
34
+ from githubasyncio.DiscussionBase import DiscussionBase
35
+ from githubasyncio.GithubObject import (
36
+ Attribute,
37
+ GraphQlObject,
38
+ NotSet,
39
+ as_rest_api_attributes,
40
+ as_rest_api_attributes_list,
41
+ is_undefined,
42
+ )
43
+ from githubasyncio.PaginatedList import PaginatedList
44
+
45
+ if TYPE_CHECKING:
46
+ from githubasyncio.Label import Label
47
+ from githubasyncio.NamedUser import NamedUser
48
+ from githubasyncio.Reaction import Reaction
49
+ from githubasyncio.Repository import Repository
50
+ from githubasyncio.RepositoryDiscussionCategory import RepositoryDiscussionCategory
51
+ from githubasyncio.RepositoryDiscussionComment import RepositoryDiscussionComment
52
+
53
+
54
+ class RepositoryDiscussion(GraphQlObject, DiscussionBase):
55
+ """
56
+ This class represents GraphQL Discussion.
57
+
58
+ The reference can be found here
59
+ https://docs.github.com/en/graphql/reference/objects#discussion
60
+
61
+ """
62
+
63
+ def _initAttributes(self) -> None:
64
+ super()._initAttributes()
65
+ self._answer: Attribute[RepositoryDiscussionComment | None] = NotSet
66
+ self._body_text: Attribute[str] = NotSet
67
+ self._category: Attribute[RepositoryDiscussionCategory] = NotSet
68
+ self._comments_page = None
69
+ self._database_id: Attribute[int] = NotSet
70
+ self._editor: Attribute[NamedUser] = NotSet
71
+ self._id: Attribute[str] = NotSet
72
+ self._labels_page = None
73
+ self._reactions_page = None
74
+ self._repository: Attribute[Repository] = NotSet
75
+
76
+ @property
77
+ def answer(self) -> RepositoryDiscussionComment | None:
78
+ return self._answer.value
79
+
80
+ @property
81
+ def body_text(self) -> str:
82
+ return self._body_text.value
83
+
84
+ @property
85
+ def category(self) -> RepositoryDiscussionCategory:
86
+ return self._category.value
87
+
88
+ @property
89
+ def database_id(self) -> int:
90
+ return self._database_id.value
91
+
92
+ @property
93
+ def editor(self) -> NamedUser:
94
+ return self._editor.value
95
+
96
+ @property
97
+ def id(self) -> str:
98
+ return self._id.value
99
+
100
+ @property
101
+ def node_id(self) -> str:
102
+ return self.id
103
+
104
+ @property
105
+ def repository(self) -> Repository:
106
+ return self._repository.value
107
+
108
+ def get_comments(self, comment_graphql_schema: str) -> PaginatedList[RepositoryDiscussionComment]:
109
+ """
110
+ :graphql: `query Discussion.comments <https://docs.github.com/en/graphql/reference/discussions#object-discussion>`_
111
+ """
112
+ if self._comments_page is not None:
113
+ return PaginatedList(
114
+ githubasyncio.RepositoryDiscussionComment.RepositoryDiscussionComment,
115
+ self._requester,
116
+ firstData=self._comments_page,
117
+ firstHeaders={},
118
+ )
119
+
120
+ if is_undefined(self._id):
121
+ raise RuntimeError("Retrieving discussion comments requires the discussion field 'id'")
122
+ if not comment_graphql_schema.startswith("\n"):
123
+ comment_graphql_schema = f" {comment_graphql_schema} "
124
+
125
+ query = (
126
+ """
127
+ query Q($discussionId: ID!, $first: Int, $last: Int, $before: String, $after: String) {
128
+ node(id: $discussionId) {
129
+ ... on Discussion {
130
+ comments(first: $first, last: $last, before: $before, after: $after) {
131
+ totalCount
132
+ pageInfo {
133
+ startCursor
134
+ endCursor
135
+ hasNextPage
136
+ hasPreviousPage
137
+ }
138
+ nodes {"""
139
+ + comment_graphql_schema
140
+ + """}
141
+ }
142
+ }
143
+ }
144
+ }"""
145
+ )
146
+ variables = {"discussionId": self.node_id}
147
+ return PaginatedList(
148
+ githubasyncio.RepositoryDiscussionComment.RepositoryDiscussionComment,
149
+ self._requester,
150
+ graphql_query=query,
151
+ graphql_variables=variables,
152
+ list_item=["node", "comments"],
153
+ )
154
+
155
+ def get_labels(self) -> PaginatedList[Label]:
156
+ if self._labels_page is None:
157
+ raise RuntimeError("Fetching labels not implemented")
158
+ return PaginatedList(githubasyncio.Label.Label, self._requester, firstData=self._labels_page, firstHeaders={})
159
+
160
+ def get_reactions(self) -> PaginatedList[Reaction]:
161
+ if self._reactions_page is None:
162
+ raise RuntimeError("Fetching reactions not implemented")
163
+ return PaginatedList(
164
+ githubasyncio.Reaction.Reaction, self._requester, firstData=self._reactions_page, firstHeaders={}
165
+ )
166
+
167
+ async def add_comment(
168
+ self, body: str, reply_to: RepositoryDiscussionComment | str | None = None, output_schema: str = "id"
169
+ ) -> RepositoryDiscussionComment:
170
+ """
171
+ :graphql: `mutation addDiscussionComment <https://docs.github.com/en/graphql/reference/discussions#mutation-adddiscussioncomment>`_
172
+ """
173
+ reply_to_id = (
174
+ reply_to.id
175
+ if isinstance(reply_to, githubasyncio.RepositoryDiscussionComment.RepositoryDiscussionComment)
176
+ else reply_to
177
+ )
178
+ if not output_schema.startswith("\n"):
179
+ output_schema = f" {output_schema} "
180
+
181
+ variables = {"body": body, "discussionId": self.id, "replyToId": reply_to_id}
182
+ return await self._requester.graphql_named_mutation_class(
183
+ "addDiscussionComment",
184
+ NotSet.remove_unset_items(variables),
185
+ f"comment {{{output_schema}}}",
186
+ "comment",
187
+ githubasyncio.RepositoryDiscussionComment.RepositoryDiscussionComment,
188
+ )
189
+
190
+ def _useAttributes(self, attributes: dict[str, Any]) -> None:
191
+ # super class is a REST API GithubObject, attributes are coming from GraphQL
192
+ super()._useAttributes(as_rest_api_attributes(attributes))
193
+ if "answer" in attributes: # pragma no branch
194
+ self._answer = self._makeClassAttribute(
195
+ githubasyncio.RepositoryDiscussionComment.RepositoryDiscussionComment, attributes["answer"]
196
+ )
197
+ if "bodyText" in attributes: # pragma no branch
198
+ self._body_text = self._makeStringAttribute(attributes["bodyText"])
199
+ if "category" in attributes: # pragma no branch
200
+ self._category = self._makeClassAttribute(
201
+ githubasyncio.RepositoryDiscussionCategory.RepositoryDiscussionCategory, attributes["category"]
202
+ )
203
+ if "comments" in attributes: # pragma no branch
204
+ # comments are GraphQL API objects
205
+ self._comments_page = attributes["comments"]["nodes"]
206
+ if "databaseId" in attributes: # pragma no branch
207
+ self._database_id = self._makeIntAttribute(attributes["databaseId"])
208
+ if "editor" in attributes: # pragma no branch
209
+ self._editor = self._makeClassAttribute(githubasyncio.NamedUser.NamedUser, attributes["editor"])
210
+ if "id" in attributes: # pragma no branch
211
+ self._id = self._makeStringAttribute(attributes["id"])
212
+ if "labels" in attributes: # pragma no branch
213
+ # labels are REST API objects
214
+ self._labels_page = as_rest_api_attributes_list(attributes["labels"]["nodes"]) # type: ignore
215
+ if "reactions" in attributes: # pragma no branch
216
+ # reactions are REST API objects
217
+ self._reactions_page = as_rest_api_attributes_list(attributes["reactions"]["nodes"]) # type: ignore
218
+ if "repository" in attributes: # pragma no branch
219
+ self._repository = self._makeClassAttribute(
220
+ githubasyncio.Repository.Repository, as_rest_api_attributes(attributes["repository"])
221
+ )