Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/gl_objects/protected_branches.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ Create a protected branch::
'push_access_level': gitlab.MAINTAINER_ACCESS
})

Create a protected branch with more granular access control::

p_branch = project.protectedbranches.create({
'name': '*-stable',
'allowed_to_push': [{"user_id": 99}, {"user_id": 98}],
'allowed_to_merge': [{"group_id": 653}],
'allowed_to_unprotect': [{"access_level": gitlab.MAINTAINER_ACCESS}]
})

Delete a protected branch::

project.protectedbranches.delete('*-stable')
Expand Down
5 changes: 4 additions & 1 deletion gitlab/v4/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -3117,7 +3117,10 @@ class ProjectProtectedBranchManager(NoUpdateMixin, RESTManager):
_path = '/projects/%(project_id)s/protected_branches'
_obj_cls = ProjectProtectedBranch
_from_parent_attrs = {'project_id': 'id'}
_create_attrs = (('name', ), ('push_access_level', 'merge_access_level'))
_create_attrs = (('name', ),
('push_access_level', 'merge_access_level',
'unprotect_access_level', 'allowed_to_push',
'allowed_to_merge', 'allowed_to_unprotect'))


class ProjectRunner(ObjectDeleteMixin, RESTObject):
Expand Down