summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Sabouraud <esabouraud@users.noreply.github.com>2018-12-07 18:10:41 +0100
committerEric Sabouraud <esabouraud@users.noreply.github.com>2018-12-07 18:10:41 +0100
commitcebbbf67f2529bd9380276ac28abe726d3a57a81 (patch)
treef80e780e1bb87f0c2f5ba444d728e985cd2868f8
parent728f2dd1677522a4fcca76769ed127146c034c29 (diff)
downloadgitlab-cebbbf67f2529bd9380276ac28abe726d3a57a81.tar.gz
Add access control options to protected branch creation
-rw-r--r--docs/gl_objects/protected_branches.rst9
-rw-r--r--gitlab/v4/objects.py5
2 files changed, 13 insertions, 1 deletions
diff --git a/docs/gl_objects/protected_branches.rst b/docs/gl_objects/protected_branches.rst
index f0479e0..3498aa5 100644
--- a/docs/gl_objects/protected_branches.rst
+++ b/docs/gl_objects/protected_branches.rst
@@ -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')
diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py
index 04444f7..fd673b5 100644
--- a/gitlab/v4/objects.py
+++ b/gitlab/v4/objects.py
@@ -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):