-
Notifications
You must be signed in to change notification settings - Fork 4
/
property_cef_expression.go
84 lines (75 loc) · 2.71 KB
/
property_cef_expression.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
package qradar
import (
"context"
"net/http"
)
// PropertyCEFExpressionService handles methods related to Property CEF Expressions of the QRadar API.
type PropertyCEFExpressionService service
const (
propertyCefExpressionAPIPrefix = "api/config/event_sources/custom_properties/property_cef_expressions"
)
// Get returns Property CEF Expressions of the current QRadar installation.
func (c *PropertyCEFExpressionService) Get(ctx context.Context, fields, filter string, from, to int) ([]PropertyExpression, error) {
req, err := c.client.requestHelp(http.MethodGet, propertyCefExpressionAPIPrefix, fields, filter, from, to, nil, nil)
if err != nil {
return nil, err
}
var result []PropertyExpression
_, err = c.client.Do(ctx, req, &result)
if err != nil {
return nil, err
}
return result, nil
}
// GetByID returns Property CEF Expression of the current QRadar installation by ID.
func (c *PropertyCEFExpressionService) GetByID(ctx context.Context, fields string, id int) (*PropertyExpression, error) {
req, err := c.client.requestHelp(http.MethodGet, propertyCefExpressionAPIPrefix, fields, "", 0, 0, &id, nil)
if err != nil {
return nil, err
}
var result PropertyExpression
_, err = c.client.Do(ctx, req, &result)
if err != nil {
return nil, err
}
return &result, nil
}
// Create creates Property CEF Expression in QRadar installation.
func (c *PropertyCEFExpressionService) Create(ctx context.Context, fields string, data interface{}) (*PropertyExpression, error) {
req, err := c.client.requestHelp(http.MethodPost, propertyCefExpressionAPIPrefix, fields, "", 0, 0, nil, data)
if err != nil {
return nil, err
}
var result PropertyExpression
_, err = c.client.Do(ctx, req, &result)
if err != nil {
return nil, err
}
return &result, nil
}
// UpdateByID updates Property CEF Expression in QRadar installation by ID.
func (c *PropertyCEFExpressionService) UpdateByID(ctx context.Context, fields string, id int, data interface{}) (*PropertyExpression, error) {
req, err := c.client.requestHelp(http.MethodPost, propertyCefExpressionAPIPrefix, fields, "", 0, 0, &id, data)
if err != nil {
return nil, err
}
var result PropertyExpression
_, err = c.client.Do(ctx, req, &result)
if err != nil {
return nil, err
}
return &result, nil
}
// DeleteByID creates A Delete Task in QRadar installation in order to safely delete Property CEF Expression by ID.
func (c *PropertyCEFExpressionService) DeleteByID(ctx context.Context, fields string, id int) error {
req, err := c.client.requestHelp(http.MethodDelete, propertyCefExpressionAPIPrefix, fields, "", 0, 0, &id, nil)
if err != nil {
return err
}
req.Header.Set("Accept", "text/plain")
_, err = c.client.Do(ctx, req, nil)
if err != nil {
return err
}
return nil
}