blib/lib/VM/EC2/VPC/NetworkAcl/Entry.pm untested

filter: Statementstmt 0.0% 0 / 28 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 9 totaltotal 0.0% 0 / 49 CC 1 SCAR 6.9
CC
1
Cov
0%
primary_id
2.0
valid_fields
2.0
egress
2.0
CRAP 2.0
1 package VM::EC2::VPC::NetworkAcl::Entry;
2  
3 =head1 NAME
4  
5 VM::EC2::VPC::NetworkAcl::Entry - VPC Network ACL entry
6  
7 =head1 SYNOPSIS
8  
9 use VM::EC2;
10  
11 my $ec2 = VM::EC2->new(...);
12 my $acl = $ec2->describe_network_acls(-network_acl_id=>'acl-12345678');
13 my @entries = $acl->entries;
14  
15 # print outgoing icmp rules
16 for my $e (@entries) {
17 if ($e->egress && $e->protocol == 1) { # icmp = 1
18 print $e->ruleNumber,"\n",
19 $e->ruleAction,"\n",
20 $e->cidrBlock,"\n",
21 $e->icmpType,"\n",
22 $e->icmpCode,"\n";
23 }
24 }
25  
26 # print incoming tcp rules
27 for my $e (@entries) {
28 if (! $e->egress && $e->protocol == 6) { # tcp = 6
29 print $e->ruleNumber,"\n",
30 $e->ruleAction,"\n",
31 $e->cidrBlock,"\n",
32 $e->port_from,'-',$e->port_to,"\n";
33 }
34 }
35  
36 =head1 DESCRIPTION
37  
38 This object represents an Amazon EC2 VPC network ACL entry
39  
40 =head1 METHODS
41  
42 These object methods are supported:
43  
44 ruleNumber -- Specific rule number for the entry. ACL entries are
45 processed in ascending order by rule number.
46 protocol -- Protocol. A value of -1 means all protocols.
47 See: http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml
48 for a list of protocol numbers.
49 ruleAction -- Whether to allow or deny the traffic that matches the
50 rule. Valid values: allow | deny
51 egress -- Boolean flag to indicate an egress rule (rule is
52 applied to traffic leaving the subnet). Value of true
53 indicates egress.
54 cidrBlock -- The network range to allow or deny, in CIDR notation.
55 icmpType -- For the ICMP protocol, this is the ICMP type
56 icmpCode -- For the ICMP protocol, this is the ICMP code.
57 portRangeFrom -- For the TCP or UDP protocols, the starting range of ports the
58 rule applies to.
59 portRangeTo -- For the TCP or UDP protocols, the ending range of ports the
60 rule applies to.
61 port_from -- Alias for portRangeFrom
62 port_to -- Alias for portRangeTo
63  
64 The object also supports the tags() method described in
65 L<VM::EC2::Generic>:
66  
67 =head1 STRING OVERLOADING
68  
69 When used in a string context, this object will interpolate the
70 rule number
71  
72 =head1 SEE ALSO
73  
74 L<VM::EC2>
75 L<VM::EC2::Generic>
76 L<VM::EC2::Tag>
77 L<VM::EC2::VPC>
78 L<VM::EC2::VPC::NetworkAcl>
79  
80 =head1 AUTHOR
81  
82 Lance Kinley E<lt>lkinley@loyaltymethods.comE<gt>.
83  
84 Copyright (c) 2012 Loyalty Methods, Inc.
85  
86 This package and its accompanying libraries is free software; you can
87 redistribute it and/or modify it under the terms of the GPL (either
88 version 1, or at your option, any later version) or the Artistic
89 License 2.0. Refer to LICENSE for the full license text. In addition,
90 please see DISCLAIMER.txt for disclaimers of warranty.
91  
92 =cut
93  
94 use strict;
95 use base 'VM::EC2::Generic';
96 use Carp 'croak';
97  
98 sub primary_id { shift->ruleNumber }
99  
100 sub valid_fields {
101 my $self = shift;
102 return qw(ruleNumber protocol ruleAction egress cidrBlock icmpTypeCode portRange);
103 }
104  
105 sub egress {
106 my $self = shift;
107 return $self->SUPER::egress eq 'true';
108 }
109  
110 sub icmpType {
111 my $self = shift;
112 my $typecode = $self->icmpTypeCode;
113 return $typecode->{type};
114 }
115  
116 sub icmpCode {
117 my $self = shift;
118 my $typecode = $self->icmpTypeCode;
119 return $typecode->{code};
120 }
121  
122 sub portRangeFrom {
123 my $self = shift;
124 my $portRange = $self->portRange;
125 return $portRange->{from};
126 }
127  
128 sub port_from { shift->portRangeFrom }
129  
130 sub portRangeTo {
131 my $self = shift;
132 my $portRange = $self->portRange;
133 return $portRange->{to};
134 }
135  
136 sub port_to { shift->portRangeTo }
137  
138 1;
139