line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package cPanel::APIClient::Request::UAPI; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Copyright 2020 cPanel, L. L. C. |
4
|
|
|
|
|
|
|
# All rights reserved. |
5
|
|
|
|
|
|
|
# http://cpanel.net |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under the |
8
|
|
|
|
|
|
|
# same terms as Perl itself. See L. |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
57
|
|
11
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
53
|
|
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
11
|
use parent qw( cPanel::APIClient::Request::HTTPBase ); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
9
|
|
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
2
|
|
85
|
use cPanel::APIClient::Utils::JSON (); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
28
|
|
16
|
2
|
|
|
2
|
|
789
|
use cPanel::APIClient::Response::UAPI (); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
748
|
|
17
|
|
|
|
|
|
|
|
18
|
4
|
|
|
4
|
0
|
26
|
sub HTTP_RESPONSE_CLASS { return 'cPanel::APIClient::Response::UAPI' } |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub new { |
21
|
7
|
|
|
7
|
0
|
27
|
my ( $class, $module, $func, $args_hr, $metaargs_hr ) = @_; |
22
|
|
|
|
|
|
|
|
23
|
7
|
50
|
|
|
|
70
|
if ($metaargs_hr) { |
24
|
0
|
|
|
|
|
0
|
my %args_copy = %$args_hr; |
25
|
0
|
|
|
|
|
0
|
_parse_metaargs( $metaargs_hr, \%args_copy ); |
26
|
0
|
|
|
|
|
0
|
$args_hr = \%args_copy; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
7
|
|
|
|
|
31
|
return bless [ $module, $func, $args_hr ], $class; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub get_http_url_path { |
33
|
7
|
|
|
7
|
0
|
16
|
my ($self) = @_; |
34
|
|
|
|
|
|
|
|
35
|
7
|
|
|
|
|
27
|
return "/execute/$self->[0]/$self->[1]"; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub get_http_payload { |
39
|
7
|
|
|
7
|
0
|
19
|
my ($self) = @_; |
40
|
|
|
|
|
|
|
|
41
|
7
|
|
|
|
|
832
|
require cPanel::APIClient::Utils::HTTPRequest; |
42
|
7
|
|
|
|
|
56
|
return cPanel::APIClient::Utils::HTTPRequest::encode_form( $self->[2] ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub get_cli_command { |
48
|
0
|
|
|
0
|
0
|
|
my ( $self, $authn ) = @_; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
0
|
|
|
|
my $username = $authn && $authn->username(); |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
require cPanel::APIClient::Utils::CLIRequest; |
53
|
|
|
|
|
|
|
return ( |
54
|
|
|
|
|
|
|
'/usr/local/cpanel/bin/uapi', |
55
|
|
|
|
|
|
|
'--output=json', |
56
|
|
|
|
|
|
|
( $username ? "--user=$username" : () ), |
57
|
0
|
0
|
|
|
|
|
@{$self}[ 0, 1 ], |
|
0
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
cPanel::APIClient::Utils::CLIRequest::to_args( $self->[2] ), |
59
|
|
|
|
|
|
|
); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub parse_cli_response { |
63
|
0
|
|
|
0
|
0
|
|
my ( $self, $resp_body ) = @_; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my $resp_struct = cPanel::APIClient::Utils::JSON::decode($resp_body); |
66
|
0
|
|
|
|
|
|
$resp_struct = $resp_struct->{'result'}; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
return cPanel::APIClient::Response::UAPI->new($resp_struct); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# sub _parse_metaargs { die 'Unimplemented' } |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |