line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package API::Plesk::Component; |
2
|
|
|
|
|
|
|
|
3
|
13
|
|
|
13
|
|
1931
|
use strict; |
|
13
|
|
|
|
|
12
|
|
|
13
|
|
|
|
|
279
|
|
4
|
13
|
|
|
13
|
|
36
|
use warnings; |
|
13
|
|
|
|
|
13
|
|
|
13
|
|
|
|
|
215
|
|
5
|
|
|
|
|
|
|
|
6
|
13
|
|
|
13
|
|
35
|
use Carp; |
|
13
|
|
|
|
|
12
|
|
|
13
|
|
|
|
|
6861
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
14
|
|
|
14
|
1
|
57
|
my ( $class, %attrs ) = @_; |
10
|
14
|
|
33
|
|
|
83
|
$class = ref $class || $class; |
11
|
|
|
|
|
|
|
|
12
|
14
|
50
|
|
|
|
65
|
confess "Required API::Plesk object!" unless $attrs{plesk}; |
13
|
|
|
|
|
|
|
|
14
|
14
|
|
|
|
|
137
|
return bless \%attrs, $class; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# API::Plesk object |
18
|
0
|
|
|
0
|
1
|
0
|
sub plesk { $_[0]->{plesk} } |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub check_required_params { |
21
|
19
|
|
|
19
|
0
|
1770
|
my ( $self, $hash, @fields ) = @_; |
22
|
|
|
|
|
|
|
|
23
|
19
|
|
|
|
|
36
|
for my $key ( @fields ) { |
24
|
31
|
100
|
|
|
|
56
|
if ( ref $key ) { |
25
|
|
|
|
|
|
|
confess "Required any of this fields: " . join( ", ", @$key) . "!" |
26
|
8
|
100
|
|
|
|
15
|
unless grep { $hash->{$_} } @$key; |
|
20
|
|
|
|
|
140
|
|
27
|
|
|
|
|
|
|
} else { |
28
|
23
|
100
|
|
|
|
311
|
confess "Required field $key!" unless exists $hash->{$key}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# sort params in right order |
34
|
|
|
|
|
|
|
sub sort_params { |
35
|
13
|
|
|
13
|
0
|
537
|
my ( $self, $params, @fields ) = @_; |
36
|
|
|
|
|
|
|
|
37
|
13
|
|
|
|
|
17
|
my @sorted; |
38
|
13
|
|
|
|
|
18
|
for my $key ( @fields ) { |
39
|
|
|
|
|
|
|
|
40
|
69
|
100
|
|
|
|
91
|
if ( ref $key ) { |
41
|
5
|
|
|
|
|
7
|
($key) = grep { exists $params->{$_} } @$key |
|
12
|
|
|
|
|
19
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
push @sorted, {$key => $params->{$key}} |
44
|
69
|
100
|
|
|
|
135
|
if exists $params->{$key}; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
13
|
|
|
|
|
42
|
return \@sorted; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# check hosting xml section |
52
|
|
|
|
|
|
|
sub check_hosting { |
53
|
8
|
|
|
8
|
0
|
675
|
my ( $self, $params, $required ) = @_; |
54
|
|
|
|
|
|
|
|
55
|
8
|
50
|
|
|
|
24
|
unless ( $params->{hosting} ) { |
56
|
0
|
0
|
|
|
|
0
|
confess "Required hosting!" if $required; |
57
|
0
|
|
|
|
|
0
|
return; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
8
|
|
|
|
|
10
|
my $hosting = $params->{hosting}; |
61
|
8
|
|
|
|
|
13
|
my $type = delete $hosting->{type}; |
62
|
8
|
|
|
|
|
12
|
my $ip = delete $hosting->{ip_address}; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
#confess "Required ip_address" unless $ip; |
65
|
|
|
|
|
|
|
|
66
|
8
|
100
|
66
|
|
|
43
|
if ( $type eq 'vrt_hst' ) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
6
|
|
|
|
|
23
|
$self->check_required_params($hosting, qw(ftp_login ftp_password)); |
69
|
|
|
|
|
|
|
|
70
|
6
|
|
|
|
|
6
|
my @properties; |
71
|
6
|
|
|
|
|
20
|
for my $key ( keys %$hosting ) { |
72
|
|
|
|
|
|
|
push @properties, { property => [ |
73
|
|
|
|
|
|
|
{name => $key}, |
74
|
12
|
|
|
|
|
42
|
{value => $hosting->{$key}} |
75
|
|
|
|
|
|
|
]}; |
76
|
12
|
|
|
|
|
20
|
delete $hosting->{$key}; |
77
|
|
|
|
|
|
|
} |
78
|
6
|
100
|
|
|
|
22
|
push(@properties, { ip_address => $ip }) if $ip; |
79
|
6
|
50
|
|
|
|
21
|
$hosting->{$type} = @properties ? \@properties : ''; |
80
|
|
|
|
|
|
|
|
81
|
6
|
|
|
|
|
16
|
return; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
elsif ( $type eq 'std_fwd' or $type eq 'frm_fwd' ) { |
85
|
|
|
|
|
|
|
|
86
|
1
|
50
|
|
|
|
2
|
confess "Required dest_url field!" unless $hosting->{dest_url}; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
$hosting->{$type} = { |
89
|
|
|
|
|
|
|
dest_url => delete $hosting->{dest_url}, |
90
|
1
|
|
|
|
|
4
|
}; |
91
|
1
|
50
|
|
|
|
2
|
$hosting->{$type}->{ip_address} = $ip if $ip; |
92
|
|
|
|
|
|
|
|
93
|
1
|
|
|
|
|
2
|
return; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
elsif ( $type eq 'none' ) { |
96
|
0
|
|
|
|
|
0
|
$hosting->{$type} = ''; |
97
|
0
|
|
|
|
|
0
|
return; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
1
|
|
|
|
|
118
|
confess "Unknown hosting type!"; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub prepare_filter { |
104
|
1
|
|
|
1
|
0
|
552
|
my ( $self, $filter, %opts ) = @_; |
105
|
|
|
|
|
|
|
|
106
|
1
|
|
|
|
|
2
|
my @filter; |
107
|
1
|
|
50
|
|
|
4
|
my $sort = $opts{sort_keys} || [keys %$filter]; |
108
|
|
|
|
|
|
|
|
109
|
1
|
|
|
|
|
3
|
for my $key ( @$sort ) { |
110
|
2
|
100
|
|
|
|
6
|
if ( ref $filter->{$key} eq 'ARRAY' ) { |
111
|
1
|
|
|
|
|
1
|
for my $value ( @{$filter->{$key}} ) { |
|
1
|
|
|
|
|
3
|
|
112
|
3
|
|
|
|
|
6
|
push @filter, { $key => $value }; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
else { |
116
|
1
|
|
|
|
|
4
|
push @filter, { $key => $filter->{$key} }; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
1
|
50
|
|
|
|
9
|
return @filter ? \@filter : ''; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
1; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
__END__ |