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.
- githubasyncio/AccessToken.py +159 -0
- githubasyncio/AdvisoryBase.py +163 -0
- githubasyncio/AdvisoryCredit.py +131 -0
- githubasyncio/AdvisoryCreditDetailed.py +110 -0
- githubasyncio/AdvisoryVulnerability.py +191 -0
- githubasyncio/AdvisoryVulnerabilityPackage.py +93 -0
- githubasyncio/AppAuthentication.py +58 -0
- githubasyncio/ApplicationOAuth.py +200 -0
- githubasyncio/Artifact.py +183 -0
- githubasyncio/Auth.py +560 -0
- githubasyncio/AuthenticatedUser.py +1251 -0
- githubasyncio/Authorization.py +192 -0
- githubasyncio/AuthorizationApplication.py +73 -0
- githubasyncio/Autolink.py +104 -0
- githubasyncio/Branch.py +689 -0
- githubasyncio/BranchProtection.py +224 -0
- githubasyncio/CVSS.py +83 -0
- githubasyncio/CWE.py +75 -0
- githubasyncio/CheckRun.py +315 -0
- githubasyncio/CheckRunAnnotation.py +134 -0
- githubasyncio/CheckRunOutput.py +108 -0
- githubasyncio/CheckSuite.py +319 -0
- githubasyncio/Clones.py +97 -0
- githubasyncio/CodeScanAlert.py +215 -0
- githubasyncio/CodeScanAlertInstance.py +134 -0
- githubasyncio/CodeScanAlertInstanceLocation.py +102 -0
- githubasyncio/CodeScanRule.py +134 -0
- githubasyncio/CodeScanTool.py +94 -0
- githubasyncio/CodeSecurityConfig.py +301 -0
- githubasyncio/CodeSecurityConfigRepository.py +70 -0
- githubasyncio/Commit.py +442 -0
- githubasyncio/CommitCombinedStatus.py +126 -0
- githubasyncio/CommitComment.py +270 -0
- githubasyncio/CommitStats.py +78 -0
- githubasyncio/CommitStatus.py +169 -0
- githubasyncio/Comparison.py +219 -0
- githubasyncio/Consts.py +197 -0
- githubasyncio/ContentFile.py +304 -0
- githubasyncio/Copilot.py +97 -0
- githubasyncio/CopilotSeat.py +132 -0
- githubasyncio/DefaultCodeSecurityConfig.py +93 -0
- githubasyncio/DependabotAlert.py +184 -0
- githubasyncio/DependabotAlertAdvisory.py +82 -0
- githubasyncio/DependabotAlertDependency.py +100 -0
- githubasyncio/DependabotAlertVulnerability.py +85 -0
- githubasyncio/Deployment.py +314 -0
- githubasyncio/DeploymentBranchPolicy.py +102 -0
- githubasyncio/DeploymentStatus.py +201 -0
- githubasyncio/DiscussionBase.py +140 -0
- githubasyncio/DiscussionCommentBase.py +140 -0
- githubasyncio/Download.py +256 -0
- githubasyncio/Enterprise.py +175 -0
- githubasyncio/EnterpriseConsumedLicenses.py +138 -0
- githubasyncio/Environment.py +354 -0
- githubasyncio/EnvironmentDeploymentBranchPolicy.py +87 -0
- githubasyncio/EnvironmentProtectionRule.py +117 -0
- githubasyncio/EnvironmentProtectionRuleReviewer.py +110 -0
- githubasyncio/Event.py +134 -0
- githubasyncio/File.py +142 -0
- githubasyncio/GeneratedReleaseNotes.py +68 -0
- githubasyncio/Gist.py +373 -0
- githubasyncio/GistComment.py +162 -0
- githubasyncio/GistFile.py +106 -0
- githubasyncio/GistHistoryState.py +245 -0
- githubasyncio/GitAuthor.py +94 -0
- githubasyncio/GitBlob.py +123 -0
- githubasyncio/GitCommit.py +208 -0
- githubasyncio/GitCommitVerification.py +103 -0
- githubasyncio/GitObject.py +84 -0
- githubasyncio/GitRef.py +122 -0
- githubasyncio/GitRelease.py +476 -0
- githubasyncio/GitReleaseAsset.py +232 -0
- githubasyncio/GitTag.py +143 -0
- githubasyncio/GitTree.py +113 -0
- githubasyncio/GitTreeElement.py +104 -0
- githubasyncio/GithubApp.py +236 -0
- githubasyncio/GithubException.py +226 -0
- githubasyncio/GithubIntegration.py +365 -0
- githubasyncio/GithubObject.py +910 -0
- githubasyncio/GithubRetry.py +253 -0
- githubasyncio/GitignoreTemplate.py +88 -0
- githubasyncio/GlobalAdvisory.py +141 -0
- githubasyncio/Hook.py +238 -0
- githubasyncio/HookDelivery.py +243 -0
- githubasyncio/HookDescription.py +85 -0
- githubasyncio/HookResponse.py +83 -0
- githubasyncio/InputFileContent.py +63 -0
- githubasyncio/InputGitAuthor.py +71 -0
- githubasyncio/InputGitTreeElement.py +79 -0
- githubasyncio/Installation.py +298 -0
- githubasyncio/InstallationAuthorization.py +138 -0
- githubasyncio/Invitation.py +171 -0
- githubasyncio/Issue.py +955 -0
- githubasyncio/IssueComment.py +309 -0
- githubasyncio/IssueDependenciesSummary.py +77 -0
- githubasyncio/IssueEvent.py +296 -0
- githubasyncio/IssuePullRequest.py +97 -0
- githubasyncio/IssueType.py +123 -0
- githubasyncio/Label.py +186 -0
- githubasyncio/License.py +169 -0
- githubasyncio/MainClass.py +1142 -0
- githubasyncio/Membership.py +154 -0
- githubasyncio/MergedUpstream.py +71 -0
- githubasyncio/Migration.py +281 -0
- githubasyncio/Milestone.py +255 -0
- githubasyncio/NamedEnterpriseUser.py +207 -0
- githubasyncio/NamedUser.py +841 -0
- githubasyncio/Notification.py +182 -0
- githubasyncio/NotificationSubject.py +96 -0
- githubasyncio/Organization.py +2462 -0
- githubasyncio/OrganizationCodeScanAlert.py +65 -0
- githubasyncio/OrganizationCustomProperty.py +215 -0
- githubasyncio/OrganizationDependabotAlert.py +75 -0
- githubasyncio/OrganizationSecret.py +191 -0
- githubasyncio/OrganizationSecretScanAlert.py +112 -0
- githubasyncio/OrganizationVariable.py +141 -0
- githubasyncio/PaginatedList.py +652 -0
- githubasyncio/Path.py +102 -0
- githubasyncio/Permissions.py +113 -0
- githubasyncio/Plan.py +108 -0
- githubasyncio/Project.py +286 -0
- githubasyncio/ProjectCard.py +257 -0
- githubasyncio/ProjectColumn.py +227 -0
- githubasyncio/PublicKey.py +138 -0
- githubasyncio/PullRequest.py +1202 -0
- githubasyncio/PullRequestComment.py +401 -0
- githubasyncio/PullRequestMergeStatus.py +89 -0
- githubasyncio/PullRequestPart.py +110 -0
- githubasyncio/PullRequestReview.py +214 -0
- githubasyncio/Rate.py +123 -0
- githubasyncio/RateLimit.py +210 -0
- githubasyncio/RateLimitOverview.py +104 -0
- githubasyncio/Reaction.py +128 -0
- githubasyncio/Referrer.py +94 -0
- githubasyncio/RepoCodeSecurityConfig.py +93 -0
- githubasyncio/Repository.py +5211 -0
- githubasyncio/RepositoryAdvisory.py +431 -0
- githubasyncio/RepositoryDiscussion.py +221 -0
- githubasyncio/RepositoryDiscussionCategory.py +150 -0
- githubasyncio/RepositoryDiscussionComment.py +159 -0
- githubasyncio/RepositoryKey.py +166 -0
- githubasyncio/RepositoryPreferences.py +82 -0
- githubasyncio/RepositoryRulesetBypassActor.py +75 -0
- githubasyncio/Requester.py +1518 -0
- githubasyncio/RequiredPullRequestReviews.py +269 -0
- githubasyncio/RequiredStatusChecks.py +153 -0
- githubasyncio/Rule.py +134 -0
- githubasyncio/Ruleset.py +292 -0
- githubasyncio/Secret.py +139 -0
- githubasyncio/SecretScanAlert.py +317 -0
- githubasyncio/SecretScanAlertInstance.py +128 -0
- githubasyncio/SecurityAndAnalysis.py +188 -0
- githubasyncio/SecurityAndAnalysisFeature.py +79 -0
- githubasyncio/SelfHostedActionsRunner.py +129 -0
- githubasyncio/SelfHostedActionsRunnerApplication.py +92 -0
- githubasyncio/SelfHostedActionsRunnerJitConfig.py +74 -0
- githubasyncio/SelfHostedActionsRunnerToken.py +118 -0
- githubasyncio/SourceImport.py +260 -0
- githubasyncio/Stargazer.py +88 -0
- githubasyncio/StatsCodeFrequency.py +81 -0
- githubasyncio/StatsCommitActivity.py +86 -0
- githubasyncio/StatsContributor.py +138 -0
- githubasyncio/StatsParticipation.py +78 -0
- githubasyncio/StatsPunchCard.py +76 -0
- githubasyncio/SubIssueSummary.py +70 -0
- githubasyncio/Tag.py +108 -0
- githubasyncio/Team.py +618 -0
- githubasyncio/TeamDiscussion.py +137 -0
- githubasyncio/TimelineEvent.py +164 -0
- githubasyncio/TimelineEventSource.py +81 -0
- githubasyncio/Topic.py +177 -0
- githubasyncio/Traffic.py +95 -0
- githubasyncio/UserKey.py +141 -0
- githubasyncio/Variable.py +155 -0
- githubasyncio/View.py +97 -0
- githubasyncio/Workflow.py +335 -0
- githubasyncio/WorkflowJob.py +253 -0
- githubasyncio/WorkflowRun.py +480 -0
- githubasyncio/WorkflowStep.py +118 -0
- githubasyncio/__init__.py +38 -0
- githubasyncio/compat/__init__.py +52 -0
- githubasyncio/requestlib/__init__.py +29 -0
- pygithub_asyncio-3.0.0b1.dist-info/METADATA +102 -0
- pygithub_asyncio-3.0.0b1.dist-info/RECORD +188 -0
- pygithub_asyncio-3.0.0b1.dist-info/WHEEL +5 -0
- pygithub_asyncio-3.0.0b1.dist-info/licenses/COPYING +674 -0
- pygithub_asyncio-3.0.0b1.dist-info/licenses/COPYING.LESSER +165 -0
- pygithub_asyncio-3.0.0b1.dist-info/top_level.txt +1 -0
githubasyncio/Branch.py
ADDED
|
@@ -0,0 +1,689 @@
|
|
|
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 2013 martinqt <m.ki2@laposte.net> #
|
|
9
|
+
# Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net> #
|
|
10
|
+
# Copyright 2015 Kyle Hornberg <khornberg@users.noreply.github.com> #
|
|
11
|
+
# Copyright 2016 Jannis Gebauer <ja.geb@me.com> #
|
|
12
|
+
# Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com> #
|
|
13
|
+
# Copyright 2018 Alice GIRARD <bouhahah@gmail.com> #
|
|
14
|
+
# Copyright 2018 Steve Kowalik <steven@wedontsleep.org> #
|
|
15
|
+
# Copyright 2018 Wan Liuyang <tsfdye@gmail.com> #
|
|
16
|
+
# Copyright 2018 sfdye <tsfdye@gmail.com> #
|
|
17
|
+
# Copyright 2019 Steve Kowalik <steven@wedontsleep.org> #
|
|
18
|
+
# Copyright 2019 Wan Liuyang <tsfdye@gmail.com> #
|
|
19
|
+
# Copyright 2020 Steve Kowalik <steven@wedontsleep.org> #
|
|
20
|
+
# Copyright 2021 Mark Walker <mark.walker@realbuzz.com> #
|
|
21
|
+
# Copyright 2021 Steve Kowalik <steven@wedontsleep.org> #
|
|
22
|
+
# Copyright 2023 Enrico Minack <github@enrico.minack.dev> #
|
|
23
|
+
# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> #
|
|
24
|
+
# Copyright 2023 Juan Manuel "Kang" Pérez <kangcoding@gmail.com> #
|
|
25
|
+
# Copyright 2023 Kevin Grandjean <Muscaw@users.noreply.github.com> #
|
|
26
|
+
# Copyright 2023 Paul Luna <paulluna0215@gmail.com> #
|
|
27
|
+
# Copyright 2023 Thomas Devoogdt <thomas@devoogdt.com> #
|
|
28
|
+
# Copyright 2023 Trim21 <trim21.me@gmail.com> #
|
|
29
|
+
# Copyright 2023 terenho <33275803+terenho@users.noreply.github.com> #
|
|
30
|
+
# Copyright 2024 Benjamin K <53038537+treee111@users.noreply.github.com> #
|
|
31
|
+
# Copyright 2024 Benjamin K. <53038537+treee111@users.noreply.github.com> #
|
|
32
|
+
# Copyright 2024 Enrico Minack <github@enrico.minack.dev> #
|
|
33
|
+
# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> #
|
|
34
|
+
# Copyright 2025 Enrico Minack <github@enrico.minack.dev> #
|
|
35
|
+
# Copyright 2026 Enrico Minack <github@enrico.minack.dev> #
|
|
36
|
+
# #
|
|
37
|
+
# This file is part of PyGithub. #
|
|
38
|
+
# http://pygithub.readthedocs.io/ #
|
|
39
|
+
# #
|
|
40
|
+
# PyGithub is free software: you can redistribute it and/or modify it under #
|
|
41
|
+
# the terms of the GNU Lesser General Public License as published by the Free #
|
|
42
|
+
# Software Foundation, either version 3 of the License, or (at your option) #
|
|
43
|
+
# any later version. #
|
|
44
|
+
# #
|
|
45
|
+
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
|
|
46
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
|
|
47
|
+
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
|
|
48
|
+
# details. #
|
|
49
|
+
# #
|
|
50
|
+
# You should have received a copy of the GNU Lesser General Public License #
|
|
51
|
+
# along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
|
|
52
|
+
# #
|
|
53
|
+
################################################################################
|
|
54
|
+
|
|
55
|
+
from __future__ import annotations
|
|
56
|
+
|
|
57
|
+
from typing import TYPE_CHECKING, Any
|
|
58
|
+
|
|
59
|
+
import githubasyncio.BranchProtection
|
|
60
|
+
import githubasyncio.Commit
|
|
61
|
+
import githubasyncio.GithubObject
|
|
62
|
+
import githubasyncio.NamedUser
|
|
63
|
+
import githubasyncio.PaginatedList
|
|
64
|
+
import githubasyncio.RequiredPullRequestReviews
|
|
65
|
+
import githubasyncio.RequiredStatusChecks
|
|
66
|
+
import githubasyncio.Rule
|
|
67
|
+
import githubasyncio.Team
|
|
68
|
+
from githubasyncio import Consts
|
|
69
|
+
from githubasyncio.GithubObject import (
|
|
70
|
+
Attribute,
|
|
71
|
+
NonCompletableGithubObject,
|
|
72
|
+
NotSet,
|
|
73
|
+
Opt,
|
|
74
|
+
is_defined,
|
|
75
|
+
is_optional,
|
|
76
|
+
is_optional_list,
|
|
77
|
+
is_undefined,
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
if TYPE_CHECKING:
|
|
81
|
+
from githubasyncio.BranchProtection import BranchProtection
|
|
82
|
+
from githubasyncio.Commit import Commit
|
|
83
|
+
from githubasyncio.NamedUser import NamedUser
|
|
84
|
+
from githubasyncio.PaginatedList import PaginatedList
|
|
85
|
+
from githubasyncio.RequiredPullRequestReviews import RequiredPullRequestReviews
|
|
86
|
+
from githubasyncio.RequiredStatusChecks import RequiredStatusChecks
|
|
87
|
+
from githubasyncio.Team import Team
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class Branch(NonCompletableGithubObject):
|
|
91
|
+
"""
|
|
92
|
+
This class represents Branches.
|
|
93
|
+
|
|
94
|
+
The reference can be found here
|
|
95
|
+
https://docs.github.com/en/rest/reference/repos#branches
|
|
96
|
+
|
|
97
|
+
The OpenAPI schema can be found at
|
|
98
|
+
|
|
99
|
+
- /components/schemas/branch-short
|
|
100
|
+
- /components/schemas/branch-with-protection
|
|
101
|
+
- /components/schemas/short-branch
|
|
102
|
+
|
|
103
|
+
"""
|
|
104
|
+
|
|
105
|
+
def _initAttributes(self) -> None:
|
|
106
|
+
self.__links: Attribute[dict[str, Any]] = NotSet
|
|
107
|
+
self._commit: Attribute[Commit] = githubasyncio.GithubObject.NotSet
|
|
108
|
+
self._name: Attribute[str] = githubasyncio.GithubObject.NotSet
|
|
109
|
+
self._pattern: Attribute[str] = NotSet
|
|
110
|
+
self._protected: Attribute[bool] = githubasyncio.GithubObject.NotSet
|
|
111
|
+
self._protection: Attribute[BranchProtection] = NotSet
|
|
112
|
+
self._protection_url: Attribute[str] = githubasyncio.GithubObject.NotSet
|
|
113
|
+
self._required_approving_review_count: Attribute[int] = NotSet
|
|
114
|
+
self._url: Attribute[str] = NotSet
|
|
115
|
+
|
|
116
|
+
def __repr__(self) -> str:
|
|
117
|
+
return self.get__repr__({"name": self._name.value})
|
|
118
|
+
|
|
119
|
+
@property
|
|
120
|
+
def _links(self) -> dict[str, Any]:
|
|
121
|
+
return self.__links.value
|
|
122
|
+
|
|
123
|
+
@property
|
|
124
|
+
def commit(self) -> Commit:
|
|
125
|
+
return self._commit.value
|
|
126
|
+
|
|
127
|
+
@property
|
|
128
|
+
def name(self) -> str:
|
|
129
|
+
return self._name.value
|
|
130
|
+
|
|
131
|
+
@property
|
|
132
|
+
def pattern(self) -> str:
|
|
133
|
+
return self._pattern.value
|
|
134
|
+
|
|
135
|
+
@property
|
|
136
|
+
def protected(self) -> bool:
|
|
137
|
+
return self._protected.value
|
|
138
|
+
|
|
139
|
+
@property
|
|
140
|
+
async def protection(self) -> BranchProtection:
|
|
141
|
+
if is_undefined(self._protection):
|
|
142
|
+
return await self.get_protection()
|
|
143
|
+
return self._protection.value
|
|
144
|
+
|
|
145
|
+
@property
|
|
146
|
+
def protection_url(self) -> str:
|
|
147
|
+
return self._protection_url.value
|
|
148
|
+
|
|
149
|
+
@property
|
|
150
|
+
def required_approving_review_count(self) -> int:
|
|
151
|
+
return self._required_approving_review_count.value
|
|
152
|
+
|
|
153
|
+
@property
|
|
154
|
+
def url(self) -> str:
|
|
155
|
+
return self._url.value
|
|
156
|
+
|
|
157
|
+
async def get_protection(self) -> BranchProtection:
|
|
158
|
+
"""
|
|
159
|
+
:calls: `GET /repos/{owner}/{repo}/branches/{branch}/protection <https://docs.github.com/en/rest/reference/repos#branches>`_
|
|
160
|
+
"""
|
|
161
|
+
headers, data = await self._requester.requestJsonAndCheck(
|
|
162
|
+
"GET",
|
|
163
|
+
self.protection_url,
|
|
164
|
+
headers={"Accept": Consts.mediaTypeRequireMultipleApprovingReviews},
|
|
165
|
+
)
|
|
166
|
+
return githubasyncio.BranchProtection.BranchProtection(self._requester, headers, data, completed=True)
|
|
167
|
+
|
|
168
|
+
async def edit_protection(
|
|
169
|
+
self,
|
|
170
|
+
strict: Opt[bool] = NotSet,
|
|
171
|
+
contexts: Opt[list[str]] = NotSet,
|
|
172
|
+
enforce_admins: Opt[bool] = NotSet,
|
|
173
|
+
dismissal_users: Opt[list[str]] = NotSet,
|
|
174
|
+
dismissal_teams: Opt[list[str]] = NotSet,
|
|
175
|
+
dismissal_apps: Opt[list[str]] = NotSet,
|
|
176
|
+
dismiss_stale_reviews: Opt[bool] = NotSet,
|
|
177
|
+
require_code_owner_reviews: Opt[bool] = NotSet,
|
|
178
|
+
required_approving_review_count: Opt[int] = NotSet,
|
|
179
|
+
user_push_restrictions: Opt[list[str]] = NotSet,
|
|
180
|
+
team_push_restrictions: Opt[list[str]] = NotSet,
|
|
181
|
+
app_push_restrictions: Opt[list[str]] = NotSet,
|
|
182
|
+
required_linear_history: Opt[bool] = NotSet,
|
|
183
|
+
allow_force_pushes: Opt[bool] = NotSet,
|
|
184
|
+
required_conversation_resolution: Opt[bool] = NotSet,
|
|
185
|
+
lock_branch: Opt[bool] = NotSet,
|
|
186
|
+
allow_fork_syncing: Opt[bool] = NotSet,
|
|
187
|
+
users_bypass_pull_request_allowances: Opt[list[str]] = NotSet,
|
|
188
|
+
teams_bypass_pull_request_allowances: Opt[list[str]] = NotSet,
|
|
189
|
+
apps_bypass_pull_request_allowances: Opt[list[str]] = NotSet,
|
|
190
|
+
block_creations: Opt[bool] = NotSet,
|
|
191
|
+
require_last_push_approval: Opt[bool] = NotSet,
|
|
192
|
+
allow_deletions: Opt[bool] = NotSet,
|
|
193
|
+
checks: Opt[list[str | tuple[str, int]]] = NotSet,
|
|
194
|
+
) -> BranchProtection:
|
|
195
|
+
"""
|
|
196
|
+
:calls: `PUT /repos/{owner}/{repo}/branches/{branch}/protection <https://docs.github.com/en/rest/reference/repos#get-branch-protection>`_
|
|
197
|
+
|
|
198
|
+
NOTE: The GitHub API groups strict and contexts together, both must
|
|
199
|
+
be submitted. Take care to pass both as arguments even if only one is
|
|
200
|
+
changing. Use edit_required_status_checks() to avoid this.
|
|
201
|
+
"""
|
|
202
|
+
assert is_optional(strict, bool), strict
|
|
203
|
+
assert is_optional_list(contexts, str), contexts
|
|
204
|
+
assert is_optional(enforce_admins, bool), enforce_admins
|
|
205
|
+
assert is_optional_list(dismissal_users, str), dismissal_users
|
|
206
|
+
assert is_optional_list(dismissal_teams, str), dismissal_teams
|
|
207
|
+
assert is_optional_list(dismissal_apps, str), dismissal_apps
|
|
208
|
+
assert is_optional(dismiss_stale_reviews, bool), dismiss_stale_reviews
|
|
209
|
+
assert is_optional(require_code_owner_reviews, bool), require_code_owner_reviews
|
|
210
|
+
assert is_optional(required_approving_review_count, int), required_approving_review_count
|
|
211
|
+
assert is_optional(required_linear_history, bool), required_linear_history
|
|
212
|
+
assert is_optional(allow_force_pushes, bool), allow_force_pushes
|
|
213
|
+
assert is_optional(required_conversation_resolution, bool), required_conversation_resolution
|
|
214
|
+
assert is_optional(lock_branch, bool), lock_branch
|
|
215
|
+
assert is_optional(allow_fork_syncing, bool), allow_fork_syncing
|
|
216
|
+
assert is_optional_list(users_bypass_pull_request_allowances, str), users_bypass_pull_request_allowances
|
|
217
|
+
assert is_optional_list(teams_bypass_pull_request_allowances, str), teams_bypass_pull_request_allowances
|
|
218
|
+
assert is_optional_list(apps_bypass_pull_request_allowances, str), apps_bypass_pull_request_allowances
|
|
219
|
+
assert is_optional(require_last_push_approval, bool), require_last_push_approval
|
|
220
|
+
assert is_optional(allow_deletions, bool), allow_deletions
|
|
221
|
+
assert is_optional_list(checks, (str, tuple)), checks
|
|
222
|
+
if is_defined(checks):
|
|
223
|
+
assert all(not isinstance(check, tuple) or list(map(type, check)) == [str, int] for check in checks), checks
|
|
224
|
+
|
|
225
|
+
post_parameters: dict[str, Any] = {}
|
|
226
|
+
if is_defined(strict) or is_defined(contexts) or is_defined(checks):
|
|
227
|
+
if is_undefined(strict):
|
|
228
|
+
strict = False
|
|
229
|
+
|
|
230
|
+
checks_parameters = []
|
|
231
|
+
if is_defined(checks):
|
|
232
|
+
checks_parameters = [
|
|
233
|
+
{"context": check[0], "app_id": check[1]} if isinstance(check, tuple) else {"context": check}
|
|
234
|
+
for check in checks
|
|
235
|
+
]
|
|
236
|
+
elif is_defined(contexts):
|
|
237
|
+
checks_parameters = [{"context": context} for context in contexts]
|
|
238
|
+
|
|
239
|
+
post_parameters["required_status_checks"] = {
|
|
240
|
+
"strict": strict,
|
|
241
|
+
"checks": checks_parameters,
|
|
242
|
+
}
|
|
243
|
+
else:
|
|
244
|
+
post_parameters["required_status_checks"] = None
|
|
245
|
+
|
|
246
|
+
if is_defined(enforce_admins):
|
|
247
|
+
post_parameters["enforce_admins"] = enforce_admins
|
|
248
|
+
else:
|
|
249
|
+
post_parameters["enforce_admins"] = None
|
|
250
|
+
|
|
251
|
+
if (
|
|
252
|
+
is_defined(dismissal_users)
|
|
253
|
+
or is_defined(dismissal_teams)
|
|
254
|
+
or is_defined(dismissal_apps)
|
|
255
|
+
or is_defined(dismiss_stale_reviews)
|
|
256
|
+
or is_defined(require_code_owner_reviews)
|
|
257
|
+
or is_defined(required_approving_review_count)
|
|
258
|
+
or is_defined(users_bypass_pull_request_allowances)
|
|
259
|
+
or is_defined(teams_bypass_pull_request_allowances)
|
|
260
|
+
or is_defined(apps_bypass_pull_request_allowances)
|
|
261
|
+
or is_defined(require_last_push_approval)
|
|
262
|
+
):
|
|
263
|
+
post_parameters["required_pull_request_reviews"] = {}
|
|
264
|
+
if is_defined(dismiss_stale_reviews):
|
|
265
|
+
post_parameters["required_pull_request_reviews"]["dismiss_stale_reviews"] = dismiss_stale_reviews
|
|
266
|
+
if is_defined(require_code_owner_reviews):
|
|
267
|
+
post_parameters["required_pull_request_reviews"]["require_code_owner_reviews"] = (
|
|
268
|
+
require_code_owner_reviews
|
|
269
|
+
)
|
|
270
|
+
if is_defined(required_approving_review_count):
|
|
271
|
+
post_parameters["required_pull_request_reviews"]["required_approving_review_count"] = (
|
|
272
|
+
required_approving_review_count
|
|
273
|
+
)
|
|
274
|
+
if is_defined(require_last_push_approval):
|
|
275
|
+
post_parameters["required_pull_request_reviews"]["require_last_push_approval"] = (
|
|
276
|
+
require_last_push_approval
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
dismissal_restrictions = {}
|
|
280
|
+
if is_defined(dismissal_users):
|
|
281
|
+
dismissal_restrictions["users"] = dismissal_users
|
|
282
|
+
if is_defined(dismissal_teams):
|
|
283
|
+
dismissal_restrictions["teams"] = dismissal_teams
|
|
284
|
+
if is_defined(dismissal_apps):
|
|
285
|
+
dismissal_restrictions["apps"] = dismissal_apps
|
|
286
|
+
|
|
287
|
+
if dismissal_restrictions:
|
|
288
|
+
post_parameters["required_pull_request_reviews"]["dismissal_restrictions"] = dismissal_restrictions
|
|
289
|
+
|
|
290
|
+
bypass_pull_request_allowances = {}
|
|
291
|
+
if is_defined(users_bypass_pull_request_allowances):
|
|
292
|
+
bypass_pull_request_allowances["users"] = users_bypass_pull_request_allowances
|
|
293
|
+
if is_defined(teams_bypass_pull_request_allowances):
|
|
294
|
+
bypass_pull_request_allowances["teams"] = teams_bypass_pull_request_allowances
|
|
295
|
+
if is_defined(apps_bypass_pull_request_allowances):
|
|
296
|
+
bypass_pull_request_allowances["apps"] = apps_bypass_pull_request_allowances
|
|
297
|
+
|
|
298
|
+
if bypass_pull_request_allowances:
|
|
299
|
+
post_parameters["required_pull_request_reviews"]["bypass_pull_request_allowances"] = (
|
|
300
|
+
bypass_pull_request_allowances
|
|
301
|
+
)
|
|
302
|
+
else:
|
|
303
|
+
post_parameters["required_pull_request_reviews"] = None
|
|
304
|
+
if (
|
|
305
|
+
is_defined(user_push_restrictions)
|
|
306
|
+
or is_defined(team_push_restrictions)
|
|
307
|
+
or is_defined(app_push_restrictions)
|
|
308
|
+
):
|
|
309
|
+
if is_undefined(user_push_restrictions):
|
|
310
|
+
user_push_restrictions = []
|
|
311
|
+
if is_undefined(team_push_restrictions):
|
|
312
|
+
team_push_restrictions = []
|
|
313
|
+
if is_undefined(app_push_restrictions):
|
|
314
|
+
app_push_restrictions = []
|
|
315
|
+
post_parameters["restrictions"] = {
|
|
316
|
+
"users": user_push_restrictions,
|
|
317
|
+
"teams": team_push_restrictions,
|
|
318
|
+
"apps": app_push_restrictions,
|
|
319
|
+
}
|
|
320
|
+
else:
|
|
321
|
+
post_parameters["restrictions"] = None
|
|
322
|
+
if is_defined(required_linear_history):
|
|
323
|
+
post_parameters["required_linear_history"] = required_linear_history
|
|
324
|
+
else:
|
|
325
|
+
post_parameters["required_linear_history"] = None
|
|
326
|
+
if is_defined(allow_force_pushes):
|
|
327
|
+
post_parameters["allow_force_pushes"] = allow_force_pushes
|
|
328
|
+
else:
|
|
329
|
+
post_parameters["allow_force_pushes"] = None
|
|
330
|
+
if is_defined(required_conversation_resolution):
|
|
331
|
+
post_parameters["required_conversation_resolution"] = required_conversation_resolution
|
|
332
|
+
else:
|
|
333
|
+
post_parameters["required_conversation_resolution"] = None
|
|
334
|
+
if is_defined(lock_branch):
|
|
335
|
+
post_parameters["lock_branch"] = lock_branch
|
|
336
|
+
else:
|
|
337
|
+
post_parameters["lock_branch"] = None
|
|
338
|
+
if is_defined(allow_fork_syncing):
|
|
339
|
+
post_parameters["allow_fork_syncing"] = allow_fork_syncing
|
|
340
|
+
else:
|
|
341
|
+
post_parameters["allow_fork_syncing"] = None
|
|
342
|
+
if is_defined(block_creations):
|
|
343
|
+
post_parameters["block_creations"] = block_creations
|
|
344
|
+
else:
|
|
345
|
+
post_parameters["block_creations"] = None
|
|
346
|
+
if is_defined(allow_deletions):
|
|
347
|
+
post_parameters["allow_deletions"] = allow_deletions
|
|
348
|
+
else:
|
|
349
|
+
post_parameters["allow_deletions"] = None
|
|
350
|
+
|
|
351
|
+
headers, data = await self._requester.requestJsonAndCheck(
|
|
352
|
+
"PUT",
|
|
353
|
+
self.protection_url,
|
|
354
|
+
headers={"Accept": Consts.mediaTypeRequireMultipleApprovingReviews},
|
|
355
|
+
input=post_parameters,
|
|
356
|
+
)
|
|
357
|
+
|
|
358
|
+
return githubasyncio.BranchProtection.BranchProtection(self._requester, headers, data, completed=True)
|
|
359
|
+
|
|
360
|
+
async def remove_protection(self) -> None:
|
|
361
|
+
"""
|
|
362
|
+
:calls: `DELETE /repos/{owner}/{repo}/branches/{branch}/protection <https://docs.github.com/en/rest/reference/repos#branches>`_
|
|
363
|
+
"""
|
|
364
|
+
headers, data = await self._requester.requestJsonAndCheck(
|
|
365
|
+
"DELETE",
|
|
366
|
+
self.protection_url,
|
|
367
|
+
)
|
|
368
|
+
|
|
369
|
+
async def get_required_status_checks(self) -> RequiredStatusChecks:
|
|
370
|
+
"""
|
|
371
|
+
:calls: `GET /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks <https://docs.github.com/en/rest/reference/repos#branches>`_
|
|
372
|
+
:rtype: :class:`githubasyncio.RequiredStatusChecks.RequiredStatusChecks`
|
|
373
|
+
"""
|
|
374
|
+
headers, data = await self._requester.requestJsonAndCheck(
|
|
375
|
+
"GET", f"{self.protection_url}/required_status_checks"
|
|
376
|
+
)
|
|
377
|
+
return githubasyncio.RequiredStatusChecks.RequiredStatusChecks(self._requester, headers, data, completed=True)
|
|
378
|
+
|
|
379
|
+
async def edit_required_status_checks(
|
|
380
|
+
self,
|
|
381
|
+
strict: Opt[bool] = NotSet,
|
|
382
|
+
contexts: Opt[list[str]] = NotSet,
|
|
383
|
+
checks: Opt[list[str | tuple[str, int]]] = NotSet,
|
|
384
|
+
) -> RequiredStatusChecks:
|
|
385
|
+
"""
|
|
386
|
+
:calls: `PATCH /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks <https://docs.github.com/en/rest/reference/repos#branches>`_
|
|
387
|
+
"""
|
|
388
|
+
assert is_optional(strict, bool), strict
|
|
389
|
+
assert is_optional_list(contexts, str), contexts
|
|
390
|
+
assert is_optional_list(checks, (str, tuple)), checks
|
|
391
|
+
if is_defined(checks):
|
|
392
|
+
assert all(not isinstance(check, tuple) or list(map(type, check)) == [str, int] for check in checks), checks
|
|
393
|
+
|
|
394
|
+
checks_parameters: Opt[list[dict[str, Any]]] = NotSet
|
|
395
|
+
if is_defined(checks):
|
|
396
|
+
checks_parameters = [
|
|
397
|
+
{"context": check[0], "app_id": check[1]} if isinstance(check, tuple) else {"context": check}
|
|
398
|
+
for check in checks
|
|
399
|
+
]
|
|
400
|
+
elif is_defined(contexts):
|
|
401
|
+
checks_parameters = [{"context": context} for context in contexts]
|
|
402
|
+
|
|
403
|
+
post_parameters: dict[str, Any] = NotSet.remove_unset_items({"strict": strict, "checks": checks_parameters})
|
|
404
|
+
|
|
405
|
+
headers, data = await self._requester.requestJsonAndCheck(
|
|
406
|
+
"PATCH",
|
|
407
|
+
f"{self.protection_url}/required_status_checks",
|
|
408
|
+
input=post_parameters,
|
|
409
|
+
)
|
|
410
|
+
|
|
411
|
+
return githubasyncio.RequiredStatusChecks.RequiredStatusChecks(self._requester, headers, data, completed=True)
|
|
412
|
+
|
|
413
|
+
async def remove_required_status_checks(self) -> None:
|
|
414
|
+
"""
|
|
415
|
+
:calls: `DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks <https://docs.github.com/en/rest/reference/repos#branches>`_
|
|
416
|
+
"""
|
|
417
|
+
headers, data = await self._requester.requestJsonAndCheck(
|
|
418
|
+
"DELETE",
|
|
419
|
+
f"{self.protection_url}/required_status_checks",
|
|
420
|
+
)
|
|
421
|
+
|
|
422
|
+
async def get_required_pull_request_reviews(self) -> RequiredPullRequestReviews:
|
|
423
|
+
"""
|
|
424
|
+
:calls: `GET /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews <https://docs.github.com/en/rest/reference/repos#branches>`_
|
|
425
|
+
"""
|
|
426
|
+
headers, data = await self._requester.requestJsonAndCheck(
|
|
427
|
+
"GET",
|
|
428
|
+
f"{self.protection_url}/required_pull_request_reviews",
|
|
429
|
+
headers={"Accept": Consts.mediaTypeRequireMultipleApprovingReviews},
|
|
430
|
+
)
|
|
431
|
+
return githubasyncio.RequiredPullRequestReviews.RequiredPullRequestReviews(
|
|
432
|
+
self._requester, headers, data, completed=True
|
|
433
|
+
)
|
|
434
|
+
|
|
435
|
+
async def edit_required_pull_request_reviews(
|
|
436
|
+
self,
|
|
437
|
+
dismissal_users: Opt[list[str]] = NotSet,
|
|
438
|
+
dismissal_teams: Opt[list[str]] = NotSet,
|
|
439
|
+
dismissal_apps: Opt[list[str]] = NotSet,
|
|
440
|
+
dismiss_stale_reviews: Opt[bool] = NotSet,
|
|
441
|
+
require_code_owner_reviews: Opt[bool] = NotSet,
|
|
442
|
+
required_approving_review_count: Opt[int] = NotSet,
|
|
443
|
+
require_last_push_approval: Opt[bool] = NotSet,
|
|
444
|
+
) -> RequiredPullRequestReviews:
|
|
445
|
+
"""
|
|
446
|
+
:calls: `PATCH /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews <https://docs.github.com/en/rest/reference/repos#branches>`_
|
|
447
|
+
"""
|
|
448
|
+
assert is_optional_list(dismissal_users, str), dismissal_users
|
|
449
|
+
assert is_optional_list(dismissal_teams, str), dismissal_teams
|
|
450
|
+
assert is_optional(dismiss_stale_reviews, bool), dismiss_stale_reviews
|
|
451
|
+
assert is_optional(require_code_owner_reviews, bool), require_code_owner_reviews
|
|
452
|
+
assert is_optional(required_approving_review_count, int), required_approving_review_count
|
|
453
|
+
assert is_optional(require_last_push_approval, bool), require_last_push_approval
|
|
454
|
+
|
|
455
|
+
post_parameters: dict[str, Any] = NotSet.remove_unset_items(
|
|
456
|
+
{
|
|
457
|
+
"dismiss_stale_reviews": dismiss_stale_reviews,
|
|
458
|
+
"require_code_owner_reviews": require_code_owner_reviews,
|
|
459
|
+
"required_approving_review_count": required_approving_review_count,
|
|
460
|
+
"require_last_push_approval": require_last_push_approval,
|
|
461
|
+
}
|
|
462
|
+
)
|
|
463
|
+
|
|
464
|
+
dismissal_restrictions: dict[str, Any] = NotSet.remove_unset_items(
|
|
465
|
+
{"users": dismissal_users, "teams": dismissal_teams, "apps": dismissal_apps}
|
|
466
|
+
)
|
|
467
|
+
|
|
468
|
+
if dismissal_restrictions:
|
|
469
|
+
post_parameters["dismissal_restrictions"] = dismissal_restrictions
|
|
470
|
+
|
|
471
|
+
headers, data = await self._requester.requestJsonAndCheck(
|
|
472
|
+
"PATCH",
|
|
473
|
+
f"{self.protection_url}/required_pull_request_reviews",
|
|
474
|
+
headers={"Accept": Consts.mediaTypeRequireMultipleApprovingReviews},
|
|
475
|
+
input=post_parameters,
|
|
476
|
+
)
|
|
477
|
+
|
|
478
|
+
return githubasyncio.RequiredPullRequestReviews.RequiredPullRequestReviews(
|
|
479
|
+
self._requester, headers, data, completed=True
|
|
480
|
+
)
|
|
481
|
+
|
|
482
|
+
async def remove_required_pull_request_reviews(self) -> None:
|
|
483
|
+
"""
|
|
484
|
+
:calls: `DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews <https://docs.github.com/en/rest/reference/repos#branches>`_
|
|
485
|
+
"""
|
|
486
|
+
headers, data = await self._requester.requestJsonAndCheck(
|
|
487
|
+
"DELETE",
|
|
488
|
+
f"{self.protection_url}/required_pull_request_reviews",
|
|
489
|
+
)
|
|
490
|
+
|
|
491
|
+
async def get_admin_enforcement(self) -> bool:
|
|
492
|
+
"""
|
|
493
|
+
:calls: `GET /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins <https://docs.github.com/en/rest/reference/repos#branches>`_
|
|
494
|
+
"""
|
|
495
|
+
headers, data = await self._requester.requestJsonAndCheck("GET", f"{self.protection_url}/enforce_admins")
|
|
496
|
+
return data["enabled"]
|
|
497
|
+
|
|
498
|
+
async def set_admin_enforcement(self) -> None:
|
|
499
|
+
"""
|
|
500
|
+
:calls: `POST /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins <https://docs.github.com/en/rest/reference/repos#branches>`_
|
|
501
|
+
"""
|
|
502
|
+
headers, data = await self._requester.requestJsonAndCheck("POST", f"{self.protection_url}/enforce_admins")
|
|
503
|
+
|
|
504
|
+
async def remove_admin_enforcement(self) -> None:
|
|
505
|
+
"""
|
|
506
|
+
:calls: `DELETE /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins <https://docs.github.com/en/rest/reference/repos#branches>`_
|
|
507
|
+
"""
|
|
508
|
+
headers, data = await self._requester.requestJsonAndCheck("DELETE", f"{self.protection_url}/enforce_admins")
|
|
509
|
+
|
|
510
|
+
def get_user_push_restrictions(self) -> PaginatedList[NamedUser]:
|
|
511
|
+
"""
|
|
512
|
+
:calls: `GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users <https://docs.github.com/en/rest/reference/repos#branches>`_
|
|
513
|
+
"""
|
|
514
|
+
return githubasyncio.PaginatedList.PaginatedList(
|
|
515
|
+
githubasyncio.NamedUser.NamedUser,
|
|
516
|
+
self._requester,
|
|
517
|
+
f"{self.protection_url}/restrictions/users",
|
|
518
|
+
None,
|
|
519
|
+
)
|
|
520
|
+
|
|
521
|
+
def get_team_push_restrictions(self) -> PaginatedList[Team]:
|
|
522
|
+
"""
|
|
523
|
+
:calls: `GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams <https://docs.github.com/en/rest/reference/repos#branches>`_
|
|
524
|
+
"""
|
|
525
|
+
return githubasyncio.PaginatedList.PaginatedList(
|
|
526
|
+
githubasyncio.Team.Team,
|
|
527
|
+
self._requester,
|
|
528
|
+
f"{self.protection_url}/restrictions/teams",
|
|
529
|
+
None,
|
|
530
|
+
)
|
|
531
|
+
|
|
532
|
+
async def add_user_push_restrictions(self, *users: str) -> None:
|
|
533
|
+
"""
|
|
534
|
+
:calls: `POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users <https://docs.github.com/en/rest/reference/repos#branches>`_
|
|
535
|
+
:users: list of strings (user names)
|
|
536
|
+
"""
|
|
537
|
+
assert all(isinstance(element, str) for element in users), users
|
|
538
|
+
|
|
539
|
+
headers, data = await self._requester.requestJsonAndCheck(
|
|
540
|
+
"POST", f"{self.protection_url}/restrictions/users", input=users
|
|
541
|
+
)
|
|
542
|
+
|
|
543
|
+
async def replace_user_push_restrictions(self, *users: str) -> None:
|
|
544
|
+
"""
|
|
545
|
+
:calls: `PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users <https://docs.github.com/en/rest/reference/repos#branches>`_
|
|
546
|
+
:users: list of strings (user names)
|
|
547
|
+
"""
|
|
548
|
+
assert all(isinstance(element, str) for element in users), users
|
|
549
|
+
|
|
550
|
+
headers, data = await self._requester.requestJsonAndCheck(
|
|
551
|
+
"PUT", f"{self.protection_url}/restrictions/users", input=users
|
|
552
|
+
)
|
|
553
|
+
|
|
554
|
+
async def remove_user_push_restrictions(self, *users: str) -> None:
|
|
555
|
+
"""
|
|
556
|
+
:calls: `DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users <https://docs.github.com/en/rest/reference/repos#branches>`_
|
|
557
|
+
:users: list of strings (user names)
|
|
558
|
+
"""
|
|
559
|
+
assert all(isinstance(element, str) for element in users), users
|
|
560
|
+
|
|
561
|
+
headers, data = await self._requester.requestJsonAndCheck(
|
|
562
|
+
"DELETE", f"{self.protection_url}/restrictions/users", input=users
|
|
563
|
+
)
|
|
564
|
+
|
|
565
|
+
async def add_team_push_restrictions(self, *teams: str) -> None:
|
|
566
|
+
"""
|
|
567
|
+
:calls: `POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams <https://docs.github.com/en/rest/reference/repos#branches>`_
|
|
568
|
+
:teams: list of strings (team slugs)
|
|
569
|
+
"""
|
|
570
|
+
assert all(isinstance(element, str) for element in teams), teams
|
|
571
|
+
|
|
572
|
+
headers, data = await self._requester.requestJsonAndCheck(
|
|
573
|
+
"POST", f"{self.protection_url}/restrictions/teams", input=teams
|
|
574
|
+
)
|
|
575
|
+
|
|
576
|
+
async def replace_team_push_restrictions(self, *teams: str) -> None:
|
|
577
|
+
"""
|
|
578
|
+
:calls: `PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams <https://docs.github.com/en/rest/reference/repos#branches>`_
|
|
579
|
+
:teams: list of strings (team slugs)
|
|
580
|
+
"""
|
|
581
|
+
assert all(isinstance(element, str) for element in teams), teams
|
|
582
|
+
|
|
583
|
+
headers, data = await self._requester.requestJsonAndCheck(
|
|
584
|
+
"PUT", f"{self.protection_url}/restrictions/teams", input=teams
|
|
585
|
+
)
|
|
586
|
+
|
|
587
|
+
async def remove_team_push_restrictions(self, *teams: str) -> None:
|
|
588
|
+
"""
|
|
589
|
+
:calls: `DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams <https://docs.github.com/en/rest/reference/repos#branches>`_
|
|
590
|
+
:teams: list of strings (team slugs)
|
|
591
|
+
"""
|
|
592
|
+
assert all(isinstance(element, str) for element in teams), teams
|
|
593
|
+
|
|
594
|
+
headers, data = await self._requester.requestJsonAndCheck(
|
|
595
|
+
"DELETE", f"{self.protection_url}/restrictions/teams", input=teams
|
|
596
|
+
)
|
|
597
|
+
|
|
598
|
+
async def remove_push_restrictions(self) -> None:
|
|
599
|
+
"""
|
|
600
|
+
:calls: `DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions <https://docs.github.com/en/rest/reference/repos#branches>`_
|
|
601
|
+
"""
|
|
602
|
+
headers, data = await self._requester.requestJsonAndCheck("DELETE", f"{self.protection_url}/restrictions")
|
|
603
|
+
|
|
604
|
+
async def get_required_signatures(self) -> bool:
|
|
605
|
+
"""
|
|
606
|
+
:calls: `GET /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures <https://docs.github.com/en/rest/reference/repos#branches>`_
|
|
607
|
+
"""
|
|
608
|
+
headers, data = await self._requester.requestJsonAndCheck(
|
|
609
|
+
"GET",
|
|
610
|
+
f"{self.protection_url}/required_signatures",
|
|
611
|
+
headers={"Accept": Consts.signaturesProtectedBranchesPreview},
|
|
612
|
+
)
|
|
613
|
+
return data["enabled"]
|
|
614
|
+
|
|
615
|
+
async def add_required_signatures(self) -> None:
|
|
616
|
+
"""
|
|
617
|
+
:calls: `POST /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures <https://docs.github.com/en/rest/reference/repos#branches>`_
|
|
618
|
+
"""
|
|
619
|
+
headers, data = await self._requester.requestJsonAndCheck(
|
|
620
|
+
"POST",
|
|
621
|
+
f"{self.protection_url}/required_signatures",
|
|
622
|
+
headers={"Accept": Consts.signaturesProtectedBranchesPreview},
|
|
623
|
+
)
|
|
624
|
+
|
|
625
|
+
async def remove_required_signatures(self) -> None:
|
|
626
|
+
"""
|
|
627
|
+
:calls: `DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures <https://docs.github.com/en/rest/reference/repos#branches>`_
|
|
628
|
+
"""
|
|
629
|
+
headers, data = await self._requester.requestJsonAndCheck(
|
|
630
|
+
"DELETE",
|
|
631
|
+
f"{self.protection_url}/required_signatures",
|
|
632
|
+
headers={"Accept": Consts.signaturesProtectedBranchesPreview},
|
|
633
|
+
)
|
|
634
|
+
|
|
635
|
+
async def get_allow_deletions(self) -> bool:
|
|
636
|
+
"""
|
|
637
|
+
:calls: `GET /repos/{owner}/{repo}/branches/{branch}/protection/allow_deletions <https://docs.github.com/en/rest/reference/repos#branches>`_
|
|
638
|
+
"""
|
|
639
|
+
headers, data = await self._requester.requestJsonAndCheck("GET", f"{self.protection_url}/allow_deletions")
|
|
640
|
+
return data["enabled"]
|
|
641
|
+
|
|
642
|
+
async def set_allow_deletions(self) -> None:
|
|
643
|
+
"""
|
|
644
|
+
:calls: `POST /repos/{owner}/{repo}/branches/{branch}/protection/allow_deletions <https://docs.github.com/en/rest/reference/repos#branches>`_
|
|
645
|
+
"""
|
|
646
|
+
headers, data = await self._requester.requestJsonAndCheck("POST", f"{self.protection_url}/allow_deletions")
|
|
647
|
+
|
|
648
|
+
async def remove_allow_deletions(self) -> None:
|
|
649
|
+
"""
|
|
650
|
+
:calls: `DELETE /repos/{owner}/{repo}/branches/{branch}/protection/allow_deletions <https://docs.github.com/en/rest/reference/repos#branches>`_
|
|
651
|
+
"""
|
|
652
|
+
headers, data = await self._requester.requestJsonAndCheck("DELETE", f"{self.protection_url}/allow_deletions")
|
|
653
|
+
|
|
654
|
+
def get_rules(self) -> PaginatedList[githubasyncio.Rule.Rule]:
|
|
655
|
+
"""
|
|
656
|
+
:calls: `GET /repos/{owner}/{repo}/rules/branches/{branch} <https://docs.github.com/en/rest/repos/rules#get-rules-for-a-branch>`_
|
|
657
|
+
:rtype: :class:`PaginatedList` of :class:`githubasyncio.Rule.Rule`
|
|
658
|
+
"""
|
|
659
|
+
repo_url = "TBD"
|
|
660
|
+
return PaginatedList(
|
|
661
|
+
githubasyncio.Rule.Rule,
|
|
662
|
+
self._requester,
|
|
663
|
+
f"{repo_url}/rules/branches/{self._name.value}",
|
|
664
|
+
None,
|
|
665
|
+
)
|
|
666
|
+
|
|
667
|
+
def _useAttributes(self, attributes: dict[str, Any]) -> None:
|
|
668
|
+
if "_links" in attributes: # pragma no branch
|
|
669
|
+
self.__links = self._makeDictAttribute(attributes["_links"])
|
|
670
|
+
if "commit" in attributes: # pragma no branch
|
|
671
|
+
self._commit = self._makeClassAttribute(githubasyncio.Commit.Commit, attributes["commit"])
|
|
672
|
+
if "name" in attributes: # pragma no branch
|
|
673
|
+
self._name = self._makeStringAttribute(attributes["name"])
|
|
674
|
+
if "pattern" in attributes: # pragma no branch
|
|
675
|
+
self._pattern = self._makeStringAttribute(attributes["pattern"])
|
|
676
|
+
if "protected" in attributes: # pragma no branch
|
|
677
|
+
self._protected = self._makeBoolAttribute(attributes["protected"])
|
|
678
|
+
if "protection" in attributes: # pragma no branch
|
|
679
|
+
self._protection = self._makeClassAttribute(
|
|
680
|
+
githubasyncio.BranchProtection.BranchProtection, attributes["protection"]
|
|
681
|
+
)
|
|
682
|
+
if "protection_url" in attributes: # pragma no branch
|
|
683
|
+
self._protection_url = self._makeStringAttribute(attributes["protection_url"])
|
|
684
|
+
if "required_approving_review_count" in attributes: # pragma no branch
|
|
685
|
+
self._required_approving_review_count = self._makeIntAttribute(
|
|
686
|
+
attributes["required_approving_review_count"]
|
|
687
|
+
)
|
|
688
|
+
if "url" in attributes:
|
|
689
|
+
self._url = self._makeStringAttribute(attributes["url"])
|