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