summaryrefslogtreecommitdiffstats
path: root/pkg/icingadb/v1/command.go
blob: cd4db2a73b71a923ea76c1b1018b622b1ce5d01a (plain)
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
package v1

import (
	"github.com/icinga/icingadb/pkg/contracts"
	"github.com/icinga/icingadb/pkg/types"
)

type Command struct {
	EntityWithChecksum `json:",inline"`
	EnvironmentMeta    `json:",inline"`
	NameCiMeta         `json:",inline"`
	ZoneId             types.Binary `json:"zone_id"`
	Command            string       `json:"command"`
	Timeout            uint32       `json:"timeout"`
}

type CommandArgument struct {
	EntityWithChecksum  `json:",inline"`
	EnvironmentMeta     `json:",inline"`
	ArgumentKey         string       `json:"argument_key"`
	ArgumentValue       types.String `json:"value"`
	ArgumentOrder       types.Int    `json:"order"`
	Description         types.String `json:"description"`
	ArgumentKeyOverride types.String `json:"key"`
	RepeatKey           types.Bool   `json:"repeat_key"`
	Required            types.Bool   `json:"required"`
	SetIf               types.String `json:"set_if"`
	Separator           types.String `json:"separator"`
	SkipKey             types.Bool   `json:"skip_key"`
}

// Init implements the contracts.Initer interface.
func (ca *CommandArgument) Init() {
	ca.RepeatKey = types.Bool{
		Bool:  true,
		Valid: true,
	}

	ca.Required = types.Bool{
		Bool:  false,
		Valid: true,
	}

	ca.SkipKey = types.Bool{
		Bool:  false,
		Valid: true,
	}
}

type CommandEnvvar struct {
	EntityWithChecksum `json:",inline"`
	EnvironmentMeta    `json:",inline"`
	EnvvarKey          string `json:"envvar_key"`
	EnvvarValue        string `json:"value"`
}

type Checkcommand struct {
	Command `json:",inline"`
}

type CheckcommandArgument struct {
	CommandArgument `json:",inline"`
	CheckcommandId  types.Binary `json:"checkcommand_id"`
}

type CheckcommandEnvvar struct {
	CommandEnvvar  `json:",inline"`
	CheckcommandId types.Binary `json:"checkcommand_id"`
}

type CheckcommandCustomvar struct {
	CustomvarMeta  `json:",inline"`
	CheckcommandId types.Binary `json:"checkcommand_id"`
}

type Eventcommand struct {
	Command `json:",inline"`
}

type EventcommandArgument struct {
	CommandArgument `json:",inline"`
	EventcommandId  types.Binary `json:"eventcommand_id"`
}

type EventcommandEnvvar struct {
	CommandEnvvar  `json:",inline"`
	EventcommandId types.Binary `json:"eventcommand_id"`
}

type EventcommandCustomvar struct {
	CustomvarMeta  `json:",inline"`
	EventcommandId types.Binary `json:"eventcommand_id"`
}

type Notificationcommand struct {
	Command `json:",inline"`
}

type NotificationcommandArgument struct {
	CommandArgument       `json:",inline"`
	NotificationcommandId types.Binary `json:"notificationcommand_id"`
}

type NotificationcommandEnvvar struct {
	CommandEnvvar         `json:",inline"`
	NotificationcommandId types.Binary `json:"notificationcommand_id"`
}

type NotificationcommandCustomvar struct {
	CustomvarMeta         `json:",inline"`
	NotificationcommandId types.Binary `json:"notificationcommand_id"`
}

func NewCheckcommand() contracts.Entity {
	return &Checkcommand{}
}

func NewCheckcommandArgument() contracts.Entity {
	return &CheckcommandArgument{}
}

func NewCheckcommandEnvvar() contracts.Entity {
	return &CheckcommandEnvvar{}
}

func NewCheckcommandCustomvar() contracts.Entity {
	return &CheckcommandCustomvar{}
}

func NewEventcommand() contracts.Entity {
	return &Eventcommand{}
}

func NewEventcommandArgument() contracts.Entity {
	return &EventcommandArgument{}
}

func NewEventcommandEnvvar() contracts.Entity {
	return &EventcommandEnvvar{}
}

func NewEventcommandCustomvar() contracts.Entity {
	return &EventcommandCustomvar{}
}

func NewNotificationcommand() contracts.Entity {
	return &Notificationcommand{}
}

func NewNotificationcommandArgument() contracts.Entity {
	return &NotificationcommandArgument{}
}

func NewNotificationcommandEnvvar() contracts.Entity {
	return &NotificationcommandEnvvar{}
}

func NewNotificationcommandCustomvar() contracts.Entity {
	return &NotificationcommandCustomvar{}
}

// Assert interface compliance.
var (
	_ contracts.Initer = (*Command)(nil)
	_ contracts.Initer = (*CommandArgument)(nil)
	_ contracts.Initer = (*Checkcommand)(nil)
	_ contracts.Initer = (*Eventcommand)(nil)
	_ contracts.Initer = (*Notificationcommand)(nil)
)