| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Opsview::REST::Config; |
|
2
|
|
|
|
|
|
|
{ |
|
3
|
|
|
|
|
|
|
$Opsview::REST::Config::VERSION = '0.013'; |
|
4
|
|
|
|
|
|
|
} |
|
5
|
|
|
|
|
|
|
|
|
6
|
9
|
|
|
9
|
|
49
|
use Moo; |
|
|
9
|
|
|
|
|
15
|
|
|
|
9
|
|
|
|
|
57
|
|
|
7
|
9
|
|
|
9
|
|
2723
|
use Carp; |
|
|
9
|
|
|
|
|
18
|
|
|
|
9
|
|
|
|
|
3795
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has base => ( |
|
10
|
|
|
|
|
|
|
is => 'ro', |
|
11
|
|
|
|
|
|
|
default => sub { '/config/' }, |
|
12
|
|
|
|
|
|
|
init_arg => undef, |
|
13
|
|
|
|
|
|
|
); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
with 'Opsview::REST::QueryBuilder'; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has '+path' => ( |
|
18
|
|
|
|
|
|
|
required => 1, |
|
19
|
|
|
|
|
|
|
); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my @valid_types = qw/ |
|
22
|
|
|
|
|
|
|
contact host role servicecheck hosttemplate attribute timeperiod hostgroup |
|
23
|
|
|
|
|
|
|
servicegroup notificationmethod hostcheckcommand keyword monitoringserver |
|
24
|
|
|
|
|
|
|
/; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub BUILDARGS { |
|
27
|
125
|
|
|
125
|
0
|
50768
|
my ($class, $obj_type, @args) = @_; |
|
28
|
|
|
|
|
|
|
|
|
29
|
125
|
100
|
|
|
|
548
|
croak "object type required" unless $obj_type; |
|
30
|
|
|
|
|
|
|
|
|
31
|
124
|
|
|
|
|
143
|
my $id; |
|
32
|
124
|
100
|
|
|
|
385
|
$id = shift @args if (scalar @args & 1 == 1); |
|
33
|
124
|
50
|
|
|
|
343
|
croak "odd number of elements" if (scalar @args & 1 == 1); |
|
34
|
|
|
|
|
|
|
|
|
35
|
124
|
100
|
|
|
|
460
|
if (defined $id) { |
|
36
|
4
|
100
|
|
|
|
16
|
if ($id !~ /^\d+$/) { |
|
37
|
2
|
|
|
|
|
28
|
croak 'id must be numeric'; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
122
|
50
|
|
|
|
264
|
if (defined $obj_type) { |
|
42
|
122
|
50
|
|
|
|
188
|
unless (scalar grep { $obj_type eq $_ } @valid_types) { |
|
|
1586
|
|
|
|
|
3533
|
|
|
43
|
0
|
|
|
|
|
0
|
croak 'object type must be one of: ' . join ' ', @valid_types; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
} else { |
|
46
|
0
|
|
|
|
|
0
|
$obj_type = ''; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
122
|
50
|
|
|
|
247
|
if (@args == 1) { |
|
50
|
0
|
|
|
|
|
0
|
return {}; |
|
51
|
|
|
|
|
|
|
} else { |
|
52
|
122
|
|
|
|
|
160
|
my $path = ''; |
|
53
|
122
|
50
|
|
|
|
277
|
if ($obj_type) { |
|
54
|
122
|
|
|
|
|
142
|
$path = $obj_type; |
|
55
|
122
|
100
|
|
|
|
283
|
$path .= "/$id" if $id; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
return { |
|
59
|
122
|
|
|
|
|
4049
|
path => $path, |
|
60
|
|
|
|
|
|
|
args => { @args }, |
|
61
|
|
|
|
|
|
|
}; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
|
68
|
|
|
|
|
|
|
__END__ |