File Coverage

blib/lib/Zabbix2/API/Action.pm
Criterion Covered Total %
statement 18 31 58.0
branch 0 4 0.0
condition n/a
subroutine 6 11 54.5
pod 2 2 100.0
total 26 48 54.1


line stmt bran cond sub pod time code
1             package Zabbix2::API::Action;
2              
3 1     1   6508 use strict;
  1         3  
  1         34  
4 1     1   4 use warnings;
  1         2  
  1         24  
5 1     1   14 use 5.010;
  1         3  
  1         25  
6 1     1   3 use Carp;
  1         2  
  1         80  
7              
8 1     1   5 use Moo::Lax;
  1         1  
  1         6  
9             extends qw/Exporter Zabbix2::API::CRUDE/;
10              
11             use constant {
12 1         558 ACTION_EVENTSOURCE_TRIGGERS => 0,
13             ACTION_EVENTSOURCE_DISCOVERY => 1,
14             ACTION_EVENTSOURCE_AUTOREGISTRATION => 2,
15              
16             ACTION_CONDITION_TYPE_HOST_GROUP => 0,
17             ACTION_CONDITION_TYPE_HOST => 1,
18             ACTION_CONDITION_TYPE_TRIGGER => 2,
19             ACTION_CONDITION_TYPE_TRIGGER_NAME => 3,
20             ACTION_CONDITION_TYPE_TRIGGER_SEVERITY => 4,
21             ACTION_CONDITION_TYPE_TRIGGER_VALUE => 5,
22             ACTION_CONDITION_TYPE_TIME_PERIOD => 6,
23             ACTION_CONDITION_TYPE_DHOST_IP => 7,
24             ACTION_CONDITION_TYPE_DSERVICE_TYPE => 8,
25             ACTION_CONDITION_TYPE_DSERVICE_PORT => 9,
26             ACTION_CONDITION_TYPE_DSTATUS => 10,
27             ACTION_CONDITION_TYPE_DUPTIME => 11,
28             ACTION_CONDITION_TYPE_DVALUE => 12,
29             ACTION_CONDITION_TYPE_HOST_TEMPLATE => 13,
30             ACTION_CONDITION_TYPE_EVENT_ACKNOWLEDGED => 14,
31             ACTION_CONDITION_TYPE_APPLICATION => 15,
32             ACTION_CONDITION_TYPE_MAINTENANCE => 16,
33             ACTION_CONDITION_TYPE_NODE => 17,
34             ACTION_CONDITION_TYPE_DRULE => 18,
35             ACTION_CONDITION_TYPE_DCHECK => 19,
36             ACTION_CONDITION_TYPE_PROXY => 20,
37             ACTION_CONDITION_TYPE_DOBJECT => 21,
38             ACTION_CONDITION_TYPE_HOST_NAME => 22,
39              
40             ACTION_CONDITION_OPERATOR_EQUAL => 0,
41             ACTION_CONDITION_OPERATOR_NOT_EQUAL => 1,
42             ACTION_CONDITION_OPERATOR_LIKE => 2,
43             ACTION_CONDITION_OPERATOR_NOT_LIKE => 3,
44             ACTION_CONDITION_OPERATOR_IN => 4,
45             ACTION_CONDITION_OPERATOR_MORE_EQUAL => 5,
46             ACTION_CONDITION_OPERATOR_LESS_EQUAL => 6,
47             ACTION_CONDITION_OPERATOR_NOT_IN => 7,
48              
49             ACTION_OPERATION_TYPE_MESSAGE => 0,
50             ACTION_OPERATION_TYPE_COMMAND => 1,
51             ACTION_OPERATION_TYPE_HOST_ADD => 2,
52             ACTION_OPERATION_TYPE_HOST_REMOVE => 3,
53             ACTION_OPERATION_TYPE_GROUP_ADD => 4,
54             ACTION_OPERATION_TYPE_GROUP_REMOVE => 5,
55             ACTION_OPERATION_TYPE_TEMPLATE_ADD => 6,
56             ACTION_OPERATION_TYPE_TEMPLATE_REMOVE => 7,
57             ACTION_OPERATION_TYPE_HOST_ENABLE => 8,
58             ACTION_OPERATION_TYPE_HOST_DISABLE => 9,
59              
60             ACTION_EVAL_TYPE_AND_OR => 0,
61             ACTION_EVAL_TYPE_AND => 1,
62             ACTION_EVAL_TYPE_OR => 2,
63 1     1   723 };
  1         1  
64              
65             our @EXPORT_OK = qw/
66             ACTION_EVENTSOURCE_TRIGGERS
67             ACTION_EVENTSOURCE_DISCOVERY
68             ACTION_EVENTSOURCE_AUTOREGISTRATION
69             ACTION_CONDITION_TYPE_HOST_GROUP
70             ACTION_CONDITION_TYPE_HOST
71             ACTION_CONDITION_TYPE_TRIGGER
72             ACTION_CONDITION_TYPE_TRIGGER_NAME
73             ACTION_CONDITION_TYPE_TRIGGER_SEVERITY
74             ACTION_CONDITION_TYPE_TRIGGER_VALUE
75             ACTION_CONDITION_TYPE_TIME_PERIOD
76             ACTION_CONDITION_TYPE_DHOST_IP
77             ACTION_CONDITION_TYPE_DSERVICE_TYPE
78             ACTION_CONDITION_TYPE_DSERVICE_PORT
79             ACTION_CONDITION_TYPE_DSTATUS
80             ACTION_CONDITION_TYPE_DUPTIME
81             ACTION_CONDITION_TYPE_DVALUE
82             ACTION_CONDITION_TYPE_HOST_TEMPLATE
83             ACTION_CONDITION_TYPE_EVENT_ACKNOWLEDGED
84             ACTION_CONDITION_TYPE_APPLICATION
85             ACTION_CONDITION_TYPE_MAINTENANCE
86             ACTION_CONDITION_TYPE_NODE
87             ACTION_CONDITION_TYPE_DRULE
88             ACTION_CONDITION_TYPE_DCHECK
89             ACTION_CONDITION_TYPE_PROXY
90             ACTION_CONDITION_TYPE_DOBJECT
91             ACTION_CONDITION_TYPE_HOST_NAME
92             ACTION_CONDITION_OPERATOR_EQUAL
93             ACTION_CONDITION_OPERATOR_NOT_EQUAL
94             ACTION_CONDITION_OPERATOR_LIKE
95             ACTION_CONDITION_OPERATOR_NOT_LIKE
96             ACTION_CONDITION_OPERATOR_IN
97             ACTION_CONDITION_OPERATOR_MORE_EQUAL
98             ACTION_CONDITION_OPERATOR_LESS_EQUAL
99             ACTION_CONDITION_OPERATOR_NOT_IN
100             ACTION_OPERATION_TYPE_MESSAGE
101             ACTION_OPERATION_TYPE_COMMAND
102             ACTION_OPERATION_TYPE_HOST_ADD
103             ACTION_OPERATION_TYPE_HOST_REMOVE
104             ACTION_OPERATION_TYPE_GROUP_ADD
105             ACTION_OPERATION_TYPE_GROUP_REMOVE
106             ACTION_OPERATION_TYPE_TEMPLATE_ADD
107             ACTION_OPERATION_TYPE_TEMPLATE_REMOVE
108             ACTION_OPERATION_TYPE_HOST_ENABLE
109             ACTION_OPERATION_TYPE_HOST_DISABLE
110             ACTION_EVAL_TYPE_AND_OR
111             ACTION_EVAL_TYPE_AND
112             ACTION_EVAL_TYPE_OR/;
113              
114             our %EXPORT_TAGS = (
115             eventsources => [
116             qw/ACTION_EVENTSOURCE_TRIGGERS
117             ACTION_EVENTSOURCE_DISCOVERY
118             ACTION_EVENTSOURCE_AUTOREGISTRATION/
119             ],
120             condition_types => [
121             qw/ACTION_CONDITION_TYPE_HOST_GROUP
122             ACTION_CONDITION_TYPE_HOST
123             ACTION_CONDITION_TYPE_TRIGGER
124             ACTION_CONDITION_TYPE_TRIGGER_NAME
125             ACTION_CONDITION_TYPE_TRIGGER_SEVERITY
126             ACTION_CONDITION_TYPE_TRIGGER_VALUE
127             ACTION_CONDITION_TYPE_TIME_PERIOD
128             ACTION_CONDITION_TYPE_DHOST_IP
129             ACTION_CONDITION_TYPE_DSERVICE_TYPE
130             ACTION_CONDITION_TYPE_DSERVICE_PORT
131             ACTION_CONDITION_TYPE_DSTATUS
132             ACTION_CONDITION_TYPE_DUPTIME
133             ACTION_CONDITION_TYPE_DVALUE
134             ACTION_CONDITION_TYPE_HOST_TEMPLATE
135             ACTION_CONDITION_TYPE_EVENT_ACKNOWLEDGED
136             ACTION_CONDITION_TYPE_APPLICATION
137             ACTION_CONDITION_TYPE_MAINTENANCE
138             ACTION_CONDITION_TYPE_NODE
139             ACTION_CONDITION_TYPE_DRULE
140             ACTION_CONDITION_TYPE_DCHECK
141             ACTION_CONDITION_TYPE_PROXY
142             ACTION_CONDITION_TYPE_DOBJECT
143             ACTION_CONDITION_TYPE_HOST_NAME/
144             ],
145             condition_operators => [
146             qw/ACTION_CONDITION_OPERATOR_EQUAL
147             ACTION_CONDITION_OPERATOR_NOT_EQUAL
148             ACTION_CONDITION_OPERATOR_LIKE
149             ACTION_CONDITION_OPERATOR_NOT_LIKE
150             ACTION_CONDITION_OPERATOR_IN
151             ACTION_CONDITION_OPERATOR_MORE_EQUAL
152             ACTION_CONDITION_OPERATOR_LESS_EQUAL
153             ACTION_CONDITION_OPERATOR_NOT_IN/
154             ],
155             operation_types => [
156             qw/ACTION_OPERATION_TYPE_MESSAGE
157             ACTION_OPERATION_TYPE_COMMAND
158             ACTION_OPERATION_TYPE_HOST_ADD
159             ACTION_OPERATION_TYPE_HOST_REMOVE
160             ACTION_OPERATION_TYPE_GROUP_ADD
161             ACTION_OPERATION_TYPE_GROUP_REMOVE
162             ACTION_OPERATION_TYPE_TEMPLATE_ADD
163             ACTION_OPERATION_TYPE_TEMPLATE_REMOVE
164             ACTION_OPERATION_TYPE_HOST_ENABLE
165             ACTION_OPERATION_TYPE_HOST_DISABLE/
166             ],
167             eval_types => [
168             qw/ACTION_EVAL_TYPE_AND_OR
169             ACTION_EVAL_TYPE_AND
170             ACTION_EVAL_TYPE_OR/
171             ],
172             );
173              
174             sub id {
175             ## mutator for id
176 0     0 1   my ($self, $value) = @_;
177 0 0         if (defined $value) {
178 0           $self->data->{actionid} = $value;
179 0           return $self->data->{actionid};
180             } else {
181 0           return $self->data->{actionid};
182             }
183             }
184              
185             sub _prefix {
186 0     0     my (undef, $suffix) = @_;
187 0 0         if ($suffix) {
188 0           return 'action'.$suffix;
189             } else {
190 0           return 'action';
191             }
192             }
193              
194             sub _readonly_properties {
195             return {
196 0     0     actionid => 1,
197             };
198             }
199              
200             sub _extension {
201 0     0     return (output => 'extend',
202             select_conditions => 'extend',
203             select_operations => 'extend');
204              
205             }
206              
207             sub name {
208 0     0 1   my $self = shift;
209 0           return $self->data->{name};
210             }
211              
212             1;
213             __END__