-
-
Notifications
You must be signed in to change notification settings - Fork 40
/
groups_include.go
118 lines (97 loc) · 4.09 KB
/
groups_include.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package gerrit
import (
"context"
"fmt"
)
// ListIncludedGroups lists the directly included groups of a group.
// The entries in the list are sorted by group name and UUID.
//
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-groups.html#included-groups
func (s *GroupsService) ListIncludedGroups(ctx context.Context, groupID string) (*[]GroupInfo, *Response, error) {
u := fmt.Sprintf("groups/%s/groups/", groupID)
req, err := s.client.NewRequest(ctx, "GET", u, nil)
if err != nil {
return nil, nil, err
}
v := new([]GroupInfo)
resp, err := s.client.Do(req, v)
if err != nil {
return nil, resp, err
}
return v, resp, err
}
// GetIncludedGroup retrieves an included group.
//
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-groups.html#get-included-group
func (s *GroupsService) GetIncludedGroup(ctx context.Context, groupID, includeGroupID string) (*GroupInfo, *Response, error) {
u := fmt.Sprintf("groups/%s/groups/%s", groupID, includeGroupID)
req, err := s.client.NewRequest(ctx, "GET", u, nil)
if err != nil {
return nil, nil, err
}
v := new(GroupInfo)
resp, err := s.client.Do(req, v)
if err != nil {
return nil, resp, err
}
return v, resp, err
}
// IncludeGroup includes an internal or external group into a Gerrit internal group.
// External groups must be specified using the UUID.
//
// As response a GroupInfo entity is returned that describes the included group.
// The request also succeeds if the group is already included in this group, but then the HTTP response code is 200 OK.
//
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-groups.html#include-group
func (s *GroupsService) IncludeGroup(ctx context.Context, groupID, includeGroupID string) (*GroupInfo, *Response, error) {
u := fmt.Sprintf("groups/%s/groups/%s", groupID, includeGroupID)
req, err := s.client.NewRequest(ctx, "PUT", u, nil)
if err != nil {
return nil, nil, err
}
v := new(GroupInfo)
resp, err := s.client.Do(req, v)
if err != nil {
return nil, resp, err
}
return v, resp, err
}
// IncludeGroups includes one or several groups into a Gerrit internal group.
// The groups to be included into the group must be provided in the request body as a GroupsInput entity.
//
// As response a list of GroupInfo entities is returned that describes the groups that were specified in the GroupsInput.
// A GroupInfo entity is returned for each group specified in the input, independently of whether the group was newly included into the group or whether the group was already included in the group.
//
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-groups.html#include-groups
func (s *GroupsService) IncludeGroups(ctx context.Context, groupID string, input *GroupsInput) (*[]GroupInfo, *Response, error) {
u := fmt.Sprintf("groups/%s/groups", groupID)
req, err := s.client.NewRequest(ctx, "POST", u, input)
if err != nil {
return nil, nil, err
}
v := new([]GroupInfo)
resp, err := s.client.Do(req, v)
if err != nil {
return nil, resp, err
}
return v, resp, err
}
// DeleteIncludedGroup deletes an included group from a Gerrit internal group.
//
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-groups.html#include-group
func (s *GroupsService) DeleteIncludedGroup(ctx context.Context, groupID, includeGroupID string) (*Response, error) {
u := fmt.Sprintf("groups/%s/groups/%s", groupID, includeGroupID)
return s.client.DeleteRequest(ctx, u, nil)
}
// DeleteIncludedGroups delete one or several included groups from a Gerrit internal group.
// The groups to be deleted from the group must be provided in the request body as a GroupsInput entity.
//
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-groups.html#delete-included-groups
func (s *GroupsService) DeleteIncludedGroups(ctx context.Context, groupID string, input *GroupsInput) (*Response, error) {
u := fmt.Sprintf("groups/%s/groups.delete", groupID)
req, err := s.client.NewRequest(ctx, "POST", u, input)
if err != nil {
return nil, err
}
return s.client.Do(req, nil)
}