Skip to content

Commit cebbbf6

Browse files
committed
Add access control options to protected branch creation
1 parent 728f2dd commit cebbbf6

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

docs/gl_objects/protected_branches.rst

+9
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ Create a protected branch::
3535
'push_access_level': gitlab.MAINTAINER_ACCESS
3636
})
3737

38+
Create a protected branch with more granular access control::
39+
40+
p_branch = project.protectedbranches.create({
41+
'name': '*-stable',
42+
'allowed_to_push': [{"user_id": 99}, {"user_id": 98}],
43+
'allowed_to_merge': [{"group_id": 653}],
44+
'allowed_to_unprotect': [{"access_level": gitlab.MAINTAINER_ACCESS}]
45+
})
46+
3847
Delete a protected branch::
3948

4049
project.protectedbranches.delete('*-stable')

gitlab/v4/objects.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -3117,7 +3117,10 @@ class ProjectProtectedBranchManager(NoUpdateMixin, RESTManager):
31173117
_path = '/projects/%(project_id)s/protected_branches'
31183118
_obj_cls = ProjectProtectedBranch
31193119
_from_parent_attrs = {'project_id': 'id'}
3120-
_create_attrs = (('name', ), ('push_access_level', 'merge_access_level'))
3120+
_create_attrs = (('name', ),
3121+
('push_access_level', 'merge_access_level',
3122+
'unprotect_access_level', 'allowed_to_push',
3123+
'allowed_to_merge', 'allowed_to_unprotect'))
31213124

31223125

31233126
class ProjectRunner(ObjectDeleteMixin, RESTObject):

0 commit comments

Comments
 (0)