summaryrefslogtreecommitdiff
path: root/gitlab/objects.py
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2016-06-19 21:33:43 +0200
committerGauvain Pocentek <gauvain@pocentek.net>2016-06-19 21:33:43 +0200
commitd340d313392e730e7147690aff0cebe2af657c89 (patch)
tree88286dc6e7ee3675f9f8e9a8c804097bfe332b43 /gitlab/objects.py
parent79feb87bd98caac008da2337c01fd7e3624d37f6 (diff)
parent6f29ff1727f490e41787a893a0e46c06871041ce (diff)
downloadgitlab-d340d313392e730e7147690aff0cebe2af657c89.tar.gz
Merge branch 'label-subscribe'
Diffstat (limited to 'gitlab/objects.py')
-rw-r--r--gitlab/objects.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/gitlab/objects.py b/gitlab/objects.py
index 96fffde..51df97c 100644
--- a/gitlab/objects.py
+++ b/gitlab/objects.py
@@ -1358,6 +1358,34 @@ class ProjectLabel(GitlabObject):
requiredUpdateAttrs = ['name']
optionalUpdateAttrs = ['new_name', 'color', 'description']
+ def subscribe(self, **kwargs):
+ """Subscribe to a label.
+
+ Raises:
+ GitlabConnectionError: If the server cannot be reached.
+ GitlabSubscribeError: If the subscription cannot be done
+ """
+ url = ('/projects/%(project_id)s/labels/%(label_id)s/subscription' %
+ {'project_id': self.project_id, 'label_id': self.name})
+
+ 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 label.
+
+ Raises:
+ GitlabConnectionError: If the server cannot be reached.
+ GitlabSubscribeError: 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})
+
+ r = self.gitlab._raw_delete(url, **kwargs)
+ raise_error_from_response(r, GitlabUnsubscribeError, [200, 304])
+ self._set_from_dict(r.json())
+
class ProjectLabelManager(BaseManager):
obj_cls = ProjectLabel