| 1 | package cPanel::APIClient::Service::whm; | ||
| 2 | |||
| 3 | 12 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 12 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 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<cPanel::APIClient::Service>. | ||
| 40 | |||
| 41 | Don’t try to create this object directly; instead, let | ||
| 42 | C<cPanel::APIClient->create()> do it for you. | ||
| 43 | |||
| 44 | =cut | ||
| 45 | |||
| 46 | #---------------------------------------------------------------------- | ||
| 47 | |||
| 48 | 12 | ▶ | use parent qw( cPanel::APIClient::Service ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 49 | |||
| 50 | # overridden in tests | ||
| 51 | 12 | our $_PORT = 2087; | |
| 52 | |||
| 53 | #---------------------------------------------------------------------- | ||
| 54 | |||
| 55 | =head1 METHODS | ||
| 56 | |||
| 57 | =head2 I<OBJ>->call_api1( $FUNCTION_NAME, \%ARGUMENTS ) | ||
| 58 | |||
| 59 | Calls WHM API v1. | ||
| 60 | |||
| 61 | I<OBJ>’s transport configuration will determine what precisely is returned; | ||
| 62 | however, it should eventually yield a L<cPanel::APIClient::Response::WHM1> | ||
| 63 | instance. | ||
| 64 | |||
| 65 | See L<cPanel’s WHM API v1 documentation|https://documentation.cpanel.net/display/DD/Guide+to+WHM+API+1> for documentation of the available API functions. | ||
| 66 | |||
| 67 | =cut | ||
| 68 | |||
| 69 | 0 | ▶ | sub call_api1 { |
|
Subroutine
call_api1: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 70 | 0 | 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<OBJ>->call_cpanel_uapi( $USERNAME, $MODULE_NAME, $FUNCTION_NAME, \%ARGUMENTS ) | ||
| 81 | |||
| 82 | Like C<call_api1()> but calls cPanel UAPI from a WHM connection. | ||
| 83 | Its eventual yield will be a L<cPanel::APIClient::Response::UAPI> | ||
| 84 | instance. | ||
| 85 | |||
| 86 | =cut | ||
| 87 | |||
| 88 | 0 | ▶ | sub call_cpanel_uapi { |
|
Subroutine
call_cpanel_uapi: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 89 | 0 | 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 | 0 | ▶ | sub get_https_port { |
|
Subroutine
get_https_port: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 101 | 0 | return $_PORT; | |
| 102 | } | ||
| 103 | |||
| 104 | =head1 LICENSE | ||
| 105 | |||
| 106 | Copyright 2020 cPanel, L. L. C. All rights reserved. L<http://cpanel.net> | ||
| 107 | |||
| 108 | This is free software; you can redistribute it and/or modify it under the | ||
| 109 | same terms as Perl itself. See L<perlartistic>. | ||
| 110 | |||
| 111 | =cut | ||
| 112 | |||
| 113 | 12 | 1; | |