-
Notifications
You must be signed in to change notification settings - Fork 4
/
log_source_group.go
67 lines (60 loc) · 2.15 KB
/
log_source_group.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
package qradar
import (
"context"
"net/http"
)
// LogSourceGroupService handles methods related to Log Source Groups of the QRadar API.
type LogSourceGroupService service
const (
logSourceGroupAPIPrefix = "api/config/event_sources/log_source_management/log_source_groups"
)
// LogSourceGroup represents QRadar's Log Source Group.
type LogSourceGroup struct {
ID *int `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
ParentID *int `json:"parent_id,omitempty"`
Owner *string `json:"owner,omitempty"`
ModificationDate *int `json:"modification_date,omitempty"`
Assignable *bool `json:"assignable,omitempty"`
ChildGroupIDs []int `json:"child_group_ids,omitempty"`
}
// Get returns Log Source Groups of the current QRadar installation.
func (c *LogSourceGroupService) Get(ctx context.Context, fields, filter string, from, to int) ([]LogSourceGroup, error) {
req, err := c.client.requestHelp(http.MethodGet, logSourceGroupAPIPrefix, fields, filter, from, to, nil, nil)
if err != nil {
return nil, err
}
var result []LogSourceGroup
_, err = c.client.Do(ctx, req, &result)
if err != nil {
return nil, err
}
return result, nil
}
// GetByID returns Log Source Group of the current QRadar installation by ID.
func (c *LogSourceGroupService) GetByID(ctx context.Context, fields string, id int) (*LogSourceGroup, error) {
req, err := c.client.requestHelp(http.MethodGet, logSourceGroupAPIPrefix, fields, "", 0, 0, &id, nil)
if err != nil {
return nil, err
}
var result LogSourceGroup
_, err = c.client.Do(ctx, req, &result)
if err != nil {
return nil, err
}
return &result, nil
}
// Create creates Log Source Group in the current QRadar installation.
func (c *LogSourceGroupService) Create(ctx context.Context, fields string, data interface{}) (*LogSourceGroup, error) {
req, err := c.client.requestHelp(http.MethodPost, logSourceGroupAPIPrefix, fields, "", 0, 0, nil, data)
if err != nil {
return nil, err
}
var result LogSourceGroup
_, err = c.client.Do(ctx, req, &result)
if err != nil {
return nil, err
}
return &result, nil
}