| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package API::Plesk::Response; |
|
3
|
|
|
|
|
|
|
|
|
4
|
14
|
|
|
14
|
|
55
|
use strict; |
|
|
14
|
|
|
|
|
25
|
|
|
|
14
|
|
|
|
|
478
|
|
|
5
|
14
|
|
|
14
|
|
48
|
use warnings; |
|
|
14
|
|
|
|
|
17
|
|
|
|
14
|
|
|
|
|
326
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
14
|
|
|
14
|
|
46
|
use Data::Dumper; |
|
|
14
|
|
|
|
|
14
|
|
|
|
14
|
|
|
|
|
8488
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
|
10
|
3
|
|
|
3
|
1
|
124
|
my ( $class, %attrs) = @_; |
|
11
|
3
|
|
33
|
|
|
14
|
$class = ref $class || $class; |
|
12
|
|
|
|
|
|
|
|
|
13
|
3
|
|
|
|
|
6
|
my $operator = $attrs{operator}; |
|
14
|
3
|
|
|
|
|
4
|
my $operation = $attrs{operation}; |
|
15
|
3
|
|
|
|
|
5
|
my $response = $attrs{response}; |
|
16
|
3
|
|
|
|
|
3
|
my $results = []; |
|
17
|
3
|
|
|
|
|
3
|
my $is_success = 1; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# internal API::Plesk error |
|
20
|
3
|
50
|
|
|
|
11
|
if ( $attrs{error} ) { |
|
|
|
50
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
$results = [{ |
|
22
|
|
|
|
|
|
|
errcode => '', |
|
23
|
|
|
|
|
|
|
errtext => $attrs{error}, |
|
24
|
0
|
|
|
|
|
0
|
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
|
3
|
|
|
|
|
21
|
for my $result ( @{$response->{packet}->{$operator}->{$operation}->[0]->{result}} ) { |
|
|
3
|
|
|
|
|
13
|
|
|
37
|
2
|
|
|
|
|
3
|
push @$results, $result; |
|
38
|
2
|
100
|
66
|
|
|
13
|
$is_success = '' if $result->{status} && $result->{status} eq 'error'; |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
3
|
|
|
|
|
9
|
my $self = { |
|
44
|
|
|
|
|
|
|
results => $results, |
|
45
|
|
|
|
|
|
|
operator => $operator, |
|
46
|
|
|
|
|
|
|
operation => $operation, |
|
47
|
|
|
|
|
|
|
is_success => $is_success, |
|
48
|
|
|
|
|
|
|
}; |
|
49
|
|
|
|
|
|
|
|
|
50
|
3
|
|
|
|
|
13
|
return bless $self, $class; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
9
|
|
|
9
|
1
|
36
|
sub is_success { $_[0]->{is_success} } |
|
54
|
|
|
|
|
|
|
|
|
55
|
2
|
|
|
2
|
0
|
10
|
sub id { $_[0]->{results}->[0]->{id} } |
|
56
|
2
|
|
|
2
|
0
|
7
|
sub guid { $_[0]->{results}->[0]->{guid} } |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub data { |
|
59
|
1
|
|
|
1
|
1
|
3
|
my ( $self ) = @_; |
|
60
|
1
|
50
|
|
|
|
2
|
return [] unless $self->is_success; |
|
61
|
1
|
50
|
|
|
|
2
|
return [ map { $_->{data} || () } @{$self->{results}} ]; |
|
|
1
|
|
|
|
|
8
|
|
|
|
1
|
|
|
|
|
2
|
|
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub results { |
|
65
|
1
|
|
|
1
|
1
|
2
|
my ( $self ) = @_; |
|
66
|
1
|
50
|
|
|
|
2
|
return undef unless $self->is_success; |
|
67
|
1
|
|
50
|
|
|
6
|
return $self->{results} || []; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
1
|
|
|
1
|
1
|
5
|
sub error_code { $_[0]->error_codes->[0]; } |
|
71
|
1
|
|
|
1
|
1
|
4
|
sub error_text { $_[0]->error_texts->[0]; } |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub error { |
|
74
|
1
|
|
|
1
|
1
|
3
|
my ( $self ) = @_; |
|
75
|
1
|
|
50
|
|
|
11
|
return ($self->{results}->[0]->{errcode} || '0') . ': ' . $self->{results}->[0]->{errtext}; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub error_codes { |
|
79
|
2
|
|
|
2
|
1
|
3
|
my ( $self ) = @_; |
|
80
|
2
|
50
|
|
|
|
4
|
return [] if $self->is_success; |
|
81
|
2
|
50
|
|
|
|
3
|
return [ map { $_->{errcode} || () } @{$self->{results}} ]; |
|
|
2
|
|
|
|
|
16
|
|
|
|
2
|
|
|
|
|
3
|
|
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub error_texts { |
|
85
|
2
|
|
|
2
|
1
|
5
|
my ( $self ) = @_; |
|
86
|
2
|
50
|
|
|
|
3
|
return [] if $self->is_success; |
|
87
|
2
|
50
|
|
|
|
3
|
return [ map { $_->{errtext} || () } @{$self->{results}} ]; |
|
|
2
|
|
|
|
|
12
|
|
|
|
2
|
|
|
|
|
4
|
|
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub errors { |
|
91
|
1
|
|
|
1
|
1
|
1
|
my ( $self ) = @_; |
|
92
|
1
|
50
|
|
|
|
3
|
return [] if $self->is_success; |
|
93
|
1
|
|
|
|
|
1
|
my @errors; |
|
94
|
1
|
|
|
|
|
2
|
for ( @{$self->{results}} ) { |
|
|
1
|
|
|
|
|
3
|
|
|
95
|
1
|
|
50
|
|
|
5
|
my $error = ($_->{errcode} || '0') . ': ' . $_->{errtext}; |
|
96
|
1
|
|
|
|
|
2
|
push @errors, $error; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
1
|
|
|
|
|
8
|
return \@errors; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub is_connection_error { |
|
102
|
0
|
|
|
0
|
1
|
|
my ( $self ) = @_; |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
return |
|
105
|
0
|
0
|
0
|
|
|
|
$self->error_text eq 'connection timeout' || |
|
106
|
|
|
|
|
|
|
$self->error_text eq '500 SSL read timeout' |
|
107
|
|
|
|
|
|
|
? 1 : 0; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
1; |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
__END__ |