@@ -1795,6 +1795,37 @@ class ProjectTagManager(NoUpdateMixin, RESTManager):
17951795 _create_attrs = (('tag_name' , 'ref' ), ('message' ,))
17961796
17971797
1798+ class ProjectMergeRequestApproval (SaveMixin , RESTObject ):
1799+ _id_attr = None
1800+
1801+
1802+ class ProjectMergeRequestApprovalManager (GetWithoutIdMixin , UpdateMixin ,
1803+ RESTManager ):
1804+ _path = '/projects/%(project_id)s/merge_requests/%(mr_iid)s/approvals'
1805+ _obj_cls = ProjectMergeRequestApproval
1806+ _from_parent_attrs = {'project_id' : 'project_id' , 'mr_iid' : 'iid' }
1807+ _update_attrs = (('approvals_required' ,), tuple ())
1808+ _update_uses_post = True
1809+
1810+ @exc .on_http_error (exc .GitlabUpdateError )
1811+ def set_approvers (self , approver_ids = [], approver_group_ids = [], ** kwargs ):
1812+ """Change MR-level allowed approvers and approver groups.
1813+
1814+ Args:
1815+ approver_ids (list): User IDs that can approve MRs
1816+ approver_group_ids (list): Group IDs whose members can approve MRs
1817+
1818+ Raises:
1819+ GitlabAuthenticationError: If authentication is not correct
1820+ GitlabUpdateError: If the server failed to perform the request
1821+ """
1822+ path = '%s/%s/approvers' % (self ._parent .manager .path ,
1823+ self ._parent .get_id ())
1824+ data = {'approver_ids' : approver_ids ,
1825+ 'approver_group_ids' : approver_group_ids }
1826+ self .gitlab .http_put (path , post_data = data , ** kwargs )
1827+
1828+
17981829class ProjectMergeRequestAwardEmoji (ObjectDeleteMixin , RESTObject ):
17991830 pass
18001831
@@ -1879,6 +1910,7 @@ class ProjectMergeRequest(SubscribableMixin, TodoMixin, TimeTrackingMixin,
18791910 _id_attr = 'iid'
18801911
18811912 _managers = (
1913+ ('approvals' , 'ProjectMergeRequestApprovalManager' ),
18821914 ('awardemojis' , 'ProjectMergeRequestAwardEmojiManager' ),
18831915 ('diffs' , 'ProjectMergeRequestDiffManager' ),
18841916 ('discussions' , 'ProjectMergeRequestDiscussionManager' ),
@@ -2761,13 +2793,12 @@ class ProjectApprovalManager(GetWithoutIdMixin, UpdateMixin, RESTManager):
27612793 _update_uses_post = True
27622794
27632795 @exc .on_http_error (exc .GitlabUpdateError )
2764- def set_approvers (self , approver_ids = [], approver_group_ids = [],
2765- ** kwargs ):
2796+ def set_approvers (self , approver_ids = [], approver_group_ids = [], ** kwargs ):
27662797 """Change project-level allowed approvers and approver groups.
27672798
27682799 Args:
2769- approver_ids (list): User IDs that can approve MRs.
2770- approver_group_ids (list): Group IDs whose members can approve MRs.
2800+ approver_ids (list): User IDs that can approve MRs
2801+ approver_group_ids (list): Group IDs whose members can approve MRs
27712802
27722803 Raises:
27732804 GitlabAuthenticationError: If authentication is not correct
@@ -2777,10 +2808,7 @@ def set_approvers(self, approver_ids=[], approver_group_ids=[],
27772808 path = '/projects/%s/approvers' % self ._parent .get_id ()
27782809 data = {'approver_ids' : approver_ids ,
27792810 'approver_group_ids' : approver_group_ids }
2780- try :
2781- self .gitlab .http_put (path , post_data = data , ** kwargs )
2782- except exc .GitlabHttpError as e :
2783- raise exc .GitlabUpdateError (e .response_code , e .error_message )
2811+ self .gitlab .http_put (path , post_data = data , ** kwargs )
27842812
27852813
27862814class ProjectDeployment (RESTObject ):
0 commit comments