dustMason-right_aws 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. data/History.txt +305 -0
  2. data/Manifest.txt +60 -0
  3. data/README.txt +165 -0
  4. data/Rakefile +112 -0
  5. data/lib/acf/right_acf_interface.rb +549 -0
  6. data/lib/acf/right_acf_invalidations.rb +144 -0
  7. data/lib/acf/right_acf_origin_access_identities.rb +230 -0
  8. data/lib/acf/right_acf_streaming_interface.rb +229 -0
  9. data/lib/acw/right_acw_interface.rb +248 -0
  10. data/lib/as/right_as_interface.rb +698 -0
  11. data/lib/awsbase/benchmark_fix.rb +39 -0
  12. data/lib/awsbase/right_awsbase.rb +1174 -0
  13. data/lib/awsbase/support.rb +35 -0
  14. data/lib/awsbase/version.rb +9 -0
  15. data/lib/ec2/right_ec2.rb +458 -0
  16. data/lib/ec2/right_ec2_ebs.rb +465 -0
  17. data/lib/ec2/right_ec2_images.rb +413 -0
  18. data/lib/ec2/right_ec2_instances.rb +785 -0
  19. data/lib/ec2/right_ec2_monitoring.rb +70 -0
  20. data/lib/ec2/right_ec2_placement_groups.rb +108 -0
  21. data/lib/ec2/right_ec2_reserved_instances.rb +174 -0
  22. data/lib/ec2/right_ec2_security_groups.rb +396 -0
  23. data/lib/ec2/right_ec2_spot_instances.rb +425 -0
  24. data/lib/ec2/right_ec2_tags.rb +139 -0
  25. data/lib/ec2/right_ec2_vpc.rb +583 -0
  26. data/lib/ec2/right_ec2_windows_mobility.rb +84 -0
  27. data/lib/elb/right_elb_interface.rb +571 -0
  28. data/lib/iam/right_iam_access_keys.rb +71 -0
  29. data/lib/iam/right_iam_groups.rb +195 -0
  30. data/lib/iam/right_iam_interface.rb +341 -0
  31. data/lib/iam/right_iam_mfa_devices.rb +67 -0
  32. data/lib/iam/right_iam_users.rb +251 -0
  33. data/lib/rds/right_rds_interface.rb +1309 -0
  34. data/lib/right_aws.rb +88 -0
  35. data/lib/route_53/right_route_53_interface.rb +630 -0
  36. data/lib/s3/right_s3.rb +1123 -0
  37. data/lib/s3/right_s3_interface.rb +1198 -0
  38. data/lib/sdb/active_sdb.rb +1107 -0
  39. data/lib/sdb/right_sdb_interface.rb +753 -0
  40. data/lib/sns/right_sns.rb +205 -0
  41. data/lib/sns/right_sns_interface.rb +343 -0
  42. data/lib/sqs/right_sqs.rb +387 -0
  43. data/lib/sqs/right_sqs_gen2.rb +342 -0
  44. data/lib/sqs/right_sqs_gen2_interface.rb +523 -0
  45. data/lib/sqs/right_sqs_interface.rb +593 -0
  46. data/right_aws.gemspec +91 -0
  47. data/test/acf/test_helper.rb +2 -0
  48. data/test/acf/test_right_acf.rb +138 -0
  49. data/test/awsbase/test_helper.rb +2 -0
  50. data/test/awsbase/test_right_awsbase.rb +12 -0
  51. data/test/ec2/test_helper.rb +2 -0
  52. data/test/ec2/test_right_ec2.rb +108 -0
  53. data/test/http_connection.rb +87 -0
  54. data/test/rds/test_helper.rb +2 -0
  55. data/test/rds/test_right_rds.rb +120 -0
  56. data/test/s3/test_helper.rb +2 -0
  57. data/test/s3/test_right_s3.rb +421 -0
  58. data/test/s3/test_right_s3_stubbed.rb +97 -0
  59. data/test/sdb/test_active_sdb.rb +357 -0
  60. data/test/sdb/test_batch_put_attributes.rb +54 -0
  61. data/test/sdb/test_helper.rb +3 -0
  62. data/test/sdb/test_right_sdb.rb +253 -0
  63. data/test/sns/test_helper.rb +2 -0
  64. data/test/sns/test_right_sns.rb +73 -0
  65. data/test/sqs/test_helper.rb +2 -0
  66. data/test/sqs/test_right_sqs.rb +285 -0
  67. data/test/sqs/test_right_sqs_gen2.rb +264 -0
  68. data/test/test_credentials.rb +37 -0
  69. data/test/ts_right_aws.rb +14 -0
  70. metadata +244 -0
@@ -0,0 +1,583 @@
1
+ #
2
+ # Copyright (c) 2009 RightScale Inc
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #
23
+
24
+ module RightAws
25
+
26
+ class Ec2
27
+
28
+ public
29
+
30
+ #-----------------
31
+ # VPC
32
+ #-----------------
33
+
34
+ # Describe VPCs.
35
+ #
36
+ # Accepts a list of vpcs and/or a set of filters as the last parameter.
37
+ #
38
+ # Filters: cidr, dchp-options-id, state, tag-key, tag-value, tag:key, vpc-id
39
+ #
40
+ # ec2.describe_vpcs #=>
41
+ # [{:vpc_id=>"vpc-890ce2e0",
42
+ # :dhcp_options_id=>"default",
43
+ # :cidr_block=>"10.0.0.0/23",
44
+ # :state=>"available"}]
45
+ #
46
+ # ec2.describe_vpcs("vpc-890ce2e0")
47
+ #
48
+ # ec2.describe_vpcs( :filters => {'tag:MyTag' => 'MyValue'} )
49
+ #
50
+ # ec2.describe_vpcs( :filters => {'cidr' => "192.168.1.0/24"} )
51
+ #
52
+ # P.S. filters: http://docs.amazonwebservices.com/AmazonVPC/latest/APIReference/index.html?ApiReference-query-DescribeVpcs.html
53
+ #
54
+ def describe_vpcs(*list_and_options)
55
+ describe_resources_with_list_and_options('DescribeVpcs', 'VpcId', QEc2DescribeVpcsParser, list_and_options)
56
+ end
57
+
58
+ # Create VPC.
59
+ #
60
+ # ec2.create_vpc('10.0.0.0/23') #=>
61
+ # {:vpc_id=>"vpc-890ce2e0",
62
+ # :dhcp_options_id=>"default",
63
+ # :cidr_block=>"10.0.0.0/23",
64
+ # :state=>"pending"}
65
+ #
66
+ def create_vpc(cidr_block)
67
+ link = generate_request("CreateVpc",'CidrBlock' => cidr_block )
68
+ request_info(link, QEc2DescribeVpcsParser.new(:logger => @logger)).first
69
+ rescue Exception
70
+ on_exception
71
+ end
72
+
73
+ # Delete VPC.
74
+ #
75
+ # ec2.delete_vpc("vpc-890ce2e0") #=> true
76
+ #
77
+ def delete_vpc(vpc_id)
78
+ link = generate_request("DeleteVpc", 'VpcId' => vpc_id )
79
+ request_info(link, RightHttp2xxParser.new(:logger => @logger))
80
+ rescue Exception
81
+ on_exception
82
+ end
83
+
84
+ #-----------------
85
+ # Subnets
86
+ #-----------------
87
+
88
+ # Describe Subnet.
89
+ #
90
+ # Accepts a list of subnets and/or a set of filters as the last parameter.
91
+ #
92
+ # Filters: availability-zone, available-ip-address-count, cidr, state, subnet-id, tag-key, tag-value, tag:key, vpc-id
93
+ #
94
+ # ec2.describe_subnets #=>
95
+ # [{:available_ip_address_count=>"251",
96
+ # :vpc_id=>"vpc-890ce2e0",
97
+ # :availability_zone=>"us-east-1a",
98
+ # :subnet_id=>"subnet-770de31e",
99
+ # :cidr_block=>"10.0.1.0/24",
100
+ # :state=>"available"}]
101
+ #
102
+ # ec2.describe_subnets(:filters => {'cidr' => "192.168.1.128/25"})
103
+ #
104
+ # P.S. filters: http://docs.amazonwebservices.com/AmazonVPC/latest/APIReference/index.html?ApiReference-query-DescribeSubnets.html
105
+ #
106
+ def describe_subnets(*list_and_options)
107
+ describe_resources_with_list_and_options('DescribeSubnets', 'SubnetId', QEc2DescribeSubnetsParser, list_and_options)
108
+ end
109
+
110
+ # Create Subnet.
111
+ #
112
+ # ec2.create_subnet("vpc-890ce2e0",'10.0.1.0/24') #=>
113
+ # {:available_ip_address_count=>"251",
114
+ # :vpc_id=>"vpc-890ce2e0",
115
+ # :availability_zone=>"us-east-1a",
116
+ # :subnet_id=>"subnet-770de31e",
117
+ # :cidr_block=>"10.0.1.0/24",
118
+ # :state=>"pending"}
119
+ #
120
+ def create_subnet(vpc_id, cidr_block, availability_zone = nil)
121
+ request_hash = { 'VpcId' => vpc_id,
122
+ 'CidrBlock' => cidr_block }
123
+ request_hash['AvailabilityZone'] = availability_zone unless availability_zone.right_blank?
124
+ link = generate_request("CreateSubnet", request_hash)
125
+ request_info(link, QEc2DescribeSubnetsParser.new(:logger => @logger)).first
126
+ rescue Exception
127
+ on_exception
128
+ end
129
+
130
+ # Delete Subnet.
131
+ #
132
+ # ec2.delete_subnet("subnet-770de31e") #=> true
133
+ #
134
+ def delete_subnet(subnet_id)
135
+ link = generate_request("DeleteSubnet", 'SubnetId' => subnet_id )
136
+ request_info(link, RightHttp2xxParser.new(:logger => @logger))
137
+ rescue Exception
138
+ on_exception
139
+ end
140
+
141
+ #-----------------
142
+ # DHCP Options
143
+ #-----------------
144
+
145
+ # Describe DHCP options.
146
+ #
147
+ # Accepts a list of DHCP options and/or a set of filters as the last parameter.
148
+ #
149
+ # Filters: dchp-options-id, key, value, tag-key, tag-value, tag:key
150
+ #
151
+ # ec2.describe_dhcp_options #=>
152
+ # [{:dhcp_options_id=>"dopt-cb0de3a2",
153
+ # :dhcp_configuration_set=>
154
+ # {"netbios-node-type"=>["1"], "domain-name"=>["my.awesomesite.ru"]}}]
155
+ #
156
+ # ec2.describe_dhcp_options(:filters => {'tag:MyTag' => 'MyValue'})
157
+ #
158
+ # P.S. filters: http://docs.amazonwebservices.com/AmazonVPC/latest/APIReference/index.html?ApiReference-query-DescribeDhcpOptions.html
159
+ #
160
+ def describe_dhcp_options(*list_and_options)
161
+ describe_resources_with_list_and_options('DescribeDhcpOptions', 'DhcpOptionsId', QEc2DescribeDhcpOptionsParser, list_and_options)
162
+ end
163
+
164
+ # Create DHCP options.
165
+ #
166
+ # ec2.create_dhcp_options('domain-name' => 'my.awesomesite.ru',
167
+ # 'netbios-node-type' => 1) #=>
168
+ # {:dhcp_options_id=>"dopt-cb0de3a2",
169
+ # :dhcp_configuration_set=>
170
+ # {"netbios-node-type"=>["1"], "domain-name"=>["my.awesomesite.ru"]}}
171
+ #
172
+ def create_dhcp_options(dhcp_configuration)
173
+ dhcp_configuration.each{ |key, values| dhcp_configuration[key] = Array(values) }
174
+ request_hash = amazonize_list(['DhcpConfiguration.?.Key','DhcpConfiguration.?.Value.?'], dhcp_configuration)
175
+ link = generate_request("CreateDhcpOptions", request_hash)
176
+ request_info(link, QEc2DescribeDhcpOptionsParser.new(:logger => @logger)).first
177
+ rescue Exception
178
+ on_exception
179
+ end
180
+
181
+ # Associate DHCP options
182
+ #
183
+ # ec2.associate_dhcp_options("dopt-cb0de3a2", "vpc-890ce2e0" ) #=> true
184
+ # ec2.describe_vpcs #=>
185
+ # [{:vpc_id=>"vpc-890ce2e0",
186
+ # :dhcp_options_id=>"dopt-cb0de3a2",
187
+ # :cidr_block=>"10.0.0.0/23",
188
+ # :state=>"available"}]
189
+ #
190
+ def associate_dhcp_options(dhcp_options_id, vpc_id)
191
+ link = generate_request("AssociateDhcpOptions", 'DhcpOptionsId' => dhcp_options_id,
192
+ 'VpcId' => vpc_id)
193
+ request_info(link, RightHttp2xxParser.new(:logger => @logger))
194
+ rescue Exception
195
+ on_exception
196
+ end
197
+
198
+ # Delete DHCP Options.
199
+ #
200
+ # ec2.delete_dhcp_options("dopt-cb0de3a2") #=> true
201
+ #
202
+ def delete_dhcp_options(dhcp_options_id)
203
+ link = generate_request("DeleteDhcpOptions", 'DhcpOptionsId' => dhcp_options_id )
204
+ request_info(link, RightHttp2xxParser.new(:logger => @logger))
205
+ rescue Exception
206
+ on_exception
207
+ end
208
+
209
+ #-----------------
210
+ # Customer Gateways
211
+ #-----------------
212
+
213
+ # Describe customer gateways.
214
+ #
215
+ # Accepts a list of gateways and/or a set of filters as the last parameter.
216
+ #
217
+ # Filters: bgp-asn, customer-gateway-id, state, type, tag-key, tag-value, tag:key
218
+ #
219
+ # ec2.describe_customer_gateways #=>
220
+ # [{:type=>"ipsec.1",
221
+ # :ip_address=>"12.1.2.3",
222
+ # :bgp_asn=>"65534",
223
+ # :state=>"available",
224
+ # :customer_gateway_id=>"cgw-d5a643bc"}]
225
+ #
226
+ # ec2.describe_customer_gateways(:filters => {'tag:MyTag' => 'MyValue'})
227
+ #
228
+ # P.S. filters: http://docs.amazonwebservices.com/AmazonVPC/latest/APIReference/index.html?ApiReference-query-DescribeCustomerGateways.html
229
+ #
230
+ def describe_customer_gateways(*list_and_options)
231
+ describe_resources_with_list_and_options('DescribeCustomerGateways', 'CustomerGatewayId', QEc2DescribeCustomerGatewaysParser, list_and_options)
232
+ end
233
+
234
+ # Create customer gateway.
235
+ #
236
+ # ec2.create_customer_gateway('ipsec.1', '12.1.2.3', 65534) #=>
237
+ # {:type=>"ipsec.1",
238
+ # :bgp_asn=>"65534",
239
+ # :ip_address=>"12.1.2.3",
240
+ # :state=>"pending",
241
+ # :customer_gateway_id=>"cgw-d5a643bc"}
242
+ #
243
+ def create_customer_gateway(type, ip_address, bgp_asn)
244
+ link = generate_request("CreateCustomerGateway", 'Type' => type,
245
+ 'IpAddress' => ip_address,
246
+ 'BgpAsn' => bgp_asn )
247
+ request_info(link, QEc2DescribeCustomerGatewaysParser.new(:logger => @logger)).first
248
+ rescue Exception
249
+ on_exception
250
+ end
251
+
252
+ # Delete customer gateway.
253
+ #
254
+ # ec2.delete_customer_gateway("cgw-d5a643bc") #=> true
255
+ #
256
+ def delete_customer_gateway(customer_gateway_id)
257
+ link = generate_request("DeleteCustomerGateway", 'CustomerGatewayId' => customer_gateway_id )
258
+ request_info(link, RightHttp2xxParser.new(:logger => @logger))
259
+ rescue Exception
260
+ on_exception
261
+ end
262
+
263
+ #-----------------
264
+ # VPN Gateways
265
+ #-----------------
266
+
267
+ # Describe VPN gateways.
268
+ #
269
+ # Accepts a list of VPN gateways and/or a set of filters as the last parameter.
270
+ #
271
+ # Filters: attachment.state, attachment.vpc-id, availability-zone, state, tag-key, tag-value, tag:key, type, vpn-gateway-id
272
+ #
273
+ # ec2.describe_vpn_gateways #=>
274
+ # [{:type=>"ipsec.1",
275
+ # :availability_zone=>"us-east-1a",
276
+ # :attachments=>[{:vpc_id=>"vpc-890ce2e0", :state=>"attached"}],
277
+ # :vpn_gateway_id=>"vgw-dfa144b6"}]
278
+ #
279
+ # ec2.describe_vpn_gateways(:filters => {'tag:MyTag' => 'MyValue'})
280
+ #
281
+ # P.S. filters: http://docs.amazonwebservices.com/AmazonVPC/latest/APIReference/index.html?ApiReference-query-DescribeVpnGateways.html
282
+ #
283
+ def describe_vpn_gateways(*list_and_options)
284
+ describe_resources_with_list_and_options('DescribeVpnGateways', 'VpnGatewayId', QEc2DescribeVpnGatewaysParser, list_and_options)
285
+ end
286
+
287
+ # Create VPN gateway.
288
+ #
289
+ # ec2.create_vpn_gateway('ipsec.1') #=>
290
+ # {:type=>"ipsec.1",
291
+ # :availability_zone=>"us-east-1a",
292
+ # :attachments=>[nil],
293
+ # :vpn_gateway_id=>"vgw-dfa144b6"}
294
+ #
295
+ def create_vpn_gateway(type, availability_zone=nil)
296
+ request_hash = { 'Type' => type }
297
+ request_hash['AvailabilityZone'] = availability_zone unless availability_zone.right_blank?
298
+ link = generate_request("CreateVpnGateway", request_hash )
299
+ request_info(link, QEc2DescribeVpnGatewaysParser.new(:logger => @logger)).first
300
+ rescue Exception
301
+ on_exception
302
+ end
303
+
304
+ # Attach VPN gateway.
305
+ #
306
+ # ec2.attach_vpn_gateway('vgw-dfa144b6','vpc-890ce2e0') #=>
307
+ # {:vpc_id=>"vpc-890ce2e0", :state=>"attaching"}
308
+ #
309
+ def attach_vpn_gateway(vpn_gateway_id, vpc_id)
310
+ link = generate_request("AttachVpnGateway", 'VpnGatewayId' => vpn_gateway_id,
311
+ 'VpcId' => vpc_id )
312
+ request_info(link, QEc2AttachVpnGatewayParser.new(:logger => @logger))
313
+ rescue Exception
314
+ on_exception
315
+ end
316
+
317
+ # Detach VPN gateway.
318
+ #
319
+ # ec2.detach_vpn_gateway('vgw-dfa144b6','vpc-890ce2e0') #=> true
320
+ #
321
+ def detach_vpn_gateway(vpn_gateway_id, vpc_id)
322
+ link = generate_request("DetachVpnGateway", 'VpnGatewayId' => vpn_gateway_id,
323
+ 'VpcId' => vpc_id )
324
+ request_info(link, RightHttp2xxParser.new(:logger => @logger))
325
+ rescue Exception
326
+ on_exception
327
+ end
328
+
329
+ # Delete vpn gateway.
330
+ #
331
+ # ec2.delete_vpn_gateway("vgw-dfa144b6") #=> true
332
+ #
333
+ def delete_vpn_gateway(vpn_gateway_id)
334
+ link = generate_request("DeleteVpnGateway", 'VpnGatewayId' => vpn_gateway_id )
335
+ request_info(link, RightHttp2xxParser.new(:logger => @logger))
336
+ rescue Exception
337
+ on_exception
338
+ end
339
+
340
+ #-----------------
341
+ # VPN Connections
342
+ #-----------------
343
+
344
+ # Describe VPN connections.
345
+ #
346
+ # Accepts a list of VPN gateways and/or a set of filters as the last parameter.
347
+ #
348
+ # Filters: customer-gateway-configuration, customer-gateway-id, state, tag-key, tag-value, tag:key,
349
+ # type, vpn-connection-id, vpn-gateway-id
350
+ #
351
+ # ec2.describe_vpn_connections #=>
352
+ # [{:type=>"ipsec.1",
353
+ # :vpn_connection_id=>"vpn-a9a643c0",
354
+ # :customer_gateway_configuration=>
355
+ # "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<vpn_connection id=\"vpn-a9a643c0\">\n...</vpn_connection>\n",
356
+ # :state=>"available",
357
+ # :vpn_gateway_id=>"vgw-dfa144b6",
358
+ # :customer_gateway_id=>"cgw-81a643e8"}]
359
+ #
360
+ # ec2.describe_vpn_gateways(:filters => {'tag:MyTag' => 'MyValue'})
361
+ #
362
+ # P.S. filters: http://docs.amazonwebservices.com/AmazonVPC/latest/APIReference/index.html?ApiReference-query-DescribeVpnConnections.html
363
+ #
364
+ def describe_vpn_connections(*list_and_options)
365
+ describe_resources_with_list_and_options('DescribeVpnConnections', 'VpnConnectionId', QEc2DescribeVpnConnectionsParser, list_and_options)
366
+ end
367
+
368
+ # Create VPN connection.
369
+ #
370
+ # ec2.create_vpn_connection('ipsec.1', 'cgw-81a643e8' ,'vgw-dfa144b6')
371
+ # {:customer_gateway_id=>"cgw-81a643e8",
372
+ # :vpn_connection_id=>"vpn-a9a643c0",
373
+ # :customer_gateway_configuration=>
374
+ # "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<vpn_connection id=\"vpn-a9a643c0\">\n...</vpn_connection>\n",
375
+ # :state=>"pending",
376
+ # :vpn_gateway_id=>"vgw-dfa144b6"}
377
+ #
378
+ def create_vpn_connection(type, customer_gateway_id, vpn_gateway_id)
379
+ link = generate_request("CreateVpnConnection", 'Type' => type,
380
+ 'CustomerGatewayId' => customer_gateway_id,
381
+ 'VpnGatewayId' => vpn_gateway_id )
382
+ request_info(link, QEc2DescribeVpnConnectionsParser.new(:logger => @logger)).first
383
+ rescue Exception
384
+ on_exception
385
+ end
386
+
387
+ # Delete VPN connection.
388
+ #
389
+ # ec2.delete_vpn_connection("vpn-a9a643c0") #=> true
390
+ #
391
+ def delete_vpn_connection(vpn_connection_id)
392
+ link = generate_request("DeleteVpnConnection", 'VpnConnectionId' => vpn_connection_id )
393
+ request_info(link, RightHttp2xxParser.new(:logger => @logger))
394
+ rescue Exception
395
+ on_exception
396
+ end
397
+
398
+ #-----------------
399
+ # Parsers
400
+ #-----------------
401
+
402
+ class QEc2DescribeVpcsParser < RightAWSParser #:nodoc:
403
+ def tagstart(name, attributes)
404
+ case full_tag_name
405
+ when %r{/(vpcSet/item|vpc)$} then @item = { :tags => {} }
406
+ when %r{/tagSet/item$} then @aws_tag = {}
407
+ end
408
+ end
409
+ def tagend(name)
410
+ case name
411
+ when 'vpcId' then @item[:vpc_id] = @text
412
+ when 'state' then @item[:state] = @text
413
+ when 'dhcpOptionsId' then @item[:dhcp_options_id] = @text
414
+ when 'cidrBlock' then @item[:cidr_block] = @text
415
+ else
416
+ case full_tag_name
417
+ when %r{/tagSet/item/key$} then @aws_tag[:key] = @text
418
+ when %r{/tagSet/item/value$} then @aws_tag[:value] = @text
419
+ when %r{/tagSet/item$} then @item[:tags][@aws_tag[:key]] = @aws_tag[:value]
420
+ when %r{(vpcSet/item|vpc)$} then @result << @item
421
+ end
422
+ end
423
+ end
424
+ def reset
425
+ @result = []
426
+ end
427
+ end
428
+
429
+ class QEc2DescribeSubnetsParser < RightAWSParser #:nodoc:
430
+ def tagstart(name, attributes)
431
+ case full_tag_name
432
+ when %r{/(subnetSet/item|subnet)$} then @item = { :tags => {} }
433
+ when %r{/tagSet/item$} then @aws_tag = {}
434
+ end
435
+ end
436
+ def tagend(name)
437
+ case name
438
+ when 'subnetId' then @item[:subnet_id] = @text
439
+ when 'state' then @item[:state] = @text
440
+ when 'vpcId' then @item[:vpc_id] = @text
441
+ when 'cidrBlock' then @item[:cidr_block] = @text
442
+ when 'availabilityZone' then @item[:availability_zone] = @text
443
+ when 'availableIpAddressCount' then @item[:available_ip_address_count] = @text
444
+ else
445
+ case full_tag_name
446
+ when %r{/tagSet/item/key$} then @aws_tag[:key] = @text
447
+ when %r{/tagSet/item/value$} then @aws_tag[:value] = @text
448
+ when %r{/tagSet/item$} then @item[:tags][@aws_tag[:key]] = @aws_tag[:value]
449
+ when %r{/(subnetSet/item|subnet)$} then @result << @item
450
+ end
451
+ end
452
+ end
453
+ def reset
454
+ @result = []
455
+ end
456
+ end
457
+
458
+ class QEc2DescribeDhcpOptionsParser < RightAWSParser #:nodoc:
459
+ def tagstart(name, attributes)
460
+ case full_tag_name
461
+ when %r{/(dhcpOptionsSet/item|dhcpOptions)$} then @item = { :tags => {}, :dhcp_configuration_set => {} }
462
+ when %r{/tagSet/item$} then @aws_tag = {}
463
+ end
464
+ end
465
+ def tagend(name)
466
+ case full_tag_name
467
+ when %r{/tagSet/item/key$} then @aws_tag[:key] = @text
468
+ when %r{/tagSet/item/value$} then @aws_tag[:value] = @text
469
+ when %r{/tagSet/item$} then @item[:tags][@aws_tag[:key]] = @aws_tag[:value]
470
+ when %r{/dhcpOptionsId$} then @item[:dhcp_options_id] = @text
471
+ when %r{/dhcpConfigurationSet/item/key$} then @conf_item_key = @text
472
+ when %r{/dhcpConfigurationSet/item/valueSet/item/value$} then (@item[:dhcp_configuration_set][@conf_item_key] ||= []) << @text
473
+ when %r{/(dhcpOptionsSet/item|dhcpOptions)$} then @result << @item
474
+ end
475
+ end
476
+ def reset
477
+ @result = []
478
+ end
479
+ end
480
+
481
+ class QEc2DescribeCustomerGatewaysParser < RightAWSParser #:nodoc:
482
+ def tagstart(name, attributes)
483
+ case full_tag_name
484
+ when %r{/(customerGatewaySet/item|customerGateway)$} then @item = { :tags => {} }
485
+ when %r{/tagSet/item$} then @aws_tag = {}
486
+ end
487
+ end
488
+ def tagend(name)
489
+ case name
490
+ when 'customerGatewayId' then @item[:customer_gateway_id] = @text
491
+ when 'state' then @item[:state] = @text
492
+ when 'type' then @item[:type] = @text
493
+ when 'ipAddress' then @item[:ip_address] = @text
494
+ when 'bgpAsn' then @item[:bgp_asn] = @text
495
+ else
496
+ case full_tag_name
497
+ when %r{/tagSet/item/key$} then @aws_tag[:key] = @text
498
+ when %r{/tagSet/item/value$} then @aws_tag[:value] = @text
499
+ when %r{/tagSet/item$} then @item[:tags][@aws_tag[:key]] = @aws_tag[:value]
500
+ when %r{/(customerGatewaySet/item|customerGateway)$} then @result << @item
501
+ end
502
+ end
503
+ end
504
+ def reset
505
+ @result = []
506
+ end
507
+ end
508
+
509
+ class QEc2DescribeVpnGatewaysParser < RightAWSParser #:nodoc:
510
+ def tagstart(name, attributes)
511
+ case full_tag_name
512
+ when %r{/(vpnGatewaySet/item|vpnGateway)$} then @item = { :tags => {}, :attachments => [] }
513
+ when %r{/attachments/item$} then @attachment = {}
514
+ when %r{/tagSet/item$} then @aws_tag = {}
515
+ end
516
+ end
517
+ def tagend(name)
518
+ case name
519
+ when 'vpnGatewayId' then @item[:vpn_gateway_id] = @text
520
+ when 'availabilityZone' then @item[:availability_zone] = @text
521
+ when 'type' then @item[:type] = @text
522
+ when 'vpcId' then @attachment[:vpc_id] = @text
523
+ else
524
+ case full_tag_name
525
+ when %r{/vpnGatewaySet/item/state$} then @item[:state] = @text
526
+ when %r{/attachments/item/state$} then @attachment[:state] = @text
527
+ when %r{/attachments/item$} then @item[:attachments] << @attachment unless @attachment.right_blank?
528
+ when %r{/tagSet/item/key$} then @aws_tag[:key] = @text
529
+ when %r{/tagSet/item/value$} then @aws_tag[:value] = @text
530
+ when %r{/tagSet/item$} then @item[:tags][@aws_tag[:key]] = @aws_tag[:value]
531
+ when %r{/(vpnGatewaySet/item|vpnGateway)$} then @result << @item
532
+ end
533
+ end
534
+ end
535
+ def reset
536
+ @result = []
537
+ end
538
+ end
539
+
540
+ class QEc2AttachVpnGatewayParser < RightAWSParser #:nodoc:
541
+ def tagend(name)
542
+ case name
543
+ when 'vpcId' then @result[:vpc_id] = @text
544
+ when 'state' then @result[:state] = @text
545
+ end
546
+ end
547
+ def reset
548
+ @result = {}
549
+ end
550
+ end
551
+
552
+
553
+ class QEc2DescribeVpnConnectionsParser < RightAWSParser #:nodoc:
554
+ def tagstart(name, attributes)
555
+ case full_tag_name
556
+ when %r{/(vpnConnectionSet/item|vpnConnection)$} then @item = { :tags => {} }
557
+ when %r{/tagSet/item$} then @aws_tag = {}
558
+ end
559
+ end
560
+ def tagend(name)
561
+ case name
562
+ when 'vpnConnectionId' then @item[:vpn_connection_id] = @text
563
+ when 'state' then @item[:state] = @text
564
+ when 'type' then @item[:type] = @text
565
+ when 'vpnGatewayId' then @item[:vpn_gateway_id] = @text
566
+ when 'customerGatewayId' then @item[:customer_gateway_id] = @text
567
+ when 'customerGatewayConfiguration' then @item[:customer_gateway_configuration] = @text
568
+ else
569
+ case full_tag_name
570
+ when %r{/tagSet/item/key$} then @aws_tag[:key] = @text
571
+ when %r{/tagSet/item/value$} then @aws_tag[:value] = @text
572
+ when %r{/tagSet/item$} then @item[:tags][@aws_tag[:key]] = @aws_tag[:value]
573
+ when %r{/(vpnConnectionSet/item|vpnConnection)$} then @result << @item
574
+ end
575
+ end
576
+ end
577
+ def reset
578
+ @result = []
579
+ end
580
+ end
581
+
582
+ end
583
+ end