summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2016-06-19 22:01:24 +0200
committerGauvain Pocentek <gauvain@pocentek.net>2016-06-19 22:01:24 +0200
commit867b7abca1cec287a413c9fb190fb5ddd9337cfc (patch)
tree963b9da3ddcef99c824a4bd56c9f9ad9838d2ccc
parentd340d313392e730e7147690aff0cebe2af657c89 (diff)
downloadgitlab-867b7abca1cec287a413c9fb190fb5ddd9337cfc.tar.gz
MR: add (un)subscribe support
-rw-r--r--gitlab/objects.py34
1 files changed, 32 insertions, 2 deletions
diff --git a/gitlab/objects.py b/gitlab/objects.py
index 51df97c..b268e78 100644
--- a/gitlab/objects.py
+++ b/gitlab/objects.py
@@ -1099,7 +1099,7 @@ class ProjectIssue(GitlabObject):
Raises:
GitlabConnectionError: If the server cannot be reached.
- GitlabSubscribeError: If the unsubscription cannot be done
+ GitlabUnsubscribeError: 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})
@@ -1249,6 +1249,36 @@ class ProjectMergeRequest(GitlabObject):
data = json.dumps(d)
return data
+ def subscribe(self, **kwargs):
+ """Subscribe to a MR.
+
+ Raises:
+ GitlabConnectionError: If the server cannot be reached.
+ GitlabSubscribeError: If the subscription cannot be done
+ """
+ url = ('/projects/%(project_id)s/merge_requests/%(mr_id)s/'
+ 'subscription' %
+ {'project_id': self.project_id, 'mr_id': self.id})
+
+ r = self.gitlab._raw_post(url, **kwargs)
+ raise_error_from_response(r, GitlabSubscribeError, [201, 304])
+ self._set_from_dict(r.json())
+
+ def unsubscribe(self, **kwargs):
+ """Unsubscribe a MR.
+
+ Raises:
+ GitlabConnectionError: If the server cannot be reached.
+ GitlabUnsubscribeError: If the unsubscription cannot be done
+ """
+ url = ('/projects/%(project_id)s/merge_requests/%(mr_id)s/'
+ 'subscription' %
+ {'project_id': self.project_id, 'mr_id': self.id})
+
+ r = self.gitlab._raw_delete(url, **kwargs)
+ raise_error_from_response(r, GitlabUnsubscribeError, [200, 304])
+ self._set_from_dict(r.json())
+
def cancel_merge_when_build_succeeds(self, **kwargs):
"""Cancel merge when build succeeds."""
@@ -1377,7 +1407,7 @@ class ProjectLabel(GitlabObject):
Raises:
GitlabConnectionError: If the server cannot be reached.
- GitlabSubscribeError: If the unsubscription cannot be done
+ GitlabUnsubscribeError: If the unsubscription cannot be done
"""
url = ('/projects/%(project_id)s/labels/%(label_id)s/subscription' %
{'project_id': self.project_id, 'label_id': self.name})