Commit a11605e2 authored by Michael Lihs's avatar Michael Lihs Committed by Sander van Harmelen

Add support for labels: subscribeTo / unsubscribeFrom (#287)

parent 7602fb35
...@@ -162,3 +162,59 @@ func (s *LabelsService) UpdateLabel(pid interface{}, opt *UpdateLabelOptions, op ...@@ -162,3 +162,59 @@ func (s *LabelsService) UpdateLabel(pid interface{}, opt *UpdateLabelOptions, op
return l, resp, err return l, resp, err
} }
// SubscribeToLabel subscribes the authenticated user to a label to receive
// notifications. If the user is already subscribed to the label,
// the status code 304 is returned.
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/labels.html#subscribe-to-a-label
func (s *LabelsService) SubscribeToLabel(pid interface{}, labelID interface{}, options ...OptionFunc) (*Label, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
label, err := parseID(labelID)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/labels/%s/subscribe", url.QueryEscape(project), label)
req, err := s.client.NewRequest("POST", u, nil, options)
if err != nil {
return nil, nil, err
}
l := new(Label)
resp, err := s.client.Do(req, l)
if err != nil {
return nil, resp, err
}
return l, resp, err
}
// UnsubscribeFromLabel unsubscribes the authenticated user from a label
// to not receive notifications from it. If the user is not subscribed
// to the label, the status code 304 is returned.
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/labels.html#unsubscribe-from-a-label
func (s *LabelsService) UnsubscribeFromLabel(pid interface{}, labelID interface{}, options ...OptionFunc) (*Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, err
}
label, err := parseID(labelID)
if err != nil {
return nil, err
}
u := fmt.Sprintf("projects/%s/labels/%s/unsubscribe", url.QueryEscape(project), label)
req, err := s.client.NewRequest("POST", u, nil, options)
if err != nil {
return nil, err
}
return s.client.Do(req, nil)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment