1
0
mirror of https://github.com/interviewstreet/go-jira.git synced 2024-11-24 08:22:42 +02:00

Refactored struct types by reusing already existing components

This commit is contained in:
Andy Grunwald 2016-06-03 23:14:27 +02:00
parent 077933ab00
commit 883aca79c0
3 changed files with 102 additions and 212 deletions

View File

@ -14,9 +14,9 @@ type AuthenticationService struct {
// Session represents a Session JSON response by the JIRA API.
type Session struct {
Self string `json:"self,omitempty"`
Name string `json:"name,omitempty"`
Session struct {
Self string `json:"self,omitempty"`
Name string `json:"name,omitempty"`
Session struct {
Name string `json:"name"`
Value string `json:"value"`
} `json:"session,omitempty"`
@ -26,7 +26,7 @@ type Session struct {
LastFailedLoginTime string `json:"lastFailedLoginTime"`
PreviousLoginTime string `json:"previousLoginTime"`
} `json:"loginInfo"`
Cookies []*http.Cookie
Cookies []*http.Cookie
}
// AcquireSessionCookie creates a new session for a user in JIRA.

153
issue.go
View File

@ -31,15 +31,15 @@ type Issue struct {
// Attachment represents a JIRA attachment
type Attachment struct {
Self string `json:"self,omitempty"`
ID string `json:"id,omitempty"`
Filename string `json:"filename,omitempty"`
Author *Assignee `json:"author,omitempty"`
Created string `json:"created,omitempty"`
Size int `json:"size,omitempty"`
MimeType string `json:"mimeType,omitempty"`
Content string `json:"content,omitempty"`
Thumbnail string `json:"thumbnail,omitempty"`
Self string `json:"self,omitempty"`
ID string `json:"id,omitempty"`
Filename string `json:"filename,omitempty"`
Author *User `json:"author,omitempty"`
Created string `json:"created,omitempty"`
Size int `json:"size,omitempty"`
MimeType string `json:"mimeType,omitempty"`
Content string `json:"content,omitempty"`
Thumbnail string `json:"thumbnail,omitempty"`
}
// IssueFields represents single fields of a JIRA issue.
@ -64,12 +64,12 @@ type IssueFields struct {
Resolutiondate string `json:"resolutiondate,omitempty"`
Created string `json:"created,omitempty"`
Watches *Watches `json:"watches,omitempty"`
Assignee *Assignee `json:"assignee,omitempty"`
Assignee *User `json:"assignee,omitempty"`
Updated string `json:"updated,omitempty"`
Description string `json:"description,omitempty"`
Summary string `json:"summary"`
Creator *Assignee `json:"Creator,omitempty"`
Reporter *Assignee `json:"reporter,omitempty"`
Creator *User `json:"Creator,omitempty"`
Reporter *User `json:"reporter,omitempty"`
Components []*Component `json:"components,omitempty"`
Status *Status `json:"status,omitempty"`
Progress *Progress `json:"progress,omitempty"`
@ -92,6 +92,7 @@ type IssueType struct {
IconURL string `json:"iconUrl,omitempty"`
Name string `json:"name,omitempty"`
Subtask bool `json:"subtask,omitempty"`
AvatarID int `json:"avatarId,omitempty"`
}
// Project represents a JIRA Project.
@ -129,13 +130,22 @@ type Watches struct {
}
// Assignee represents a user who is this JIRA issue assigned to.
type Assignee struct {
Self string `json:"self,omitempty"`
Name string `json:"name,omitempty"`
EmailAddress string `json:"emailAddress,omitempty"`
AvatarURLs map[string]string `json:"avatarUrls,omitempty"`
DisplayName string `json:"displayName,omitempty"`
Active bool `json:"active,omitempty"`
type User struct {
Self string `json:"self,omitempty"`
Name string `json:"name,omitempty"`
Key string `json:"key,omitempty"`
EmailAddress string `json:"emailAddress,omitempty"`
AvatarUrls AvatarUrls `json:"avatarUrls,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.
@ -177,88 +187,31 @@ 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 {
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"`
StartAt int `json:"startAt"`
MaxResults int `json:"maxResults"`
Total int `json:"total"`
Worklogs []WorklogRecord `json:"worklogs"`
}
type WorklogRecord struct {
Self string `json:"self"`
Author User `json:"author"`
UpdateAuthor User `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"`
}
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"`
ID string `json:"id"`
Key string `json:"key"`
Self string `json:"self"`
Fields IssueFields `json:"fields"`
}
// IssueLink represents a link between two issues in JIRA.
@ -285,9 +238,9 @@ type IssueLinkType struct {
type Comment struct {
Self string `json:"self,omitempty"`
Name string `json:"name,omitempty"`
Author Assignee `json:"author,omitempty"`
Author User `json:"author,omitempty"`
Body string `json:"body,omitempty"`
UpdateAuthor Assignee `json:"updateAuthor,omitempty"`
UpdateAuthor User `json:"updateAuthor,omitempty"`
Updated string `json:"updated,omitempty"`
Created string `json:"created,omitempty"`
Visibility CommentVisibility `json:"visibility,omitempty"`

View File

@ -11,122 +11,59 @@ type ProjectService struct {
// Project list type
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"`
Expand string `json:"expand"`
Self string `json:"self"`
ID string `json:"id"`
Key string `json:"key"`
Name string `json:"name"`
AvatarUrls AvatarUrls `json:"avatarUrls"`
ProjectTypeKey string `json:"projectTypeKey"`
ProjectCategory ProjectCategory `json:"projectCategory,omitempty"`
}
type ProjectCategory struct {
Self string `json:"self"`
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
}
// Full project description
// Can't name it project because it exist in issue
type FullProject struct {
Expand string `json:"expand"`
Self string `json:"self"`
ID string `json:"id"`
Key string `json:"key"`
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"`
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"`
Expand string `json:"expand"`
Self string `json:"self"`
ID string `json:"id"`
Key string `json:"key"`
Description string `json:"description"`
Lead User `json:"lead"`
Components []ProjectComponent `json:"components"`
IssueTypes []IssueType `json:"issueTypes"`
URL string `json:"url"`
Email string `json:"email"`
AssigneeType string `json:"assigneeType"`
Versions []interface{} `json:"versions"`
Name string `json:"name"`
Roles struct {
Developers string `json:"Developers"`
} `json:"roles"`
AvatarUrls struct {
Four8X48 string `json:"48x48"`
Two4X24 string `json:"24x24"`
One6X16 string `json:"16x16"`
Three2X32 string `json:"32x32"`
} `json:"avatarUrls"`
ProjectCategory struct {
Self string `json:"self"`
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
} `json:"projectCategory"`
AvatarUrls AvatarUrls `json:"avatarUrls"`
ProjectCategory ProjectCategory `json:"projectCategory"`
}
type ProjectComponent struct {
Self string `json:"self"`
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Lead User `json:"lead"`
AssigneeType string `json:"assigneeType"`
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