-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjira-worklog.go
28 lines (24 loc) · 1019 Bytes
/
jira-worklog.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
package main
import (
"bytes"
"github.com/andygrunwald/go-jira"
)
//WorklogRequest represents the request object used to make request to JIRA API.
//This is a data type is a minimal subset of the Worklog type included in the go-jira
//library. The included data type JSON representation cannot be used to create a
//worklog entry with only the fields below.
type WorklogRequest struct {
TimeSpentSeconds string `json:"timeSpentSeconds"`
Started string `json:"started"`
Comment string `json:"comment"`
}
//Calls JIRA worklog endpoint to create a worklog entry for an issue.
//Implemented using generic interface provided by go-jira due to this endpoint not being
//implemented at the time of implementation.
func addWorklog(jiraClient *jira.Client, issueKey string, worklog WorklogRequest) error {
req, _ := jiraClient.NewRequest("POST", "/rest/api/2/issue/"+issueKey+"/worklog", worklog)
resp, err := jiraClient.Do(req, nil)
buf := new(bytes.Buffer)
buf.ReadFrom(resp.Body)
return err
}