aboisvert_aws 3.0.0

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