| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package API::Plesk::Response; |
|
3
|
|
|
|
|
|
|
|
|
4
|
16
|
|
|
16
|
|
106
|
use strict; |
|
|
16
|
|
|
|
|
36
|
|
|
|
16
|
|
|
|
|
749
|
|
|
5
|
16
|
|
|
16
|
|
89
|
use warnings; |
|
|
16
|
|
|
|
|
31
|
|
|
|
16
|
|
|
|
|
469
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
16
|
|
|
16
|
|
230
|
use Data::Dumper; |
|
|
16
|
|
|
|
|
28
|
|
|
|
16
|
|
|
|
|
23147
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
|
10
|
4
|
|
|
4
|
1
|
229
|
my ( $class, %attrs) = @_; |
|
11
|
4
|
|
33
|
|
|
29
|
$class = ref $class || $class; |
|
12
|
|
|
|
|
|
|
|
|
13
|
4
|
|
|
|
|
8
|
my $operator = $attrs{operator}; |
|
14
|
4
|
|
|
|
|
8
|
my $operation = $attrs{operation}; |
|
15
|
4
|
|
|
|
|
8
|
my $response = $attrs{response}; |
|
16
|
4
|
|
|
|
|
8
|
my $results = []; |
|
17
|
4
|
|
|
|
|
8
|
my $is_success = 1; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# internal API::Plesk error |
|
20
|
4
|
50
|
|
|
|
22
|
if ( $attrs{error} ) { |
|
|
|
50
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
0
|
$results = [{ |
|
22
|
|
|
|
|
|
|
errcode => '', |
|
23
|
|
|
|
|
|
|
errtext => $attrs{error}, |
|
24
|
|
|
|
|
|
|
status => 'error' |
|
25
|
|
|
|
|
|
|
}]; |
|
26
|
0
|
|
|
|
|
0
|
$is_success = ''; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
# remote system plesk error |
|
29
|
|
|
|
|
|
|
elsif ( exists $response->{packet}->{'system'} ) { |
|
30
|
0
|
|
|
|
|
0
|
$results = [$response->{packet}->{'system'}]; |
|
31
|
0
|
|
|
|
|
0
|
$is_success = ''; |
|
32
|
0
|
|
|
|
|
0
|
$operator = 'system'; |
|
33
|
0
|
|
|
|
|
0
|
$operation = ''; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
else { |
|
36
|
|
|
|
|
|
|
eval { |
|
37
|
4
|
|
|
|
|
8
|
for my $result ( @{$response->{packet}->{$operator}->{$operation}->[0]->{result}} ) { |
|
|
4
|
|
|
|
|
20
|
|
|
38
|
3
|
|
|
|
|
7
|
push @$results, $result; |
|
39
|
3
|
100
|
66
|
|
|
42
|
$is_success = '' if $result->{status} && $result->{status} eq 'error'; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
4
|
|
|
|
|
13
|
1; |
|
42
|
4
|
50
|
|
|
|
32
|
} || do { |
|
43
|
0
|
|
|
|
|
0
|
$results = [{ |
|
44
|
|
|
|
|
|
|
errcode => '', |
|
45
|
|
|
|
|
|
|
errtext => "Internal Plesk error: $_.\nError: $@\nDetails:" . Dumper( $response ), |
|
46
|
|
|
|
|
|
|
status => 'error' |
|
47
|
|
|
|
|
|
|
}]; |
|
48
|
|
|
|
|
|
|
}; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
4
|
|
|
|
|
20
|
my $self = { |
|
52
|
|
|
|
|
|
|
results => $results, |
|
53
|
|
|
|
|
|
|
operator => $operator, |
|
54
|
|
|
|
|
|
|
operation => $operation, |
|
55
|
|
|
|
|
|
|
is_success => $is_success, |
|
56
|
|
|
|
|
|
|
}; |
|
57
|
|
|
|
|
|
|
|
|
58
|
4
|
|
|
|
|
33
|
return bless $self, $class; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
9
|
|
|
9
|
1
|
64
|
sub is_success { $_[0]->{is_success} } |
|
62
|
|
|
|
|
|
|
|
|
63
|
3
|
|
|
3
|
0
|
1595
|
sub id { $_[0]->{results}->[0]->{id} } |
|
64
|
2
|
|
|
2
|
0
|
13
|
sub guid { $_[0]->{results}->[0]->{guid} } |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub data { |
|
67
|
1
|
|
|
1
|
1
|
3
|
my ( $self ) = @_; |
|
68
|
1
|
50
|
|
|
|
6
|
return [] unless $self->is_success; |
|
69
|
1
|
50
|
|
|
|
2
|
return [ map { $_->{data} || () } @{$self->{results}} ]; |
|
|
1
|
|
|
|
|
11
|
|
|
|
1
|
|
|
|
|
4
|
|
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub results { |
|
73
|
1
|
|
|
1
|
1
|
3
|
my ( $self ) = @_; |
|
74
|
1
|
50
|
|
|
|
3
|
return unless $self->is_success; |
|
75
|
1
|
|
50
|
|
|
9
|
return $self->{results} || []; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
1
|
|
|
1
|
1
|
5
|
sub error_code { $_[0]->error_codes->[0]; } |
|
79
|
1
|
|
|
1
|
1
|
5
|
sub error_text { $_[0]->error_texts->[0]; } |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub error { |
|
82
|
1
|
|
|
1
|
1
|
5
|
my ( $self ) = @_; |
|
83
|
1
|
|
50
|
|
|
12
|
return ($self->{results}->[0]->{errcode} || '0') . ': ' . $self->{results}->[0]->{errtext}; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub error_codes { |
|
87
|
2
|
|
|
2
|
1
|
4
|
my ( $self ) = @_; |
|
88
|
2
|
50
|
|
|
|
7
|
return [] if $self->is_success; |
|
89
|
2
|
50
|
|
|
|
3
|
return [ map { $_->{errcode} || () } @{$self->{results}} ]; |
|
|
2
|
|
|
|
|
18
|
|
|
|
2
|
|
|
|
|
5
|
|
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub error_texts { |
|
93
|
2
|
|
|
2
|
1
|
4
|
my ( $self ) = @_; |
|
94
|
2
|
50
|
|
|
|
4
|
return [] if $self->is_success; |
|
95
|
2
|
50
|
|
|
|
4
|
return [ map { $_->{errtext} || () } @{$self->{results}} ]; |
|
|
2
|
|
|
|
|
15
|
|
|
|
2
|
|
|
|
|
8
|
|
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub errors { |
|
99
|
1
|
|
|
1
|
1
|
2
|
my ( $self ) = @_; |
|
100
|
1
|
50
|
|
|
|
4
|
return [] if $self->is_success; |
|
101
|
1
|
|
|
|
|
2
|
my @errors; |
|
102
|
1
|
|
|
|
|
3
|
for ( @{$self->{results}} ) { |
|
|
1
|
|
|
|
|
5
|
|
|
103
|
1
|
|
50
|
|
|
9
|
my $error = ($_->{errcode} || '0') . ': ' . $_->{errtext}; |
|
104
|
1
|
|
|
|
|
4
|
push @errors, $error; |
|
105
|
|
|
|
|
|
|
} |
|
106
|
1
|
|
|
|
|
11
|
return \@errors; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub is_connection_error { |
|
110
|
0
|
|
|
0
|
1
|
|
my ( $self ) = @_; |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
return |
|
113
|
0
|
0
|
0
|
|
|
|
$self->error_text =~ /connection failed/ || |
|
114
|
|
|
|
|
|
|
$self->error_text =~ /connection timeout/ || |
|
115
|
|
|
|
|
|
|
$self->error_text =~ /500\s+/ |
|
116
|
|
|
|
|
|
|
? 1 : 0; |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
1; |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
__END__ |