Skip to content

Commit 1b14f5c

Browse files
author
Gauvain Pocentek
committed
project issue: doc and CLI for (un)subscribe
1 parent 7bbbfbd commit 1b14f5c

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

gitlab/cli.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
'blob': {'required': ['id', 'project-id',
4242
'filepath']},
4343
'builds': {'required': ['id', 'project-id']}},
44+
gitlab.ProjectIssue: {'subscribe': {'required': ['id', 'project-id']},
45+
'unsubscribe': {'required': ['id', 'project-id']}},
4446
gitlab.ProjectMergeRequest: {
4547
'closes-issues': {'required': ['id', 'project-id']},
4648
'cancel': {'required': ['id', 'project-id']},
@@ -248,6 +250,20 @@ def do_project_build_retry(self, cls, gl, what, args):
248250
except Exception as e:
249251
_die("Impossible to retry project build (%s)" % str(e))
250252

253+
def do_project_issue_subscribe(self, cls, gl, what, args):
254+
try:
255+
o = self.do_get(cls, gl, what, args)
256+
o.subscribe()
257+
except Exception as e:
258+
_die("Impossible to subscribe to issue (%s)" % str(e))
259+
260+
def do_project_issue_unsubscribe(self, cls, gl, what, args):
261+
try:
262+
o = self.do_get(cls, gl, what, args)
263+
o.unsubscribe()
264+
except Exception as e:
265+
_die("Impossible to subscribe to issue (%s)" % str(e))
266+
251267
def do_project_merge_request_closesissues(self, cls, gl, what, args):
252268
try:
253269
o = self.do_get(cls, gl, what, args)

gitlab/objects.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,12 @@ def Note(self, id=None, **kwargs):
999999
**kwargs)
10001000

10011001
def subscribe(self, **kwargs):
1002+
"""Subscribe to an issue.
1003+
1004+
Raises:
1005+
GitlabConnectionError: If the server cannot be reached.
1006+
GitlabSubscribeError: If the subscription cannot be done
1007+
"""
10021008
url = ('/projects/%(project_id)s/issues/%(issue_id)s/subscription' %
10031009
{'project_id': self.project_id, 'issue_id': self.id})
10041010

@@ -1007,6 +1013,12 @@ def subscribe(self, **kwargs):
10071013
self._set_from_dict(r.json())
10081014

10091015
def unsubscribe(self, **kwargs):
1016+
"""Unsubscribe an issue.
1017+
1018+
Raises:
1019+
GitlabConnectionError: If the server cannot be reached.
1020+
GitlabSubscribeError: If the unsubscription cannot be done
1021+
"""
10101022
url = ('/projects/%(project_id)s/issues/%(issue_id)s/subscription' %
10111023
{'project_id': self.project_id, 'issue_id': self.id})
10121024

0 commit comments

Comments
 (0)