Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/boto/vpc/networkacl.py @ 0:26e78fe6e8c4 draft
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
author | shellac |
---|---|
date | Sat, 02 May 2020 07:14:21 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:26e78fe6e8c4 |
---|---|
1 # Copyright (c) 2009-2010 Mitch Garnaat http://garnaat.org/ | |
2 # | |
3 # Permission is hereby granted, free of charge, to any person obtaining a | |
4 # copy of this software and associated documentation files (the | |
5 # "Software"), to deal in the Software without restriction, including | |
6 # without limitation the rights to use, copy, modify, merge, publish, dis- | |
7 # tribute, sublicense, and/or sell copies of the Software, and to permit | |
8 # persons to whom the Software is furnished to do so, subject to the fol- | |
9 # lowing conditions: | |
10 # | |
11 # The above copyright notice and this permission notice shall be included | |
12 # in all copies or substantial portions of the Software. | |
13 # | |
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
15 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- | |
16 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT | |
17 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |
18 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | |
20 # IN THE SOFTWARE. | |
21 | |
22 """ | |
23 Represents a Network ACL | |
24 """ | |
25 | |
26 from boto.ec2.ec2object import TaggedEC2Object | |
27 from boto.resultset import ResultSet | |
28 | |
29 | |
30 class Icmp(object): | |
31 """ | |
32 Defines the ICMP code and type. | |
33 """ | |
34 def __init__(self, connection=None): | |
35 self.code = None | |
36 self.type = None | |
37 | |
38 def __repr__(self): | |
39 return 'Icmp::code:%s, type:%s)' % ( self.code, self.type) | |
40 | |
41 def startElement(self, name, attrs, connection): | |
42 pass | |
43 | |
44 def endElement(self, name, value, connection): | |
45 | |
46 if name == 'code': | |
47 self.code = value | |
48 elif name == 'type': | |
49 self.type = value | |
50 | |
51 class NetworkAcl(TaggedEC2Object): | |
52 | |
53 def __init__(self, connection=None): | |
54 super(NetworkAcl, self).__init__(connection) | |
55 self.id = None | |
56 self.vpc_id = None | |
57 self.network_acl_entries = [] | |
58 self.associations = [] | |
59 | |
60 def __repr__(self): | |
61 return 'NetworkAcl:%s' % self.id | |
62 | |
63 def startElement(self, name, attrs, connection): | |
64 result = super(NetworkAcl, self).startElement(name, attrs, connection) | |
65 | |
66 if result is not None: | |
67 # Parent found an interested element, just return it | |
68 return result | |
69 | |
70 if name == 'entrySet': | |
71 self.network_acl_entries = ResultSet([('item', NetworkAclEntry)]) | |
72 return self.network_acl_entries | |
73 elif name == 'associationSet': | |
74 self.associations = ResultSet([('item', NetworkAclAssociation)]) | |
75 return self.associations | |
76 else: | |
77 return None | |
78 | |
79 def endElement(self, name, value, connection): | |
80 if name == 'networkAclId': | |
81 self.id = value | |
82 elif name == 'vpcId': | |
83 self.vpc_id = value | |
84 else: | |
85 setattr(self, name, value) | |
86 | |
87 class NetworkAclEntry(object): | |
88 def __init__(self, connection=None): | |
89 self.rule_number = None | |
90 self.protocol = None | |
91 self.rule_action = None | |
92 self.egress = None | |
93 self.cidr_block = None | |
94 self.port_range = PortRange() | |
95 self.icmp = Icmp() | |
96 | |
97 def __repr__(self): | |
98 return 'Acl:%s' % self.rule_number | |
99 | |
100 def startElement(self, name, attrs, connection): | |
101 | |
102 if name == 'portRange': | |
103 return self.port_range | |
104 elif name == 'icmpTypeCode': | |
105 return self.icmp | |
106 else: | |
107 return None | |
108 | |
109 def endElement(self, name, value, connection): | |
110 if name == 'cidrBlock': | |
111 self.cidr_block = value | |
112 elif name == 'egress': | |
113 self.egress = value | |
114 elif name == 'protocol': | |
115 self.protocol = value | |
116 elif name == 'ruleAction': | |
117 self.rule_action = value | |
118 elif name == 'ruleNumber': | |
119 self.rule_number = value | |
120 | |
121 | |
122 class NetworkAclAssociation(object): | |
123 def __init__(self, connection=None): | |
124 self.id = None | |
125 self.subnet_id = None | |
126 self.network_acl_id = None | |
127 | |
128 def __repr__(self): | |
129 return 'NetworkAclAssociation:%s' % self.id | |
130 | |
131 def startElement(self, name, attrs, connection): | |
132 return None | |
133 | |
134 def endElement(self, name, value, connection): | |
135 if name == 'networkAclAssociationId': | |
136 self.id = value | |
137 elif name == 'networkAclId': | |
138 self.network_acl_id = value | |
139 elif name == 'subnetId': | |
140 self.subnet_id = value | |
141 | |
142 class PortRange(object): | |
143 """ | |
144 Define the port range for the ACL entry if it is tcp / udp | |
145 """ | |
146 | |
147 def __init__(self, connection=None): | |
148 self.from_port = None | |
149 self.to_port = None | |
150 | |
151 def __repr__(self): | |
152 return 'PortRange:(%s-%s)' % ( self.from_port, self.to_port) | |
153 | |
154 def startElement(self, name, attrs, connection): | |
155 pass | |
156 | |
157 def endElement(self, name, value, connection): | |
158 | |
159 if name == 'from': | |
160 self.from_port = value | |
161 elif name == 'to': | |
162 self.to_port = value | |
163 | |
164 |