This repository has been archived by the owner on Jun 1, 2023. It is now read-only.
/
stream.go
78 lines (70 loc) · 3.66 KB
/
stream.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
package graylog
import (
"github.com/suzuki-shunsuke/go-ptr"
)
// CloneStream
// POST /streams/{streamID}/clone Clone a stream
// TestMatchStream
// POST /streams/{streamID}/testMatch Test matching of a stream against a supplied message
// Stream represents a steram.
type Stream struct {
ID string `json:"id,omitempty" v-create:"isdefault" v-update:"required,objectid"`
Title string `json:"title,omitempty" v-create:"required"`
IndexSetID string `json:"index_set_id,omitempty" v-create:"required"`
// ex. "2018-02-20T11:37:19.371Z"
CreatedAt string `json:"created_at,omitempty" v-create:"isdefault"`
// ex. local:admin
CreatorUserID string `json:"creator_user_id,omitempty" v-create:"isdefault"`
Description string `json:"description,omitempty"`
// ex. "AND"
MatchingType string `json:"matching_type,omitempty"`
Outputs []Output `json:"outputs,omitempty" v-create:"isdefault"`
Rules []StreamRule `json:"rules,omitempty"`
AlertConditions []AlertCondition `json:"alert_conditions,omitempty" v-create:"isdefault"`
AlertReceivers *AlertReceivers `json:"alert_receivers,omitempty" v-create:"isdefault"`
Disabled bool `json:"disabled,omitempty" v-create:"isdefault"`
RemoveMatchesFromDefaultStream bool `json:"remove_matches_from_default_stream,omitempty"`
IsDefault bool `json:"is_default,omitempty" v-create:"isdefault"`
// ContentPack `json:"content_pack,omitempty"`
}
// StreamUpdateParams represents a steram update params.
type StreamUpdateParams struct {
ID string `json:"id,omitempty" v-update:"required,objectid"`
Title string `json:"title,omitempty"`
IndexSetID string `json:"index_set_id,omitempty"`
Description string `json:"description,omitempty"`
Outputs []Output `json:"outputs,omitempty"`
MatchingType string `json:"matching_type,omitempty"`
Rules []StreamRule `json:"rules,omitempty"`
AlertConditions []AlertCondition `json:"alert_conditions,omitempty"`
AlertReceivers *AlertReceivers `json:"alert_receivers,omitempty"`
RemoveMatchesFromDefaultStream *bool `json:"remove_matches_from_default_stream,omitempty"`
}
// NewUpdateParams converts Stream to StreamUpdateParams.
func (stream *Stream) NewUpdateParams() *StreamUpdateParams {
return &StreamUpdateParams{
ID: stream.ID,
Title: stream.Title,
IndexSetID: stream.IndexSetID,
Description: stream.Description,
Outputs: stream.Outputs,
MatchingType: stream.MatchingType,
Rules: stream.Rules,
AlertConditions: stream.AlertConditions,
AlertReceivers: stream.AlertReceivers,
RemoveMatchesFromDefaultStream: ptr.PBool(stream.RemoveMatchesFromDefaultStream),
}
}
// Output represents an output.
type Output struct{}
// AlertReceivers represents alert receivers.
type AlertReceivers struct {
Emails []string `json:"emails,omitempty"`
Users []string `json:"users,omitempty"`
}
// StreamsBody represents Get Streams API's response body.
// Basically users don't use this struct, but this struct is public because some sub packages use this struct.
type StreamsBody struct {
Total int `json:"total,omitempty"`
Streams []Stream `json:"streams,omitempty"`
}