| 1 | package cPanel::APIClient::Service::cpanel; | ||||||||||
| 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::cpanel | ||||||||||
| 11 | |||||||||||
| 12 | =head1 SYNOPSIS | ||||||||||
| 13 | |||||||||||
| 14 | If your transport uses blocking I/O: | ||||||||||
| 15 | |||||||||||
| 16 | my $resp = $client->call_uapi('Email', 'list_pops', \%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_uapi('Email', 'list_pops', \%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 | =cut | ||||||||||
| 37 | |||||||||||
| 38 | #---------------------------------------------------------------------- | ||||||||||
| 39 | |||||||||||
| 40 | 12 | ▶ | use parent qw( cPanel::APIClient::Service ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 41 | |||||||||||
| 42 | # overridden in tests | ||||||||||
| 43 | 12 | our $_PORT = 2083; | |||||||||
| 44 | |||||||||||
| 45 | #---------------------------------------------------------------------- | ||||||||||
| 46 | |||||||||||
| 47 | =head1 METHODS | ||||||||||
| 48 | |||||||||||
| 49 | =head2 $whatsit = I<OBJ>->call_uapi( $MODULE, $FUNC, \%ARGS, \%METAARGS ) | ||||||||||
| 50 | |||||||||||
| 51 | Calls a single UAPI call. %ARGS values should be simple scalars or arrays | ||||||||||
| 52 | thereof. | ||||||||||
| 53 | |||||||||||
| 54 | The return value depends on I<OBJ>’s configured transport: | ||||||||||
| 55 | |||||||||||
| 56 | =over | ||||||||||
| 57 | |||||||||||
| 58 | =item * If the transport uses blocking I/O, then the return will be a | ||||||||||
| 59 | L<cPanel::APIClient::Response::UAPI> instance. | ||||||||||
| 60 | |||||||||||
| 61 | =item * A transport that uses non-blocking I/O can determine its own | ||||||||||
| 62 | mechanism | ||||||||||
| 63 | for returning the API call response. Some might return a promise (e.g., | ||||||||||
| 64 | L<Promise::XS>), others a L<Future>, and still others might | ||||||||||
| 65 | return nothing and instead take a callback as a parameter. See the | ||||||||||
| 66 | individual transport’s documentation for details. Eventually, though, | ||||||||||
| 67 | a L<cPanel::APIClient::Response::UAPI> instance should somehow be given | ||||||||||
| 68 | to indicate the API call response. | ||||||||||
| 69 | |||||||||||
| 70 | =back | ||||||||||
| 71 | |||||||||||
| 72 | =cut | ||||||||||
| 73 | |||||||||||
| 74 | 8 | ▶ | sub call_uapi { | ||||||||
|
Subroutine
call_uapi: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 75 | 8 | my ( $self, $module, $func, $args_hr, $metaargs_hr ) = @_; | |||||||||
| 76 | |||||||||||
| 77 | 8 | ▶ | die "Meta-arguments are not implemented!" if $metaargs_hr; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 78 | |||||||||||
| 79 | 8 | require cPanel::APIClient::Request::UAPI; | |||||||||
| 80 | 8 | my $req = cPanel::APIClient::Request::UAPI->new( $module, $func, $args_hr, $metaargs_hr ); | |||||||||
| 81 | |||||||||||
| 82 | 8 | return $self->{'transporter'}->request( $self, $req ); | |||||||||
| 83 | } | ||||||||||
| 84 | |||||||||||
| 85 | # undocumented for now | ||||||||||
| 86 | 9 | ▶ | sub get_https_port { | ||||||||
|
Subroutine
get_https_port: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 87 | 9 | return $_PORT; | |||||||||
| 88 | } | ||||||||||
| 89 | |||||||||||
| 90 | =head1 LICENSE | ||||||||||
| 91 | |||||||||||
| 92 | Copyright 2020 cPanel, L. L. C. All rights reserved. L<http://cpanel.net> | ||||||||||
| 93 | |||||||||||
| 94 | This is free software; you can redistribute it and/or modify it under the | ||||||||||
| 95 | same terms as Perl itself. See L<perlartistic>. | ||||||||||
| 96 | |||||||||||
| 97 | =cut | ||||||||||
| 98 | |||||||||||
| 99 | 12 | 1; | |||||||||