aws-sdk 1.3.5 → 1.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/lib/aws/api_config/EC2-2011-12-15.yml +2791 -0
  2. data/lib/aws/core.rb +4 -4
  3. data/lib/aws/core/client.rb +1 -0
  4. data/lib/aws/core/client_logging.rb +9 -2
  5. data/lib/aws/core/lazy_error_classes.rb +1 -1
  6. data/lib/aws/core/response.rb +5 -0
  7. data/lib/aws/core/service_interface.rb +3 -2
  8. data/lib/aws/core/uri_escape.rb +1 -2
  9. data/lib/aws/ec2.rb +80 -1
  10. data/lib/aws/ec2/client.rb +29 -10
  11. data/lib/aws/ec2/client/xml.rb +51 -1
  12. data/lib/aws/ec2/customer_gateway.rb +90 -0
  13. data/lib/aws/ec2/customer_gateway_collection.rb +73 -0
  14. data/lib/aws/ec2/dhcp_options.rb +106 -0
  15. data/lib/aws/ec2/dhcp_options_collection.rb +87 -0
  16. data/lib/aws/ec2/filtered_collection.rb +27 -2
  17. data/lib/aws/ec2/image.rb +7 -4
  18. data/lib/aws/ec2/instance.rb +54 -2
  19. data/lib/aws/ec2/instance_collection.rb +5 -3
  20. data/lib/aws/ec2/internet_gateway.rb +122 -0
  21. data/lib/aws/ec2/internet_gateway/attachment.rb +78 -0
  22. data/lib/aws/ec2/internet_gateway_collection.rb +54 -0
  23. data/lib/aws/ec2/network_acl.rb +254 -0
  24. data/lib/aws/ec2/network_acl/association.rb +56 -0
  25. data/lib/aws/ec2/network_acl/entry.rb +147 -0
  26. data/lib/aws/ec2/network_acl_collection.rb +65 -0
  27. data/lib/aws/ec2/network_interface.rb +174 -0
  28. data/lib/aws/ec2/network_interface/attachment.rb +100 -0
  29. data/lib/aws/ec2/network_interface_collection.rb +103 -0
  30. data/lib/aws/ec2/region.rb +11 -1
  31. data/lib/aws/ec2/resource.rb +6 -2
  32. data/lib/aws/ec2/route_table.rb +204 -0
  33. data/lib/aws/ec2/route_table/association.rb +119 -0
  34. data/lib/aws/ec2/route_table/route.rb +113 -0
  35. data/lib/aws/ec2/route_table_collection.rb +73 -0
  36. data/lib/aws/ec2/security_group.rb +15 -5
  37. data/lib/aws/ec2/security_group_collection.rb +15 -12
  38. data/lib/aws/ec2/subnet.rb +161 -0
  39. data/lib/aws/ec2/subnet_collection.rb +115 -0
  40. data/lib/aws/ec2/vpc.rb +166 -0
  41. data/lib/aws/ec2/vpc_collection.rb +71 -0
  42. data/lib/aws/ec2/vpn_connection.rb +99 -0
  43. data/lib/aws/ec2/vpn_connection/telemetry.rb +49 -0
  44. data/lib/aws/ec2/vpn_connection_collection.rb +96 -0
  45. data/lib/aws/ec2/vpn_gateway.rb +123 -0
  46. data/lib/aws/ec2/vpn_gateway/attachment.rb +45 -0
  47. data/lib/aws/ec2/vpn_gateway_collection.rb +77 -0
  48. data/lib/aws/iam/login_profile.rb +4 -0
  49. data/lib/aws/iam/user.rb +6 -0
  50. data/lib/aws/record/hash_model.rb +3 -3
  51. data/lib/aws/simple_workflow.rb +6 -3
  52. data/lib/aws/simple_workflow/activity_task_collection.rb +7 -2
  53. data/lib/aws/simple_workflow/decision_task_collection.rb +11 -5
  54. data/lib/aws/simple_workflow/option_formatters.rb +7 -0
  55. data/lib/net/http/connection_pool.rb +19 -5
  56. metadata +33 -5
  57. data/lib/aws/api_config/EC2-2011-02-28.yml +0 -2314
@@ -0,0 +1,166 @@
1
+ # Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
4
+ # may not use this file except in compliance with the License. A copy of
5
+ # the License is located at
6
+ #
7
+ # http://aws.amazon.com/apache2.0/
8
+ #
9
+ # or in the "license" file accompanying this file. This file is
10
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
+ # ANY KIND, either express or implied. See the License for the specific
12
+ # language governing permissions and limitations under the License.
13
+
14
+ module AWS
15
+ class EC2
16
+
17
+ # @attr_reader [Symbol] state
18
+ # @attr_reader [String] cidr_block
19
+ # @attr_reader [String] dhcp_options_id
20
+ # @attr_reader [Symbol] instance_tenancy
21
+ class VPC < Resource
22
+
23
+ include TaggedItem
24
+
25
+ def initialize vpc_id, options = {}
26
+ @vpc_id = vpc_id
27
+ super
28
+ end
29
+
30
+ # @return [String]
31
+ attr_reader :vpc_id
32
+
33
+ alias_method :id, :vpc_id
34
+
35
+ attribute :state, :to_sym => true
36
+
37
+ attribute :cidr_block, :static => true
38
+
39
+ attribute :dhcp_options_id
40
+
41
+ attribute :instance_tenancy, :static => true, :to_sym => true
42
+
43
+ populates_from(:create_vpc) do |resp|
44
+ resp.vpc if resp.vpc.vpc_id == vpc_id
45
+ end
46
+
47
+ populates_from(:describe_vpcs) do |resp|
48
+ resp.vpc_set.find{|v| v.vpc_id == vpc_id }
49
+ end
50
+
51
+ # Deletes the current VPC. The VPC must be empty before it can
52
+ # be deleted.
53
+ # @return [nil]
54
+ def delete
55
+ client.delete_vpc(:vpc_id => vpc_id)
56
+ nil
57
+ end
58
+
59
+ # @return [InstanceCollection] Returns a filtered collection of
60
+ # instances that are in this VPC.
61
+ def instances
62
+ InstanceCollection.new(:config => config).filter('vpc-id', vpc_id)
63
+ end
64
+
65
+ # @return [SecurityGroupCollection] Returns a filtered collection of
66
+ # security groups that are in this VPC.
67
+ def security_groups
68
+ SecurityGroupCollection.new(:config => config).filter('vpc-id', vpc_id)
69
+ end
70
+
71
+ # @return [SubnetCollection] Returns a filtered collection of
72
+ # subnets that are in this VPC.
73
+ def subnets
74
+ SubnetCollection.new(:config => config).filter('vpc-id', vpc_id)
75
+ end
76
+
77
+ # @return [NetworkACLCollection] Returns a filtered collection of
78
+ # network ACLs that are in this VPC.
79
+ def network_acls
80
+ NetworkACLCollection.new(:config => config).filter('vpc-id', vpc_id)
81
+ end
82
+
83
+ # @return [RouteTableCollection] Returns a filtered collection of
84
+ # route tables that are in this VPC.
85
+ def route_tables
86
+ RouteTableCollection.new(:config => config).filter('vpc-id', vpc_id)
87
+ end
88
+
89
+ # @return [NetworkInterfaceCollection] Returns a filtered collection of
90
+ # network interfaces that are in this VPC.
91
+ def network_interfaces
92
+ NetworkInterfaceCollection.new(:config => config).filter('vpc-id', id)
93
+ end
94
+
95
+ # @return [InternetGateway,nil] Returns the internet gateway attached to
96
+ # this VPC. If no internet gateway has been attached, then
97
+ # nil is returned.
98
+ def internet_gateway
99
+ gateways = InternetGatewayCollection.new(:config => config)
100
+ gateways.filter('attachment.vpc-id', vpc_id).first
101
+ end
102
+
103
+ # Attaches the given internet gateway to this VPC. If there is already
104
+ # an internet gateway attached, it will be detached from this VPC first.
105
+ # If you pass nil, this will leave the current VPC without an attached
106
+ # internet gateway.
107
+ #
108
+ # vpc.internet_gateway = gateway_1
109
+ # vpc.internet_gateway = gateway_2 # detaches gateway_1 first
110
+ # vpc.internet_gateway = nil # detaches gateway_2
111
+ #
112
+ # @param [InternetGateway,String] internet_gateway An {InternetGateway}
113
+ # object or internet gateway id string.
114
+ #
115
+ def internet_gateway= internet_gateway
116
+
117
+ # remove currently attached internet gateway
118
+ gateway = self.internet_gateway
119
+ gateway.detach(self) if gateway
120
+
121
+ if internet_gateway
122
+ unless internet_gateway.is_a?(InternetGateway)
123
+ internet_gateway = InternetGateway.new(internet_gateway,
124
+ :config => config)
125
+ end
126
+ internet_gateway.attach(self)
127
+ end
128
+
129
+ end
130
+
131
+ # @return [VPNGateway,nil] Returns the vpn gateway attached to
132
+ # this VPC. If no vpn gateway has been attached, then
133
+ # nil is returned.
134
+ def vpn_gateway
135
+ gateways = VPNGatewayCollection.new(:config => config)
136
+ gateways.filter('attachment.vpc-id', vpc_id).first
137
+ end
138
+
139
+ # @return [DHCPOptions] Returns the dhcp options associated with
140
+ # this VPC.
141
+ def dhcp_options
142
+ DHCPOptions.new(dhcp_options_id, :config => config)
143
+ end
144
+
145
+ # Associates the given dhcp options with this VPC.
146
+ #
147
+ # vpc.dhcp_optinos = ec2.dhcp_options['dopt-a1234abc']
148
+ #
149
+ # You can also specify the string 'default' to use Amazon's
150
+ # default dhcp options.
151
+ #
152
+ # vpc.dhcp_optinos = 'defualt'
153
+ #
154
+ # @param [DHCPOptions,String] dhcp_options A {DHCPOptions} object
155
+ # or a dhcp options id string.
156
+ #
157
+ def dhcp_options= dhcp_options
158
+ unless dhcp_options.is_a?(DHCPOptions)
159
+ dhcp_options = DHCPOptions.new(dhcp_options, :config => config)
160
+ end
161
+ dhcp_options.associate(self)
162
+ end
163
+
164
+ end
165
+ end
166
+ end
@@ -0,0 +1,71 @@
1
+ # Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
4
+ # may not use this file except in compliance with the License. A copy of
5
+ # the License is located at
6
+ #
7
+ # http://aws.amazon.com/apache2.0/
8
+ #
9
+ # or in the "license" file accompanying this file. This file is
10
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
+ # ANY KIND, either express or implied. See the License for the specific
12
+ # language governing permissions and limitations under the License.
13
+
14
+ module AWS
15
+ class EC2
16
+
17
+ class VPCCollection < Collection
18
+
19
+ include TaggedCollection
20
+ include Core::Collection::Simple
21
+
22
+ # Creates a VPC with the CIDR block you specify. The smallest VPC you
23
+ # can create uses a /28 netmask (16 IP addresses), and the largest
24
+ # uses a /16 netmask (65,536 IP addresses).
25
+ #
26
+ # vpc = ec2.vpcs.create('10.0.0.0/16')
27
+ #
28
+ # @param [String] cidr_block The CIDR block you want the VPC to
29
+ # cover (e.g., 10.0.0.0/16).
30
+ #
31
+ # @param [Hash] options
32
+ #
33
+ # @option options [Boolean] :instance_tenancy (:default)
34
+ # The allowed tenancy of instances launched into the VPC. A value of
35
+ # +:default+ means instances can be launched with any tenancy; a value
36
+ # of +:dedicated+ means instances must be launched with tenancy as
37
+ # dedicated.
38
+ # dedicated tenancy.
39
+ #
40
+ # @return [VPC]
41
+ #
42
+ def create cidr_block, options = {}
43
+
44
+ tenancy = options.key?(:instance_tenancy) ?
45
+ options[:instance_tenancy].to_s : 'default'
46
+
47
+ client_opts = {}
48
+ client_opts[:cidr_block] = cidr_block
49
+ client_opts[:instance_tenancy] = tenancy
50
+
51
+ resp = client.create_vpc(client_opts)
52
+
53
+ VPC.new_from(:create_vpc, resp.vpc, resp.vpc.vpc_id, :config => config)
54
+
55
+ end
56
+
57
+ def [] vpc_id
58
+ VPC.new(vpc_id, :config => config)
59
+ end
60
+
61
+ protected
62
+ def _each_item options = {}, &block
63
+ response = filtered_request(:describe_vpcs, options, &block)
64
+ response.vpc_set.each do |v|
65
+ yield(VPC.new_from(:describe_vpcs, v, v.vpc_id, :config => config))
66
+ end
67
+ end
68
+
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,99 @@
1
+ # Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
4
+ # may not use this file except in compliance with the License. A copy of
5
+ # the License is located at
6
+ #
7
+ # http://aws.amazon.com/apache2.0/
8
+ #
9
+ # or in the "license" file accompanying this file. This file is
10
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
+ # ANY KIND, either express or implied. See the License for the specific
12
+ # language governing permissions and limitations under the License.
13
+
14
+ require 'aws/ec2/vpn_connection/telemetry'
15
+
16
+ module AWS
17
+ class EC2
18
+
19
+ # @attr_reader [Symbol] state
20
+ #
21
+ # @attr_reader [String] vpn_type
22
+ #
23
+ # @attr_reader [String] vpn_gateway_id
24
+ #
25
+ # @attr_reader [String] customer_gateway_id
26
+ #
27
+ # @attr_reader [String] customer_gateway_configuration
28
+ # Configuration XML for the VPN connection's customer gateway This
29
+ # attribute is always present after creating a vpn connection while
30
+ # the connection state is :pending or :available.
31
+ #
32
+ class VPNConnection < Resource
33
+
34
+ include TaggedItem
35
+
36
+ # @private
37
+ def initialize vpn_connection_id, options = {}
38
+ @vpn_connection_id = vpn_connection_id
39
+ super
40
+ end
41
+
42
+ # @return [String]
43
+ attr_reader :vpn_connection_id
44
+
45
+ alias_method :id, :vpn_connection_id
46
+
47
+ attribute :state, :to_sym => true
48
+
49
+ attribute :vpn_type, :static => true
50
+
51
+ attribute :vpn_gateway_id, :static => true
52
+
53
+ attribute :customer_gateway_id, :static => true
54
+
55
+ attribute :customer_gateway_configuration, :static => true
56
+
57
+ attribute :vgw_telemetry_details, :as => :vgw_telemetry
58
+
59
+ protected :vgw_telemetry_details
60
+
61
+ populates_from(:create_vpn_connection) do |resp|
62
+ resp.vpn_connection if resp.vpn_connection.vpn_connection_id == id
63
+ end
64
+
65
+ populates_from(:describe_vpn_connections) do |resp|
66
+ resp.vpn_connection_set.find do |vpn_connection|
67
+ vpn_connection.vpn_connection_id == vpn_connection_id
68
+ end
69
+ end
70
+
71
+ # @return [VPNGateway]
72
+ def vpn_gateway
73
+ VPNGateway.new(vpn_gateway_id, :config => config)
74
+ end
75
+
76
+ # @return [CustomerGateway]
77
+ def customer_gateway
78
+ CustomerGateway.new(customer_gateway_id, :config => config)
79
+ end
80
+
81
+ # @return [Array<Telemetry>]
82
+ def vgw_telemetry
83
+ vgw_telemetry_details.collect do |details|
84
+ Telemetry.new(self, details)
85
+ end
86
+ end
87
+
88
+ # Deletes this vpn connection.
89
+ # @return [nil]
90
+ def delete
91
+ client_opts = {}
92
+ client_opts[:vpn_connection_id] = vpn_connection_id
93
+ client.delete_vpn_connection(client_opts)
94
+ nil
95
+ end
96
+
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,49 @@
1
+ # Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
4
+ # may not use this file except in compliance with the License. A copy of
5
+ # the License is located at
6
+ #
7
+ # http://aws.amazon.com/apache2.0/
8
+ #
9
+ # or in the "license" file accompanying this file. This file is
10
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
+ # ANY KIND, either express or implied. See the License for the specific
12
+ # language governing permissions and limitations under the License.
13
+
14
+ module AWS
15
+ class EC2
16
+ class VPNConnection < Resource
17
+ class Telemetry
18
+
19
+ def initialize vpn_connection, details
20
+ @vpn_connection = vpn_connection
21
+ @outside_ip_address = details.outside_ip_address
22
+ @status = details.status.downcase.to_sym
23
+ @last_status_change = details.last_status_change
24
+ @status_message = details.status_message
25
+ @accepted_route_count = details.accepted_route_count
26
+ end
27
+
28
+ # @return [VPNConnection]
29
+ attr_reader :vpn_connection
30
+
31
+ # @return [String]
32
+ attr_reader :outside_ip_address
33
+
34
+ # @return [Symbol] :up or :down
35
+ attr_reader :status
36
+
37
+ # @return [Time]
38
+ attr_reader :last_status_change
39
+
40
+ # @return [String]
41
+ attr_reader :status_message
42
+
43
+ # @return [Integer]
44
+ attr_reader :accepted_route_count
45
+
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,96 @@
1
+ # Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
4
+ # may not use this file except in compliance with the License. A copy of
5
+ # the License is located at
6
+ #
7
+ # http://aws.amazon.com/apache2.0/
8
+ #
9
+ # or in the "license" file accompanying this file. This file is
10
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
+ # ANY KIND, either express or implied. See the License for the specific
12
+ # language governing permissions and limitations under the License.
13
+
14
+ module AWS
15
+ class EC2
16
+
17
+ class VPNConnectionCollection < Collection
18
+
19
+ include TaggedCollection
20
+ include Core::Collection::Simple
21
+
22
+ # Creates a new VPN connection between an existing virtual private
23
+ # gateway and a VPN customer gateway.
24
+ #
25
+ # @param [Hash] options
26
+ #
27
+ # @option options [CustomerGateway,String] :customer_gateway
28
+ # The {CustomerGateway} object or customer gateway id string.
29
+ #
30
+ # @option options [VPNGateway,String] :vpn_gateway
31
+ # The {VPNGateway} object or vpn gateway id string.
32
+ #
33
+ # @option options [String] :vpn_type ('ipsec.1')
34
+ # The type of VPN connection.
35
+ #
36
+ # @return [VPNConnection]
37
+ #
38
+ def create options = {}
39
+
40
+ client_opts = {}
41
+ client_opts[:customer_gateway_id] = customer_gateway_id(options)
42
+ client_opts[:vpn_gateway_id] = vpn_gateway_id(options)
43
+ client_opts[:type] = options[:vpn_type] || 'ipsec.1'
44
+
45
+ resp = client.create_vpn_connection(client_opts)
46
+
47
+ VPNConnection.new_from(:create_vpn_connection, resp,
48
+ resp.vpn_connection.vpn_connection_id, :config => config)
49
+
50
+ end
51
+
52
+ # Returns a reference to the VPN connection with the given id.
53
+ #
54
+ # vpn_connection = ec2.vpn_connections['vpn-connection-id']
55
+ #
56
+ # @param [String] vpn_connection_id
57
+ #
58
+ # @return [VPNConnection]
59
+ #
60
+ def [] vpn_connection_id
61
+ VPNConnection.new(vpn_connection_id, :config => config)
62
+ end
63
+
64
+ protected
65
+
66
+ def _each_item options = {}, &block
67
+ response = filtered_request(:describe_vpn_connections, options, &block)
68
+ response.vpn_connection_set.each do |c|
69
+
70
+ vpn_connection = VPNConnection.new_from(:describe_vpn_connections,
71
+ c, c.vpn_connection_id, :config => config)
72
+
73
+ yield(vpn_connection)
74
+
75
+ end
76
+ end
77
+
78
+ def customer_gateway_id options
79
+ gateway_id = options.delete(:customer_gateway)
80
+ gateway_id ||= options[:customer_gateway_id]
81
+ gateway_id ||= filter_value_for('customer-gateway-id')
82
+ gateway_id = gateway_id.id if gateway_id.is_a?(CustomerGateway)
83
+ gateway_id
84
+ end
85
+
86
+ def vpn_gateway_id options
87
+ gateway_id = options.delete(:vpn_gateway)
88
+ gateway_id ||= options[:vpn_gateway_id]
89
+ gateway_id ||= filter_value_for('vpn-gateway-id')
90
+ gateway_id = gateway_id.id if gateway_id.is_a?(VPNGateway)
91
+ gateway_id
92
+ end
93
+
94
+ end
95
+ end
96
+ end