-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdomains.go
102 lines (93 loc) · 3.26 KB
/
domains.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
package qradar
import (
"context"
"net/http"
)
// DomainService handles methods related to Domains of the QRadar API.
type DomainService service
const domainsAPIPrefix = "api/config/domain_management/domains"
// Domain represents QRadar's Domain.
type Domain struct {
AssetScannerIds []int `json:"asset_scanner_ids,omitempty"`
CustomProperties []struct {
CaptureResult *string `json:"capture_result,omitempty"`
ID *int `json:"id,omitempty"`
} `json:"custom_properties,omitempty"`
Deleted *bool `json:"deleted,omitempty"`
Description *string `json:"description,omitempty"`
EventCollectorIds []int `json:"event_collector_ids,omitempty"`
FlowCollectorIds []int `json:"flow_collector_ids,omitempty"`
FlowSourceIds []int `json:"flow_source_ids,omitempty"`
FlowVlanIds []int `json:"flow_vlan_ids,omitempty"`
ID *int `json:"id,omitempty"`
LogSourceGroupIds []int `json:"log_source_group_ids,omitempty"`
LogSourceIds []int `json:"log_source_ids,omitempty"`
Name *string `json:"name,omitempty"`
QvmScannerIds []int `json:"qvm_scanner_ids,omitempty"`
TenantID *int `json:"tenant_id,omitempty"`
}
// Get returns Domains of the current QRadar installation.
func (c *DomainService) Get(ctx context.Context, fields, filter string, from, to int) ([]Domain, error) {
req, err := c.client.requestHelp(http.MethodGet, domainsAPIPrefix, fields, filter, from, to, nil, nil)
if err != nil {
return nil, err
}
var result []Domain
_, err = c.client.Do(ctx, req, &result)
if err != nil {
return nil, err
}
return result, nil
}
// GetByID returns Domain of the current QRadar installation by ID.
func (c *DomainService) GetByID(ctx context.Context, fields string, id int) (*Domain, error) {
req, err := c.client.requestHelp(http.MethodGet, domainsAPIPrefix, fields, "", 0, 0, &id, nil)
if err != nil {
return nil, err
}
var result Domain
_, err = c.client.Do(ctx, req, &result)
if err != nil {
return nil, err
}
return &result, nil
}
// Create creates Domain in the current QRadar installation.
func (c *DomainService) Create(ctx context.Context, fields string, data interface{}) (*Domain, error) {
req, err := c.client.requestHelp(http.MethodPost, domainsAPIPrefix, fields, "", 0, 0, nil, data)
if err != nil {
return nil, err
}
var result Domain
_, err = c.client.Do(ctx, req, &result)
if err != nil {
return nil, err
}
return &result, nil
}
// UpdateByID updates Domain in QRadar installation by ID.
func (c *DomainService) UpdateByID(ctx context.Context, fields string, id int, data interface{}) (*Domain, error) {
req, err := c.client.requestHelp(http.MethodPost, domainsAPIPrefix, fields, "", 0, 0, &id, data)
if err != nil {
return nil, err
}
var result Domain
_, err = c.client.Do(ctx, req, &result)
if err != nil {
return nil, err
}
return &result, nil
}
// DeleteByID deletes Domain in QRadar installation by ID.
func (c *DomainService) DeleteByID(ctx context.Context, fields string, id int) (*Domain, error) {
req, err := c.client.requestHelp(http.MethodDelete, domainsAPIPrefix, fields, "", 0, 0, &id, nil)
if err != nil {
return nil, err
}
var result Domain
_, err = c.client.Do(ctx, req, &result)
if err != nil {
return nil, err
}
return &result, nil
}