mirror of
https://github.com/interviewstreet/go-jira.git
synced 2025-04-23 12:08:51 +02:00
Refactored struct types by reusing already existing components
This commit is contained in:
parent
077933ab00
commit
883aca79c0
@ -14,9 +14,9 @@ type AuthenticationService struct {
|
|||||||
|
|
||||||
// Session represents a Session JSON response by the JIRA API.
|
// Session represents a Session JSON response by the JIRA API.
|
||||||
type Session struct {
|
type Session struct {
|
||||||
Self string `json:"self,omitempty"`
|
Self string `json:"self,omitempty"`
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
Session struct {
|
Session struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Value string `json:"value"`
|
Value string `json:"value"`
|
||||||
} `json:"session,omitempty"`
|
} `json:"session,omitempty"`
|
||||||
@ -26,7 +26,7 @@ type Session struct {
|
|||||||
LastFailedLoginTime string `json:"lastFailedLoginTime"`
|
LastFailedLoginTime string `json:"lastFailedLoginTime"`
|
||||||
PreviousLoginTime string `json:"previousLoginTime"`
|
PreviousLoginTime string `json:"previousLoginTime"`
|
||||||
} `json:"loginInfo"`
|
} `json:"loginInfo"`
|
||||||
Cookies []*http.Cookie
|
Cookies []*http.Cookie
|
||||||
}
|
}
|
||||||
|
|
||||||
// AcquireSessionCookie creates a new session for a user in JIRA.
|
// AcquireSessionCookie creates a new session for a user in JIRA.
|
||||||
|
153
issue.go
153
issue.go
@ -31,15 +31,15 @@ type Issue struct {
|
|||||||
|
|
||||||
// Attachment represents a JIRA attachment
|
// Attachment represents a JIRA attachment
|
||||||
type Attachment struct {
|
type Attachment struct {
|
||||||
Self string `json:"self,omitempty"`
|
Self string `json:"self,omitempty"`
|
||||||
ID string `json:"id,omitempty"`
|
ID string `json:"id,omitempty"`
|
||||||
Filename string `json:"filename,omitempty"`
|
Filename string `json:"filename,omitempty"`
|
||||||
Author *Assignee `json:"author,omitempty"`
|
Author *User `json:"author,omitempty"`
|
||||||
Created string `json:"created,omitempty"`
|
Created string `json:"created,omitempty"`
|
||||||
Size int `json:"size,omitempty"`
|
Size int `json:"size,omitempty"`
|
||||||
MimeType string `json:"mimeType,omitempty"`
|
MimeType string `json:"mimeType,omitempty"`
|
||||||
Content string `json:"content,omitempty"`
|
Content string `json:"content,omitempty"`
|
||||||
Thumbnail string `json:"thumbnail,omitempty"`
|
Thumbnail string `json:"thumbnail,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// IssueFields represents single fields of a JIRA issue.
|
// IssueFields represents single fields of a JIRA issue.
|
||||||
@ -64,12 +64,12 @@ type IssueFields struct {
|
|||||||
Resolutiondate string `json:"resolutiondate,omitempty"`
|
Resolutiondate string `json:"resolutiondate,omitempty"`
|
||||||
Created string `json:"created,omitempty"`
|
Created string `json:"created,omitempty"`
|
||||||
Watches *Watches `json:"watches,omitempty"`
|
Watches *Watches `json:"watches,omitempty"`
|
||||||
Assignee *Assignee `json:"assignee,omitempty"`
|
Assignee *User `json:"assignee,omitempty"`
|
||||||
Updated string `json:"updated,omitempty"`
|
Updated string `json:"updated,omitempty"`
|
||||||
Description string `json:"description,omitempty"`
|
Description string `json:"description,omitempty"`
|
||||||
Summary string `json:"summary"`
|
Summary string `json:"summary"`
|
||||||
Creator *Assignee `json:"Creator,omitempty"`
|
Creator *User `json:"Creator,omitempty"`
|
||||||
Reporter *Assignee `json:"reporter,omitempty"`
|
Reporter *User `json:"reporter,omitempty"`
|
||||||
Components []*Component `json:"components,omitempty"`
|
Components []*Component `json:"components,omitempty"`
|
||||||
Status *Status `json:"status,omitempty"`
|
Status *Status `json:"status,omitempty"`
|
||||||
Progress *Progress `json:"progress,omitempty"`
|
Progress *Progress `json:"progress,omitempty"`
|
||||||
@ -92,6 +92,7 @@ type IssueType struct {
|
|||||||
IconURL string `json:"iconUrl,omitempty"`
|
IconURL string `json:"iconUrl,omitempty"`
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
Subtask bool `json:"subtask,omitempty"`
|
Subtask bool `json:"subtask,omitempty"`
|
||||||
|
AvatarID int `json:"avatarId,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Project represents a JIRA Project.
|
// Project represents a JIRA Project.
|
||||||
@ -129,13 +130,22 @@ type Watches struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Assignee represents a user who is this JIRA issue assigned to.
|
// Assignee represents a user who is this JIRA issue assigned to.
|
||||||
type Assignee struct {
|
type User struct {
|
||||||
Self string `json:"self,omitempty"`
|
Self string `json:"self,omitempty"`
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
EmailAddress string `json:"emailAddress,omitempty"`
|
Key string `json:"key,omitempty"`
|
||||||
AvatarURLs map[string]string `json:"avatarUrls,omitempty"`
|
EmailAddress string `json:"emailAddress,omitempty"`
|
||||||
DisplayName string `json:"displayName,omitempty"`
|
AvatarUrls AvatarUrls `json:"avatarUrls,omitempty"`
|
||||||
Active bool `json:"active,omitempty"`
|
DisplayName string `json:"displayName,omitempty"`
|
||||||
|
Active bool `json:"active,omitempty"`
|
||||||
|
TimeZone string `json:"timeZone,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AvatarUrls struct {
|
||||||
|
Four8X48 string `json:"48x48,omitempty"`
|
||||||
|
Two4X24 string `json:"24x24,omitempty"`
|
||||||
|
One6X16 string `json:"16x16,omitempty"`
|
||||||
|
Three2X32 string `json:"32x32,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Component represents a "component" of a JIRA issue.
|
// Component represents a "component" of a JIRA issue.
|
||||||
@ -177,88 +187,31 @@ type Progress struct {
|
|||||||
// Worklog represents the work log of a JIRA issue.
|
// Worklog represents the work log of a JIRA issue.
|
||||||
// JIRA Wiki: https://confluence.atlassian.com/jira/logging-work-on-an-issue-185729605.html
|
// JIRA Wiki: https://confluence.atlassian.com/jira/logging-work-on-an-issue-185729605.html
|
||||||
type Worklog struct {
|
type Worklog struct {
|
||||||
StartAt int `json:"startAt"`
|
StartAt int `json:"startAt"`
|
||||||
MaxResults int `json:"maxResults"`
|
MaxResults int `json:"maxResults"`
|
||||||
Total int `json:"total"`
|
Total int `json:"total"`
|
||||||
Worklogs []struct {
|
Worklogs []WorklogRecord `json:"worklogs"`
|
||||||
Self string `json:"self"`
|
}
|
||||||
Author struct {
|
|
||||||
Self string `json:"self"`
|
type WorklogRecord struct {
|
||||||
Name string `json:"name"`
|
Self string `json:"self"`
|
||||||
Key string `json:"key"`
|
Author User `json:"author"`
|
||||||
EmailAddress string `json:"emailAddress"`
|
UpdateAuthor User `json:"updateAuthor"`
|
||||||
AvatarUrls struct {
|
Comment string `json:"comment"`
|
||||||
Four8X48 string `json:"48x48"`
|
Created string `json:"created"`
|
||||||
Two4X24 string `json:"24x24"`
|
Updated string `json:"updated"`
|
||||||
One6X16 string `json:"16x16"`
|
Started string `json:"started"`
|
||||||
Three2X32 string `json:"32x32"`
|
TimeSpent string `json:"timeSpent"`
|
||||||
} `json:"avatarUrls"`
|
TimeSpentSeconds int `json:"timeSpentSeconds"`
|
||||||
DisplayName string `json:"displayName"`
|
ID string `json:"id"`
|
||||||
Active bool `json:"active"`
|
IssueID string `json:"issueId"`
|
||||||
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 {
|
type Subtasks struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Key string `json:"key"`
|
Key string `json:"key"`
|
||||||
Self string `json:"self"`
|
Self string `json:"self"`
|
||||||
Fields struct {
|
Fields IssueFields `json:"fields"`
|
||||||
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.
|
// IssueLink represents a link between two issues in JIRA.
|
||||||
@ -285,9 +238,9 @@ type IssueLinkType struct {
|
|||||||
type Comment struct {
|
type Comment struct {
|
||||||
Self string `json:"self,omitempty"`
|
Self string `json:"self,omitempty"`
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
Author Assignee `json:"author,omitempty"`
|
Author User `json:"author,omitempty"`
|
||||||
Body string `json:"body,omitempty"`
|
Body string `json:"body,omitempty"`
|
||||||
UpdateAuthor Assignee `json:"updateAuthor,omitempty"`
|
UpdateAuthor User `json:"updateAuthor,omitempty"`
|
||||||
Updated string `json:"updated,omitempty"`
|
Updated string `json:"updated,omitempty"`
|
||||||
Created string `json:"created,omitempty"`
|
Created string `json:"created,omitempty"`
|
||||||
Visibility CommentVisibility `json:"visibility,omitempty"`
|
Visibility CommentVisibility `json:"visibility,omitempty"`
|
||||||
|
153
project.go
153
project.go
@ -11,122 +11,59 @@ type ProjectService struct {
|
|||||||
|
|
||||||
// Project list type
|
// Project list type
|
||||||
type ProjectList []struct {
|
type ProjectList []struct {
|
||||||
Expand string `json:"expand"`
|
Expand string `json:"expand"`
|
||||||
Self string `json:"self"`
|
Self string `json:"self"`
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Key string `json:"key"`
|
Key string `json:"key"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
AvatarUrls struct {
|
AvatarUrls AvatarUrls `json:"avatarUrls"`
|
||||||
Four8X48 string `json:"48x48"`
|
ProjectTypeKey string `json:"projectTypeKey"`
|
||||||
Two4X24 string `json:"24x24"`
|
ProjectCategory ProjectCategory `json:"projectCategory,omitempty"`
|
||||||
One6X16 string `json:"16x16"`
|
}
|
||||||
Three2X32 string `json:"32x32"`
|
|
||||||
} `json:"avatarUrls"`
|
type ProjectCategory struct {
|
||||||
ProjectTypeKey string `json:"projectTypeKey"`
|
Self string `json:"self"`
|
||||||
ProjectCategory struct {
|
ID string `json:"id"`
|
||||||
Self string `json:"self"`
|
Name string `json:"name"`
|
||||||
ID string `json:"id"`
|
Description string `json:"description"`
|
||||||
Name string `json:"name"`
|
|
||||||
Description string `json:"description"`
|
|
||||||
} `json:"projectCategory,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Full project description
|
// Full project description
|
||||||
// Can't name it project because it exist in issue
|
// Can't name it project because it exist in issue
|
||||||
type FullProject struct {
|
type FullProject struct {
|
||||||
Expand string `json:"expand"`
|
Expand string `json:"expand"`
|
||||||
Self string `json:"self"`
|
Self string `json:"self"`
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Key string `json:"key"`
|
Key string `json:"key"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Lead struct {
|
Lead User `json:"lead"`
|
||||||
Self string `json:"self"`
|
Components []ProjectComponent `json:"components"`
|
||||||
Name string `json:"name"`
|
IssueTypes []IssueType `json:"issueTypes"`
|
||||||
AvatarUrls struct {
|
URL string `json:"url"`
|
||||||
Four8X48 string `json:"48x48"`
|
Email string `json:"email"`
|
||||||
Two4X24 string `json:"24x24"`
|
AssigneeType string `json:"assigneeType"`
|
||||||
One6X16 string `json:"16x16"`
|
Versions []interface{} `json:"versions"`
|
||||||
Three2X32 string `json:"32x32"`
|
Name string `json:"name"`
|
||||||
} `json:"avatarUrls"`
|
|
||||||
DisplayName string `json:"displayName"`
|
|
||||||
Active bool `json:"active"`
|
|
||||||
} `json:"lead"`
|
|
||||||
Components []struct {
|
|
||||||
Self string `json:"self"`
|
|
||||||
ID string `json:"id"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
Description string `json:"description"`
|
|
||||||
Lead struct {
|
|
||||||
Self string `json:"self"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
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"`
|
|
||||||
} `json:"lead"`
|
|
||||||
AssigneeType string `json:"assigneeType"`
|
|
||||||
Assignee struct {
|
|
||||||
Self string `json:"self"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
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"`
|
|
||||||
} `json:"assignee"`
|
|
||||||
RealAssigneeType string `json:"realAssigneeType"`
|
|
||||||
RealAssignee struct {
|
|
||||||
Self string `json:"self"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
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"`
|
|
||||||
} `json:"realAssignee"`
|
|
||||||
IsAssigneeTypeValid bool `json:"isAssigneeTypeValid"`
|
|
||||||
Project string `json:"project"`
|
|
||||||
ProjectID int `json:"projectId"`
|
|
||||||
} `json:"components"`
|
|
||||||
IssueTypes []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:"issueTypes"`
|
|
||||||
URL string `json:"url"`
|
|
||||||
Email string `json:"email"`
|
|
||||||
AssigneeType string `json:"assigneeType"`
|
|
||||||
Versions []interface{} `json:"versions"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
Roles struct {
|
Roles struct {
|
||||||
Developers string `json:"Developers"`
|
Developers string `json:"Developers"`
|
||||||
} `json:"roles"`
|
} `json:"roles"`
|
||||||
AvatarUrls struct {
|
AvatarUrls AvatarUrls `json:"avatarUrls"`
|
||||||
Four8X48 string `json:"48x48"`
|
ProjectCategory ProjectCategory `json:"projectCategory"`
|
||||||
Two4X24 string `json:"24x24"`
|
}
|
||||||
One6X16 string `json:"16x16"`
|
|
||||||
Three2X32 string `json:"32x32"`
|
type ProjectComponent struct {
|
||||||
} `json:"avatarUrls"`
|
Self string `json:"self"`
|
||||||
ProjectCategory struct {
|
ID string `json:"id"`
|
||||||
Self string `json:"self"`
|
Name string `json:"name"`
|
||||||
ID string `json:"id"`
|
Description string `json:"description"`
|
||||||
Name string `json:"name"`
|
Lead User `json:"lead"`
|
||||||
Description string `json:"description"`
|
AssigneeType string `json:"assigneeType"`
|
||||||
} `json:"projectCategory"`
|
Assignee User `json:"assignee"`
|
||||||
|
RealAssigneeType string `json:"realAssigneeType"`
|
||||||
|
RealAssignee User `json:"realAssignee"`
|
||||||
|
IsAssigneeTypeValid bool `json:"isAssigneeTypeValid"`
|
||||||
|
Project string `json:"project"`
|
||||||
|
ProjectID int `json:"projectId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all projects form jira
|
// Get all projects form jira
|
||||||
|
Loading…
x
Reference in New Issue
Block a user