-
Notifications
You must be signed in to change notification settings - Fork 4
/
reference_map_of_sets.go
103 lines (90 loc) · 3.21 KB
/
reference_map_of_sets.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package qradar
import (
"context"
"net/http"
)
// ReferenceMapOfSetsService handles methods related to Reference Maps of Sets of the QRadar API.
type ReferenceMapOfSetsService service
const (
referenceMapOfSetsServiceAPIPrefix = "api/reference_data/map_of_sets"
)
// ReferenceMapOfSets represents QRadar's Reference maps of sets.
type ReferenceMapOfSets struct {
Name *string `json:"name,omitempty"`
CreationTime *int `json:"creation_time,omitempty"`
ElementType *string `json:"element_type,omitempty"`
KeyLabel *string `json:"key_label,omitempty"`
NumberOfElements *int `json:"number_of_elements,omitempty"`
TimeToLive *string `json:"time_to_live,omitempty"`
TimeoutType *string `json:"timeout_type,omitempty"`
ValueLabel *string `json:"value_label,omitempty"`
Data map[string][]ReferenceData `json:"data,omitempty"`
}
// Get returns Reference maps of sets of the current QRadar installation.
func (c *ReferenceMapOfSetsService) Get(ctx context.Context, fields, filter string, from, to int) ([]ReferenceMapOfSets, error) {
req, err := c.client.requestHelp(http.MethodGet, referenceMapOfSetsServiceAPIPrefix, fields, filter, from, to, nil, nil)
if err != nil {
return nil, err
}
var result []ReferenceMapOfSets
_, err = c.client.Do(ctx, req, &result)
if err != nil {
return nil, err
}
return result, nil
}
// Create creates Reference maps of sets in QRadar installation.
func (c *ReferenceMapOfSetsService) Create(ctx context.Context, fields string, data *ReferenceMapOfSets) (*ReferenceMapOfSets, error) {
req, err := c.client.requestHelp(http.MethodPost, referenceMapOfSetsServiceAPIPrefix, fields, "", 0, 0, nil, nil)
if err != nil {
return nil, err
}
q := req.URL.Query()
if data != nil {
if data.Name != nil {
q.Add("name", *data.Name)
}
if data.ElementType != nil {
q.Add("element_type", *data.ElementType)
}
if data.TimeToLive != nil {
q.Add("time_to_live", *data.TimeToLive)
}
if data.TimeoutType != nil {
q.Add("timeout_type", *data.TimeoutType)
}
}
req.URL.RawQuery = q.Encode()
var result ReferenceMapOfSets
_, err = c.client.Do(ctx, req, &result)
if err != nil {
return nil, err
}
return &result, nil
}
// GetWithData returns Reference Map of Sets with data of the current QRadar installation.
func (c *ReferenceMapOfSetsService) GetWithData(ctx context.Context, fields, filter, name string, from, to int) (*ReferenceMapOfSets, error) {
req, err := c.client.requestHelp(http.MethodGet, referenceMapOfSetsServiceAPIPrefix+"/"+name, fields, filter, from, to, nil, nil)
if err != nil {
return nil, err
}
var result ReferenceMapOfSets
_, err = c.client.Do(ctx, req, &result)
if err != nil {
return nil, err
}
return &result, nil
}
// BulkLoad uploads many values in QRadar's Reference Map o Sets
func (c *ReferenceMapOfSetsService) BulkLoad(ctx context.Context, fields, name string, data interface{}) (*ReferenceMapOfSets, error) {
req, err := c.client.requestHelp(http.MethodPost, referenceMapOfSetsServiceAPIPrefix+"/bulk_load/"+name, fields, "", 0, 0, nil, data)
if err != nil {
return nil, err
}
var result ReferenceMapOfSets
_, err = c.client.Do(ctx, req, &result)
if err != nil {
return nil, err
}
return &result, nil
}