@@ -2277,23 +2277,46 @@ def changes(self, **kwargs):
2277
2277
path = '%s/%s/changes' % (self .manager .path , self .get_id ())
2278
2278
return self .manager .gitlab .http_get (path , ** kwargs )
2279
2279
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.
2284
2284
2285
2285
Args:
2286
+ sha (str): Head SHA of MR
2286
2287
**kwargs: Extra options to send to the server (e.g. sudo)
2287
2288
2288
2289
Raises:
2289
2290
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
2291
2297
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
2294
2313
"""
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 )
2297
2320
2298
2321
@cli .register_custom_action ('ProjectMergeRequest' , tuple (),
2299
2322
('merge_commit_message' ,
0 commit comments