line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Webservice::OVH::Cloud::Project::Image; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=encoding utf-8 |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Webservice::OVH::Cloud::Project::Image |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Webservice::OVH; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $ovh = Webservice::OVH->new_from_json("credentials.json"); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $projects = $ovh->cloud->projects; |
16
|
|
|
|
|
|
|
my $example_project = $projects->[0]; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $images = $project->images; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
foreach my $image (@$images) { |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
print $image->type; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 DESCRIPTION |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Provides access to information about an image. Nothing more can be done with this. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 METHODS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
36
|
|
|
36
|
|
289
|
use strict; |
|
36
|
|
|
|
|
96
|
|
|
36
|
|
|
|
|
1099
|
|
34
|
36
|
|
|
36
|
|
221
|
use warnings; |
|
36
|
|
|
|
|
84
|
|
|
36
|
|
|
|
|
1147
|
|
35
|
36
|
|
|
36
|
|
225
|
use Carp qw{ carp croak }; |
|
36
|
|
|
|
|
102
|
|
|
36
|
|
|
|
|
29764
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
our $VERSION = 0.48; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 _new_existing |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Internal Method to create the image object. |
42
|
|
|
|
|
|
|
This method is not ment to be called directly. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=over |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=item * Parameter: %params - key => value |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item * Return: L<Webservice::OVH::Cloud::Project::Image> |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=item * Synopsis: Webservice::OVH::Cloud::Project::Image->_new(wrapper => $ovh_api_wrapper, project => $project, module => $module, id => $id ); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=back |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _new_existing { |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
0
|
|
|
my ( $class, %params ) = @_; |
59
|
|
|
|
|
|
|
|
60
|
0
|
0
|
|
|
|
|
die "Missing id" unless $params{id}; |
61
|
0
|
0
|
|
|
|
|
die "Missing module" unless $params{module}; |
62
|
0
|
0
|
|
|
|
|
die "Missing wrapper" unless $params{wrapper}; |
63
|
0
|
0
|
|
|
|
|
die "Missing project" unless $params{project}; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my $project = $params{project}; |
66
|
0
|
|
|
|
|
|
my $project_id = $project->id; |
67
|
0
|
|
|
|
|
|
my $api_wrapper = $params{wrapper}; |
68
|
0
|
|
|
|
|
|
my $module = $params{module}; |
69
|
0
|
|
|
|
|
|
my $image_id = $params{id}; |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
my $response = $api_wrapper->rawCall( method => 'get', path => "/cloud/project/$project_id/image/$image_id", noSignature => 0 ); |
72
|
0
|
0
|
|
|
|
|
carp $response->error if $response->error; |
73
|
|
|
|
|
|
|
|
74
|
0
|
0
|
|
|
|
|
if ( !$response->error ) { |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
my $porperties = $response->content; |
77
|
0
|
|
|
|
|
|
my $self = bless { _module => $module, _valid => 1, _api_wrapper => $api_wrapper, _id => $image_id, _properties => $porperties, _project => $project }, $class; |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
return $self; |
80
|
|
|
|
|
|
|
} else { |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
return undef; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 project |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Root Project. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=over |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item * Return: L<Webservice::OVH::Cloud::Project> |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item * Synopsis: my $project = $ssh_key->project; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=back |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub project { |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
return $self->{_project}; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 id |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Returns the api id |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=over |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item * Return: VALUE |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item * Synopsis: my $id = $image->id; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=back |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub id { |
122
|
|
|
|
|
|
|
|
123
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
124
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
return $self->{_id}; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 properties |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Returns the raw properties as a hash. |
131
|
|
|
|
|
|
|
This is the original return value of the web-api. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=over |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item * Return: HASH |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item * Synopsis: my $properties = $image->properties; |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=back |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub properties { |
144
|
|
|
|
|
|
|
|
145
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
146
|
|
|
|
|
|
|
|
147
|
0
|
|
|
|
|
|
my $api = $self->{_api_wrapper}; |
148
|
0
|
|
|
|
|
|
my $project_id = $self->project->id; |
149
|
0
|
|
|
|
|
|
my $image_id = $self->id; |
150
|
0
|
|
|
|
|
|
my $response = $api->rawCall( method => 'get', path => "/cloud/project/$project_id/image/$image_id", noSignature => 0 ); |
151
|
0
|
0
|
|
|
|
|
croak $response->error if $response->error; |
152
|
0
|
|
|
|
|
|
$self->{_properties} = $response->content; |
153
|
0
|
|
|
|
|
|
return $self->{_properties}; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head2 visibility |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Exposed property value. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=over |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=item * Return: VALUE |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=item * Synopsis: my $visibility = $image->visibility; |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=back |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=cut |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub visibility { |
171
|
|
|
|
|
|
|
|
172
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
173
|
|
|
|
|
|
|
|
174
|
0
|
|
|
|
|
|
return $self->{_properties}->{visibility}; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head2 status |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Exposed property value. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=over |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=item * Return: VALUE |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=item * Synopsis: my $status = $image->status; |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=back |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=cut |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
sub status { |
192
|
|
|
|
|
|
|
|
193
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
194
|
|
|
|
|
|
|
|
195
|
0
|
|
|
|
|
|
return $self->{_properties}->{status}; |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head2 name |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
Exposed property value. |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=over |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=item * Return: VALUE |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=item * Synopsis: my $name = $image->name; |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=back |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=cut |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
sub name { |
213
|
|
|
|
|
|
|
|
214
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
215
|
|
|
|
|
|
|
|
216
|
0
|
|
|
|
|
|
return $self->{_properties}->{name}; |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=head2 region |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
Exposed property value. |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=over |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=item * Return: VALUE |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=item * Synopsis: my $region = $image->region; |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=back |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=cut |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
sub region { |
234
|
|
|
|
|
|
|
|
235
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
236
|
|
|
|
|
|
|
|
237
|
0
|
|
|
|
|
|
return $self->{_properties}->{region}; |
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=head2 min_disk |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
Exposed property value. |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=over |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=item * Return: VALUE |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=item * Synopsis: my $min_disk = $image->min_disk; |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=back |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=cut |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
sub min_disk { |
255
|
|
|
|
|
|
|
|
256
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
257
|
|
|
|
|
|
|
|
258
|
0
|
|
|
|
|
|
return $self->{_properties}->{minDisk}; |
259
|
|
|
|
|
|
|
} |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=head2 size |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
Exposed property value. |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=over |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=item * Return: VALUE |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=item * Synopsis: my $size = $image->size; |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
=back |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=cut |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
sub size { |
276
|
|
|
|
|
|
|
|
277
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
278
|
|
|
|
|
|
|
|
279
|
0
|
|
|
|
|
|
return $self->{_properties}->{size}; |
280
|
|
|
|
|
|
|
} |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=head2 creation_date |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
Exposed property value. |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
=over |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
=item * Return: DateTime |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
=item * Synopsis: my $creation_date = $image->creation_date; |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
=back |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
=cut |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
sub creation_date { |
297
|
|
|
|
|
|
|
|
298
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
299
|
|
|
|
|
|
|
|
300
|
0
|
|
|
|
|
|
my $str_datetime = $self->{_properties}->{creationDate}; |
301
|
0
|
|
|
|
|
|
my $datetime = Webservice::OVH::Helper->parse_datetime($str_datetime); |
302
|
0
|
|
|
|
|
|
return $datetime; |
303
|
|
|
|
|
|
|
} |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
=head2 min_ram |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
Exposed property value. |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
=over |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
=item * Return: VALUE |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
=item * Synopsis: my $min_ram = $image->min_ram; |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
=back |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
=cut |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
sub min_ram { |
320
|
|
|
|
|
|
|
|
321
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
322
|
|
|
|
|
|
|
|
323
|
0
|
|
|
|
|
|
return $self->{_properties}->{minRam}; |
324
|
|
|
|
|
|
|
} |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
=head2 user |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
Exposed property value. |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
=over |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
=item * Return: VALUE |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
=item * Synopsis: my $user = $image->user; |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
=back |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
=cut |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
sub user { |
341
|
|
|
|
|
|
|
|
342
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
343
|
|
|
|
|
|
|
|
344
|
0
|
|
|
|
|
|
return $self->{_properties}->{user}; |
345
|
|
|
|
|
|
|
} |
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
=head2 type |
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
Exposed property value. |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
=over |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
=item * Return: VALUE |
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
=item * Synopsis: my $type = $image->type; |
356
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
=back |
358
|
|
|
|
|
|
|
|
359
|
|
|
|
|
|
|
=cut |
360
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
sub type { |
362
|
|
|
|
|
|
|
|
363
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
364
|
|
|
|
|
|
|
|
365
|
0
|
|
|
|
|
|
return $self->{_properties}->{type}; |
366
|
|
|
|
|
|
|
} |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
1; |