summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2016-05-28 09:59:26 +0200
committerGauvain Pocentek <gauvain@pocentek.net>2016-05-28 09:59:26 +0200
commit1b14f5c9b1ff0af083abedff80eafb9adcae629c (patch)
treea586652141a492133c33dc4cbccb19d7ffce824c
parent7bbbfbdc534a4d26aa61b1b4287911c9f7c6f8a5 (diff)
downloadgitlab-1b14f5c9b1ff0af083abedff80eafb9adcae629c.tar.gz
project issue: doc and CLI for (un)subscribe
-rw-r--r--gitlab/cli.py16
-rw-r--r--gitlab/objects.py12
2 files changed, 28 insertions, 0 deletions
diff --git a/gitlab/cli.py b/gitlab/cli.py
index c7daceb..181cc56 100644
--- a/gitlab/cli.py
+++ b/gitlab/cli.py
@@ -41,6 +41,8 @@ EXTRA_ACTIONS = {
'blob': {'required': ['id', 'project-id',
'filepath']},
'builds': {'required': ['id', 'project-id']}},
+ gitlab.ProjectIssue: {'subscribe': {'required': ['id', 'project-id']},
+ 'unsubscribe': {'required': ['id', 'project-id']}},
gitlab.ProjectMergeRequest: {
'closes-issues': {'required': ['id', 'project-id']},
'cancel': {'required': ['id', 'project-id']},
@@ -248,6 +250,20 @@ class GitlabCLI(object):
except Exception as e:
_die("Impossible to retry project build (%s)" % str(e))
+ def do_project_issue_subscribe(self, cls, gl, what, args):
+ try:
+ o = self.do_get(cls, gl, what, args)
+ o.subscribe()
+ except Exception as e:
+ _die("Impossible to subscribe to issue (%s)" % str(e))
+
+ def do_project_issue_unsubscribe(self, cls, gl, what, args):
+ try:
+ o = self.do_get(cls, gl, what, args)
+ o.unsubscribe()
+ except Exception as e:
+ _die("Impossible to subscribe to issue (%s)" % str(e))
+
def do_project_merge_request_closesissues(self, cls, gl, what, args):
try:
o = self.do_get(cls, gl, what, args)
diff --git a/gitlab/objects.py b/gitlab/objects.py
index a865ad4..313ed96 100644
--- a/gitlab/objects.py
+++ b/gitlab/objects.py
@@ -999,6 +999,12 @@ class ProjectIssue(GitlabObject):
**kwargs)
def subscribe(self, **kwargs):
+ """Subscribe to an issue.
+
+ Raises:
+ GitlabConnectionError: If the server cannot be reached.
+ GitlabSubscribeError: If the subscription cannot be done
+ """
url = ('/projects/%(project_id)s/issues/%(issue_id)s/subscription' %
{'project_id': self.project_id, 'issue_id': self.id})
@@ -1007,6 +1013,12 @@ class ProjectIssue(GitlabObject):
self._set_from_dict(r.json())
def unsubscribe(self, **kwargs):
+ """Unsubscribe an issue.
+
+ Raises:
+ GitlabConnectionError: If the server cannot be reached.
+ GitlabSubscribeError: If the unsubscription cannot be done
+ """
url = ('/projects/%(project_id)s/issues/%(issue_id)s/subscription' %
{'project_id': self.project_id, 'issue_id': self.id})