@@ -1795,6 +1795,37 @@ class ProjectTagManager(NoUpdateMixin, RESTManager):
1795
1795
_create_attrs = (('tag_name' , 'ref' ), ('message' ,))
1796
1796
1797
1797
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
+
1798
1829
class ProjectMergeRequestAwardEmoji (ObjectDeleteMixin , RESTObject ):
1799
1830
pass
1800
1831
@@ -1879,6 +1910,7 @@ class ProjectMergeRequest(SubscribableMixin, TodoMixin, TimeTrackingMixin,
1879
1910
_id_attr = 'iid'
1880
1911
1881
1912
_managers = (
1913
+ ('approvals' , 'ProjectMergeRequestApprovalManager' ),
1882
1914
('awardemojis' , 'ProjectMergeRequestAwardEmojiManager' ),
1883
1915
('diffs' , 'ProjectMergeRequestDiffManager' ),
1884
1916
('discussions' , 'ProjectMergeRequestDiscussionManager' ),
@@ -2761,13 +2793,12 @@ class ProjectApprovalManager(GetWithoutIdMixin, UpdateMixin, RESTManager):
2761
2793
_update_uses_post = True
2762
2794
2763
2795
@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 ):
2766
2797
"""Change project-level allowed approvers and approver groups.
2767
2798
2768
2799
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
2771
2802
2772
2803
Raises:
2773
2804
GitlabAuthenticationError: If authentication is not correct
@@ -2777,10 +2808,7 @@ def set_approvers(self, approver_ids=[], approver_group_ids=[],
2777
2808
path = '/projects/%s/approvers' % self ._parent .get_id ()
2778
2809
data = {'approver_ids' : approver_ids ,
2779
2810
'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 )
2784
2812
2785
2813
2786
2814
class ProjectDeployment (RESTObject ):
0 commit comments