mirror of
https://github.com/interviewstreet/go-jira.git
synced 2024-11-30 08:47:11 +02:00
Implement workload in issue and Project list
This commit is contained in:
parent
d4429e3977
commit
bbc0470766
87
issue.go
87
issue.go
@ -40,7 +40,6 @@ type IssueFields struct {
|
||||
// * "timetracking": {},
|
||||
// * "attachment": [],
|
||||
// * "aggregatetimeestimate": null,
|
||||
// * "subtasks": [],
|
||||
// * "environment": null,
|
||||
// * "duedate": null,
|
||||
Type IssueType `json:"issuetype"`
|
||||
@ -60,11 +59,12 @@ type IssueFields struct {
|
||||
Status *Status `json:"status,omitempty"`
|
||||
Progress *Progress `json:"progress,omitempty"`
|
||||
AggregateProgress *Progress `json:"aggregateprogress,omitempty"`
|
||||
Worklog []*Worklog `json:"worklog.worklogs,omitempty"`
|
||||
Worklog *Worklog `json:"worklog,omitempty"`
|
||||
IssueLinks []*IssueLink `json:"issuelinks,omitempty"`
|
||||
Comments []*Comment `json:"comment.comments,omitempty"`
|
||||
FixVersions []*FixVersion `json:"fixVersions,omitempty"`
|
||||
Labels []string `json:"labels,omitempty"`
|
||||
Subtasks []*Subtasks `json:"subtasks,omitempty"`
|
||||
}
|
||||
|
||||
// IssueType represents a type of a JIRA issue.
|
||||
@ -161,7 +161,88 @@ type Progress struct {
|
||||
// Worklog represents the work log of a JIRA issue.
|
||||
// JIRA Wiki: https://confluence.atlassian.com/jira/logging-work-on-an-issue-185729605.html
|
||||
type Worklog struct {
|
||||
// TODO Add Worklogs
|
||||
StartAt int `json:"startAt"`
|
||||
MaxResults int `json:"maxResults"`
|
||||
Total int `json:"total"`
|
||||
Worklogs []struct {
|
||||
Self string `json:"self"`
|
||||
Author struct {
|
||||
Self string `json:"self"`
|
||||
Name string `json:"name"`
|
||||
Key string `json:"key"`
|
||||
EmailAddress string `json:"emailAddress"`
|
||||
AvatarUrls struct {
|
||||
Four8X48 string `json:"48x48"`
|
||||
Two4X24 string `json:"24x24"`
|
||||
One6X16 string `json:"16x16"`
|
||||
Three2X32 string `json:"32x32"`
|
||||
} `json:"avatarUrls"`
|
||||
DisplayName string `json:"displayName"`
|
||||
Active bool `json:"active"`
|
||||
TimeZone string `json:"timeZone"`
|
||||
} `json:"author"`
|
||||
UpdateAuthor struct {
|
||||
Self string `json:"self"`
|
||||
Name string `json:"name"`
|
||||
Key string `json:"key"`
|
||||
EmailAddress string `json:"emailAddress"`
|
||||
AvatarUrls struct {
|
||||
Four8X48 string `json:"48x48"`
|
||||
Two4X24 string `json:"24x24"`
|
||||
One6X16 string `json:"16x16"`
|
||||
Three2X32 string `json:"32x32"`
|
||||
} `json:"avatarUrls"`
|
||||
DisplayName string `json:"displayName"`
|
||||
Active bool `json:"active"`
|
||||
TimeZone string `json:"timeZone"`
|
||||
} `json:"updateAuthor"`
|
||||
Comment string `json:"comment"`
|
||||
Created string `json:"created"`
|
||||
Updated string `json:"updated"`
|
||||
Started string `json:"started"`
|
||||
TimeSpent string `json:"timeSpent"`
|
||||
TimeSpentSeconds int `json:"timeSpentSeconds"`
|
||||
ID string `json:"id"`
|
||||
IssueID string `json:"issueId"`
|
||||
} `json:"worklogs"`
|
||||
}
|
||||
|
||||
type Subtasks struct {
|
||||
ID string `json:"id"`
|
||||
Key string `json:"key"`
|
||||
Self string `json:"self"`
|
||||
Fields struct {
|
||||
Summary string `json:"summary"`
|
||||
Status struct {
|
||||
Self string `json:"self"`
|
||||
Description string `json:"description"`
|
||||
IconURL string `json:"iconUrl"`
|
||||
Name string `json:"name"`
|
||||
ID string `json:"id"`
|
||||
StatusCategory struct {
|
||||
Self string `json:"self"`
|
||||
ID int `json:"id"`
|
||||
Key string `json:"key"`
|
||||
ColorName string `json:"colorName"`
|
||||
Name string `json:"name"`
|
||||
} `json:"statusCategory"`
|
||||
} `json:"status"`
|
||||
Priority struct {
|
||||
Self string `json:"self"`
|
||||
IconURL string `json:"iconUrl"`
|
||||
Name string `json:"name"`
|
||||
ID string `json:"id"`
|
||||
} `json:"priority"`
|
||||
Issuetype struct {
|
||||
Self string `json:"self"`
|
||||
ID string `json:"id"`
|
||||
Description string `json:"description"`
|
||||
IconURL string `json:"iconUrl"`
|
||||
Name string `json:"name"`
|
||||
Subtask bool `json:"subtask"`
|
||||
AvatarID int `json:"avatarId"`
|
||||
} `json:"issuetype"`
|
||||
} `json:"fields"`
|
||||
}
|
||||
|
||||
// IssueLink represents a link between two issues in JIRA.
|
||||
|
2
jira.go
2
jira.go
@ -23,6 +23,7 @@ type Client struct {
|
||||
// Services used for talking to different parts of the JIRA API.
|
||||
Authentication *AuthenticationService
|
||||
Issue *IssueService
|
||||
Project *ProjectService
|
||||
}
|
||||
|
||||
// NewClient returns a new JIRA API client.
|
||||
@ -48,6 +49,7 @@ func NewClient(httpClient *http.Client, baseURL string) (*Client, error) {
|
||||
}
|
||||
c.Authentication = &AuthenticationService{client: c}
|
||||
c.Issue = &IssueService{client: c}
|
||||
c.Project = &ProjectService{client: c}
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
49
progect.go
Normal file
49
progect.go
Normal file
@ -0,0 +1,49 @@
|
||||
package jira
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type ProjectService struct {
|
||||
client *Client
|
||||
}
|
||||
|
||||
type ProjectList []struct {
|
||||
Expand string `json:"expand"`
|
||||
Self string `json:"self"`
|
||||
ID string `json:"id"`
|
||||
Key string `json:"key"`
|
||||
Name string `json:"name"`
|
||||
AvatarUrls struct {
|
||||
Four8X48 string `json:"48x48"`
|
||||
Two4X24 string `json:"24x24"`
|
||||
One6X16 string `json:"16x16"`
|
||||
Three2X32 string `json:"32x32"`
|
||||
} `json:"avatarUrls"`
|
||||
ProjectTypeKey string `json:"projectTypeKey"`
|
||||
ProjectCategory struct {
|
||||
Self string `json:"self"`
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
} `json:"projectCategory,omitempty"`
|
||||
}
|
||||
|
||||
//Get all projects form jira
|
||||
// Return array of projects
|
||||
func (s *ProjectService) GetList() (*ProjectList, *http.Response, error) {
|
||||
|
||||
apiEndpoint := "rest/api/2/project"
|
||||
req, err := s.client.NewRequest("GET", apiEndpoint, nil)
|
||||
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
projectList := new(ProjectList)
|
||||
resp, err := s.client.Do(req, projectList)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
return projectList, resp, nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user