APIClient/Request/UAPI.pm

filter: Statementstmt 67.5% 25 / 37 Branchbran 25.0% 1 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 81.8% 9 / 11 Podpod 0.0% 0 / 6 totaltotal 55.5% 35 / 63 CC 4 SCAR 12.9
CC
4
Cov
59%
get_cli_command
12.0
new
2.5
parse_cli_response
2.0
CRAP 3.6
« APIClient/Transport/CLISync.pm ↑ Summary APIClient/Transport/MojoUserAgent.pm »
1 package cPanel::APIClient::Request::UAPI;
2  
3 # Copyright 2020 cPanel, L. L. C.
4 # All rights reserved.
5 # http://cpanel.net
6 #
7 # This is free software; you can redistribute it and/or modify it under the
8 # same terms as Perl itself. See L<perlartistic>.
9  
10 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 2 ▶use parent qw( cPanel::APIClient::Request::HTTPBase );
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 2 ▶use cPanel::APIClient::Utils::JSON ();
Subroutine BEGIN: called CC=1 SCAR=0.0
16 2 ▶use cPanel::APIClient::Response::UAPI ();
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 5 ▶sub HTTP_RESPONSE_CLASS { return 'cPanel::APIClient::Response::UAPI' }
Subroutine HTTP_RESPONSE_CLASS: called CC=1 SCAR=0.0
Pod undocumented
19  
20 8 ▶sub new {
Subroutine new: called CC=2 SCAR=9.2
Pod undocumented
21 8 my ( $class, $module, $func, $args_hr, $metaargs_hr ) = @_;
22  
23 8 ▶ if ($metaargs_hr) {
Branch: 1 branch
BranchTrueFalseTotal
if ($metaargs_hr) 0 8 8
24 0 my %args_copy = %$args_hr;
25 0 _parse_metaargs( $metaargs_hr, \%args_copy );
26 0 $args_hr = \%args_copy;
27 }
28  
29 8 return bless [ $module, $func, $args_hr ], $class;
30 }
31  
32 8 ▶sub get_http_url_path {
Subroutine get_http_url_path: called CC=1 SCAR=0.0
Pod undocumented
33 8 my ($self) = @_;
34  
35 8 return "/execute/$self->[0]/$self->[1]";
36 }
37  
38 8 ▶sub get_http_payload {
Subroutine get_http_payload: called CC=1 SCAR=0.0
Pod undocumented
39 8 my ($self) = @_;
40  
41 8 require cPanel::APIClient::Utils::HTTPRequest;
42 8 return cPanel::APIClient::Utils::HTTPRequest::encode_form( $self->[2] );
43 }
44  
45 #----------------------------------------------------------------------
46  
47 0 ▶sub get_cli_command {
Subroutine get_cli_command: not called CC=3 SCAR=24.8
Pod undocumented
48 0 my ( $self, $authn ) = @_;
49  
50 0 ▶ my $username = $authn && $authn->username();
Condition0%0/3
$authn && $authn->username
!ll&&!rl&&r
000
MC/DC0%0/2
$authn && $authn->username
$authn $authn->username
Truth table0%0/3
A && B
A= $authnB= $authn->username
ABresult
0X0
100
111
51  
52 0 require cPanel::APIClient::Utils::CLIRequest;
53 return (
54 '/usr/local/cpanel/bin/uapi',
55 '--output=json',
56 ( $username ? "--user=$username" : () ),
57 0 ▶ @{$self}[ 0, 1 ],
Branch: 1 branch
BranchTrueFalseTotal
$username ? : 0 0 0
58 cPanel::APIClient::Utils::CLIRequest::to_args( $self->[2] ),
59 );
60 }
61  
62 0 ▶sub parse_cli_response {
Subroutine parse_cli_response: not called CC=1 SCAR=6.9
Pod undocumented
63 0 my ( $self, $resp_body ) = @_;
64  
65 0 my $resp_struct = cPanel::APIClient::Utils::JSON::decode($resp_body);
66 0 $resp_struct = $resp_struct->{'result'};
67  
68 0 return cPanel::APIClient::Response::UAPI->new($resp_struct);
69 }
70  
71 #----------------------------------------------------------------------
72  
73 # sub _parse_metaargs { die 'Unimplemented' }
74  
75 2 1;
« APIClient/Transport/CLISync.pm ↑ Summary APIClient/Transport/MojoUserAgent.pm »