forked from DependencyTrack/client-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
acl.go
48 lines (38 loc) · 1.11 KB
/
acl.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
package dtrack
import (
"context"
"fmt"
"net/http"
"github.com/google/uuid"
)
type ACLMapping struct {
Team uuid.UUID `json:"team,omitempty"`
Project uuid.UUID `json:"project,omitempty"`
}
type ACLMappingService struct {
client *Client
}
func (as ACLMappingService) Get(ctx context.Context, teamUUID uuid.UUID) (mappings []Project, err error) {
req, err := as.client.newRequest(ctx, http.MethodGet, fmt.Sprintf("/api/v1/acl/team/%s", teamUUID.String()))
if err != nil {
return
}
_, err = as.client.doRequest(req, &mappings)
return
}
func (as ACLMappingService) Create(ctx context.Context, mapping ACLMapping) (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 ACLMappingService) Delete(ctx context.Context, mapping ACLMapping) (err error) {
req, err := as.client.newRequest(ctx, http.MethodDelete, fmt.Sprintf("/api/v1/acl/mapping/team/%s/project/%s", mapping.Team, mapping.Project))
if err != nil {
return
}
_, err = as.client.doRequest(req, nil)
return
}