-
Notifications
You must be signed in to change notification settings - Fork 676
Expand file tree
/
Copy pathbranches.py
More file actions
75 lines (62 loc) · 2.06 KB
/
branches.py
File metadata and controls
75 lines (62 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
from gitlab.base import RESTObject
from gitlab.mixins import (
CRUDMixin,
NoUpdateMixin,
ObjectDeleteMixin,
SaveMixin,
UpdateMethod,
)
from gitlab.types import RequiredOptional
__all__ = [
"ProjectBranch",
"ProjectBranchManager",
"ProjectProtectedBranch",
"ProjectProtectedBranchManager",
]
class ProjectBranch(ObjectDeleteMixin, RESTObject):
_id_attr = "name"
class ProjectBranchManager(NoUpdateMixin[ProjectBranch]):
_path = "/projects/{project_id}/repository/branches"
_obj_cls = ProjectBranch
_from_parent_attrs = {"project_id": "id"}
_create_attrs = RequiredOptional(required=("branch", "ref"))
class ProjectProtectedBranch(SaveMixin, ObjectDeleteMixin, RESTObject):
_id_attr = "name"
class ProjectProtectedBranchManager(CRUDMixin[ProjectProtectedBranch]):
_path = "/projects/{project_id}/protected_branches"
_obj_cls = ProjectProtectedBranch
_from_parent_attrs = {"project_id": "id"}
_create_attrs = RequiredOptional(
required=("name",),
optional=(
"push_access_level",
"merge_access_level",
"unprotect_access_level",
"allow_force_push",
"allowed_to_push",
"allowed_to_merge",
"allowed_to_unprotect",
"code_owner_approval_required",
),
)
_update_method = UpdateMethod.PATCH
class GroupProtectedBranch(SaveMixin, ObjectDeleteMixin, RESTObject):
_id_attr = "name"
class GroupProtectedBranchManager(CRUDMixin[GroupProtectedBranch]):
_path = "/groups/{group_id}/protected_branches"
_obj_cls = GroupProtectedBranch
_from_parent_attrs = {"group_id": "id"}
_create_attrs = RequiredOptional(
required=("name",),
optional=(
"push_access_level",
"merge_access_level",
"unprotect_access_level",
"allow_force_push",
"allowed_to_push",
"allowed_to_merge",
"allowed_to_unprotect",
"code_owner_approval_required",
),
)
_update_method = UpdateMethod.PATCH