Webservice/OVH/Cloud/Project/IP/Failover.pm

filter: Statementstmt 18.9% 11 / 58 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 18.7% 3 / 16 Podpod 100% 12 / 12 totaltotal 26.0% 26 / 100 CC 8 SCAR 22.6
CC
8
Cov
15%
_new
30.0
attach
12.0
properties
6.0
CRAP 9.6
« OVH/OvhApi/Answer.pm ↑ Summary Webservice/OVH/Order.pm »
1 package Webservice::OVH::Cloud::Project::IP::Failover;
2  
3 =encoding utf-8
4  
5 =head1 NAME
6  
7 Webservice::OVH::Cloud::Project::IP::Failover
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 $failover_ips = $project->ip->failovers;
19
20 foreach my $ip (@$failover_ips) {
21
22 print $ip->routed_to;
23 }
24  
25 =head1 DESCRIPTION
26  
27 Gives access to failover ip functionality.
28  
29 =head1 METHODS
30  
31 =cut
32  
33 36 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 36 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 36 ▶use Carp qw{ carp croak };
Subroutine BEGIN: called CC=1 SCAR=0.0
36  
37 36 our $VERSION = 0.48;
38  
39 =head2 _new
40  
41 Internal Method to create the SSH 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::IP::Failover>
49  
50 =item * Synopsis: Webservice::OVH::Cloud::Project::IP::Failover->_new(wrapper => $ovh_api_wrapper, project => $project, module => $module, id => $id );
51  
52 =back
53  
54 =cut
55  
56 0 ▶sub _new {
Subroutine _new: not called CC=5 SCAR=34.0
57  
58 0 my ( $class, %params ) = @_;
59  
60 0 ▶ die "Missing id" unless $params{id};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"id"} 0 0 0
61 0 ▶ die "Missing project" unless $params{project};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"project"} 0 0 0
62 0 ▶ die "Missing module" unless $params{module};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"module"} 0 0 0
63 0 ▶ die "Missing wrapper" unless $params{wrapper};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"wrapper"} 0 0 0
64  
65 0 my $api_wrapper = $params{wrapper};
66 0 my $module = $params{module};
67 0 my $project = $params{project};
68 0 my $failover_id = $params{id};
69  
70 0 my $self = bless { module => $module, _api_wrapper => $api_wrapper, _project => $project, _id => $failover_id, _properties => {} }, $class;
71  
72 0 $self->properties;
73  
74 0 return $self;
75 }
76  
77 =head2 id
78  
79 Returns the api id
80  
81 =over
82  
83 =item * Return: VALUE
84  
85 =item * Synopsis: my $id = $failover_ip->id;
86  
87 =back
88  
89 =cut
90  
91 0 ▶sub id {
Subroutine id: not called CC=1 SCAR=6.9
Pod documented
92  
93 0 my ($self) = @_;
94  
95 0 return $self->{_id};
96 }
97  
98 =head2 project
99  
100 Root Project.
101  
102 =over
103  
104 =item * Return: L<Webservice::OVH::Cloud::Project>
105  
106 =item * Synopsis: my $project = $failover_ip->project;
107  
108 =back
109  
110 =cut
111  
112 0 ▶sub project {
Subroutine project: not called CC=1 SCAR=6.9
Pod documented
113  
114 0 my ($self) = @_;
115  
116 0 return $self->{_propject};
117 }
118  
119 =head2 properties
120  
121 Returns the raw properties as a hash.
122 This is the original return value of the web-api.
123  
124 =over
125  
126 =item * Return: HASH
127  
128 =item * Synopsis: my $properties = $failover->properties;
129  
130 =back
131  
132 =cut
133  
134 0 ▶sub properties {
Subroutine properties: not called CC=2 SCAR=17.9
Pod documented
135  
136 0 my ($self) = @_;
137  
138 0 my $api = $self->{_api_wrapper};
139 0 my $failover_id = $self->id;
140 0 my $project_id = $self->project->id;
141 0 my $response = $api->rawCall( method => 'get', path => "/cloud/project/$project_id/ip/failover/$failover_id", noSignature => 0 );
142 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
143 0 $self->{_properties} = $response->content;
144 0 return $self->{_properties};
145 }
146  
147 =head2 continent_code
148  
149 Exposed property value.
150  
151 =over
152  
153 =item * Return: VALUE
154  
155 =item * Synopsis: my $continent_code = $failover_ip->continent_code;
156  
157 =back
158  
159 =cut
160  
161 0 ▶sub continent_code {
Subroutine continent_code: not called CC=1 SCAR=6.9
Pod documented
162  
163 0 my ($self) = @_;
164  
165 0 return $self->{_properties}->{continentCode};
166 }
167  
168 =head2 progress
169  
170 Exposed property value.
171  
172 =over
173  
174 =item * Return: VALUE
175  
176 =item * Synopsis: my $progress = $failover_ip->progress;
177  
178 =back
179  
180 =cut
181  
182 0 ▶sub progress {
Subroutine progress: not called CC=1 SCAR=6.9
Pod documented
183  
184 0 my ($self) = @_;
185  
186 0 return $self->{_properties}->{progress};
187 }
188  
189 =head2 status
190  
191 Exposed property value.
192  
193 =over
194  
195 =item * Return: VALUE
196  
197 =item * Synopsis: my $status = $failover_ip->status;
198  
199 =back
200  
201 =cut
202  
203 0 ▶sub status {
Subroutine status: not called CC=1 SCAR=6.9
Pod documented
204  
205 0 my ($self) = @_;
206  
207 0 return $self->{_properties}->{status};
208 }
209  
210 =head2 ip
211  
212 Exposed property value.
213  
214 =over
215  
216 =item * Return: VALUE
217  
218 =item * Synopsis: my $ip = $failover_ip->ip;
219  
220 =back
221  
222 =cut
223  
224 0 ▶sub ip {
Subroutine ip: not called CC=1 SCAR=6.9
Pod documented
225  
226 0 my ($self) = @_;
227  
228 0 return $self->{_properties}->{ip};
229 }
230  
231 =head2 routed_to
232  
233 Exposed property value.
234  
235 =over
236  
237 =item * Return: VALUE
238  
239 =item * Synopsis: my $routed_to = $failover_ip->routed_to;
240  
241 =back
242  
243 =cut
244  
245 0 ▶sub routed_to {
Subroutine routed_to: not called CC=1 SCAR=6.9
Pod documented
246  
247 0 my ($self) = @_;
248  
249 0 return $self->{_properties}->{routedTo};
250 }
251  
252 =head2 sub_type
253  
254 Exposed property value.
255  
256 =over
257  
258 =item * Return: VALUE
259  
260 =item * Synopsis: my $sub_type = $failover_ip->sub_type;
261  
262 =back
263  
264 =cut
265  
266 0 ▶sub sub_type {
Subroutine sub_type: not called CC=1 SCAR=6.9
Pod documented
267  
268 0 my ($self) = @_;
269  
270 0 return $self->{_properties}->{subType};
271 }
272  
273 =head2 block
274  
275 Exposed property value.
276  
277 =over
278  
279 =item * Return: VALUE
280  
281 =item * Synopsis: my $block = $failover_ip->block;
282  
283 =back
284  
285 =cut
286  
287 0 ▶sub block {
Subroutine block: not called CC=1 SCAR=6.9
Pod documented
288  
289 0 my ($self) = @_;
290  
291 0 return $self->{_properties}->{block};
292 }
293  
294 =head2 geoloc
295  
296 Exposed property value.
297  
298 =over
299  
300 =item * Return: VALUE
301  
302 =item * Synopsis: my $geoloc = $failover_ip->geoloc;
303  
304 =back
305  
306 =cut
307  
308 0 ▶sub geoloc {
Subroutine geoloc: not called CC=1 SCAR=6.9
Pod documented
309  
310 0 my ($self) = @_;
311  
312 0 return $self->{_properties}->{geoloc};
313 }
314  
315 =head2 attach
316  
317 Attach failover ip to an instance.
318  
319 =over
320  
321 =item * Parameter: instance_id - instance id
322  
323 =item * Synopsis: $failover_ip->attach($instace_id);
324  
325 =back
326  
327 =cut
328  
329 0 ▶sub attach {
Subroutine attach: not called CC=3 SCAR=24.8
Pod documented
330  
331 0 my ( $self, $instance_id ) = @_;
332  
333 0 my $api = $self->{_api_wrapper};
334 0 my $failover_id = $self->id;
335 0 my $project_id = $self->project->id;
336  
337 0 ▶ croak "Missing instance_id" unless $instance_id;
Branch: 1 branch
BranchTrueFalseTotal
unless $instance_id 0 0 0
338  
339 0 my $response = $api->rawCall( method => 'post', path => "/cloud/project/$project_id/ip/failover/$failover_id/attach", body => { instanceId => $instance_id }, noSignature => 0 );
340 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
341 }
342  
343 36 1;
« OVH/OvhApi/Answer.pm ↑ Summary Webservice/OVH/Order.pm »