-
Notifications
You must be signed in to change notification settings - Fork 4
/
ingestion_keys.go
44 lines (39 loc) · 1.17 KB
/
ingestion_keys.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
package limacharlie
import (
"fmt"
"net/http"
"net/url"
)
func (org *Organization) GetIngestionKeys() (Dict, error) {
resp := map[string]Dict{}
request := makeDefaultRequest(&resp)
if err := org.client.reliableRequest(http.MethodGet, fmt.Sprintf("insight/%s/ingestion_keys", org.GetOID()), request); err != nil {
return nil, err
}
keys, ok := resp["keys"]
if !ok {
return nil, fmt.Errorf("no ingestion keys")
}
return keys, nil
}
func (org Organization) SetIngestionKeys(name string) (Dict, error) {
resp := Dict{}
req := Dict{
"name": name,
}
request := makeDefaultRequest(&resp).withFormData(req)
if err := org.client.reliableRequest(http.MethodPost, fmt.Sprintf("insight/%s/ingestion_keys", org.GetOID()), request); err != nil {
return nil, err
}
return resp, nil
}
func (org Organization) DelIngestionKeys(name string) (Dict, error) {
resp := Dict{}
req := Dict{}
escapedName := url.QueryEscape(name)
request := makeDefaultRequest(&resp).withFormData(req)
if err := org.client.reliableRequest(http.MethodDelete, fmt.Sprintf("insight/%s/ingestion_keys?name=%s", org.GetOID(), escapedName), request); err != nil {
return nil, err
}
return resp, nil
}