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,175 @@
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 Enrico Minack <github@enrico.minack.dev> #
17
+ # Copyright 2023 Mark Amery <markamery@btinternet.com> #
18
+ # Copyright 2023 Trim21 <trim21.me@gmail.com> #
19
+ # Copyright 2023 YugoHino <henom06@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
+ # Copyright 2026 Enrico Minack <github@enrico.minack.dev> #
24
+ # #
25
+ # This file is part of PyGithub. #
26
+ # http://pygithub.readthedocs.io/ #
27
+ # #
28
+ # PyGithub is free software: you can redistribute it and/or modify it under #
29
+ # the terms of the GNU Lesser General Public License as published by the Free #
30
+ # Software Foundation, either version 3 of the License, or (at your option) #
31
+ # any later version. #
32
+ # #
33
+ # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
34
+ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
35
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
36
+ # details. #
37
+ # #
38
+ # You should have received a copy of the GNU Lesser General Public License #
39
+ # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
40
+ # #
41
+ ################################################################################
42
+
43
+ from __future__ import annotations
44
+
45
+ from datetime import datetime
46
+ from typing import TYPE_CHECKING, Any
47
+
48
+ import githubasyncio.EnterpriseConsumedLicenses
49
+ import githubasyncio.Requester
50
+ from githubasyncio.compat import deprecated
51
+ from githubasyncio.GithubObject import Attribute, NonCompletableGithubObject, NotSet, is_defined, is_undefined
52
+
53
+ if TYPE_CHECKING:
54
+ from githubasyncio.EnterpriseConsumedLicenses import EnterpriseConsumedLicenses
55
+ from githubasyncio.Requester import Requester
56
+
57
+
58
+ class Enterprise(NonCompletableGithubObject):
59
+ """
60
+ This class represents Enterprises.
61
+
62
+ The reference can be found here
63
+ https://docs.github.com/en/enterprise-cloud@latest/rest/enterprise-admin
64
+
65
+ The OpenAPI schema can be found at
66
+
67
+ - /components/schemas/enterprise
68
+
69
+ """
70
+
71
+ def _initAttributes(self) -> None:
72
+ self._avatar_url: Attribute[str] = NotSet
73
+ self._created_at: Attribute[datetime] = NotSet
74
+ self._description: Attribute[str] = NotSet
75
+ self._html_url: Attribute[str] = NotSet
76
+ self._id: Attribute[int] = NotSet
77
+ self._name: Attribute[str] = NotSet
78
+ self._node_id: Attribute[str] = NotSet
79
+ self._slug: Attribute[str] = NotSet
80
+ self._updated_at: Attribute[datetime] = NotSet
81
+ self._url: Attribute[str] = NotSet
82
+ self._website_url: Attribute[str] = NotSet
83
+
84
+ def __repr__(self) -> str:
85
+ return self.get__repr__({"slug": self._slug.value})
86
+
87
+ @property
88
+ def avatar_url(self) -> str:
89
+ return self._avatar_url.value
90
+
91
+ @property
92
+ def created_at(self) -> datetime:
93
+ return self._created_at.value
94
+
95
+ @property
96
+ def description(self) -> str:
97
+ return self._description.value
98
+
99
+ @property
100
+ @deprecated("Use slug instead")
101
+ def enterprise(self) -> str:
102
+ # alias for slug
103
+ return self._slug.value
104
+
105
+ @property
106
+ def html_url(self) -> str:
107
+ return self._html_url.value
108
+
109
+ @property
110
+ def id(self) -> int:
111
+ return self._id.value
112
+
113
+ @property
114
+ def name(self) -> str:
115
+ return self._name.value
116
+
117
+ @property
118
+ def node_id(self) -> str:
119
+ return self._node_id.value
120
+
121
+ @property
122
+ def slug(self) -> str:
123
+ return self._slug.value
124
+
125
+ @property
126
+ def updated_at(self) -> datetime:
127
+ return self._updated_at.value
128
+
129
+ @property
130
+ def url(self) -> str:
131
+ if is_undefined(self._url) and is_defined(self._slug):
132
+ self._url = self._makeStringAttribute(f"/enterprises/{self.slug}")
133
+ return self._url.value
134
+
135
+ @property
136
+ def website_url(self) -> str:
137
+ return self._website_url.value
138
+
139
+ @staticmethod
140
+ def from_slug(requester: Requester, slug: str) -> Enterprise:
141
+ return Enterprise(requester, {}, {"slug": slug})
142
+
143
+ def get_consumed_licenses(self, *, licence_users_per_page: int | None = None) -> EnterpriseConsumedLicenses:
144
+ """
145
+ :calls: `GET /enterprises/{enterprise}/consumed-licenses <https://docs.github.com/en/enterprise-cloud@latest/rest/enterprise-admin/license#list-enterprise-consumed-licenses>`_
146
+ :param licence_users_per_page: int Number of users retrieved with the licences. Iterating over users property will fetch pages of this size. The default page size is 30, the maximum is 100.
147
+ """
148
+ # licence_users_per_page asserted in EnterpriseConsumedLicenses(CompletableGithubObjectWithPaginatedProperty)
149
+ return githubasyncio.EnterpriseConsumedLicenses.EnterpriseConsumedLicenses(
150
+ self._requester, url=self.url + "/consumed-licenses", per_page=licence_users_per_page
151
+ )
152
+
153
+ def _useAttributes(self, attributes: dict[str, Any]) -> None:
154
+ if "avatar_url" in attributes: # pragma no branch
155
+ self._avatar_url = self._makeStringAttribute(attributes["avatar_url"])
156
+ if "created_at" in attributes: # pragma no branch
157
+ self._created_at = self._makeDatetimeAttribute(attributes["created_at"])
158
+ if "description" in attributes: # pragma no branch
159
+ self._description = self._makeStringAttribute(attributes["description"])
160
+ if "html_url" in attributes: # pragma no branch
161
+ self._html_url = self._makeStringAttribute(attributes["html_url"])
162
+ if "id" in attributes: # pragma no branch
163
+ self._id = self._makeIntAttribute(attributes["id"])
164
+ if "name" in attributes: # pragma no branch
165
+ self._name = self._makeStringAttribute(attributes["name"])
166
+ if "node_id" in attributes: # pragma no branch
167
+ self._node_id = self._makeStringAttribute(attributes["node_id"])
168
+ if "slug" in attributes: # pragma no branch
169
+ self._slug = self._makeStringAttribute(attributes["slug"])
170
+ if "updated_at" in attributes: # pragma no branch
171
+ self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"])
172
+ if "url" in attributes: # pragma no branch
173
+ self._url = self._makeStringAttribute(attributes["url"])
174
+ if "website_url" in attributes: # pragma no branch
175
+ self._website_url = self._makeStringAttribute(attributes["website_url"])
@@ -0,0 +1,138 @@
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 2023 Enrico Minack <github@enrico.minack.dev> #
18
+ # Copyright 2023 Trim21 <trim21.me@gmail.com> #
19
+ # Copyright 2023 YugoHino <henom06@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
+ # Copyright 2026 Enrico Minack <github@enrico.minack.dev> #
24
+ # #
25
+ # This file is part of PyGithub. #
26
+ # http://pygithub.readthedocs.io/ #
27
+ # #
28
+ # PyGithub is free software: you can redistribute it and/or modify it under #
29
+ # the terms of the GNU Lesser General Public License as published by the Free #
30
+ # Software Foundation, either version 3 of the License, or (at your option) #
31
+ # any later version. #
32
+ # #
33
+ # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
34
+ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
35
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
36
+ # details. #
37
+ # #
38
+ # You should have received a copy of the GNU Lesser General Public License #
39
+ # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
40
+ # #
41
+ ################################################################################
42
+
43
+ from __future__ import annotations
44
+
45
+ from typing import TYPE_CHECKING, Any
46
+
47
+ import githubasyncio.NamedEnterpriseUser
48
+ from githubasyncio.GithubObject import Attribute, CompletableGithubObjectWithPaginatedProperty, NotSet
49
+ from githubasyncio.PaginatedList import PaginatedList
50
+
51
+ if TYPE_CHECKING:
52
+ from githubasyncio.NamedEnterpriseUser import NamedEnterpriseUser
53
+
54
+
55
+ class EnterpriseConsumedLicenses(CompletableGithubObjectWithPaginatedProperty):
56
+ """
57
+ This class represents license consumed by enterprises.
58
+
59
+ The reference can be found here
60
+ https://docs.github.com/en/enterprise-cloud@latest/rest/enterprise-admin/license#list-enterprise-consumed-licenses
61
+
62
+ This class has a `paginated property <https://pygithub.readthedocs.io/en/stable/utilities.html#classes-with-paginated-properties>`_.
63
+ For details, see :meth:`EnterpriseConsumedLicenses.users` or :meth:`EnterpriseConsumedLicenses.get_users`.
64
+
65
+ """
66
+
67
+ def _initAttributes(self) -> None:
68
+ super()._initAttributes()
69
+ self._enterprise: Attribute[str] = NotSet
70
+ self._total_seats_consumed: Attribute[int] = NotSet
71
+ self._total_seats_purchased: Attribute[int] = NotSet
72
+
73
+ def __repr__(self) -> str:
74
+ return self.get__repr__({"enterprise": self._enterprise.value})
75
+
76
+ @property
77
+ async def enterprise(self) -> str:
78
+ await self._completeIfNotSet(self._enterprise)
79
+ return self._enterprise.value
80
+
81
+ @property
82
+ def total_seats_consumed(self) -> int:
83
+ return self._total_seats_consumed.value
84
+
85
+ @property
86
+ def total_seats_purchased(self) -> int:
87
+ return self._total_seats_purchased.value
88
+
89
+ @property
90
+ async def users(self) -> PaginatedList[NamedEnterpriseUser]:
91
+ """
92
+ This is a `paginated property <https://pygithub.readthedocs.io/en/stable/utilities.html#classes-with-paginated-properties>`_.
93
+
94
+ Iterating over this paginated list may fetch multiple pages. The size of these pages can be controlled via
95
+ the ``…_per_page`` parameter of :meth:`githubasyncio.Enterprise.Enterprise.get_consumed_licenses`,
96
+ :meth:`EnterpriseConsumedLicenses.get_users`, or :meth:`github.Github`.
97
+
98
+ If no ``per_page`` is given, the default page size is 30. The maximum is 100.
99
+ """
100
+ return PaginatedList(
101
+ githubasyncio.NamedEnterpriseUser.NamedEnterpriseUser,
102
+ self._requester,
103
+ await self.url,
104
+ self._pagination_parameters,
105
+ headers=None,
106
+ list_item="users",
107
+ firstData=await self.raw_data,
108
+ firstHeaders=await self.raw_headers,
109
+ )
110
+
111
+ async def get_users(self, licence_users_per_page: int | None = None) -> PaginatedList[NamedEnterpriseUser]:
112
+ """
113
+ :calls: `GET /enterprises/{enterprise}/consumed-licenses <https://docs.github.com/en/enterprise-cloud@latest/rest/enterprise-admin/license#list-enterprise-consumed-licenses>`_
114
+
115
+ Identical to calling :meth:`EnterpriseConsumedLicenses.users`, except that this uses the given ``per_page`` value.
116
+
117
+ For more details, see :meth:`EnterpriseConsumedLicenses.users`.
118
+
119
+ :param licence_users_per_page: int Number of users retrieved per page.
120
+ Iterating over the users will fetch pages of this size. The default page size is 30, the maximum is 100.
121
+ """
122
+ return PaginatedList(
123
+ githubasyncio.NamedEnterpriseUser.NamedEnterpriseUser,
124
+ self._requester,
125
+ await self.url,
126
+ self._pagination_parameters_with(page=1, per_page=licence_users_per_page),
127
+ headers=None,
128
+ list_item="users",
129
+ )
130
+
131
+ def _useAttributes(self, attributes: dict[str, Any]) -> None:
132
+ super()._useAttributes(attributes)
133
+ if "enterprise" in attributes: # pragma no branch
134
+ self._enterprise = self._makeStringAttribute(attributes["enterprise"])
135
+ if "total_seats_consumed" in attributes: # pragma no branch
136
+ self._total_seats_consumed = self._makeIntAttribute(attributes["total_seats_consumed"])
137
+ if "total_seats_purchased" in attributes: # pragma no branch
138
+ self._total_seats_purchased = self._makeIntAttribute(attributes["total_seats_purchased"])
@@ -0,0 +1,354 @@
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 2017 Jannis Gebauer <ja.geb@me.com> #
12
+ # Copyright 2017 Simon <spam@esemi.ru> #
13
+ # Copyright 2018 sfdye <tsfdye@gmail.com> #
14
+ # Copyright 2019 Steve Kowalik <steven@wedontsleep.org> #
15
+ # Copyright 2019 Wan Liuyang <tsfdye@gmail.com> #
16
+ # Copyright 2020 Steve Kowalik <steven@wedontsleep.org> #
17
+ # Copyright 2021 Steve Kowalik <steven@wedontsleep.org> #
18
+ # Copyright 2023 Andrew Dawes <53574062+AndrewJDawes@users.noreply.github.com> #
19
+ # Copyright 2023 Enrico Minack <github@enrico.minack.dev> #
20
+ # Copyright 2023 Trim21 <trim21.me@gmail.com> #
21
+ # Copyright 2023 alson <git@alm.nufan.net> #
22
+ # Copyright 2024 Enrico Minack <github@enrico.minack.dev> #
23
+ # Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> #
24
+ # Copyright 2025 Enrico Minack <github@enrico.minack.dev> #
25
+ # #
26
+ # This file is part of PyGithub. #
27
+ # http://pygithub.readthedocs.io/ #
28
+ # #
29
+ # PyGithub is free software: you can redistribute it and/or modify it under #
30
+ # the terms of the GNU Lesser General Public License as published by the Free #
31
+ # Software Foundation, either version 3 of the License, or (at your option) #
32
+ # any later version. #
33
+ # #
34
+ # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
35
+ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
36
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
37
+ # details. #
38
+ # #
39
+ # You should have received a copy of the GNU Lesser General Public License #
40
+ # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
41
+ # #
42
+ ################################################################################
43
+
44
+ from __future__ import annotations
45
+
46
+ import urllib.parse
47
+ from datetime import datetime
48
+ from typing import TYPE_CHECKING, Any
49
+
50
+ import githubasyncio.DeploymentBranchPolicy
51
+ import githubasyncio.EnvironmentDeploymentBranchPolicy
52
+ import githubasyncio.EnvironmentProtectionRule
53
+ import githubasyncio.PublicKey
54
+ import githubasyncio.Secret
55
+ import githubasyncio.Variable
56
+ from githubasyncio.GithubObject import Attribute, CompletableGithubObject, NotSet, Opt, is_optional, is_undefined
57
+ from githubasyncio.PaginatedList import PaginatedList
58
+
59
+ if TYPE_CHECKING:
60
+ from githubasyncio.DeploymentBranchPolicy import DeploymentBranchPolicy
61
+ from githubasyncio.EnvironmentDeploymentBranchPolicy import EnvironmentDeploymentBranchPolicy
62
+ from githubasyncio.EnvironmentProtectionRule import EnvironmentProtectionRule
63
+ from githubasyncio.PublicKey import PublicKey
64
+ from githubasyncio.Secret import Secret
65
+ from githubasyncio.Variable import Variable
66
+
67
+
68
+ class Environment(CompletableGithubObject):
69
+ """
70
+ This class represents Environment.
71
+
72
+ The reference can be found here
73
+ https://docs.github.com/en/rest/reference/deployments#environments
74
+
75
+ The OpenAPI schema can be found at
76
+
77
+ - /components/schemas/environment
78
+
79
+ """
80
+
81
+ def _initAttributes(self) -> None:
82
+ self._created_at: Attribute[datetime] = NotSet
83
+ self._deployment_branch_policy: Attribute[EnvironmentDeploymentBranchPolicy] = NotSet
84
+ self._environments_url: Attribute[str] = NotSet
85
+ self._html_url: Attribute[str] = NotSet
86
+ self._id: Attribute[int] = NotSet
87
+ self._name: Attribute[str] = NotSet
88
+ self._node_id: Attribute[str] = NotSet
89
+ self._protection_rules: Attribute[list[EnvironmentProtectionRule]] = NotSet
90
+ self._updated_at: Attribute[datetime] = NotSet
91
+ self._url: Attribute[str] = NotSet
92
+
93
+ def __repr__(self) -> str:
94
+ return self.get__repr__({"name": self._name.value})
95
+
96
+ @property
97
+ async def created_at(self) -> datetime:
98
+ await self._completeIfNotSet(self._created_at)
99
+ return self._created_at.value
100
+
101
+ @property
102
+ async def deployment_branch_policy(
103
+ self,
104
+ ) -> EnvironmentDeploymentBranchPolicy:
105
+ await self._completeIfNotSet(self._deployment_branch_policy)
106
+ return self._deployment_branch_policy.value
107
+
108
+ @property
109
+ def environments_url(self) -> str:
110
+ """
111
+ :type: string
112
+ """
113
+ return self._environments_url.value
114
+
115
+ @property
116
+ async def html_url(self) -> str:
117
+ await self._completeIfNotSet(self._html_url)
118
+ return self._html_url.value
119
+
120
+ @property
121
+ async def id(self) -> int:
122
+ await self._completeIfNotSet(self._id)
123
+ return self._id.value
124
+
125
+ @property
126
+ async def name(self) -> str:
127
+ await self._completeIfNotSet(self._name)
128
+ return self._name.value
129
+
130
+ @property
131
+ async def node_id(self) -> str:
132
+ await self._completeIfNotSet(self._node_id)
133
+ return self._node_id.value
134
+
135
+ @property
136
+ async def protection_rules(
137
+ self,
138
+ ) -> list[EnvironmentProtectionRule]:
139
+ await self._completeIfNotSet(self._protection_rules)
140
+ return self._protection_rules.value
141
+
142
+ @property
143
+ async def updated_at(self) -> datetime:
144
+ await self._completeIfNotSet(self._updated_at)
145
+ return self._updated_at.value
146
+
147
+ @property
148
+ async def url(self) -> str:
149
+ """
150
+ :type: string
151
+ """
152
+ # Construct url from environments_url and name, if self._url. is not set
153
+ if is_undefined(self._url):
154
+ self._url = self._makeStringAttribute(self.environments_url + "/" + await self.name)
155
+ return self._url.value
156
+
157
+ async def get_public_key(self) -> PublicKey:
158
+ """
159
+ :calls: `GET /repos/{owner}/{repo}/environments/{environment_name}/secrets/public-key <https://docs.github.com/en/rest/reference#get-a-repository-public-key>`_
160
+ :rtype: :class:`PublicKey`
161
+ """
162
+ # https://stackoverflow.com/a/76474814
163
+ # https://docs.github.com/en/rest/secrets?apiVersion=2022-11-28#get-an-environment-public-key
164
+ headers, data = await self._requester.requestJsonAndCheck("GET", f"{await self.url}/secrets/public-key")
165
+ return githubasyncio.PublicKey.PublicKey(self._requester, headers, data, completed=True)
166
+
167
+ async def create_secret(self, secret_name: str, unencrypted_value: str) -> Secret:
168
+ """
169
+ :calls: `PUT /repos/{owner}/{repo}/environments/{environment_name}/secrets/{secret_name} <https://docs.github.com/en/rest/secrets#get-a-repository-secret>`_
170
+ """
171
+ assert isinstance(secret_name, str), secret_name
172
+ assert isinstance(unencrypted_value, str), unencrypted_value
173
+ public_key = await self.get_public_key()
174
+ payload = await public_key.encrypt(unencrypted_value)
175
+ put_parameters = {
176
+ "key_id": (await public_key.key_id),
177
+ "encrypted_value": payload,
178
+ }
179
+ quoted_secret_name = urllib.parse.quote(secret_name, safe="")
180
+ url = f"{await self.url}/secrets/{quoted_secret_name}"
181
+ await self._requester.requestJsonAndCheck("PUT", url, input=put_parameters)
182
+ return githubasyncio.Secret.Secret(
183
+ self._requester,
184
+ url=url,
185
+ attributes={"name": secret_name},
186
+ completed=False,
187
+ )
188
+
189
+ async def get_secrets(self) -> PaginatedList[Secret]:
190
+ """
191
+ Gets all repository secrets.
192
+
193
+ :calls: `GET /repos/{owner}/{repo}/environments/{environment_name}/secrets </repos/{owner}/{repo}/environments/{environment_name}/secrets>`_
194
+
195
+ """
196
+ return PaginatedList(
197
+ githubasyncio.Secret.Secret,
198
+ self._requester,
199
+ f"{await self.url}/secrets",
200
+ None,
201
+ attributesTransformer=PaginatedList.override_attributes({"secrets_url": f"{await self.url}/secrets"}),
202
+ list_item="secrets",
203
+ )
204
+
205
+ async def get_secret(self, secret_name: str) -> Secret:
206
+ """
207
+ :calls: `GET /repos/{owner}/{repo}/environments/{environment_name}/secrets/{secret_name} <https://docs.github.com/en/rest/secrets#get-an-organization-secret>`_
208
+ """
209
+ assert isinstance(secret_name, str), secret_name
210
+ secret_name = urllib.parse.quote(secret_name, safe="")
211
+ return githubasyncio.Secret.Secret(self._requester, url=f"{await self.url}/secrets/{secret_name}")
212
+
213
+ async def create_variable(self, variable_name: str, value: str) -> Variable:
214
+ """
215
+ :calls: `POST /repos/{owner}/{repo}/environments/{environment_name}/variables/{name} <https://docs.github.com/en/rest/variables#create-a-repository-variable>`_
216
+ """
217
+ assert isinstance(variable_name, str), variable_name
218
+ assert isinstance(value, str), value
219
+ post_parameters = {
220
+ "name": variable_name,
221
+ "value": value,
222
+ }
223
+ await self._requester.requestJsonAndCheck("POST", f"{await self.url}/variables", input=post_parameters)
224
+
225
+ quoted_variable_name = urllib.parse.quote(variable_name, safe="")
226
+ url = f"{await self.url}/variables/{quoted_variable_name}"
227
+ return githubasyncio.Variable.Variable(
228
+ self._requester,
229
+ url=url,
230
+ attributes={
231
+ "name": variable_name,
232
+ "value": value,
233
+ },
234
+ completed=False,
235
+ )
236
+
237
+ async def get_variables(self) -> PaginatedList[Variable]:
238
+ """
239
+ Gets all repository variables :rtype: :class:`PaginatedList` of :class:`Variable`
240
+ """
241
+ return PaginatedList(
242
+ githubasyncio.Variable.Variable,
243
+ self._requester,
244
+ f"{await self.url}/variables",
245
+ None,
246
+ attributesTransformer=PaginatedList.override_attributes({"variables_url": f"{await self.url}/variables"}),
247
+ list_item="variables",
248
+ )
249
+
250
+ async def get_variable(self, variable_name: str) -> Variable:
251
+ """
252
+ :calls: `GET /repos/{owner}/{repo}/environments/{environment_name}/variables/{name} <https://docs.github.com/rest/actions/variables#get-an-environment-variable>`_
253
+ :param variable_name: string
254
+ :rtype: Variable
255
+ """
256
+ assert isinstance(variable_name, str), variable_name
257
+ variable_name = urllib.parse.quote(variable_name, safe="")
258
+ url = f"{await self.url}/variables/{variable_name}"
259
+ return githubasyncio.Variable.Variable(self._requester, url=url)
260
+
261
+ async def delete_secret(self, secret_name: str) -> bool:
262
+ """
263
+ :calls: `DELETE /repos/{owner}/{repo}/environments/{environment_name}/secrets/{secret_name} <https://docs.github.com/en/rest/reference#delete-a-repository-secret>`_
264
+ :param secret_name: string
265
+ :rtype: bool
266
+ """
267
+ assert isinstance(secret_name, str), secret_name
268
+ status, headers, data = await self._requester.requestJson("DELETE", f"{await self.url}/secrets/{secret_name}")
269
+ return status == 204
270
+
271
+ async def delete_variable(self, variable_name: str) -> bool:
272
+ """
273
+ :calls: `DELETE /repos/{owner}/{repo}/environments/{environment_name}/variables/{name} <https://docs.github.com/en/rest/reference#delete-a-repository-variable>`_
274
+ :param variable_name: string
275
+ :rtype: bool
276
+ """
277
+ assert isinstance(variable_name, str), variable_name
278
+ status, headers, data = await self._requester.requestJson(
279
+ "DELETE", f"{await self.url}/variables/{variable_name}"
280
+ )
281
+ return status == 204
282
+
283
+ async def get_deployment_branch_policies(self) -> PaginatedList[DeploymentBranchPolicy]:
284
+ """
285
+ :calls: `GET /repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies <https://docs.github.com/en/rest/deployments/branch-policies#list-deployment-branch-policies>`_
286
+ """
287
+ return PaginatedList(
288
+ githubasyncio.DeploymentBranchPolicy.DeploymentBranchPolicy,
289
+ self._requester,
290
+ f"{await self.url}/deployment-branch-policies",
291
+ None,
292
+ list_item="branch_policies",
293
+ attributesTransformer=PaginatedList.override_attributes(
294
+ {"branch_policies_url": f"{await self.url}/deployment-branch-policies"}
295
+ ),
296
+ )
297
+
298
+ async def get_deployment_branch_policy(self, id: int) -> DeploymentBranchPolicy:
299
+ """
300
+ :calls: `GET /repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies/{branch_policy_id} <https://docs.github.com/en/rest/deployments/branch-policies#get-a-deployment-branch-policy>`_
301
+ """
302
+ assert isinstance(id, int), id
303
+ headers, data = await self._requester.requestJsonAndCheck(
304
+ "GET", f"{await self.url}/deployment-branch-policies/{id}"
305
+ )
306
+ data["branch_policies_url"] = f"{await self.url}/deployment-branch-policies"
307
+ return githubasyncio.DeploymentBranchPolicy.DeploymentBranchPolicy(self._requester, headers, data)
308
+
309
+ async def create_deployment_branch_policy(self, name: str, type: Opt[str] = NotSet) -> DeploymentBranchPolicy:
310
+ """
311
+ :calls: `POST /repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies <https://docs.github.com/en/rest/deployments/branch-policies#create-a-deployment-branch-policy>`_
312
+ :param name: name pattern that branches or tags must match to be deployed to the environment
313
+ :param type: whether the pattern is for a ``branch`` or a ``tag``, GitHub uses ``branch`` if it is not given
314
+ """
315
+ assert isinstance(name, str), name
316
+ assert is_optional(type, str), type
317
+ post_parameters = NotSet.remove_unset_items({"name": name, "type": type})
318
+ headers, data = await self._requester.requestJsonAndCheck(
319
+ "POST", f"{await self.url}/deployment-branch-policies", input=post_parameters
320
+ )
321
+ data["branch_policies_url"] = f"{await self.url}/deployment-branch-policies"
322
+ return githubasyncio.DeploymentBranchPolicy.DeploymentBranchPolicy(self._requester, headers, data)
323
+
324
+ def _useAttributes(self, attributes: dict[str, Any]) -> None:
325
+ if "created_at" in attributes: # pragma no branch
326
+ self._created_at = self._makeDatetimeAttribute(attributes["created_at"])
327
+ if "deployment_branch_policy" in attributes: # pragma no branch
328
+ self._deployment_branch_policy = self._makeClassAttribute(
329
+ githubasyncio.EnvironmentDeploymentBranchPolicy.EnvironmentDeploymentBranchPolicy,
330
+ attributes["deployment_branch_policy"],
331
+ )
332
+ if "environments_url" in attributes:
333
+ self._environments_url = self._makeStringAttribute(attributes["environments_url"])
334
+ if "html_url" in attributes: # pragma no branch
335
+ self._html_url = self._makeStringAttribute(attributes["html_url"])
336
+ if "id" in attributes: # pragma no branch
337
+ self._id = self._makeIntAttribute(attributes["id"])
338
+ if "name" in attributes: # pragma no branch
339
+ self._name = self._makeStringAttribute(attributes["name"])
340
+ elif "url" in attributes and attributes["url"]:
341
+ quoted_name = attributes["url"].split("/")[-1]
342
+ name = urllib.parse.unquote(quoted_name)
343
+ self._name = self._makeStringAttribute(name)
344
+ if "node_id" in attributes: # pragma no branch
345
+ self._node_id = self._makeStringAttribute(attributes["node_id"])
346
+ if "protection_rules" in attributes: # pragma no branch
347
+ self._protection_rules = self._makeListOfClassesAttribute(
348
+ githubasyncio.EnvironmentProtectionRule.EnvironmentProtectionRule,
349
+ attributes["protection_rules"],
350
+ )
351
+ if "updated_at" in attributes: # pragma no branch
352
+ self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"])
353
+ if "url" in attributes: # pragma no branch
354
+ self._url = self._makeStringAttribute(attributes["url"])