FreeIPA.pm

filter: Statementstmt 100% 12 / 12 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 100% 16 / 16 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« FreeIPA/RPC.pm ↑ Summary FreeIPA/API/Data.pm »
1 package Net::FreeIPA;
2 # dzil abstract
3 # ABSTRACT: Net::FreeIPA is a perl FreeIPA JSON API client class
4 $Net::FreeIPA::VERSION = '3.0.3';
5 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 6 ▶use Net::FreeIPA::DummyLogger;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 6 ▶use parent qw(Net::FreeIPA::Base
Subroutine BEGIN: called CC=1 SCAR=0.0
11 Net::FreeIPA::RPC
12 Net::FreeIPA::API
13 6 Net::FreeIPA::Common);
14  
15 =head1 NAME
16  
17 Net::FreeIPA is a perl FreeIPA JSON API client class
18  
19 =head1 SYNOPSIS
20  
21 'ipa user-find' equivalent using API call and basic result postprocessing.
22 The connection in this example will (try to) use kerberos authentication.
23 See L<Net::FreeIPA::RPC::new_client> for authentication details.
24  
25 my $fi = Net::FreeIPA->new("host.example.com");
26  
27 die("Failed to initialise the rest client") if ! $fi->{rc};
28  
29 if($fi->api_user_find("")) {
30 print "Found ", scalar @{$fi->{result}}, " users\n";
31 } else {
32 print "Something went wrong\n";
33 }
34  
35  
36 =head2 Private methods
37  
38 =over
39  
40 =item _initialize
41  
42 Handle the actual initializtion of new. Return 1 on success, undef otherwise.
43  
44 =over
45  
46 =item log
47  
48 An instance that can be used for logging (with error/warn/info/debug methods)
49 (e.g. L<LOG::Log4perl>).
50  
51 =item debugapi
52  
53 When true, log the JSON POST and JSON reply data with debug.
54  
55 =back
56  
57 All other arguments and options are passed to L<Net::FreeIPA::RPC::new_client>
58 during initialisation. (Check the presence of an C<rc> attribute for succesfull
59 initialisation of the underlying rest client. An error is logged in case of failure.)
60  
61  
62 =cut
63  
64 sub _initialize
65 {
66 my ($self, $hostname, %opts) = @_;
67  
68 $self->{log} = delete $opts{log} || Net::FreeIPA::DummyLogger->new();
69  
70 $self->{debugapi} = delete $opts{debugapi};
71  
72 # Pass all other options to new_client
73 my $nc = $self->new_client($hostname, %opts) if $hostname;
74  
75 # Return 1, $self holds any errors from new_client in answer attribute
76 return 1;
77 }
78  
79 =pod
80  
81 =back
82  
83 =cut
84  
85 1;
« FreeIPA/RPC.pm ↑ Summary FreeIPA/API/Data.pm »