Client.pm

filter: Statementstmt 100% 17 / 17 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 100% 23 / 23 CC 2 SCAR 3.4
CC
2
Cov
100%
_initialize
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
« Client/API/Version/v1.pm ↑ Summary Client/API/Identity/v3.pm »
1 package Net::OpenStack::Client;
2 7 $Net::OpenStack::Client::VERSION = '0.1.4';
3 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 7 ▶use parent qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
7 Net::OpenStack::Client::API
8 Net::OpenStack::Client::Auth
9 Net::OpenStack::Client::Base
10 Net::OpenStack::Client::REST
11 7 );
12  
13 # ABSTRACT: OpenStack REST API client
14  
15 =head1 NAME
16  
17 Net::OpenStack::Client
18  
19 =head1 SYNOPSIS
20  
21 Example usage:
22 use Net::OpenStack::Client;
23 ...
24 my $cl = Net::OpenStack::Client->new(openrc => '/home/admin/.openrc');
25  
26 For basic reporting:
27 use Net::OpenStack::Client;
28 use Log::Log4perl qw(:easy);
29 Log::Log4perl->easy_init($INFO);
30 ...
31 my $cl = Net::OpenStack::Client->new(
32 openrc => '/home/admin/.openrc',
33 log => Log::Log4perl->get_logger()
34 );
35  
36 For debugging, including full JSON request / repsonse and headers (so contains sensitive data!):
37 use Net::OpenStack::Client;
38 use Log::Log4perl qw(:easy);
39 Log::Log4perl->easy_init($DEBUG);
40 ...
41 my $cl = Net::OpenStack::Client->new(
42 openrc => '/home/admin/.openrc',
43 log => Log::Log4perl->get_logger(),
44 debugapi => 1
45 );
46  
47 =head2 Public methods
48  
49 =over
50  
51 =item new
52  
53 Options
54  
55 =over
56  
57 =item log
58  
59 An instance that can be used for logging (with error/warn/info/debug methods)
60 (e.g. L<LOG::Log4perl>).
61  
62 =item debugapi
63  
64 When true, log the request and response body and headers with debug.
65  
66 =back
67  
68 If more options are definded, e.g. C<openrc>, they are passed to
69 passed to L<Net::OpenStack::Client::Auth::login>.
70 (If no other options are defined, C<login> is not called).
71  
72 =cut
73  
74 # return 1 on success
75 sub _initialize
76 6 ▶{
Subroutine _initialize: called CC=2 SCAR=6.9
77 6 my ($self, %opts) = @_;
78  
79 6 $self->{log} = delete $opts{log};
80 6 $self->{debugapi} = delete $opts{debugapi};
81  
82 # Initialise the REST::Client
83 6 $self->_new_client();
84  
85 # Login, get token and gather services
86 6 ▶ $self->login(%opts) if scalar keys %opts;
Branch: 1 branch
BranchTrueFalseTotal
if scalar keys %opts 2 4 6
87  
88 6 return 1;
89 }
90  
91 =pod
92  
93 =back
94  
95 =cut
96  
97 7 1;
« Client/API/Version/v1.pm ↑ Summary Client/API/Identity/v3.pm »