1
0
mirror of https://github.com/interviewstreet/go-jira.git synced 2025-07-01 00:25:00 +02:00

feat: Implement get remote links method

This commit is contained in:
Roman Volodin
2019-12-11 16:50:22 +03:00
committed by Wes McNamee
parent e37cc6c689
commit 1946cac0fe
3 changed files with 148 additions and 0 deletions

View File

@ -547,6 +547,44 @@ type AddWorklogQueryOptions struct {
// This can heavily differ between JIRA instances
type CustomFields map[string]string
// RemoteLink represents remote links which linked to issues
type RemoteLink struct {
ID int `json:"id,omitempty" structs:"id,omitempty"`
Self string `json:"self,omitempty" structs:"self,omitempty"`
GlobalID string `json:"globalId,omitempty" structs:"globalId,omitempty"`
Application *RemoteLinkApplication `json:"application,omitempty" structs:"application,omitempty"`
Relationship string `json:"relationship,omitempty" structs:"relationship,omitempty"`
Object *RemoteLinkObject `json:"object,omitempty" structs:"object,omitempty"`
}
// RemoteLinkApplication represents remote links application
type RemoteLinkApplication struct {
Type string `json:"type,omitempty" structs:"type,omitempty"`
Name string `json:"name,omitempty" structs:"name,omitempty"`
}
// RemoteLinkObject represents remote link object itself
type RemoteLinkObject struct {
URL string `json:"url,omitempty" structs:"url,omitempty"`
Title string `json:"title,omitempty" structs:"title,omitempty"`
Summary string `json:"summary,omitempty" structs:"summary,omitempty"`
Icon *RemoteLinkIcon `json:"icon,omitempty" structs:"icon,omitempty"`
Status *RemoteLinkStatus `json:"status,omitempty" structs:"status,omitempty"`
}
// RemoteLinkIcon represents icon displayed next to link
type RemoteLinkIcon struct {
Url16x16 string `json:"url16x16,omitempty" structs:"url16x16,omitempty"`
Title string `json:"title,omitempty" structs:"title,omitempty"`
Link string `json:"link,omitempty" structs:"link,omitempty"`
}
// RemoteLinkStatus if the link is a resolvable object (issue, epic) - the structure represent its status
type RemoteLinkStatus struct {
Resolved bool
Icon *RemoteLinkIcon
}
// Get returns a full representation of the issue for the given issue key.
// JIRA will attempt to identify the issue by the issueIdOrKey path parameter.
// This can be an issue id, or an issue key.
@ -1274,3 +1312,21 @@ func (c ChangelogHistory) CreatedTime() (time.Time, error) {
t, err := time.Parse("2006-01-02T15:04:05.999-0700", c.Created)
return t, err
}
// GetRemoteLinks gets remote issue links on the issue.
//
// JIRA API docs: https://docs.atlassian.com/jira/REST/latest/#api/2/issue-getRemoteIssueLinks
func (s *IssueService) GetRemoteLinks(id string) (*[]RemoteLink, *Response, error) {
apiEndpoint := fmt.Sprintf("rest/api/2/issue/%s/remotelink", id)
req, err := s.client.NewRequest("GET", apiEndpoint, nil)
if err != nil {
return nil, nil, err
}
result := new([]RemoteLink)
resp, err := s.client.Do(req, result)
if err != nil {
err = NewJiraError(resp, err)
}
return result, resp, err
}