1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package gitlab
18
19 import (
20 "fmt"
21 "net/http"
22 )
23
24
25
26
27
28 type EpicIssuesService struct {
29 client *Client
30 }
31
32
33
34
35
36 type EpicIssueAssignment struct {
37 ID int `json:"id"`
38 Epic *Epic `json:"epic"`
39 Issue *Issue `json:"issue"`
40 }
41
42
43
44
45
46 func (s *EpicIssuesService) ListEpicIssues(gid interface{}, epic int, opt *ListOptions, options ...RequestOptionFunc) ([]*Issue, *Response, error) {
47 group, err := parseID(gid)
48 if err != nil {
49 return nil, nil, err
50 }
51 u := fmt.Sprintf("groups/%s/epics/%d/issues", PathEscape(group), epic)
52
53 req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
54 if err != nil {
55 return nil, nil, err
56 }
57
58 var is []*Issue
59 resp, err := s.client.Do(req, &is)
60 if err != nil {
61 return nil, resp, err
62 }
63
64 return is, resp, nil
65 }
66
67
68
69
70
71 func (s *EpicIssuesService) AssignEpicIssue(gid interface{}, epic, issue int, options ...RequestOptionFunc) (*EpicIssueAssignment, *Response, error) {
72 group, err := parseID(gid)
73 if err != nil {
74 return nil, nil, err
75 }
76 u := fmt.Sprintf("groups/%s/epics/%d/issues/%d", PathEscape(group), epic, issue)
77
78 req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
79 if err != nil {
80 return nil, nil, err
81 }
82
83 a := new(EpicIssueAssignment)
84 resp, err := s.client.Do(req, a)
85 if err != nil {
86 return nil, resp, err
87 }
88
89 return a, resp, nil
90 }
91
92
93
94
95
96 func (s *EpicIssuesService) RemoveEpicIssue(gid interface{}, epic, epicIssue int, options ...RequestOptionFunc) (*EpicIssueAssignment, *Response, error) {
97 group, err := parseID(gid)
98 if err != nil {
99 return nil, nil, err
100 }
101 u := fmt.Sprintf("groups/%s/epics/%d/issues/%d", PathEscape(group), epic, epicIssue)
102
103 req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
104 if err != nil {
105 return nil, nil, err
106 }
107
108 a := new(EpicIssueAssignment)
109 resp, err := s.client.Do(req, a)
110 if err != nil {
111 return nil, resp, err
112 }
113
114 return a, resp, nil
115 }
116
117
118
119
120
121
122 type UpdateEpicIsssueAssignmentOptions struct {
123 *ListOptions
124 MoveBeforeID *int `url:"move_before_id,omitempty" json:"move_before_id,omitempty"`
125 MoveAfterID *int `url:"move_after_id,omitempty" json:"move_after_id,omitempty"`
126 }
127
128
129
130
131
132
133 func (s *EpicIssuesService) UpdateEpicIssueAssignment(gid interface{}, epic, epicIssue int, opt *UpdateEpicIsssueAssignmentOptions, options ...RequestOptionFunc) ([]*Issue, *Response, error) {
134 group, err := parseID(gid)
135 if err != nil {
136 return nil, nil, err
137 }
138 u := fmt.Sprintf("groups/%s/epics/%d/issues/%d", PathEscape(group), epic, epicIssue)
139
140 req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
141 if err != nil {
142 return nil, nil, err
143 }
144
145 var is []*Issue
146 resp, err := s.client.Do(req, &is)
147 if err != nil {
148 return nil, resp, err
149 }
150
151 return is, resp, nil
152 }
153
View as plain text