Skip to content

Commit

Permalink
project issue: doc and CLI for (un)subscribe
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauvain Pocentek committed May 28, 2016
1 parent 7bbbfbd commit 1b14f5c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
16 changes: 16 additions & 0 deletions gitlab/cli.py
Expand Up @@ -41,6 +41,8 @@
'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']},
Expand Down Expand Up @@ -248,6 +250,20 @@ def do_project_build_retry(self, cls, gl, what, args):
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)
Expand Down
12 changes: 12 additions & 0 deletions gitlab/objects.py
Expand Up @@ -999,6 +999,12 @@ def Note(self, id=None, **kwargs):
**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})

Expand All @@ -1007,6 +1013,12 @@ def subscribe(self, **kwargs):
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})

Expand Down

0 comments on commit 1b14f5c

Please sign in to comment.