line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::FreeIPA::Request; |
2
|
|
|
|
|
|
|
$Net::FreeIPA::Request::VERSION = '3.0.1'; |
3
|
9
|
|
|
9
|
|
742
|
use strict; |
|
9
|
|
|
|
|
9
|
|
|
9
|
|
|
|
|
236
|
|
4
|
9
|
|
|
9
|
|
29
|
use warnings; |
|
9
|
|
|
|
|
10
|
|
|
9
|
|
|
|
|
266
|
|
5
|
|
|
|
|
|
|
|
6
|
9
|
|
|
9
|
|
32
|
use base qw(Exporter); |
|
9
|
|
|
|
|
13
|
|
|
9
|
|
|
|
|
724
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our @EXPORT = qw(mkrequest); |
9
|
|
|
|
|
|
|
|
10
|
9
|
|
|
9
|
|
1961
|
use overload bool => '_boolean'; |
|
9
|
|
|
|
|
1285
|
|
|
9
|
|
|
|
|
60
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Net::FreeIPA::Request is an request class for Net::FreeIPA. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Boolean logic is overloaded using C<_boolean> method (as inverse of C). |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head2 Public methods |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=over |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=item mkrequest |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
A C factory |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub mkrequest |
29
|
|
|
|
|
|
|
{ |
30
|
8
|
|
|
8
|
1
|
369
|
return Net::FreeIPA::Request->new(@_); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=item new |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Create new request instance from options for command C. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Options |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=over |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=item args: positional arguments |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=item opts: optional arguments |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=item error: an error (no default) |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item id: id (no default) |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=back |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub new |
55
|
|
|
|
|
|
|
{ |
56
|
9
|
|
|
9
|
1
|
29
|
my ($this, $command, %opts) = @_; |
57
|
9
|
|
33
|
|
|
29
|
my $class = ref($this) || $this; |
58
|
|
|
|
|
|
|
my $self = { |
59
|
|
|
|
|
|
|
command => $command, |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
args => $opts{args} || [], |
62
|
|
|
|
|
|
|
opts => $opts{opts} || {}, |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
rpc => $opts{rpc} || {}, # options for rpc |
65
|
|
|
|
|
|
|
post => $opts{post} || {}, # options for post |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
error => $opts{error}, # no default |
68
|
|
|
|
|
|
|
id => $opts{id}, # no default |
69
|
9
|
|
100
|
|
|
90
|
}; |
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
9
|
|
|
|
|
12
|
bless $self, $class; |
72
|
|
|
|
|
|
|
|
73
|
9
|
|
|
|
|
44
|
return $self; |
74
|
|
|
|
|
|
|
}; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=item post_data |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Return the RPC::POST hashref (no JSON encoding). |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Returns undef if the id is not defined. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub post_data |
85
|
|
|
|
|
|
|
{ |
86
|
2
|
|
|
2
|
1
|
2
|
my $self = shift; |
87
|
|
|
|
|
|
|
|
88
|
2
|
100
|
|
|
|
9
|
return if (! defined($self->{id})); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
my $data = { |
91
|
|
|
|
|
|
|
method => $self->{command}, |
92
|
|
|
|
|
|
|
params => [$self->{args}, $self->{opts}], |
93
|
|
|
|
|
|
|
id => $self->{id}, |
94
|
1
|
|
|
|
|
5
|
}; |
95
|
|
|
|
|
|
|
|
96
|
1
|
|
|
|
|
7
|
return $data; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item is_error |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Test if this is an error or not (based on error attribute). |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub is_error |
106
|
|
|
|
|
|
|
{ |
107
|
11
|
|
|
11
|
1
|
3931
|
my $self = shift; |
108
|
11
|
100
|
|
|
|
38
|
return $self->{error} ? 1 : 0; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# Overloaded boolean, inverse of is_error |
112
|
|
|
|
|
|
|
sub _boolean |
113
|
|
|
|
|
|
|
{ |
114
|
8
|
|
|
8
|
|
1211
|
my $self = shift; |
115
|
8
|
|
|
|
|
13
|
return ! $self->is_error(); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=pod |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=back |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
1; |