| line | stmt | bran | cond | sub | pod | time | code | 
| 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.2'; | 
| 5 | 6 |  |  | 6 |  | 154181 | use strict; | 
|  | 6 |  |  |  |  | 10 |  | 
|  | 6 |  |  |  |  | 172 |  | 
| 6 | 6 |  |  | 6 |  | 24 | use warnings; | 
|  | 6 |  |  |  |  | 9 |  | 
|  | 6 |  |  |  |  | 192 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 | 6 |  |  | 6 |  | 2478 | use Net::FreeIPA::DummyLogger; | 
|  | 6 |  |  |  |  | 11 |  | 
|  | 6 |  |  |  |  | 182 |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 | 6 |  |  |  |  | 33 | use parent qw(Net::FreeIPA::Base | 
| 11 |  |  |  |  |  |  | Net::FreeIPA::RPC | 
| 12 |  |  |  |  |  |  | Net::FreeIPA::API | 
| 13 | 6 |  |  | 6 |  | 2692 | Net::FreeIPA::Common); | 
|  | 6 |  |  |  |  | 1772 |  | 
| 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 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). | 
| 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 | 
| 58 |  |  |  |  |  |  | during initialisation. (Check the presence of an C 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; |