forked from DependencyTrack/client-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathacl.go
More file actions
50 lines (42 loc) · 1.18 KB
/
acl.go
File metadata and controls
50 lines (42 loc) · 1.18 KB
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
package dtrack
import (
"context"
"fmt"
"net/http"
"github.com/google/uuid"
)
type ACLService struct {
client *Client
}
type ACLMappingRequest struct {
Team uuid.UUID `json:"team"`
Project uuid.UUID `json:"project"`
}
func (as ACLService) AddProjectMapping(ctx context.Context, mapping ACLMappingRequest) (err error) {
req, err := as.client.newRequest(ctx, http.MethodPut, "/api/v1/acl/mapping", withBody(mapping))
if err != nil {
return
}
_, err = as.client.doRequest(req, nil)
return
}
func (as ACLService) RemoveProjectMapping(ctx context.Context, team, project uuid.UUID) (err error) {
req, err := as.client.newRequest(ctx, http.MethodDelete, fmt.Sprintf("/api/v1/acl/mapping/team/%s/project/%s", team, project))
if err != nil {
return
}
_, err = as.client.doRequest(req, nil)
return
}
func (as ACLService) GetAllProjects(ctx context.Context, team uuid.UUID, po PageOptions) (p Page[Project], err error) {
req, err := as.client.newRequest(ctx, http.MethodGet, fmt.Sprintf("/api/v1/acl/team/%s", team), withPageOptions(po))
if err != nil {
return
}
res, err := as.client.doRequest(req, &p.Items)
if err != nil {
return
}
p.TotalCount = res.TotalCount
return
}