-
Notifications
You must be signed in to change notification settings - Fork 29
/
issueLabel.go
49 lines (39 loc) · 1.22 KB
/
issueLabel.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package jira
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
"strconv"
)
type LabelService struct{ client *Client }
type IssueLabelsScheme struct {
MaxResults int `json:"maxResults"`
StartAt int `json:"startAt"`
Total int `json:"total"`
IsLast bool `json:"isLast"`
Values []string `json:"values"`
}
// Returns a paginated list of labels.
// Docs: https://docs.go-atlassian.io/jira-software-cloud/issues/labels#get-all-labels
func (l *LabelService) Gets(ctx context.Context, startAt, maxResults int) (result *IssueLabelsScheme, response *Response, err error) {
params := url.Values{}
params.Add("startAt", strconv.Itoa(startAt))
params.Add("maxResults", strconv.Itoa(maxResults))
var endpoint = fmt.Sprintf("rest/api/3/label?%v", params.Encode())
request, err := l.client.newRequest(ctx, http.MethodGet, endpoint, nil)
if err != nil {
return
}
request.Header.Set("Accept", "application/json")
response, err = l.client.Do(request)
if err != nil {
return
}
result = new(IssueLabelsScheme)
if err = json.Unmarshal(response.BodyAsBytes, &result); err != nil {
return nil, response, fmt.Errorf("unable to marshall the response body, error: %v", err.Error())
}
return
}