File Coverage

blib/lib/Zabbix/API/Action.pm
Criterion Covered Total %
statement 18 33 54.5
branch 0 4 0.0
condition n/a
subroutine 6 11 54.5
pod 5 5 100.0
total 29 53 54.7


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