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
29 type GroupIssueBoardsService struct {
30 client *Client
31 }
32
33
34
35
36
37 type GroupIssueBoard struct {
38 ID int `json:"id"`
39 Name string `json:"name"`
40 Group *Group `json:"group"`
41 Milestone *Milestone `json:"milestone"`
42 Labels []*GroupLabel `json:"labels"`
43 Lists []*BoardList `json:"lists"`
44 }
45
46 func (b GroupIssueBoard) String() string {
47 return Stringify(b)
48 }
49
50
51
52
53
54
55 type ListGroupIssueBoardsOptions ListOptions
56
57
58
59
60
61 func (s *GroupIssueBoardsService) ListGroupIssueBoards(gid interface{}, opt *ListGroupIssueBoardsOptions, options ...RequestOptionFunc) ([]*GroupIssueBoard, *Response, error) {
62 group, err := parseID(gid)
63 if err != nil {
64 return nil, nil, err
65 }
66 u := fmt.Sprintf("groups/%s/boards", PathEscape(group))
67
68 req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
69 if err != nil {
70 return nil, nil, err
71 }
72
73 var gs []*GroupIssueBoard
74 resp, err := s.client.Do(req, &gs)
75 if err != nil {
76 return nil, resp, err
77 }
78
79 return gs, resp, nil
80 }
81
82
83
84
85
86
87 type CreateGroupIssueBoardOptions struct {
88 Name *string `url:"name" json:"name"`
89 }
90
91
92
93
94
95 func (s *GroupIssueBoardsService) CreateGroupIssueBoard(gid interface{}, opt *CreateGroupIssueBoardOptions, options ...RequestOptionFunc) (*GroupIssueBoard, *Response, error) {
96 group, err := parseID(gid)
97 if err != nil {
98 return nil, nil, err
99 }
100 u := fmt.Sprintf("groups/%s/boards", PathEscape(group))
101
102 req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
103 if err != nil {
104 return nil, nil, err
105 }
106
107 gib := new(GroupIssueBoard)
108 resp, err := s.client.Do(req, gib)
109 if err != nil {
110 return nil, resp, err
111 }
112
113 return gib, resp, nil
114 }
115
116
117
118
119
120 func (s *GroupIssueBoardsService) GetGroupIssueBoard(gid interface{}, board int, options ...RequestOptionFunc) (*GroupIssueBoard, *Response, error) {
121 group, err := parseID(gid)
122 if err != nil {
123 return nil, nil, err
124 }
125 u := fmt.Sprintf("groups/%s/boards/%d", PathEscape(group), board)
126
127 req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
128 if err != nil {
129 return nil, nil, err
130 }
131
132 gib := new(GroupIssueBoard)
133 resp, err := s.client.Do(req, gib)
134 if err != nil {
135 return nil, resp, err
136 }
137
138 return gib, resp, nil
139 }
140
141
142
143
144
145 type UpdateGroupIssueBoardOptions struct {
146 Name *string `url:"name,omitempty" json:"name,omitempty"`
147 AssigneeID *int `url:"assignee_id,omitempty" json:"assignee_id,omitempty"`
148 MilestoneID *int `url:"milestone_id,omitempty" json:"milestone_id,omitempty"`
149 Labels *LabelOptions `url:"labels,omitempty" json:"labels,omitempty"`
150 Weight *int `url:"weight,omitempty" json:"weight,omitempty"`
151 }
152
153
154
155
156
157 func (s *GroupIssueBoardsService) UpdateIssueBoard(gid interface{}, board int, opt *UpdateGroupIssueBoardOptions, options ...RequestOptionFunc) (*GroupIssueBoard, *Response, error) {
158 group, err := parseID(gid)
159 if err != nil {
160 return nil, nil, err
161 }
162 u := fmt.Sprintf("groups/%s/boards/%d", PathEscape(group), board)
163
164 req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
165 if err != nil {
166 return nil, nil, err
167 }
168
169 gib := new(GroupIssueBoard)
170 resp, err := s.client.Do(req, gib)
171 if err != nil {
172 return nil, resp, err
173 }
174
175 return gib, resp, nil
176 }
177
178
179
180
181
182 func (s *GroupIssueBoardsService) DeleteIssueBoard(gid interface{}, board int, options ...RequestOptionFunc) (*Response, error) {
183 group, err := parseID(gid)
184 if err != nil {
185 return nil, err
186 }
187 u := fmt.Sprintf("groups/%s/boards/%d", PathEscape(group), board)
188
189 req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
190 if err != nil {
191 return nil, err
192 }
193
194 return s.client.Do(req, nil)
195 }
196
197
198
199
200
201
202 type ListGroupIssueBoardListsOptions ListOptions
203
204
205
206
207
208 func (s *GroupIssueBoardsService) ListGroupIssueBoardLists(gid interface{}, board int, opt *ListGroupIssueBoardListsOptions, options ...RequestOptionFunc) ([]*BoardList, *Response, error) {
209 group, err := parseID(gid)
210 if err != nil {
211 return nil, nil, err
212 }
213 u := fmt.Sprintf("groups/%s/boards/%d/lists", PathEscape(group), board)
214
215 req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
216 if err != nil {
217 return nil, nil, err
218 }
219
220 var gbl []*BoardList
221 resp, err := s.client.Do(req, &gbl)
222 if err != nil {
223 return nil, resp, err
224 }
225
226 return gbl, resp, nil
227 }
228
229
230
231
232
233 func (s *GroupIssueBoardsService) GetGroupIssueBoardList(gid interface{}, board, list int, options ...RequestOptionFunc) (*BoardList, *Response, error) {
234 group, err := parseID(gid)
235 if err != nil {
236 return nil, nil, err
237 }
238 u := fmt.Sprintf("groups/%s/boards/%d/lists/%d",
239 PathEscape(group),
240 board,
241 list,
242 )
243
244 req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
245 if err != nil {
246 return nil, nil, err
247 }
248
249 gbl := new(BoardList)
250 resp, err := s.client.Do(req, gbl)
251 if err != nil {
252 return nil, resp, err
253 }
254
255 return gbl, resp, nil
256 }
257
258
259
260
261
262
263 type CreateGroupIssueBoardListOptions struct {
264 LabelID *int `url:"label_id" json:"label_id"`
265 }
266
267
268
269
270
271 func (s *GroupIssueBoardsService) CreateGroupIssueBoardList(gid interface{}, board int, opt *CreateGroupIssueBoardListOptions, options ...RequestOptionFunc) (*BoardList, *Response, error) {
272 group, err := parseID(gid)
273 if err != nil {
274 return nil, nil, err
275 }
276 u := fmt.Sprintf("groups/%s/boards/%d/lists", PathEscape(group), board)
277
278 req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
279 if err != nil {
280 return nil, nil, err
281 }
282
283 gbl := new(BoardList)
284 resp, err := s.client.Do(req, gbl)
285 if err != nil {
286 return nil, resp, err
287 }
288
289 return gbl, resp, nil
290 }
291
292
293
294
295
296
297 type UpdateGroupIssueBoardListOptions struct {
298 Position *int `url:"position" json:"position"`
299 }
300
301
302
303
304
305
306 func (s *GroupIssueBoardsService) UpdateIssueBoardList(gid interface{}, board, list int, opt *UpdateGroupIssueBoardListOptions, options ...RequestOptionFunc) ([]*BoardList, *Response, error) {
307 group, err := parseID(gid)
308 if err != nil {
309 return nil, nil, err
310 }
311 u := fmt.Sprintf("groups/%s/boards/%d/lists/%d",
312 PathEscape(group),
313 board,
314 list,
315 )
316
317 req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
318 if err != nil {
319 return nil, nil, err
320 }
321
322 var gbl []*BoardList
323 resp, err := s.client.Do(req, &gbl)
324 if err != nil {
325 return nil, resp, err
326 }
327
328 return gbl, resp, nil
329 }
330
331
332
333
334
335
336 func (s *GroupIssueBoardsService) DeleteGroupIssueBoardList(gid interface{}, board, list int, options ...RequestOptionFunc) (*Response, error) {
337 group, err := parseID(gid)
338 if err != nil {
339 return nil, err
340 }
341 u := fmt.Sprintf("groups/%s/boards/%d/lists/%d",
342 PathEscape(group),
343 board,
344 list,
345 )
346
347 req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
348 if err != nil {
349 return nil, err
350 }
351
352 return s.client.Do(req, nil)
353 }
354
View as plain text