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
|
|
12880
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
29
|
|
11
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
6
|
use parent qw( cPanel::APIClient::Request::HTTPBase ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
44
|
use cPanel::APIClient::Utils::JSON (); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
14
|
|
16
|
1
|
|
|
1
|
|
402
|
use cPanel::APIClient::Response::WHM1 (); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
384
|
|
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
0
|
0
|
0
|
sub HTTP_RESPONSE_CLASS { return 'cPanel::APIClient::Response::WHM1' } |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub new { |
21
|
1
|
|
|
1
|
0
|
2502
|
my ( $class, $func, $args_hr, $metaargs_hr ) = @_; |
22
|
|
|
|
|
|
|
|
23
|
1
|
50
|
|
|
|
5
|
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
|
7
|
my ( $self, $authn ) = @_; |
51
|
|
|
|
|
|
|
|
52
|
1
|
|
33
|
|
|
4
|
my $username = $authn && $authn->username(); |
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
413
|
require cPanel::APIClient::Utils::CLIRequest; |
55
|
|
|
|
|
|
|
return ( |
56
|
1
|
50
|
|
|
|
21
|
'/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; |