-
Notifications
You must be signed in to change notification settings - Fork 4
/
dsm.go
80 lines (72 loc) · 2.31 KB
/
dsm.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
package qradar
import (
"context"
"net/http"
)
// DSMService handles methods related to DSMs of the QRadar API.
type DSMService service
const (
dsmAPIPrefix = "api/data_classification/dsm_event_mappings"
)
// DSM represents QRadar's DSM
type DSM struct {
ID *int `json:"id,omitempty"`
LogSourceTypeID *int `json:"log_source_type_id,omitempty"`
LogSourceEventID *string `json:"log_source_event_id,omitempty"`
LogSourceEventCategory *string `json:"log_source_event_category,omitempty"`
CustomEvent *bool `json:"custom_event,omitempty"`
QIDRecordID *int `json:"qid_record_id,omitempty"`
UUID *string `json:"uuid,omitempty"`
}
// Get returns DSMs of the current QRadar installation.
func (c *DSMService) Get(ctx context.Context, fields, filter string, from, to int) ([]DSM, error) {
req, err := c.client.requestHelp(http.MethodGet, dsmAPIPrefix, fields, filter, from, to, nil, nil)
if err != nil {
return nil, err
}
var result []DSM
_, err = c.client.Do(ctx, req, &result)
if err != nil {
return nil, err
}
return result, nil
}
// Create creates DSM in the current QRadar installation.
func (c *DSMService) Create(ctx context.Context, fields string, data interface{}) (*DSM, error) {
req, err := c.client.requestHelp(http.MethodPost, dsmAPIPrefix, fields, "", 0, 0, nil, data)
if err != nil {
return nil, err
}
var result DSM
_, err = c.client.Do(ctx, req, &result)
if err != nil {
return nil, err
}
return &result, nil
}
// GetByID returns DSM of the current QRadar installation by ID.
func (c *DSMService) GetByID(ctx context.Context, fields string, id int) (*DSM, error) {
req, err := c.client.requestHelp(http.MethodGet, dsmAPIPrefix, fields, "", 0, 0, &id, nil)
if err != nil {
return nil, err
}
var result DSM
_, err = c.client.Do(ctx, req, &result)
if err != nil {
return nil, err
}
return &result, nil
}
// UpdateByID updates DSM in QRadar installation by ID.
func (c *DSMService) UpdateByID(ctx context.Context, fields string, id int, data interface{}) (*DSM, error) {
req, err := c.client.requestHelp(http.MethodPost, dsmAPIPrefix, fields, "", 0, 0, &id, data)
if err != nil {
return nil, err
}
var result DSM
_, err = c.client.Do(ctx, req, &result)
if err != nil {
return nil, err
}
return &result, nil
}