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,292 @@
1
+ # FILE AUTO GENERATED DO NOT TOUCH
2
+ ############################ Copyrights and license ############################
3
+ # #
4
+ # Copyright 2025 Jens Keiner <jens.keiner@gmail.com> #
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 datetime import datetime
27
+ from typing import TYPE_CHECKING, Any
28
+
29
+ from githubasyncio.GithubObject import (
30
+ Attribute,
31
+ CompletableGithubObject,
32
+ NotSet,
33
+ Opt,
34
+ is_defined,
35
+ is_optional,
36
+ is_optional_list,
37
+ )
38
+ from githubasyncio.RepositoryRulesetBypassActor import RepositoryRulesetBypassActor
39
+ from githubasyncio.Rule import Rule
40
+
41
+ if TYPE_CHECKING:
42
+ pass
43
+
44
+
45
+ class Ruleset(CompletableGithubObject):
46
+ """
47
+ This class represents Rulesets. A ruleset is a set of rules that are applied when specified conditions are met.
48
+
49
+ The reference can be found here https://docs.github.com/en/rest/repos/rules
50
+
51
+ The OpenAPI schema can be found at
52
+
53
+ - /components/schemas/repository-ruleset
54
+
55
+ """
56
+
57
+ def _initAttributes(self) -> None:
58
+ self.__links: Attribute[dict[str, Any]] = NotSet
59
+ self._bypass_actors: Attribute[list[RepositoryRulesetBypassActor]] = NotSet
60
+ self._conditions: Attribute[dict[str, Any]] = NotSet
61
+ self._created_at: Attribute[datetime] = NotSet
62
+ self._current_user_can_bypass: Attribute[str] = NotSet
63
+ self._enforcement: Attribute[str] = NotSet
64
+ self._id: Attribute[int] = NotSet
65
+ self._name: Attribute[str] = NotSet
66
+ self._node_id: Attribute[str] = NotSet
67
+ self._rules: Attribute[list[Rule]] = NotSet
68
+ self._source: Attribute[str] = NotSet
69
+ self._source_type: Attribute[str] = NotSet
70
+ self._target: Attribute[str] = NotSet
71
+ self._updated_at: Attribute[datetime] = NotSet
72
+ self._url: Attribute[str] = NotSet
73
+
74
+ def __repr__(self) -> str:
75
+ return self.get__repr__({"name": self._name.value})
76
+
77
+ @property
78
+ def _links(self) -> dict[str, Any]:
79
+ """
80
+ :type: dict
81
+ :return: URLs related to the ruleset, including self URL and optional html URL
82
+ """
83
+ return self.__links.value
84
+
85
+ @property
86
+ async def bypass_actors(self) -> list[RepositoryRulesetBypassActor]:
87
+ """
88
+ :type: list[RepositoryRulesetBypassActor]
89
+ :return: The actors that can bypass the rules in this ruleset
90
+ """
91
+ await self._completeIfNotSet(self._bypass_actors)
92
+ return self._bypass_actors.value
93
+
94
+ @property
95
+ async def conditions(self) -> dict[str, Any]:
96
+ """
97
+ :type: dict
98
+ :return: The conditions that determine when the ruleset will be enforced
99
+ """
100
+ await self._completeIfNotSet(self._conditions)
101
+ return self._conditions.value
102
+
103
+ @property
104
+ async def created_at(self) -> datetime:
105
+ """
106
+ :type: datetime
107
+ :return: The date and time when the ruleset was created
108
+ """
109
+ await self._completeIfNotSet(self._created_at)
110
+ return self._created_at.value
111
+
112
+ @property
113
+ async def current_user_can_bypass(self) -> str:
114
+ """
115
+ :type: string
116
+ :return: The bypass type of the current user for this ruleset (always, pull_requests_only, or never)
117
+ """
118
+ await self._completeIfNotSet(self._current_user_can_bypass)
119
+ return self._current_user_can_bypass.value
120
+
121
+ @property
122
+ async def enforcement(self) -> str:
123
+ """
124
+ :type: string
125
+ :return: The enforcement status of the ruleset (active, disabled, or evaluate)
126
+ """
127
+ await self._completeIfNotSet(self._enforcement)
128
+ return self._enforcement.value
129
+
130
+ @property
131
+ async def id(self) -> int:
132
+ """
133
+ :type: integer
134
+ :return: The unique identifier of the ruleset
135
+ """
136
+ await self._completeIfNotSet(self._id)
137
+ return self._id.value
138
+
139
+ @property
140
+ async def name(self) -> str:
141
+ """
142
+ :type: string
143
+ :return: The name of the ruleset
144
+ """
145
+ await self._completeIfNotSet(self._name)
146
+ return self._name.value
147
+
148
+ @property
149
+ async def node_id(self) -> str:
150
+ """
151
+ :type: string
152
+ :return: The node ID of the ruleset
153
+ """
154
+ await self._completeIfNotSet(self._node_id)
155
+ return self._node_id.value
156
+
157
+ @property
158
+ async def rules(self) -> list[Rule]:
159
+ """
160
+ :type: list[:class:`githubasyncio.Rule.Rule`]
161
+ :return: The list of rules included in this ruleset
162
+ """
163
+ await self._completeIfNotSet(self._rules)
164
+ return self._rules.value
165
+
166
+ @property
167
+ async def source(self) -> str:
168
+ """
169
+ :type: string
170
+ :return: The name of the source where the ruleset was created
171
+ """
172
+ await self._completeIfNotSet(self._source)
173
+ return self._source.value
174
+
175
+ @property
176
+ async def source_type(self) -> str:
177
+ """
178
+ :type: string
179
+ :return: The type of the source of the ruleset (Repository, Organization, or Enterprise)
180
+ """
181
+ await self._completeIfNotSet(self._source_type)
182
+ return self._source_type.value
183
+
184
+ @property
185
+ async def target(self) -> str:
186
+ """
187
+ :type: string
188
+ :return: The target of the ruleset (branch, tag, push, or repository)
189
+ """
190
+ await self._completeIfNotSet(self._target)
191
+ return self._target.value
192
+
193
+ @property
194
+ async def updated_at(self) -> datetime:
195
+ """
196
+ :type: datetime
197
+ :return: The date and time when the ruleset was last updated
198
+ """
199
+ await self._completeIfNotSet(self._updated_at)
200
+ return self._updated_at.value
201
+
202
+ @property
203
+ async def url(self) -> str:
204
+ """
205
+ :type: string
206
+ :return: The API URL of the ruleset
207
+ """
208
+ await self._completeIfNotSet(self._url)
209
+ return self._url.value
210
+
211
+ async def edit(
212
+ self,
213
+ name: Opt[str] = NotSet,
214
+ target: Opt[str] = NotSet,
215
+ enforcement: Opt[str] = NotSet,
216
+ bypass_actors: Opt[list[dict[str, Any]]] = NotSet,
217
+ conditions: Opt[dict[str, Any]] = NotSet,
218
+ rules: Opt[list[dict[str, Any]]] = NotSet,
219
+ ) -> Ruleset:
220
+ """
221
+ :calls: `PUT /repos/{owner}/{repo}/rulesets/{ruleset_id} <https://docs.github.com/en/rest/repos/rules#update-a-repository-ruleset>`_
222
+ :param name: string
223
+ :param target: string
224
+ :param enforcement: string
225
+ :param bypass_actors: list of dict
226
+ :param conditions: dict
227
+ :param rules: list of dict
228
+ """
229
+ assert is_optional(name, str), name
230
+ assert is_optional(target, str), target
231
+ if is_defined(target):
232
+ assert target in ["branch", "tag", "push"], target
233
+ assert is_optional(enforcement, str), enforcement
234
+ if is_defined(enforcement):
235
+ assert enforcement in ["active", "disabled", "evaluate"], enforcement
236
+ assert is_optional_list(bypass_actors, dict), bypass_actors
237
+ assert is_optional(conditions, dict), conditions
238
+ assert is_optional_list(rules, dict), rules
239
+
240
+ put_parameters = NotSet.remove_unset_items(
241
+ {
242
+ "name": name,
243
+ "target": target,
244
+ "enforcement": enforcement,
245
+ "bypass_actors": bypass_actors,
246
+ "conditions": conditions,
247
+ "rules": rules,
248
+ }
249
+ )
250
+
251
+ headers, data = await self._requester.requestJsonAndCheck("PUT", await self.url, input=put_parameters)
252
+ return Ruleset(self._requester, headers, data, completed=True)
253
+
254
+ async def delete(self) -> bool:
255
+ """
256
+ :calls: `DELETE /repos/{owner}/{repo}/rulesets/{ruleset_id} <https://docs.github.com/en/rest/repos/rules#delete-a-repository-ruleset>`_
257
+ """
258
+ status, _, _ = await self._requester.requestJson("DELETE", await self.url)
259
+ return status == 204
260
+
261
+ def _useAttributes(self, attributes: dict[str, Any]) -> None:
262
+ super()._useAttributes(attributes)
263
+ if "_links" in attributes: # pragma no branch
264
+ self.__links = self._makeDictAttribute(attributes["_links"])
265
+ if "bypass_actors" in attributes: # pragma no branch
266
+ self._bypass_actors = self._makeListOfClassesAttribute(
267
+ RepositoryRulesetBypassActor, attributes["bypass_actors"]
268
+ )
269
+ if "conditions" in attributes: # pragma no branch
270
+ self._conditions = self._makeDictAttribute(attributes["conditions"])
271
+ if "created_at" in attributes: # pragma no branch
272
+ self._created_at = self._makeDatetimeAttribute(attributes["created_at"])
273
+ if "current_user_can_bypass" in attributes: # pragma no branch
274
+ self._current_user_can_bypass = self._makeStringAttribute(attributes["current_user_can_bypass"])
275
+ if "enforcement" in attributes: # pragma no branch
276
+ self._enforcement = self._makeStringAttribute(attributes["enforcement"])
277
+ if "id" in attributes: # pragma no branch
278
+ self._id = self._makeIntAttribute(attributes["id"])
279
+ if "name" in attributes: # pragma no branch
280
+ self._name = self._makeStringAttribute(attributes["name"])
281
+ if "node_id" in attributes: # pragma no branch
282
+ self._node_id = self._makeStringAttribute(attributes["node_id"])
283
+ if "rules" in attributes: # pragma no branch
284
+ self._rules = self._makeListOfClassesAttribute(Rule, attributes["rules"])
285
+ if "source" in attributes: # pragma no branch
286
+ self._source = self._makeStringAttribute(attributes["source"])
287
+ if "source_type" in attributes: # pragma no branch
288
+ self._source_type = self._makeStringAttribute(attributes["source_type"])
289
+ if "target" in attributes: # pragma no branch
290
+ self._target = self._makeStringAttribute(attributes["target"])
291
+ if "updated_at" in attributes: # pragma no branch
292
+ self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"])
@@ -0,0 +1,139 @@
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 2023 Andrew Dawes <53574062+AndrewJDawes@users.noreply.github.com> #
17
+ # Copyright 2023 Enrico Minack <github@enrico.minack.dev> #
18
+ # Copyright 2023 Mauricio Alejandro Martínez Pacheco <mauricio.martinez@premise.com>#
19
+ # Copyright 2023 Trim21 <trim21.me@gmail.com> #
20
+ # Copyright 2024 Enrico Minack <github@enrico.minack.dev> #
21
+ # Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> #
22
+ # Copyright 2025 Enrico Minack <github@enrico.minack.dev> #
23
+ # #
24
+ # This file is part of PyGithub. #
25
+ # http://pygithub.readthedocs.io/ #
26
+ # #
27
+ # PyGithub is free software: you can redistribute it and/or modify it under #
28
+ # the terms of the GNU Lesser General Public License as published by the Free #
29
+ # Software Foundation, either version 3 of the License, or (at your option) #
30
+ # any later version. #
31
+ # #
32
+ # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
33
+ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
34
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
35
+ # details. #
36
+ # #
37
+ # You should have received a copy of the GNU Lesser General Public License #
38
+ # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
39
+ # #
40
+ ################################################################################
41
+
42
+ from __future__ import annotations
43
+
44
+ import urllib.parse
45
+ from datetime import datetime
46
+ from typing import Any
47
+
48
+ from githubasyncio.GithubObject import Attribute, CompletableGithubObject, NotSet, is_undefined
49
+
50
+
51
+ class Secret(CompletableGithubObject):
52
+ """
53
+ This class represents a GitHub secret.
54
+
55
+ The reference can be found here
56
+ https://docs.github.com/en/rest/actions/secrets
57
+
58
+ The OpenAPI schema can be found at
59
+
60
+ - /components/schemas/actions-secret
61
+
62
+ """
63
+
64
+ def _initAttributes(self) -> None:
65
+ self._created_at: Attribute[datetime] = NotSet
66
+ self._name: Attribute[str] = NotSet
67
+ self._secrets_url: Attribute[str] = NotSet
68
+ self._updated_at: Attribute[datetime] = NotSet
69
+ self._url: Attribute[str] = NotSet
70
+
71
+ def __repr__(self) -> str:
72
+ return self.get__repr__({"name": self._name.value})
73
+
74
+ @property
75
+ async def created_at(self) -> datetime:
76
+ """
77
+ :type: datetime.datetime
78
+ """
79
+ await self._completeIfNotSet(self._created_at)
80
+ return self._created_at.value
81
+
82
+ @property
83
+ async def name(self) -> str:
84
+ """
85
+ :type: string
86
+ """
87
+ await self._completeIfNotSet(self._name)
88
+ return self._name.value
89
+
90
+ @property
91
+ def secrets_url(self) -> str:
92
+ """
93
+ :type: string
94
+ """
95
+ return self._secrets_url.value
96
+
97
+ @property
98
+ async def updated_at(self) -> datetime:
99
+ """
100
+ :type: datetime.datetime
101
+ """
102
+ await self._completeIfNotSet(self._updated_at)
103
+ return self._updated_at.value
104
+
105
+ @property
106
+ async def url(self) -> str:
107
+ """
108
+ :type: string
109
+ """
110
+ # Construct url from secrets_url and name, if self._url. is not set
111
+ if is_undefined(self._url):
112
+ self._url = self._makeStringAttribute(self.secrets_url + "/" + await self.name)
113
+ return self._url.value
114
+
115
+ async def delete(self) -> None:
116
+ """
117
+ :calls: `DELETE /repos/{owner}/{repo}/actions/secrets/{secret_name} <https://docs.github.com/rest/dependabot/secrets#delete-a-repository-secret>`_
118
+ :calls: `DELETE /repos/{owner}/{repo}/dependabot/secrets/{secret_name} <https://docs.github.com/rest/dependabot/secrets#delete-a-repository-secret>`_
119
+ :calls: `DELETE /repos/{owner}/{repo}/environments/{environment_name}/secrets/{secret_name} <https://docs.github.com/en/rest/actions/secrets>`_
120
+ :calls: `DELETE /orgs/{org}/actions/secrets/{secret_name} <https://docs.github.com/rest/actions/secrets#delete-an-organization-secret>`_
121
+ :calls: `DELETE /orgs/{org}/dependabot/secrets/{secret_name} <https://docs.github.com/rest/dependabot/secrets#get-an-organization-secret>`_
122
+ """
123
+ await self._requester.requestJsonAndCheck("DELETE", await self.url)
124
+
125
+ def _useAttributes(self, attributes: dict[str, Any]) -> None:
126
+ if "created_at" in attributes:
127
+ self._created_at = self._makeDatetimeAttribute(attributes["created_at"])
128
+ if "name" in attributes:
129
+ self._name = self._makeStringAttribute(attributes["name"])
130
+ elif "url" in attributes and attributes["url"]:
131
+ quoted_name = attributes["url"].split("/")[-1]
132
+ name = urllib.parse.unquote(quoted_name)
133
+ self._name = self._makeStringAttribute(name)
134
+ if "secrets_url" in attributes:
135
+ self._secrets_url = self._makeStringAttribute(attributes["secrets_url"])
136
+ if "updated_at" in attributes:
137
+ self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"])
138
+ if "url" in attributes:
139
+ self._url = self._makeStringAttribute(attributes["url"])