| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Chef::REST::Client; |
|
2
|
|
|
|
|
|
|
$Chef::REST::Client::VERSION = 1.2; |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=pod |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Chef::REST::Client |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
1.2 |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use Chef::REST::Client; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $obj = new Chef::REST::Client |
|
19
|
|
|
|
|
|
|
( 'chef_client_name' => $chef_client_name , |
|
20
|
|
|
|
|
|
|
'chef_client_privaate_key' => $private_key ); |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
$obj->private_key( $private_key ); |
|
23
|
|
|
|
|
|
|
$obj->name( $chef_client_name ); |
|
24
|
|
|
|
|
|
|
$obj->roles('vagrant')->details; |
|
25
|
|
|
|
|
|
|
$obj->roles('vagrant','environments')->details |
|
26
|
|
|
|
|
|
|
$obj->roles->list; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
$obj->search( 'secrets' , { q => 'id:centrify', rows => 1 } )->details |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
$obj->environments(,'cookbooks' , )->details; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$obj->environments(,'cookbooks_versions' |
|
33
|
|
|
|
|
|
|
,{ 'method' => 'post' |
|
34
|
|
|
|
|
|
|
, 'data' => { 'runlist' => [ 'ms-scribe'] } |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
); |
|
37
|
|
|
|
|
|
|
$obj->roles()->details->override_attributes; |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
This is the interface to the Chef server api methods listed on opscode documentation |
|
42
|
|
|
|
|
|
|
L |
|
43
|
|
|
|
|
|
|
currently it provides implementation for only GET methods |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 METHODS |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 role( $role ) |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
returns new L object |
|
50
|
|
|
|
|
|
|
used by other classes |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 roles ( @roles ) |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
makes a GET request to the chef server for all the @roles and returns and L object. |
|
55
|
|
|
|
|
|
|
you can directly get details for all the roles as $obj->role( 'role1', 'role2' )->details; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
this inturn will return L |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=over |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=item /roles |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
$obj->roles->list |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=item /roles/ |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
$obj->roles()->details |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
$obj->roles()->details->run_list; |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
$obj->roles()->details->override_attributes; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=back |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 runlist ( @$recipes ) |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
returns new L object. it takes a list of recipies as parameter. |
|
78
|
|
|
|
|
|
|
used by other classes |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 sandboxes |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
returns new L object. $obj->sandboxes->list; |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=over |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item /sandboxes |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
$obj->sandboxes->list |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item /sandboxes/ |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
$obj->sandboxes()->details |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=back |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 search |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
returns new L |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=over |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item /search |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
$obj->search->listen |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item /search/ |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
$obj->search()->details |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item /search/ query id:centrify and get rows 1 |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
$obj->search( 'secrets' , { q => 'id:centrify', rows => 1 } )->details |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=back |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 recipe |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
returns new L object. used by other classes |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 principals |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
returns new L object. $obj->principals->details; |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=over |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item /principals |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
$obj->principals->list |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item /principals/ |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
$obj->principals()->details |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=back |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head2 node |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
returns new L object. $obj->node->details; |
|
139
|
|
|
|
|
|
|
used by other classes |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 nodes |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
returns new L object. $obj->nodes->list; |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=over |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item /nodes |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
$obj->nodes->listen |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item /nodes/ |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
$obj->nodes()->details |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=back |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head2 envrunlist |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
returns new L object. used by other classes |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head2 environment |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
returns new L object. used by other classes |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head2 environments |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
returns new L object. |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=over |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=item /environment/ |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
$obj->environments()->details; |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=item /environment//cookbooks/ |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
$obj->environments(,'cookbooks' , )->details; |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=item /environment//cookbooks |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
$obj->environments(,'cookbooks') |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=item POST /environments//cookbooks_versions |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
$obj->environments(,'cookbooks_versions' |
|
186
|
|
|
|
|
|
|
,{ 'method' => 'post' |
|
187
|
|
|
|
|
|
|
, 'data' => { 'runlist' => [ 'ms-scribe'] } |
|
188
|
|
|
|
|
|
|
} |
|
189
|
|
|
|
|
|
|
); |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=back |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head2 databag |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
returns new L object. |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head2 data |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
returns new L object. |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=over |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=item /data |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
$obj->data->list |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=item /data/ |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
$obj->data( )->details |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=back |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head2 cookbook |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
returns new L object. |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=head2 cookbooks |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
returns new L object. |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=over |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=item /cookbooks |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
$obj->cookbooks->list |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=item /cookbooks/ |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
$obj->cookbooks()->details |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
$obj->cookbooks( , '_latest' )->details->recipes; |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
$obj->cookbooks( , '_latest' )->details->attributes; |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=back |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=head2 cookbook_version |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
returns new L object. |
|
240
|
|
|
|
|
|
|
used by other classes |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=head2 cookbook_versions |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
returns new L object. |
|
245
|
|
|
|
|
|
|
collection of L |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=head2 clients |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
returns new L object. |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=over |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=item /clients |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
$obj->clients->list |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=item /clients// |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
$obj->clients()->details |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=back |
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=head2 attribute |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
returns new L object. |
|
267
|
|
|
|
|
|
|
used by other classes to structure data |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=head2 attributes |
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
returns new L object. |
|
272
|
|
|
|
|
|
|
collection of L |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=cut |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
my @base; |
|
277
|
|
|
|
|
|
|
BEGIN { |
|
278
|
1
|
|
|
1
|
|
1309
|
use File::Basename qw { dirname }; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
53
|
|
|
279
|
1
|
|
|
1
|
|
5
|
use File::Spec::Functions qw { splitdir rel2abs }; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
81
|
|
|
280
|
1
|
|
|
1
|
|
45
|
@base = ( splitdir ( rel2abs ( dirname(__FILE__) ) ) ); |
|
281
|
1
|
|
|
|
|
22
|
pop @base; #REST |
|
282
|
1
|
|
|
|
|
2
|
pop @base; #Chef |
|
283
|
1
|
|
|
|
|
23
|
push @INC, '/', @base; |
|
284
|
|
|
|
|
|
|
}; |
|
285
|
|
|
|
|
|
|
|
|
286
|
1
|
|
|
1
|
|
5
|
use parent qw { Chef::REST }; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
6
|
|
|
287
|
1
|
|
|
1
|
|
50
|
use Mojo::JSON; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
45
|
|
|
288
|
1
|
|
|
1
|
|
7
|
use Module::Load; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
10
|
|
|
289
|
1
|
|
|
1
|
|
68
|
use vars qw { $AUTOLOAD }; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
234
|
|
|
290
|
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
sub new { |
|
292
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
|
293
|
0
|
|
|
|
|
|
my $param = {@_}; |
|
294
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new(@_); |
|
295
|
0
|
0
|
|
|
|
|
$self->name($param->{'chef_client_name'}) if defined $param->{'chef_client_name'}; |
|
296
|
0
|
0
|
|
|
|
|
$self->private_key($param->{'chef_client_private_key'}) if defined $param->{'chef_client_private_key'}; |
|
297
|
0
|
|
|
|
|
|
bless $self, $class; |
|
298
|
0
|
|
|
|
|
|
return $self; |
|
299
|
|
|
|
|
|
|
} |
|
300
|
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
sub name { |
|
302
|
0
|
|
|
0
|
1
|
|
my ($self,$client_name) = (@_); |
|
303
|
0
|
0
|
|
|
|
|
$self->{ 'CHEF_CLIENT' } = $client_name if defined $client_name; |
|
304
|
0
|
|
|
|
|
|
return $self->{ 'CHEF_CLIENT' }; |
|
305
|
|
|
|
|
|
|
} |
|
306
|
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
#----------------------------------# |
|
308
|
|
|
|
|
|
|
# Class : Chef::REST::Client::Role # |
|
309
|
|
|
|
|
|
|
#----------------------------------# |
|
310
|
|
|
|
|
|
|
sub role_ |
|
311
|
|
|
|
|
|
|
{ |
|
312
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
313
|
0
|
|
|
|
|
|
my $param = {@_}; |
|
314
|
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
} |
|
317
|
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
#-----------------------------------# |
|
319
|
|
|
|
|
|
|
# Class : Chef::REST::Client::Roles # |
|
320
|
|
|
|
|
|
|
#-----------------------------------# |
|
321
|
|
|
|
|
|
|
sub roles_ |
|
322
|
|
|
|
|
|
|
{ |
|
323
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
324
|
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
package Chef::REST::Client::roles; |
|
326
|
|
|
|
|
|
|
|
|
327
|
1
|
|
|
1
|
|
5
|
use parent qw { Chef::REST::Client }; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
4
|
|
|
328
|
|
|
|
|
|
|
|
|
329
|
0
|
|
|
|
|
|
bless $self, 'Chef::REST::Client::roles'; |
|
330
|
0
|
|
|
|
|
|
$self->api_end_point('roles'); |
|
331
|
0
|
|
|
|
|
|
return $self; |
|
332
|
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
sub api_end_point |
|
334
|
|
|
|
|
|
|
{ |
|
335
|
0
|
|
|
0
|
1
|
|
my ($self,$api_end_point) = (@_); |
|
336
|
0
|
0
|
|
|
|
|
$self->{ 'API_END_POINT' } = $api_end_point if defined $api_end_point; |
|
337
|
0
|
|
|
|
|
|
return $self->{ 'API_END_POINT' }; |
|
338
|
|
|
|
|
|
|
} |
|
339
|
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
sub list |
|
341
|
|
|
|
|
|
|
{ |
|
342
|
|
|
|
|
|
|
my $self = shift; |
|
343
|
|
|
|
|
|
|
my $end_point = $self->api_end_point; |
|
344
|
|
|
|
|
|
|
my $mojo_json = new Mojo::JSON(); |
|
345
|
|
|
|
|
|
|
my $list_of_roles = |
|
346
|
|
|
|
|
|
|
$mojo_json->decode( |
|
347
|
|
|
|
|
|
|
$self->ua( 'client_name' => $self->name ) |
|
348
|
|
|
|
|
|
|
->get( 'api_end_point' => $end_point ) |
|
349
|
|
|
|
|
|
|
->decoded_content |
|
350
|
|
|
|
|
|
|
); |
|
351
|
|
|
|
|
|
|
my @_roles; |
|
352
|
|
|
|
|
|
|
foreach my $r ( keys(%$list_of_roles) ){ |
|
353
|
|
|
|
|
|
|
my $role = Chef::REST::Client::role( 'name' => $r, |
|
354
|
|
|
|
|
|
|
'url' => $list_of_roles->{$r} |
|
355
|
|
|
|
|
|
|
); |
|
356
|
|
|
|
|
|
|
push @_roles , $role; |
|
357
|
|
|
|
|
|
|
} |
|
358
|
|
|
|
|
|
|
return \@_roles; |
|
359
|
|
|
|
|
|
|
} |
|
360
|
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
} |
|
362
|
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
sub AUTOLOAD { |
|
364
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
365
|
0
|
|
|
|
|
|
my $hash_param = pop @_; |
|
366
|
0
|
|
|
|
|
|
my ($method, $data) = ( 'GET'); |
|
367
|
0
|
|
|
|
|
|
my $request_url = undef; |
|
368
|
|
|
|
|
|
|
|
|
369
|
0
|
0
|
|
|
|
|
if( ref $hash_param ne 'HASH') |
|
370
|
|
|
|
|
|
|
{ |
|
371
|
0
|
0
|
|
|
|
|
push @_ , $hash_param if defined $hash_param; |
|
372
|
0
|
|
|
|
|
|
undef $hash_param; |
|
373
|
|
|
|
|
|
|
} |
|
374
|
|
|
|
|
|
|
else { |
|
375
|
0
|
0
|
|
|
|
|
$method = 'POST' if $hash_param->{'method'} =~ m/post/i; |
|
376
|
0
|
|
|
|
|
|
$data = $hash_param->{'data'}; |
|
377
|
|
|
|
|
|
|
} |
|
378
|
|
|
|
|
|
|
|
|
379
|
0
|
|
|
|
|
|
my @param = @_; |
|
380
|
|
|
|
|
|
|
|
|
381
|
0
|
|
|
|
|
|
my $module = (split ('::', $AUTOLOAD))[-1]; |
|
382
|
0
|
|
|
|
|
|
load $AUTOLOAD; |
|
383
|
0
|
|
|
|
|
|
my $obj = $AUTOLOAD->new(); |
|
384
|
|
|
|
|
|
|
|
|
385
|
0
|
|
|
|
|
|
my (@api_end_point, @q ); |
|
386
|
0
|
|
|
|
|
|
@api_end_point = ( $module , @param ); |
|
387
|
|
|
|
|
|
|
|
|
388
|
0
|
|
|
|
|
|
foreach my $k ( keys(%$hash_param)) |
|
389
|
|
|
|
|
|
|
{ |
|
390
|
0
|
|
|
|
|
|
push @q , join '=' , ($k , $hash_param->{$k}); |
|
391
|
|
|
|
|
|
|
} |
|
392
|
|
|
|
|
|
|
|
|
393
|
0
|
|
|
|
|
|
$request_url = join '/', @api_end_point; |
|
394
|
0
|
0
|
|
|
|
|
$request_url = join '?' , $request_url , (join '&', @q ) if defined $q[0]; |
|
395
|
|
|
|
|
|
|
|
|
396
|
0
|
|
|
|
|
|
my $result; |
|
397
|
|
|
|
|
|
|
|
|
398
|
0
|
0
|
|
|
|
|
if ($method eq 'GET' ) |
|
|
|
0
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
{ |
|
400
|
0
|
|
|
|
|
|
$result = $self->get( 'api_end_point' => $request_url )->decoded_content; |
|
401
|
|
|
|
|
|
|
} |
|
402
|
|
|
|
|
|
|
elsif( $method eq 'POST') |
|
403
|
|
|
|
|
|
|
{ |
|
404
|
0
|
|
|
|
|
|
$result = $self->post( |
|
405
|
|
|
|
|
|
|
'api_end_point' => $request_url , |
|
406
|
|
|
|
|
|
|
'data' => $data |
|
407
|
|
|
|
|
|
|
); |
|
408
|
|
|
|
|
|
|
} |
|
409
|
0
|
|
|
|
|
|
$obj->populate( $result ); |
|
410
|
0
|
|
|
|
|
|
return $obj; |
|
411
|
|
|
|
|
|
|
} |
|
412
|
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
1; |
|
414
|
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
=head1 KNOWN BUGS |
|
416
|
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
=head1 SUPPORT |
|
418
|
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
open a github ticket or email comments to Bhavin Patel |
|
420
|
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
422
|
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
This Software is free to use , licensed under : The Artisic License 2.0 (GPL Compatible) |
|
424
|
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
=cut |