From 2cef2bb40b1f37b97bb2ee9894ab3b9970cef231 Mon Sep 17 00:00:00 2001 From: Srikanth Chelluri Date: Wed, 23 Oct 2019 16:51:10 -0400 Subject: fix(projects): support `approval_rules` endpoint for projects The `approvers` API endpoint is deprecated [1]. GitLab instead uses the `approval_rules` API endpoint to modify approval settings for merge requests. This adds the functionality for project-level merge request approval settings. Note that there does not exist an endpoint to 'get' a single approval rule at this moment - only 'list'. [1] https://docs.gitlab.com/ee/api/merge_request_approvals.html --- gitlab/v4/objects.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'gitlab/v4/objects.py') diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py index fcac301..7b9c8f3 100644 --- a/gitlab/v4/objects.py +++ b/gitlab/v4/objects.py @@ -3777,6 +3777,19 @@ class ProjectApprovalManager(GetWithoutIdMixin, UpdateMixin, RESTManager): self.gitlab.http_put(path, post_data=data, **kwargs) +class ProjectApprovalRule(SaveMixin, ObjectDeleteMixin, RESTObject): + _id_attr = "id" + + +class ProjectApprovalRuleManager( + ListMixin, CreateMixin, UpdateMixin, DeleteMixin, RESTManager +): + _path = "/projects/%(project_id)s/approval_rules" + _obj_cls = ProjectApprovalRule + _from_parent_attrs = {"project_id": "id"} + _create_attrs = (("name", "approvals_required"), ("user_ids", "group_ids")) + + class ProjectDeployment(RESTObject, SaveMixin): pass @@ -3888,6 +3901,7 @@ class Project(SaveMixin, ObjectDeleteMixin, RESTObject): _managers = ( ("accessrequests", "ProjectAccessRequestManager"), ("approvals", "ProjectApprovalManager"), + ("approvalrules", "ProjectApprovalRuleManager"), ("badges", "ProjectBadgeManager"), ("boards", "ProjectBoardManager"), ("branches", "ProjectBranchManager"), -- cgit v1.2.1