File Coverage

blib/lib/cPanel/APIClient/Service/cpanel.pm
Criterion Covered Total %
statement 15 15 100.0
branch 1 2 50.0
condition n/a
subroutine 5 5 100.0
pod 1 2 50.0
total 22 24 91.6


line stmt bran cond sub pod time code
1             package cPanel::APIClient::Service::cpanel;
2              
3 10     10   8455 use strict;
  10         28  
  10         307  
4 10     10   57 use warnings;
  10         20  
  10         360  
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 10     10   58 use parent qw( cPanel::APIClient::Service );
  10         19  
  10         70  
41              
42             # overridden in tests
43             our $_PORT = 2083;
44              
45             #----------------------------------------------------------------------
46              
47             =head1 METHODS
48              
49             =head2 $whatsit = I->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’s configured transport:
55              
56             =over
57              
58             =item * If the transport uses blocking I/O, then the return will be a
59             L 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), others a L, 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 instance should somehow be given
68             to indicate the API call response.
69              
70             =back
71              
72             =cut
73              
74             sub call_uapi {
75 7     7 1 510 my ( $self, $module, $func, $args_hr, $metaargs_hr ) = @_;
76              
77 7 50       26 die "Meta-arguments are not implemented!" if $metaargs_hr;
78              
79 7         917 require cPanel::APIClient::Request::UAPI;
80 7         52 my $req = cPanel::APIClient::Request::UAPI->new( $module, $func, $args_hr, $metaargs_hr );
81              
82 7         41 return $self->{'transporter'}->request( $self, $req );
83             }
84              
85             # undocumented for now
86             sub get_https_port {
87 7     7 0 30 return $_PORT;
88             }
89              
90             =head1 LICENSE
91              
92             Copyright 2020 cPanel, L. L. C. All rights reserved. L
93              
94             This is free software; you can redistribute it and/or modify it under the
95             same terms as Perl itself. See L.
96              
97             =cut
98              
99             1;