@@ -2277,23 +2277,46 @@ def changes(self, **kwargs):
22772277 path = '%s/%s/changes' % (self .manager .path , self .get_id ())
22782278 return self .manager .gitlab .http_get (path , ** kwargs )
22792279
2280- @cli .register_custom_action ('ProjectMergeRequest' )
2281- @exc .on_http_error (exc .GitlabListError )
2282- def pipelines (self , ** kwargs ):
2283- """List the merge request pipelines .
2280+ @cli .register_custom_action ('ProjectMergeRequest' , tuple (), ( 'sha' ) )
2281+ @exc .on_http_error (exc .GitlabMRApprovalError )
2282+ def approve (self , sha = None , ** kwargs ):
2283+ """Approve the merge request.
22842284
22852285 Args:
2286+ sha (str): Head SHA of MR
22862287 **kwargs: Extra options to send to the server (e.g. sudo)
22872288
22882289 Raises:
22892290 GitlabAuthenticationError: If authentication is not correct
2290- GitlabListError: If the list could not be retrieved
2291+ GitlabMRApprovalError: If the approval failed
2292+ """
2293+ path = '%s/%s/approve' % (self .manager .path , self .get_id ())
2294+ data = {}
2295+ if sha :
2296+ data ['sha' ] = sha
22912297
2292- Returns:
2293- RESTObjectList: List of changes
2298+ server_data = self .manager .gitlab .http_post (path , post_data = data ,
2299+ ** kwargs )
2300+ self ._update_attrs (server_data )
2301+
2302+ @cli .register_custom_action ('ProjectMergeRequest' )
2303+ @exc .on_http_error (exc .GitlabMRApprovalError )
2304+ def unapprove (self , ** kwargs ):
2305+ """Unapprove the merge request.
2306+
2307+ Args:
2308+ **kwargs: Extra options to send to the server (e.g. sudo)
2309+
2310+ Raises:
2311+ GitlabAuthenticationError: If authentication is not correct
2312+ GitlabMRApprovalError: If the unapproval failed
22942313 """
2295- path = '%s/%s/pipelines' % (self .manager .path , self .get_id ())
2296- return self .manager .gitlab .http_get (path , ** kwargs )
2314+ path = '%s/%s/unapprove' % (self .manager .path , self .get_id ())
2315+ data = {}
2316+
2317+ server_data = self .manager .gitlab .http_post (path , post_data = data ,
2318+ ** kwargs )
2319+ self ._update_attrs (server_data )
22972320
22982321 @cli .register_custom_action ('ProjectMergeRequest' , tuple (),
22992322 ('merge_commit_message' ,
0 commit comments