|
| 1 | +// |
| 2 | +// Copyright 2021, Patrick Webster |
| 3 | +// |
| 4 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +// you may not use this file except in compliance with the License. |
| 6 | +// You may obtain a copy of the License at |
| 7 | +// |
| 8 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +// |
| 10 | +// Unless required by applicable law or agreed to in writing, software |
| 11 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +// See the License for the specific language governing permissions and |
| 14 | +// limitations under the License. |
| 15 | +// |
| 16 | + |
| 17 | +package gitlab |
| 18 | + |
| 19 | +import ( |
| 20 | + "fmt" |
| 21 | + "net/http" |
| 22 | +) |
| 23 | + |
| 24 | +// GroupEpicBoardsService handles communication with the group epic board |
| 25 | +// related methods of the GitLab API. |
| 26 | +// |
| 27 | +// GitLab API docs: |
| 28 | +// https://docs.gitlab.com/ee/api/group_epic_boards.html |
| 29 | +type GroupEpicBoardsService struct { |
| 30 | + client *Client |
| 31 | +} |
| 32 | + |
| 33 | +// GroupEpicBoard represents a GitLab group epic board. |
| 34 | +// |
| 35 | +// GitLab API docs: |
| 36 | +// https://docs.gitlab.com/ee/api/group_epic_boards.html |
| 37 | +type GroupEpicBoard struct { |
| 38 | + ID int `json:"id"` |
| 39 | + Name string `json:"name"` |
| 40 | + Group *Group `json:"group"` |
| 41 | + Labels []*LabelDetails `json:"labels"` |
| 42 | + Lists []*BoardList `json:"lists"` |
| 43 | +} |
| 44 | + |
| 45 | +func (b GroupEpicBoard) String() string { |
| 46 | + return Stringify(b) |
| 47 | +} |
| 48 | + |
| 49 | +// ListGroupEpicBoardsOptions represents the available |
| 50 | +// ListGroupEpicBoards() options. |
| 51 | +// |
| 52 | +// GitLab API docs: |
| 53 | +// https://docs.gitlab.com/ee/api/group_epic_boards.html#list-all-epic-boards-in-a-group |
| 54 | +type ListGroupEpicBoardsOptions ListOptions |
| 55 | + |
| 56 | +// ListGroupEpicBoards gets a list of all epic boards in a group. |
| 57 | +// |
| 58 | +// GitLab API docs: |
| 59 | +// https://docs.gitlab.com/ee/api/group_epic_boards.html#list-all-epic-boards-in-a-group |
| 60 | +func (s *GroupEpicBoardsService) ListGroupEpicBoards(gid interface{}, opt *ListGroupEpicBoardsOptions, options ...RequestOptionFunc) ([]*GroupEpicBoard, *Response, error) { |
| 61 | + group, err := parseID(gid) |
| 62 | + if err != nil { |
| 63 | + return nil, nil, err |
| 64 | + } |
| 65 | + u := fmt.Sprintf("groups/%s/epic_boards", PathEscape(group)) |
| 66 | + |
| 67 | + req, err := s.client.NewRequest(http.MethodGet, u, opt, options) |
| 68 | + if err != nil { |
| 69 | + return nil, nil, err |
| 70 | + } |
| 71 | + |
| 72 | + var gs []*GroupEpicBoard |
| 73 | + resp, err := s.client.Do(req, &gs) |
| 74 | + if err != nil { |
| 75 | + return nil, resp, err |
| 76 | + } |
| 77 | + |
| 78 | + return gs, resp, nil |
| 79 | +} |
| 80 | + |
| 81 | +// GetGroupEpicBoard gets a single epic board of a group. |
| 82 | +// |
| 83 | +// GitLab API docs: |
| 84 | +// https://docs.gitlab.com/ee/api/group_epic_boards.html#single-group-epic-board |
| 85 | +func (s *GroupEpicBoardsService) GetGroupEpicBoard(gid interface{}, board int, options ...RequestOptionFunc) (*GroupEpicBoard, *Response, error) { |
| 86 | + group, err := parseID(gid) |
| 87 | + if err != nil { |
| 88 | + return nil, nil, err |
| 89 | + } |
| 90 | + u := fmt.Sprintf("groups/%s/epic_boards/%d", PathEscape(group), board) |
| 91 | + |
| 92 | + req, err := s.client.NewRequest(http.MethodGet, u, nil, options) |
| 93 | + if err != nil { |
| 94 | + return nil, nil, err |
| 95 | + } |
| 96 | + |
| 97 | + gib := new(GroupEpicBoard) |
| 98 | + resp, err := s.client.Do(req, gib) |
| 99 | + if err != nil { |
| 100 | + return nil, resp, err |
| 101 | + } |
| 102 | + |
| 103 | + return gib, resp, nil |
| 104 | +} |
0 commit comments