diff options
Diffstat (limited to 'gitlab/objects.py')
-rw-r--r-- | gitlab/objects.py | 28 |
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 |