File Coverage

blib/lib/cPanel/APIClient/Service/cpanel.pm
Criterion Covered Total %
statement 9 15 60.0
branch 0 2 0.0
condition n/a
subroutine 3 5 60.0
pod 1 2 50.0
total 13 24 54.1


line stmt bran cond sub pod time code
1             package cPanel::APIClient::Service::cpanel;
2              
3 5     5   4475 use strict;
  5         12  
  5         158  
4 5     5   29 use warnings;
  5         12  
  5         177  
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 5     5   28 use parent qw( cPanel::APIClient::Service );
  5         11  
  5         35  
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 0     0 1   my ( $self, $module, $func, $args_hr, $metaargs_hr ) = @_;
76              
77 0 0         die "Meta-arguments are not implemented!" if $metaargs_hr;
78              
79 0           require cPanel::APIClient::Request::UAPI;
80 0           my $req = cPanel::APIClient::Request::UAPI->new( $module, $func, $args_hr, $metaargs_hr );
81              
82 0           return $self->{'transporter'}->request( $self, $req );
83             }
84              
85             # undocumented for now
86             sub get_https_port {
87 0     0 0   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;