line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package cPanel::APIClient::Service::whm; |
2
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
4065
|
use strict; |
|
10
|
|
|
|
|
21
|
|
|
10
|
|
|
|
|
318
|
|
4
|
10
|
|
|
10
|
|
52
|
use warnings; |
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
331
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=encoding utf-8 |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
cPanel::APIClient::Service::whm - WebHost Manager access |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
If your transport uses blocking I/O: |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $resp = $client->call_api1('listaccts', \%args); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $pops_ar = $resp->get_data(); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
If your transport uses non-blocking I/O: |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $call = $client->call_api1('listaccts', \%args); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
$call->promise()->then( sub { |
25
|
|
|
|
|
|
|
my ($resp) = @_; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $pops_ar = $resp->get_data(); |
28
|
|
|
|
|
|
|
} ); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Some non-blocking transports support canceling in-progress requests, thus: |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$client->cancel($call, ..); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
See your transport’s documentation for more details. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 DESCRIPTION |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
This class stores a WHM API access configuration and exposes |
39
|
|
|
|
|
|
|
methods to call WHM APIs. It extends L. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Don’t try to create this object directly; instead, let |
42
|
|
|
|
|
|
|
Ccreate()> do it for you. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
47
|
|
|
|
|
|
|
|
48
|
10
|
|
|
10
|
|
49
|
use parent qw( cPanel::APIClient::Service ); |
|
10
|
|
|
|
|
19
|
|
|
10
|
|
|
|
|
132
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# overridden in tests |
51
|
|
|
|
|
|
|
our $_PORT = 2087; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 METHODS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 I->call_api1( $FUNCTION_NAME, \%ARGUMENTS ) |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Calls WHM API v1. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
I’s transport configuration will determine what precisely is returned; |
62
|
|
|
|
|
|
|
however, it should eventually yield a L |
63
|
|
|
|
|
|
|
instance. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
See L for documentation of the available API functions. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub call_api1 { |
70
|
0
|
|
|
0
|
1
|
|
my ( $self, $func, $args_hr, $metaargs_hr ) = @_; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
require cPanel::APIClient::Request::WHM1; |
73
|
0
|
|
|
|
|
|
my $req = cPanel::APIClient::Request::WHM1->new( $func, $args_hr, $metaargs_hr ); |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
return $self->{'transporter'}->request( $self, $req ); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 I->call_cpanel_uapi( $USERNAME, $MODULE_NAME, $FUNCTION_NAME, \%ARGUMENTS ) |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Like C but calls cPanel UAPI from a WHM connection. |
83
|
|
|
|
|
|
|
Its eventual yield will be a L |
84
|
|
|
|
|
|
|
instance. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub call_cpanel_uapi { |
89
|
0
|
|
|
0
|
1
|
|
my ( $self, $cpusername, $mod, $func, $args_hr, $metaargs_hr ) = @_; |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
require cPanel::APIClient::Request::UAPIFromWHM1; |
92
|
0
|
|
|
|
|
|
my $req = cPanel::APIClient::Request::UAPIFromWHM1->new( $cpusername, $mod, $func, $args_hr, $metaargs_hr ); |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
return $self->{'transporter'}->request( $self, $req ); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# left undocumented since unneeded |
100
|
|
|
|
|
|
|
sub get_https_port { |
101
|
0
|
|
|
0
|
0
|
|
return $_PORT; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 LICENSE |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Copyright 2020 cPanel, L. L. C. All rights reserved. L |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under the |
109
|
|
|
|
|
|
|
same terms as Perl itself. See L. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
1; |