From 6f29ff1727f490e41787a893a0e46c06871041ce Mon Sep 17 00:00:00 2001 From: Gauvain Pocentek Date: Sun, 19 Jun 2016 20:53:14 +0200 Subject: Add support for label (un)subscribe --- gitlab/objects.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'gitlab/objects.py') diff --git a/gitlab/objects.py b/gitlab/objects.py index 8231219..367543b 100644 --- a/gitlab/objects.py +++ b/gitlab/objects.py @@ -1344,6 +1344,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 -- cgit v1.2.1