17
17
18
18
import gitlab
19
19
from gitlab import base
20
+ from gitlab import cli
20
21
from gitlab import exceptions as exc
21
22
22
23
@@ -296,6 +297,8 @@ def delete(self, **kwargs):
296
297
297
298
298
299
class AccessRequestMixin (object ):
300
+ @cli .register_custom_action (('ProjectAccessRequest' , 'GroupAccessRequest' ),
301
+ tuple (), ('access_level' , ))
299
302
@exc .on_http_error (exc .GitlabUpdateError )
300
303
def approve (self , access_level = gitlab .DEVELOPER_ACCESS , ** kwargs ):
301
304
"""Approve an access request.
@@ -317,6 +320,8 @@ def approve(self, access_level=gitlab.DEVELOPER_ACCESS, **kwargs):
317
320
318
321
319
322
class SubscribableMixin (object ):
323
+ @cli .register_custom_action (('ProjectIssue' , 'ProjectMergeRequest' ,
324
+ 'ProjectLabel' ))
320
325
@exc .on_http_error (exc .GitlabSubscribeError )
321
326
def subscribe (self , ** kwargs ):
322
327
"""Subscribe to the object notifications.
@@ -332,6 +337,8 @@ def subscribe(self, **kwargs):
332
337
server_data = self .manager .gitlab .http_post (path , ** kwargs )
333
338
self ._update_attrs (server_data )
334
339
340
+ @cli .register_custom_action (('ProjectIssue' , 'ProjectMergeRequest' ,
341
+ 'ProjectLabel' ))
335
342
@exc .on_http_error (exc .GitlabUnsubscribeError )
336
343
def unsubscribe (self , ** kwargs ):
337
344
"""Unsubscribe from the object notifications.
@@ -349,6 +356,7 @@ def unsubscribe(self, **kwargs):
349
356
350
357
351
358
class TodoMixin (object ):
359
+ @cli .register_custom_action (('ProjectIssue' , 'ProjectMergeRequest' ))
352
360
@exc .on_http_error (exc .GitlabHttpError )
353
361
def todo (self , ** kwargs ):
354
362
"""Create a todo associated to the object.
@@ -365,6 +373,7 @@ def todo(self, **kwargs):
365
373
366
374
367
375
class TimeTrackingMixin (object ):
376
+ @cli .register_custom_action (('ProjectIssue' , 'ProjectMergeRequest' ))
368
377
@exc .on_http_error (exc .GitlabTimeTrackingError )
369
378
def time_stats (self , ** kwargs ):
370
379
"""Get time stats for the object.
@@ -379,6 +388,8 @@ def time_stats(self, **kwargs):
379
388
path = '%s/%s/time_stats' % (self .manager .path , self .get_id ())
380
389
return self .manager .gitlab .http_get (path , ** kwargs )
381
390
391
+ @cli .register_custom_action (('ProjectIssue' , 'ProjectMergeRequest' ),
392
+ ('duration' , ))
382
393
@exc .on_http_error (exc .GitlabTimeTrackingError )
383
394
def time_estimate (self , duration , ** kwargs ):
384
395
"""Set an estimated time of work for the object.
@@ -395,6 +406,7 @@ def time_estimate(self, duration, **kwargs):
395
406
data = {'duration' : duration }
396
407
return self .manager .gitlab .http_post (path , post_data = data , ** kwargs )
397
408
409
+ @cli .register_custom_action (('ProjectIssue' , 'ProjectMergeRequest' ))
398
410
@exc .on_http_error (exc .GitlabTimeTrackingError )
399
411
def reset_time_estimate (self , ** kwargs ):
400
412
"""Resets estimated time for the object to 0 seconds.
@@ -409,6 +421,8 @@ def reset_time_estimate(self, **kwargs):
409
421
path = '%s/%s/rest_time_estimate' % (self .manager .path , self .get_id ())
410
422
return self .manager .gitlab .http_post (path , ** kwargs )
411
423
424
+ @cli .register_custom_action (('ProjectIssue' , 'ProjectMergeRequest' ),
425
+ ('duration' , ))
412
426
@exc .on_http_error (exc .GitlabTimeTrackingError )
413
427
def add_spent_time (self , duration , ** kwargs ):
414
428
"""Add time spent working on the object.
@@ -425,6 +439,7 @@ def add_spent_time(self, duration, **kwargs):
425
439
data = {'duration' : duration }
426
440
return self .manager .gitlab .http_post (path , post_data = data , ** kwargs )
427
441
442
+ @cli .register_custom_action (('ProjectIssue' , 'ProjectMergeRequest' ))
428
443
@exc .on_http_error (exc .GitlabTimeTrackingError )
429
444
def reset_spent_time (self , ** kwargs ):
430
445
"""Resets the time spent working on the object.
0 commit comments