line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::FreeIPA::Response; |
2
|
|
|
|
|
|
|
$Net::FreeIPA::Response::VERSION = '3.0.1'; |
3
|
8
|
|
|
8
|
|
406
|
use strict; |
|
8
|
|
|
|
|
9
|
|
|
8
|
|
|
|
|
198
|
|
4
|
8
|
|
|
8
|
|
23
|
use warnings; |
|
8
|
|
|
|
|
10
|
|
|
8
|
|
|
|
|
166
|
|
5
|
|
|
|
|
|
|
|
6
|
8
|
|
|
8
|
|
28
|
use base qw(Exporter); |
|
8
|
|
|
|
|
9
|
|
|
8
|
|
|
|
|
477
|
|
7
|
|
|
|
|
|
|
|
8
|
8
|
|
|
8
|
|
409
|
use Net::FreeIPA::Error; |
|
8
|
|
|
|
|
9
|
|
|
8
|
|
|
|
|
440
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @EXPORT = qw(mkresponse); |
11
|
|
|
|
|
|
|
|
12
|
8
|
|
|
8
|
|
31
|
use overload bool => '_boolean'; |
|
8
|
|
|
|
|
8
|
|
|
8
|
|
|
|
|
34
|
|
13
|
|
|
|
|
|
|
|
14
|
8
|
|
|
8
|
|
362
|
use Readonly; |
|
8
|
|
|
|
|
9
|
|
|
8
|
|
|
|
|
2517
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Readonly my $RESULT_PATH => 'result/result'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 NAME |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Net::FreeIPA::Response is an response class for Net::FreeIPA. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Boolean logic is overloaded using C<_boolean> method (as inverse of C). |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head2 Public methods |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=over |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=item mkresponse |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
A C factory |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub mkresponse |
35
|
|
|
|
|
|
|
{ |
36
|
4
|
|
|
4
|
1
|
380
|
return Net::FreeIPA::Response->new(@_); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=item new |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Create new response instance. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Options |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=over |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item answer: complete answer hashref |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=item error: an error (passed to C). |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=item result_path: passed to C to set the result attribute. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=back |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub new |
59
|
|
|
|
|
|
|
{ |
60
|
5
|
|
|
5
|
1
|
19
|
my ($this, %opts) = @_; |
61
|
5
|
|
33
|
|
|
20
|
my $class = ref($this) || $this; |
62
|
|
|
|
|
|
|
my $self = { |
63
|
|
|
|
|
|
|
answer => $opts{answer} || {}, |
64
|
5
|
|
100
|
|
|
17
|
}; |
65
|
5
|
|
|
|
|
5
|
bless $self, $class; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# First error |
68
|
5
|
|
|
|
|
11
|
$self->set_error($opts{error}); |
69
|
|
|
|
|
|
|
# Then result |
70
|
5
|
|
|
|
|
10
|
$self->set_result($opts{result_path}); |
71
|
|
|
|
|
|
|
|
72
|
5
|
|
|
|
|
11
|
return $self; |
73
|
|
|
|
|
|
|
}; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=item set_error |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Set and return the error attribute using C. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub set_error |
82
|
|
|
|
|
|
|
{ |
83
|
7
|
|
|
7
|
1
|
7
|
my $self = shift; |
84
|
7
|
|
|
|
|
17
|
$self->{error} = mkerror(@_); |
85
|
7
|
|
|
|
|
10
|
return $self->{error}; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item set_result |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Set and return the result attribute based on the C. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
The C is path-like string, indicating which subtree of the answer |
93
|
|
|
|
|
|
|
should be set as result attribute (default C). |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub set_result |
98
|
|
|
|
|
|
|
{ |
99
|
9
|
|
|
9
|
1
|
16
|
my ($self, $result_path) = @_; |
100
|
|
|
|
|
|
|
|
101
|
9
|
|
|
|
|
6
|
my $res; |
102
|
|
|
|
|
|
|
|
103
|
9
|
100
|
|
|
|
10
|
if (! $self->is_error()) { |
104
|
6
|
100
|
|
|
|
18
|
$result_path = $RESULT_PATH if ! defined($result_path); |
105
|
|
|
|
|
|
|
|
106
|
6
|
|
|
|
|
17
|
$res = $self->{answer}; |
107
|
|
|
|
|
|
|
# remove any "empty" paths |
108
|
6
|
|
|
|
|
14
|
foreach my $subpath (grep {$_} split('/', $result_path)) { |
|
14
|
|
|
|
|
16
|
|
109
|
14
|
100
|
|
|
|
24
|
$res = $res->{$subpath} if (defined($res)); |
110
|
|
|
|
|
|
|
}; |
111
|
|
|
|
|
|
|
}; |
112
|
|
|
|
|
|
|
|
113
|
9
|
|
|
|
|
13
|
$self->{result} = $res; |
114
|
|
|
|
|
|
|
|
115
|
9
|
|
|
|
|
18
|
return $self->{result}; |
116
|
|
|
|
|
|
|
}; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item is_error |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Test if this is an error or not (based on error attribute). |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub is_error |
125
|
|
|
|
|
|
|
{ |
126
|
18
|
|
|
18
|
1
|
425
|
my $self = shift; |
127
|
18
|
100
|
|
|
|
39
|
return $self->{error} ? 1 : 0; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
# Overloaded boolean, inverse of is_error |
131
|
|
|
|
|
|
|
sub _boolean |
132
|
|
|
|
|
|
|
{ |
133
|
4
|
|
|
4
|
|
23
|
my $self = shift; |
134
|
4
|
|
|
|
|
5
|
return ! $self->is_error(); |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=pod |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=back |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
1; |