This repository has been archived by the owner on Jun 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
stream_rule.go
47 lines (42 loc) · 1.72 KB
/
stream_rule.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
package graylog
import (
"github.com/suzuki-shunsuke/go-ptr"
)
// StreamRule represents a stream rule.
type StreamRule struct {
ID string `json:"id,omitempty" v-create:"isdefault"`
StreamID string `json:"stream_id,omitempty" v-create:"required"`
Field string `json:"field,omitempty" v-create:"required"`
Value string `json:"value,omitempty" v-create:"required"`
Description string `json:"description,omitempty"`
Type int `json:"type,omitempty"`
Inverted bool `json:"inverted,omitempty"`
}
// StreamRuleUpdateParams represents Update Stream API's paramteres.
type StreamRuleUpdateParams struct {
ID string `json:"id,omitempty" v-update:"required,objectid"`
StreamID string `json:"stream_id,omitempty" v-update:"required,objectid"`
Field string `json:"field,omitempty" v-update:"required"`
Value string `json:"value,omitempty" v-update:"required"`
Description string `json:"description,omitempty"`
Type *int `json:"type,omitempty"`
Inverted *bool `json:"inverted,omitempty"`
}
// NewUpdateParams converts StreamRule to StreamRuleUpdateParams.
func (rule *StreamRule) NewUpdateParams() *StreamRuleUpdateParams {
return &StreamRuleUpdateParams{
ID: rule.ID,
StreamID: rule.StreamID,
Field: rule.Field,
Description: rule.Description,
Type: ptr.PInt(rule.Type),
Inverted: ptr.PBool(rule.Inverted),
Value: rule.Value,
}
}
// StreamRulesBody represents Get stream rules API's response body.
// Basically users don't use this struct, but this struct is public because some sub packages use this struct.
type StreamRulesBody struct {
Total int `json:"total"`
StreamRules []StreamRule `json:"stream_rules"`
}