forked from DependencyTrack/client-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
61 lines (50 loc) · 1.83 KB
/
config.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
package dtrack
import (
"context"
"net/http"
)
type ConfigPropertyType string
const (
ConfigPropertyTypeBoolean ConfigPropertyType = "BOOLEAN"
ConfigPropertyTypeInteger ConfigPropertyType = "INTEGER"
ConfigPropertyTypeNumber ConfigPropertyType = "NUMBER"
ConfigPropertyTypeString ConfigPropertyType = "STRING"
ConfigPropertyTypeEncryptedString ConfigPropertyType = "ENCRYPTEDSTRING"
ConfigPropertyTypeTimestamp ConfigPropertyType = "TIMESTAMP"
ConfigPropertyTypeURL ConfigPropertyType = "URL"
ConfigPropertyTypeUUID ConfigPropertyType = "UUID"
)
type ConfigProperty struct {
GroupName string `json:"groupName,omitempty"`
PropertyName string `json:"propertyName,omitempty"`
PropertyValue *string `json:"propertyValue,omitempty"`
PropertyType ConfigPropertyType `json:"propertyType,omitempty"`
Description string `json:"description,omitempty"`
}
type ConfigService struct {
client *Client
}
func (ps ConfigService) GetAllConfigProperties(ctx context.Context) (cp []ConfigProperty, err error) {
req, err := ps.client.newRequest(ctx, http.MethodGet, "/api/v1/configProperty")
if err != nil {
return
}
_, err = ps.client.doRequest(req, &cp)
if err != nil {
return
}
return
}
type SetConfigPropertyRequest struct {
GroupName string `json:"groupName,omitempty"`
PropertyName string `json:"propertyName,omitempty"`
PropertyValue string `json:"propertyValue,omitempty"`
}
func (ps ConfigService) SetConfigProperty(ctx context.Context, setConfigPropertyRequest SetConfigPropertyRequest) (p ConfigProperty, err error) {
req, err := ps.client.newRequest(ctx, http.MethodPost, "/api/v1/configProperty", withBody(setConfigPropertyRequest))
if err != nil {
return
}
_, err = ps.client.doRequest(req, &p)
return
}