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