-
-
Notifications
You must be signed in to change notification settings - Fork 40
/
access.go
79 lines (69 loc) · 3.24 KB
/
access.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
package gerrit
import "context"
// AccessService contains Access Right related REST endpoints
//
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-access.html
type AccessService struct {
client *Client
}
// AccessSectionInfo describes the access rights that are assigned on a ref.
//
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-access.html#access-section-info
type AccessSectionInfo struct {
Permissions map[string]PermissionInfo `json:"permissions"`
}
// PermissionInfo entity contains information about an assigned permission.
//
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-access.html#permission-info
type PermissionInfo struct {
Label string `json:"label,omitempty"`
Exclusive bool `json:"exclusive"`
Rules map[string]PermissionRuleInfo `json:"rules"`
}
// PermissionRuleInfo entity contains information about a permission rule that is assigned to group.
//
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-access.html#permission-rule-info
type PermissionRuleInfo struct {
// TODO Possible values for action: ALLOW, DENY or BLOCK, INTERACTIVE and BATCH
Action string `json:"action"`
Force bool `json:"force"`
Min int `json:"min"`
Max int `json:"max"`
}
// ProjectAccessInfo entity contains information about the access rights for a project.
//
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-access.html#project-access-info
type ProjectAccessInfo struct {
Revision string `json:"revision"`
InheritsFrom ProjectInfo `json:"inherits_from"`
Local map[string]AccessSectionInfo `json:"local"`
IsOwner bool `json:"is_owner"`
OwnerOf []string `json:"owner_of"`
CanUpload bool `json:"can_upload"`
CanAdd bool `json:"can_add"`
CanAddTags bool `json:"can_add_tags"`
ConfigVisible bool `json:"config_visible"`
Groups map[string]GroupInfo `json:"groups"`
ConfigWebLinks []string `json:"configWebLinks"`
}
// ListAccessRightsOptions specifies the parameters to the AccessService.ListAccessRights.
type ListAccessRightsOptions struct {
// The projects for which the access rights should be returned must be specified as project options.
// The project can be specified multiple times.
Project []string `url:"project,omitempty"`
}
// ListAccessRights lists the access rights for projects.
// As result a map is returned that maps the project name to ProjectAccessInfo entities.
// The entries in the map are sorted by project name.
//
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-access.html#list-access
func (s *AccessService) ListAccessRights(ctx context.Context, opt *ListAccessRightsOptions) (*map[string]ProjectAccessInfo, *Response, error) {
u := "access/"
u, err := addOptions(u, opt)
if err != nil {
return nil, nil, err
}
v := new(map[string]ProjectAccessInfo)
resp, err := s.client.Call(ctx, "GET", u, nil, v)
return v, resp, err
}