lib/VM/EC2/REST/internet_gateway.pm

filter: Statementstmt 20.5% 8 / 39 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 28.5% 2 / 7 Podpod 0.0% 0 / 5 totaltotal 12.6% 10 / 79 CC 9 SCAR 30.2
CC
9
Cov
14%
attach_internet_gateway
30.0
detach_internet_gateway
30.0
create_internet_gateway
2.0
CRAP 20.5
« lib/VM/EC2/ReservedInstance/ParmParser.pm ↑ Summary blib/lib/VM/EC2/REST/spot_instance.pm »
1 package VM::EC2::REST::internet_gateway;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use VM::EC2 ''; # important not to import anything!
Subroutine BEGIN: called CC=1 SCAR=0.0
5 package VM::EC2; # add methods to VM::EC2
6  
7 1 VM::EC2::Dispatch->register(
8 CreateInternetGateway => 'fetch_one,internetGateway,VM::EC2::VPC::InternetGateway',
9 DescribeInternetGateways => 'fetch_items,internetGatewaySet,VM::EC2::VPC::InternetGateway',
10 DeleteInternetGateway => 'boolean',
11 AttachInternetGateway => 'boolean',
12 DetachInternetGateway => 'boolean',
13 );
14  
15 =head1 NAME VM::EC2::REST::internet_gateway
16  
17 =head1 SYNOPSIS
18  
19 use VM::EC2 ':vpc'
20  
21 =head1 METHODS
22  
23 These methods provide methods for creating, associating and deleting
24 Internet Gateway objects.
25  
26 Implemented:
27 AttachInternetGateway
28 CreateInternetGateway
29 DeleteInternetGateway
30 DescribeInternetGateways
31 DetachInternetGateway
32  
33 Unimplemented:
34 (none)
35  
36 =head2 $gateway = $ec2->create_internet_gateway()
37  
38 This method creates a new Internet gateway. It takes no arguments and
39 returns a VM::EC2::VPC::InternetGateway object. Gateways are initially
40 independent of any VPC, but later can be attached to one or more VPCs
41 using attach_internet_gateway().
42  
43 =cut
44  
45 sub create_internet_gateway {
46 0 ▶ my $self = shift;
Subroutine create_internet_gateway: not called CC=1 SCAR=6.9
Pod undocumented
47 0 return $self->call('CreateInternetGateway');
48 }
49  
50 =head2 $success = $ec2->delete_internet_gateway($internet_gateway_id)
51  
52 =head2 $success = $ec2->delete_internet_gateway(-internet_gateway_id=>$id)
53  
54 This method deletes the indicated internet gateway. It may be called
55 with a single argument corresponding to the route table's ID, or using
56 the named form with argument -internet_gateway_id.
57  
58 =cut
59  
60 sub delete_internet_gateway {
61 0 ▶ my $self = shift;
Subroutine delete_internet_gateway: not called CC=1 SCAR=6.9
Pod undocumented
62 0 my %args = $self->args(-internet_gateway_id=>@_);
63 0 my @parm = $self->single_parm(InternetGatewayId=>\%args);
64 0 return $self->call('DeleteInternetGateway',@parm);
65 }
66  
67  
68 =head2 @gateways = $ec2->describe_internet_gateways(@gateway_ids)
69  
70 =head2 @gateways = $ec2->describe_internet_gateways(\%filters)
71  
72 =head2 @gateways = $ec2->describe_internet_gateways(-internet_gateway_id=>\@ids,
73 -filter =>\$filters)
74  
75 This method describes all or some of the internet gateways available
76 to you. You may use the filter to restrict the search to a particular
77 type of internet gateway using one or more of the filters described at
78 http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeInternetGateways.html.
79  
80 Some of the commonly used filters are:
81  
82 attachment.vpc-id ID of one of the VPCs the gateway is attached to
83 attachment.state State of the gateway, always "available"
84 tag:<key> Value of a tag
85  
86 On success this method returns a list of VM::EC2::VPC::InternetGateway
87 objects.
88  
89 =cut
90  
91 sub describe_internet_gateways {
92 0 ▶ my $self = shift;
Subroutine describe_internet_gateways: not called CC=1 SCAR=6.9
Pod undocumented
93 0 my %args = $self->args(-internet_gateway_id => @_);
94 0 my @parm = $self->list_parm('InternetGatewayId',\%args);
95 0 push @parm, $self->filter_parm(\%args);
96 0 return $self->call('DescribeInternetGateways',@parm);
97 }
98  
99 =head2 $boolean = $ec2->attach_internet_gateway($internet_gateway_id,$vpc_id)
100  
101 =head2 $boolean = $ec2->attach_internet_gateway(-internet_gateway_id => $id,
102 -vpc_id => $id)
103  
104 This method attaches an internet gateway to a VPC. You can use
105 internet gateway and VPC IDs, or their corresponding
106 VM::EC2::VPC::InternetGateway and VM::EC2::VPC objects.
107  
108 Required arguments:
109  
110 -internet_gateway_id ID of the network interface to attach.
111 -vpc_id ID of the instance to attach the interface to.
112  
113 On success, this method a true value.
114  
115 Note that it may be more convenient to attach and detach gateways via
116 methods in the VM::EC2::VPC and VM::EC2::VPC::Gateway objects.
117  
118 $vpc->attach_internet_gateway($gateway);
119 $gateway->attach($vpc);
120  
121 =cut
122  
123 sub attach_internet_gateway {
124 0 ▶ my $self = shift;
Subroutine attach_internet_gateway: not called CC=5 SCAR=34.0
Pod undocumented
125 0 my %args;
126 0 ▶ if ($_[0] !~ /^-/ && @_ == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $_[0] =~ /^-/ and @_ == 2) { } 0 0 0
Condition0%0/3
not $_[0] =~ /^-/ and @_ == 2
!ll&&!rl&&r
000
MC/DC0%0/2
not $_[0] =~ /^-/ and @_ == 2
not $_[0] =~ /^-/ @_ == 2
Truth table0%0/3
not(A) and B
A= not $_[0] =~ /^-/B= @_ == 2
ABresult
0X0
100
111
127 0 @args{qw(-internet_gateway_id -vpc_id)} = @_;
128 } else {
129 0 %args = @_;
130 }
131 $args{-internet_gateway_id} && $args{-vpc_id}
132 0 ▶ or croak "-internet_gateway_id and-vpc_id arguments must be specified";
Branch: 1 branch
BranchTrueFalseTotal
$args{"-internet_gateway_id"} and $args{"-vpc_id"} or croak("-internet_gateway_id and-vpc_id arguments must be specified") 0 0 0
Condition0%0/3
$args{"-internet_gateway_id"} and $args{"-vpc_id"}
!ll&&!rl&&r
000
MC/DC0%0/2
$args{"-internet_gateway_id"} and $args{"-vpc_id"}
$args{"-internet_gateway_id"} $args{"-vpc_id"}
Truth table0%0/3
A and B
A= $args{"-internet_gateway_id"}B= $args{"-vpc_id"}
ABresult
0X0
100
111
133  
134 0 $args{-device_index} =~ s/^eth//;
135
136 0 my @param = $self->single_parm(InternetGatewayId=>\%args);
137 0 push @param,$self->single_parm(VpcId=>\%args);
138 0 return $self->call('AttachInternetGateway',@param);
139 }
140  
141 =head2 $boolean = $ec2->detach_internet_gateway($internet_gateway_id,$vpc_id)
142  
143 =head2 $boolean = $ec2->detach_internet_gateway(-internet_gateway_id => $id,
144 -vpc_id => $id)
145  
146 This method detaches an internet gateway to a VPC. You can use
147 internet gateway and VPC IDs, or their corresponding
148 VM::EC2::VPC::InternetGateway and VM::EC2::VPC objects.
149  
150 Required arguments:
151  
152 -internet_gateway_id ID of the network interface to detach.
153 -vpc_id ID of the VPC to detach the gateway from.
154  
155 On success, this method a true value.
156  
157 Note that it may be more convenient to detach and detach gateways via
158 methods in the VM::EC2::VPC and VM::EC2::VPC::Gateway objects.
159  
160 $vpc->detach_internet_gateway($gateway);
161 $gateway->detach($vpc);
162  
163 =cut
164  
165 sub detach_internet_gateway {
166 0 ▶ my $self = shift;
Subroutine detach_internet_gateway: not called CC=5 SCAR=34.0
Pod undocumented
167 0 my %args;
168 0 ▶ if ($_[0] !~ /^-/ && @_ == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $_[0] =~ /^-/ and @_ == 2) { } 0 0 0
Condition0%0/3
not $_[0] =~ /^-/ and @_ == 2
!ll&&!rl&&r
000
MC/DC0%0/2
not $_[0] =~ /^-/ and @_ == 2
not $_[0] =~ /^-/ @_ == 2
Truth table0%0/3
not(A) and B
A= not $_[0] =~ /^-/B= @_ == 2
ABresult
0X0
100
111
169 0 @args{qw(-internet_gateway_id -vpc_id)} = @_;
170 } else {
171 0 %args = @_;
172 }
173 $args{-internet_gateway_id} && $args{-vpc_id}
174 0 ▶ or croak "-internet_gateway_id and-vpc_id arguments must be specified";
Branch: 1 branch
BranchTrueFalseTotal
$args{"-internet_gateway_id"} and $args{"-vpc_id"} or croak("-internet_gateway_id and-vpc_id arguments must be specified") 0 0 0
Condition0%0/3
$args{"-internet_gateway_id"} and $args{"-vpc_id"}
!ll&&!rl&&r
000
MC/DC0%0/2
$args{"-internet_gateway_id"} and $args{"-vpc_id"}
$args{"-internet_gateway_id"} $args{"-vpc_id"}
Truth table0%0/3
A and B
A= $args{"-internet_gateway_id"}B= $args{"-vpc_id"}
ABresult
0X0
100
111
175  
176 0 $args{-device_index} =~ s/^eth//;
177
178 0 my @param = $self->single_parm(InternetGatewayId=>\%args);
179 0 push @param,$self->single_parm(VpcId=>\%args);
180 0 return $self->call('DetachInternetGateway',@param);
181 }
182  
183 =head1 SEE ALSO
184  
185 L<VM::EC2>
186  
187 =head1 AUTHOR
188  
189 Lincoln Stein E<lt>lincoln.stein@gmail.comE<gt>.
190  
191 Copyright (c) 2011 Ontario Institute for Cancer Research
192  
193 This package and its accompanying libraries is free software; you can
194 redistribute it and/or modify it under the terms of the GPL (either
195 version 1, or at your option, any later version) or the Artistic
196 License 2.0. Refer to LICENSE for the full license text. In addition,
197 please see DISCLAIMER.txt for disclaimers of warranty.
198  
199 =cut
200  
201  
202 1 1;
« lib/VM/EC2/ReservedInstance/ParmParser.pm ↑ Summary blib/lib/VM/EC2/REST/spot_instance.pm »