line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Zabbix2::API::Application; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
566
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
35
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
5
|
1
|
|
|
1
|
|
23
|
use 5.010; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
32
|
|
6
|
1
|
|
|
1
|
|
7
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
68
|
|
7
|
1
|
|
|
1
|
|
5
|
use autodie; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
8
|
|
8
|
1
|
|
|
1
|
|
3680
|
use utf8; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
19
|
use Moo::Lax; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
8
|
|
11
|
|
|
|
|
|
|
extends qw/Zabbix2::API::CRUDE/; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has 'items' => (is => 'ro', |
14
|
|
|
|
|
|
|
lazy => 1, |
15
|
|
|
|
|
|
|
builder => '_fetch_items'); |
16
|
|
|
|
|
|
|
has 'host' => (is => 'ro', |
17
|
|
|
|
|
|
|
lazy => 1, |
18
|
|
|
|
|
|
|
builder => '_fetch_host'); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub id { |
21
|
|
|
|
|
|
|
## mutator for id |
22
|
0
|
|
|
0
|
1
|
|
my ($self, $value) = @_; |
23
|
0
|
0
|
|
|
|
|
if (defined $value) { |
24
|
0
|
|
|
|
|
|
$self->data->{applicationid} = $value; |
25
|
0
|
|
|
|
|
|
return $self->data->{applicationid}; |
26
|
|
|
|
|
|
|
} else { |
27
|
0
|
|
|
|
|
|
return $self->data->{applicationid}; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _readonly_properties { |
32
|
|
|
|
|
|
|
return { |
33
|
0
|
|
|
0
|
|
|
applicationid => 1, |
34
|
|
|
|
|
|
|
# 2.2 uses templateids, 2.0 uses templateid, neither are updatable |
35
|
|
|
|
|
|
|
templateids => 1, |
36
|
|
|
|
|
|
|
templateid => 1, |
37
|
|
|
|
|
|
|
}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _prefix { |
41
|
0
|
|
|
0
|
|
|
my (undef, $suffix) = @_; |
42
|
0
|
0
|
|
|
|
|
if ($suffix) { |
43
|
0
|
|
|
|
|
|
return 'application'.$suffix; |
44
|
|
|
|
|
|
|
} else { |
45
|
0
|
|
|
|
|
|
return 'application'; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub _extension { |
50
|
0
|
|
|
0
|
|
|
return (output => 'extend'); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub name { |
54
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
55
|
0
|
|
0
|
|
|
|
return $self->data->{name} || '???'; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _fetch_items { |
59
|
0
|
|
|
0
|
|
|
my $self = shift; |
60
|
0
|
|
|
|
|
|
my $items = $self->{root}->fetch('Item', params => { applicationids => [ $self->id ] }); |
61
|
0
|
|
|
|
|
|
return $items; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub _fetch_host { |
65
|
0
|
|
|
0
|
|
|
my $self = shift; |
66
|
0
|
|
|
|
|
|
my $host = $self->{root}->fetch_single('Host', params => { hostids => [ $self->data->{hostid} ] }); |
67
|
0
|
|
|
|
|
|
return $host; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
before 'update' => sub { |
71
|
|
|
|
|
|
|
# you can create an Application with a hostid, but you can never |
72
|
|
|
|
|
|
|
# update it |
73
|
|
|
|
|
|
|
my ($self) = @_; |
74
|
|
|
|
|
|
|
delete $self->data->{hostid}; |
75
|
|
|
|
|
|
|
}; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
__END__ |