line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::FreeIPA::Response; |
2
|
|
|
|
|
|
|
$Net::FreeIPA::Response::VERSION = '3.0.2'; |
3
|
8
|
|
|
8
|
|
576
|
use strict; |
|
8
|
|
|
|
|
10
|
|
|
8
|
|
|
|
|
217
|
|
4
|
8
|
|
|
8
|
|
25
|
use warnings; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
190
|
|
5
|
|
|
|
|
|
|
|
6
|
8
|
|
|
8
|
|
26
|
use base qw(Exporter); |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
530
|
|
7
|
|
|
|
|
|
|
|
8
|
8
|
|
|
8
|
|
419
|
use Net::FreeIPA::Error; |
|
8
|
|
|
|
|
10
|
|
|
8
|
|
|
|
|
489
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @EXPORT = qw(mkresponse); |
11
|
|
|
|
|
|
|
|
12
|
8
|
|
|
8
|
|
33
|
use overload bool => '_boolean'; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
34
|
|
13
|
|
|
|
|
|
|
|
14
|
8
|
|
|
8
|
|
417
|
use Readonly; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
2714
|
|
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
|
378
|
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
|
18
|
my ($this, %opts) = @_; |
61
|
5
|
|
33
|
|
|
22
|
my $class = ref($this) || $this; |
62
|
|
|
|
|
|
|
my $self = { |
63
|
|
|
|
|
|
|
answer => $opts{answer} || {}, |
64
|
5
|
|
100
|
|
|
21
|
}; |
65
|
5
|
|
|
|
|
7
|
bless $self, $class; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# First error |
68
|
5
|
|
|
|
|
14
|
$self->set_error($opts{error}); |
69
|
|
|
|
|
|
|
# Then result |
70
|
5
|
|
|
|
|
16
|
$self->set_result($opts{result_path}); |
71
|
|
|
|
|
|
|
|
72
|
5
|
|
|
|
|
13
|
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
|
9
|
my $self = shift; |
84
|
7
|
|
|
|
|
16
|
$self->{error} = mkerror(@_); |
85
|
7
|
|
|
|
|
12
|
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
|
12
|
my ($self, $result_path) = @_; |
100
|
|
|
|
|
|
|
|
101
|
9
|
|
|
|
|
10
|
my $res; |
102
|
|
|
|
|
|
|
|
103
|
9
|
100
|
|
|
|
12
|
if (! $self->is_error()) { |
104
|
6
|
100
|
|
|
|
17
|
$result_path = $RESULT_PATH if ! defined($result_path); |
105
|
|
|
|
|
|
|
|
106
|
6
|
|
|
|
|
21
|
$res = $self->{answer}; |
107
|
|
|
|
|
|
|
# remove any "empty" paths |
108
|
6
|
|
|
|
|
17
|
foreach my $subpath (grep {$_} split('/', $result_path)) { |
|
14
|
|
|
|
|
21
|
|
109
|
14
|
100
|
|
|
|
30
|
$res = $res->{$subpath} if (defined($res)); |
110
|
|
|
|
|
|
|
}; |
111
|
|
|
|
|
|
|
}; |
112
|
|
|
|
|
|
|
|
113
|
9
|
|
|
|
|
14
|
$self->{result} = $res; |
114
|
|
|
|
|
|
|
|
115
|
9
|
|
|
|
|
19
|
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
|
485
|
my $self = shift; |
127
|
18
|
100
|
|
|
|
64
|
return $self->{error} ? 1 : 0; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
# Overloaded boolean, inverse of is_error |
131
|
|
|
|
|
|
|
sub _boolean |
132
|
|
|
|
|
|
|
{ |
133
|
4
|
|
|
4
|
|
30
|
my $self = shift; |
134
|
4
|
|
|
|
|
5
|
return ! $self->is_error(); |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=pod |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=back |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
1; |