line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
=encoding utf-8 |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
Webservice::OVH - A perl representation of the ovh-api |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 SYNOPSIS |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Webservice::OVH; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $ovh = Webservice::OVH->new("credentials.json"); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $ovh = Webservice::OVH->new(application_key => $key, application_secret => $secret, consumer_key => $token); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $services = $ovh->domain->services; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
foreach my $service (@$services) { |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $last_update = $service->last_update; |
21
|
|
|
|
|
|
|
print $last_update->datetime; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 DESCRIPTION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
This module reflects the path structure of the ovh web-api. |
27
|
|
|
|
|
|
|
This is the base object from where all api calls originate. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
This module uses the perl api module provided by ovh. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=begin html |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
<p><center><img src="https://raw.githubusercontent.com/itnode/Webservice-OVH/master/inc/API_HowTo.png"></center></p> |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=end html |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 METHODS |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
use strict; |
43
|
36
|
|
|
36
|
|
3185421
|
use warnings; |
|
36
|
|
|
|
|
411
|
|
|
36
|
|
|
|
|
954
|
|
44
|
36
|
|
|
36
|
|
168
|
use Carp qw{ carp croak }; |
|
36
|
|
|
|
|
59
|
|
|
36
|
|
|
|
|
933
|
|
45
|
36
|
|
|
36
|
|
151
|
|
|
36
|
|
|
|
|
54
|
|
|
36
|
|
|
|
|
1925
|
|
46
|
|
|
|
|
|
|
our $VERSION = 0.47; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# api module provided by ovh |
49
|
|
|
|
|
|
|
use OVH::OvhApi; |
50
|
36
|
|
|
36
|
|
13097
|
|
|
36
|
|
|
|
|
97
|
|
|
36
|
|
|
|
|
1255
|
|
51
|
|
|
|
|
|
|
# sub-modules |
52
|
|
|
|
|
|
|
use Webservice::OVH::Domain; |
53
|
36
|
|
|
36
|
|
15438
|
use Webservice::OVH::Me; |
|
36
|
|
|
|
|
123
|
|
|
36
|
|
|
|
|
1293
|
|
54
|
36
|
|
|
36
|
|
15467
|
use Webservice::OVH::Order; |
|
36
|
|
|
|
|
99
|
|
|
36
|
|
|
|
|
1066
|
|
55
|
36
|
|
|
36
|
|
15412
|
use Webservice::OVH::Email; |
|
36
|
|
|
|
|
153
|
|
|
36
|
|
|
|
|
1498
|
|
56
|
36
|
|
|
36
|
|
12787
|
use Webservice::OVH::Cloud; |
|
36
|
|
|
|
|
101
|
|
|
36
|
|
|
|
|
1135
|
|
57
|
36
|
|
|
36
|
|
15691
|
use Webservice::OVH::Hosting; |
|
36
|
|
|
|
|
109
|
|
|
36
|
|
|
|
|
1118
|
|
58
|
36
|
|
|
36
|
|
14292
|
|
|
36
|
|
|
|
|
88
|
|
|
36
|
|
|
|
|
1089
|
|
59
|
|
|
|
|
|
|
# other requirements |
60
|
|
|
|
|
|
|
use JSON; |
61
|
36
|
|
|
36
|
|
252
|
use File::Slurp qw(read_file); |
|
36
|
|
|
|
|
68
|
|
|
36
|
|
|
|
|
159
|
|
62
|
36
|
|
|
36
|
|
21001
|
|
|
36
|
|
|
|
|
717092
|
|
|
36
|
|
|
|
|
25611
|
|
63
|
|
|
|
|
|
|
=head2 new_from_json |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Creates an api Object based on credentials in a json File |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=over |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=item * Parameter: $file_json - dir to json file |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item * Return: L<Webservice::OVH> |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item * Synopsis: Webservice::OVH->new_from_json("path/file"); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=back |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=over 2 |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item * application_key is generated when creating an application via ovh web interface |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item * application_secret is generated when creating an application via ovh web interface |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item * consumer_key must be requested through ovh authentification |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=item * timeout timeout in milliseconds, warning some request may take a while |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=back |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
my ( $class, $file_json ) = @_; |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
0
|
1
|
|
# slurp file |
95
|
|
|
|
|
|
|
my $json = read_file($file_json, { binmode => ':raw' }); |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
# decode json |
98
|
|
|
|
|
|
|
my $Json = JSON->new->allow_nonref; |
99
|
|
|
|
|
|
|
my $data = $Json->decode($json); |
100
|
0
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
# check for missing parameters in the json file |
102
|
|
|
|
|
|
|
my @keys = qw{ application_key application_secret consumer_key }; |
103
|
|
|
|
|
|
|
if ( my @missing_parameters = grep { not $data->{$_} } @keys ) { |
104
|
0
|
|
|
|
|
|
|
105
|
0
|
0
|
|
|
|
|
croak "Missing parameter: @missing_parameters"; |
|
0
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
} |
107
|
0
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
my $self = bless {}, $class; |
109
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
# Create internal objects to mirror the web api of ovh |
111
|
|
|
|
|
|
|
my $api_wrapper = OVH::OvhApi->new( 'type' => "https://eu.api.ovh.com/1.0", applicationKey => $data->{application_key}, applicationSecret => $data->{application_secret}, consumerKey => $data->{consumer_key} ); |
112
|
|
|
|
|
|
|
my $domain = Webservice::OVH::Domain->_new( wrapper => $api_wrapper, module => $self ); |
113
|
0
|
|
|
|
|
|
my $me = Webservice::OVH::Me->_new( wrapper => $api_wrapper, module => $self ); |
114
|
0
|
|
|
|
|
|
my $order = Webservice::OVH::Order->_new( wrapper => $api_wrapper, module => $self ); |
115
|
0
|
|
|
|
|
|
my $email = Webservice::OVH::Email->_new( wrapper => $api_wrapper, module => $self ); |
116
|
0
|
|
|
|
|
|
my $cloud = Webservice::OVH::Cloud->_new( wrapper => $api_wrapper, module => $self ); |
117
|
0
|
|
|
|
|
|
my $hosting = Webservice::OVH::Hosting->_new( wrapper => $api_wrapper, module => $self ); |
118
|
0
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
# Timeout can be also set in the json file |
120
|
|
|
|
|
|
|
OVH::OvhApi->setRequestTimeout( timeout => $data->{timeout} || 120 ); |
121
|
|
|
|
|
|
|
|
122
|
0
|
|
0
|
|
|
|
# Setting private variables |
123
|
|
|
|
|
|
|
$self->{_domain} = $domain; |
124
|
|
|
|
|
|
|
$self->{_me} = $me; |
125
|
0
|
|
|
|
|
|
$self->{_order} = $order; |
126
|
0
|
|
|
|
|
|
$self->{_api_wrapper} = $api_wrapper; |
127
|
0
|
|
|
|
|
|
$self->{_email} = $email; |
128
|
0
|
|
|
|
|
|
$self->{_cloud} = $cloud; |
129
|
0
|
|
|
|
|
|
$self->{_hosting} = $hosting; |
130
|
0
|
|
|
|
|
|
|
131
|
0
|
|
|
|
|
|
return $self; |
132
|
|
|
|
|
|
|
} |
133
|
0
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head2 new |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Create the api object. Credentials are given directly via %params |
137
|
|
|
|
|
|
|
Credentials can be generated via ovh web interface and ovh authentification |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=over |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item * Parameter: %params - application_key => value, application_secret => value, consumer_key => value |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item * Return: L<Webservice::OVH> |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item * Synopsis: Webservice::OVH->new(application_key => $key, application_secret => $secret, consumer_key => $token); |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=back |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
my ( $class, %params ) = @_; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
my @keys = qw{ application_key application_secret consumer_key }; |
155
|
0
|
|
|
0
|
1
|
|
|
156
|
|
|
|
|
|
|
if ( my @missing_parameters = grep { not $params{$_} } @keys ) { |
157
|
0
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
croak "Missing parameter: @missing_parameters"; |
159
|
0
|
0
|
|
|
|
|
} |
|
0
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
|
161
|
0
|
|
|
|
|
|
my $self = bless {}, $class; |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
my $api_wrapper = OVH::OvhApi->new( 'type' => "https://eu.api.ovh.com/1.0", applicationKey => $params{application_key}, applicationSecret => $params{application_secret}, consumerKey => $params{consumer_key} ); |
164
|
0
|
|
|
|
|
|
my $domain = Webservice::OVH::Domain->_new( wrapper => $api_wrapper, module => $self ); |
165
|
|
|
|
|
|
|
my $me = Webservice::OVH::Me->_new( wrapper => $api_wrapper, module => $self ); |
166
|
0
|
|
|
|
|
|
my $order = Webservice::OVH::Order->_new( wrapper => $api_wrapper, module => $self ); |
167
|
0
|
|
|
|
|
|
my $email = Webservice::OVH::Email->_new( wrapper => $api_wrapper, module => $self ); |
168
|
0
|
|
|
|
|
|
my $cloud = Webservice::OVH::Cloud->_new( wrapper => $api_wrapper, module => $self ); |
169
|
0
|
|
|
|
|
|
my $hosting = Webservice::OVH::Hosting->_new( wrapper => $api_wrapper, module => $self ); |
170
|
0
|
|
|
|
|
|
|
171
|
0
|
|
|
|
|
|
OVH::OvhApi->setRequestTimeout( timeout => $params{timeout} || 120 ); |
172
|
0
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
$self->{_domain} = $domain; |
174
|
0
|
|
0
|
|
|
|
$self->{_me} = $me; |
175
|
|
|
|
|
|
|
$self->{_order} = $order; |
176
|
0
|
|
|
|
|
|
$self->{_api_wrapper} = $api_wrapper; |
177
|
0
|
|
|
|
|
|
$self->{_email} = $email; |
178
|
0
|
|
|
|
|
|
$self->{_cloud} = $cloud; |
179
|
0
|
|
|
|
|
|
$self->{_hosting} = $hosting; |
180
|
0
|
|
|
|
|
|
|
181
|
0
|
|
|
|
|
|
return $self; |
182
|
0
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
0
|
|
|
|
|
|
=head2 set_timeout |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Sets the timeout of the underlying LWP::Agent |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=over |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=item * Parameter: timeout - in milliseconds default 120 |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=item * Synopsis: Webservice::OVH->set_timeout(120); |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=back |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=cut |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
my ( $class, $timeout ) = @_; |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
OVH::OvhApi->setRequestTimeout( timeout => $timeout ); |
202
|
|
|
|
|
|
|
} |
203
|
0
|
|
|
0
|
1
|
|
|
204
|
|
|
|
|
|
|
=head2 domain |
205
|
0
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
Main access to all /domain/ api methods |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=over |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=item * Return: L<Webservice::OVH::Domain> |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=item * Synopsis: $ovh->domain; |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=back |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=cut |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
my ($self) = @_; |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
return $self->{_domain}; |
222
|
|
|
|
|
|
|
} |
223
|
|
|
|
|
|
|
|
224
|
0
|
|
|
0
|
1
|
|
=head2 me |
225
|
|
|
|
|
|
|
|
226
|
0
|
|
|
|
|
|
Main access to all /me/ api methods |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=over |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=item * Return: L<Webservice::OVH::Me> |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=item * Synopsis: $ovh->me; |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=back |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=cut |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
my ($self) = @_; |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
return $self->{_me}; |
242
|
|
|
|
|
|
|
} |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=head2 order |
245
|
0
|
|
|
0
|
1
|
|
|
246
|
|
|
|
|
|
|
Main access to all /order/ api methods |
247
|
0
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=over |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=item * Return: L<Webservice::OVH::Order> |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=item * Synopsis: $ovh->order; |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=back |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=cut |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
my ($self) = @_; |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
return $self->{_order}; |
262
|
|
|
|
|
|
|
} |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=head2 email |
265
|
|
|
|
|
|
|
|
266
|
0
|
|
|
0
|
1
|
|
Main access to all /email/ api methods |
267
|
|
|
|
|
|
|
|
268
|
0
|
|
|
|
|
|
=over |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
=item * Return: L<Webservice::OVH::Email> |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=item * Synopsis: $ovh->email; |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=back |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=cut |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
my ($self) = @_; |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
return $self->{_email}; |
282
|
|
|
|
|
|
|
} |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=head2 cloud |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
Main access to all /cloud/ api methods |
287
|
0
|
|
|
0
|
1
|
|
|
288
|
|
|
|
|
|
|
=over |
289
|
0
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
=item * Return: L<Webservice::OVH::Cloud> |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
=item * Synopsis: $ovh->cloud; |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
=back |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
=cut |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
my ($self) = @_; |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
return $self->{_cloud}; |
302
|
|
|
|
|
|
|
} |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
=head2 hosting |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
Main access to all /hosting/ api methods |
307
|
|
|
|
|
|
|
|
308
|
0
|
|
|
0
|
1
|
|
=over |
309
|
|
|
|
|
|
|
|
310
|
0
|
|
|
|
|
|
=item * Return: L<Webservice::OVH::Cloud> |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
=item * Synopsis: $ovh->cloud; |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
=back |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
=cut |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
my ($self) = @_; |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
return $self->{_hosting}; |
322
|
|
|
|
|
|
|
} |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
=head1 AUTHOR |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
Patrick Jendral |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
329
|
0
|
|
|
0
|
1
|
|
|
330
|
|
|
|
|
|
|
This library is free software; you may redistribute it and/or modify it under the same terms as Perl itself. |
331
|
0
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
=cut |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
1; |