line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package cPanel::APIClient::Request::WHM1; |
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
|
1
|
|
|
1
|
|
10132
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
11
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
4
|
use parent qw( cPanel::APIClient::Request::HTTPBase ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
33
|
use cPanel::APIClient::Utils::JSON (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
12
|
|
16
|
1
|
|
|
1
|
|
315
|
use cPanel::APIClient::Response::WHM1 (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
272
|
|
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
0
|
0
|
0
|
sub HTTP_RESPONSE_CLASS { return 'cPanel::APIClient::Response::WHM1' } |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub new { |
21
|
1
|
|
|
1
|
0
|
1948
|
my ( $class, $func, $args_hr, $metaargs_hr ) = @_; |
22
|
|
|
|
|
|
|
|
23
|
1
|
50
|
|
|
|
4
|
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
|
1
|
|
|
|
|
4
|
return bless [ $func, $args_hr ], $class; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub get_http_url_path { |
33
|
0
|
|
|
0
|
0
|
0
|
my ($self) = @_; |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
0
|
return "/json-api/$self->[0]"; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub get_http_payload { |
39
|
0
|
|
|
0
|
0
|
0
|
my ($self) = @_; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
0
|
local $self->[1]{'api.version'} = 1; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
0
|
require cPanel::APIClient::Utils::HTTPRequest; |
44
|
0
|
|
|
|
|
0
|
return cPanel::APIClient::Utils::HTTPRequest::encode_form( $self->[1] ); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub get_cli_command { |
50
|
1
|
|
|
1
|
0
|
4
|
my ( $self, $authn ) = @_; |
51
|
|
|
|
|
|
|
|
52
|
1
|
|
33
|
|
|
2
|
my $username = $authn && $authn->username(); |
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
329
|
require cPanel::APIClient::Utils::CLIRequest; |
55
|
|
|
|
|
|
|
return ( |
56
|
1
|
50
|
|
|
|
12
|
'/usr/local/cpanel/bin/whmapi1', |
57
|
|
|
|
|
|
|
'--output=json', |
58
|
|
|
|
|
|
|
( $username ? "--user=$username" : () ), |
59
|
|
|
|
|
|
|
$self->[0], |
60
|
|
|
|
|
|
|
cPanel::APIClient::Utils::CLIRequest::to_args( $self->[1] ), |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub parse_cli_response { |
65
|
0
|
|
|
0
|
0
|
|
my ( $self, $resp_body ) = @_; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
my $resp_struct = cPanel::APIClient::Utils::JSON::decode($resp_body); |
68
|
0
|
|
|
|
|
|
return $self->HTTP_RESPONSE_CLASS()->new($resp_struct); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
0
|
|
|
sub _parse_metaargs { die 'Unimplemented' } |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |