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
@@ -52,7 +52,7 @@ module AWS
52
52
  end
53
53
 
54
54
  protected
55
- def get_resource attribute
55
+ def get_resource attribute = nil
56
56
  describe_call
57
57
  end
58
58
 
@@ -87,7 +87,11 @@ module AWS
87
87
  protected
88
88
  def update_resource attribute, value
89
89
  options = {}
90
- options[attribute.set_as] = { :value => value }
90
+ if value.is_a?(Array)
91
+ options[attribute.set_as] = value
92
+ else
93
+ options[attribute.set_as] = { :value => value }
94
+ end
91
95
  options[:"#{inflected_name}_id"] = __resource_id__
92
96
  method_name = "modify_#{inflected_name}_attribute"
93
97
  client.send(method_name, options)
@@ -0,0 +1,204 @@
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/route_table/route'
15
+ require 'aws/ec2/route_table/association'
16
+
17
+ module AWS
18
+ class EC2
19
+
20
+ class RouteTable < Resource
21
+
22
+ include TaggedItem
23
+
24
+ def initialize route_table_id, options = {}
25
+ @route_table_id = route_table_id
26
+ super
27
+ end
28
+
29
+ # @return [String]
30
+ attr_reader :route_table_id
31
+
32
+ alias_method :id, :route_table_id
33
+
34
+ attribute :vpc_id, :static => true
35
+
36
+ attribute :route_set
37
+
38
+ protected :route_set
39
+
40
+ attribute :association_set
41
+
42
+ protected :association_set
43
+
44
+ populates_from(:create_route_table) do |resp|
45
+ resp.route_table if resp.route_table.route_table_id == route_table_id
46
+ end
47
+
48
+ populates_from(:describe_route_tables) do |resp|
49
+ resp.route_table_set.find{|t| t.route_table_id == route_table_id }
50
+ end
51
+
52
+ # @return [Boolean] Returns true if this is the main (default)
53
+ # route table.
54
+ def main?
55
+ @main = !!associations.find{|a| a.main? } if @main.nil?
56
+ @main
57
+ end
58
+
59
+ # @return [VPC] Returns the VPC this route table belongs to.
60
+ def vpc
61
+ VPC.new(vpc_id, :config => config)
62
+ end
63
+
64
+ # @return [Array<Subnet>] Returns an array of subnets ({Subnet})
65
+ # that currently associated to this route table.
66
+ def subnets
67
+
68
+ subnets = associations.map(&:subnet)
69
+
70
+ # The default route table has a single association where #subnet
71
+ # returns nil (the main association). If this is not the main
72
+ # route table we can safely return the subnets.
73
+ return subnets unless subnets.include?(nil)
74
+
75
+ subnets.compact!
76
+
77
+ # This is the default route table and to get the complete list of
78
+ # subnets we have to find all subnets without an association
79
+ AWS.memoize do
80
+
81
+ # every subnet
82
+ all_subnets = vpc.subnets.to_a
83
+
84
+ # subnets assigned directly to a route table
85
+ associated_subnets = vpc.route_tables.
86
+ map(&:associations).flatten.
87
+ map(&:subnet).flatten.
88
+ compact
89
+
90
+ # subnets NOT assigned to a route table, these default as
91
+ # belonging to the default route table through the "main"
92
+ # association
93
+ unassociated_subnets = all_subnets.inject([]) do |list,subnet|
94
+ unless associated_subnets.include?(subnet)
95
+ list << subnet
96
+ end
97
+ list
98
+ end
99
+
100
+ subnets + unassociated_subnets
101
+
102
+ end
103
+
104
+ end
105
+
106
+ # @return [Array<RouteTable::Association>] Returns an array of
107
+ # {RouteTable::Association} objects (association to subnets).
108
+ def associations
109
+ association_set.collect do |details|
110
+ subnet_id = details.respond_to?(:subnet_id) ? details.subnet_id : nil
111
+ Association.new(self, details.route_table_association_id, subnet_id)
112
+ end
113
+ end
114
+
115
+ # @return [Array<Route>] Returns an array of routes ({Route} objects)
116
+ # belonging to this route table.
117
+ def routes
118
+ route_set.map do |route_details|
119
+ Route.new(self, route_details)
120
+ end
121
+ end
122
+
123
+ # Creates a new route in this route route. The route must be attached
124
+ # to a gateway, instance or network interface.
125
+ #
126
+ # @param [String] destination_cidr_block The CIDR address block
127
+ # used for the destination match. For example: 0.0.0.0/0.
128
+ # Routing decisions are based on the most specific match.
129
+ #
130
+ # @param [Hash] options
131
+ #
132
+ # @option options [InternetGateway,String] :internet_gateway
133
+ # An {InternetGateway} object or an internet gateway id string to
134
+ # attach the route to.
135
+ #
136
+ # @option options [Instance,String] :instance An {Instance} object
137
+ # or instance id string to attach the route to.
138
+ #
139
+ # @option options [NetworkInterface,String] :network_interface
140
+ # A {NetworkInterface} object or network interface id string to
141
+ # attach the route to.
142
+ #
143
+ # @return [nil]
144
+ #
145
+ def create_route destination_cidr_block, options = {}
146
+ client.create_route(route_options(destination_cidr_block, options))
147
+ nil
148
+ end
149
+
150
+ # Replaces an existing route within a route table in a VPC.
151
+ # @param (see #create_route)
152
+ # @option (see #create_route)
153
+ # @return [nil]
154
+ def replace_route destination_cidr_block, options = {}
155
+ client.replace_route(route_options(destination_cidr_block, options))
156
+ nil
157
+ end
158
+
159
+ # @param [String] destination_cidr_block The CIDR block address of the
160
+ # route to delete.
161
+ # @return [nil]
162
+ def delete_route destination_cidr_block
163
+ client.delete_route(route_options(destination_cidr_block))
164
+ nil
165
+ end
166
+
167
+ # Deletes this route table. The route table must not be
168
+ # associated with a subnet. You can't delete the main route table.
169
+ # @return [nil]
170
+ def delete
171
+ client.delete_route_table(:route_table_id => route_table_id)
172
+ nil
173
+ end
174
+
175
+ protected
176
+
177
+ def route_options destination_cidr_block, options = {}
178
+
179
+ client_opts = {}
180
+ client_opts[:route_table_id] = route_table_id
181
+ client_opts[:destination_cidr_block] = destination_cidr_block
182
+
183
+ if gateway = options[:internet_gateway]
184
+ gateway = gateway.id if gateway.is_a?(InternetGateway)
185
+ client_opts[:gateway_id] = gateway
186
+ end
187
+
188
+ if instance = options[:instance]
189
+ instance = instance.id if instance.is_a?(Instance)
190
+ client_opts[:instance_id] = instance
191
+ end
192
+
193
+ if interface = options[:network_interface]
194
+ interface = interface.id if interface.is_a?(NetworkInterface)
195
+ client_opts[:network_interface_id] = interface
196
+ end
197
+
198
+ client_opts
199
+
200
+ end
201
+
202
+ end
203
+ end
204
+ end
@@ -0,0 +1,119 @@
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 RouteTable < Resource
17
+
18
+ # Represents the association between a {RouteTable} and a {Subnet}.
19
+ #
20
+ # You can get a route table association 2 ways:
21
+ #
22
+ # * enumerating associations from a route table
23
+ # * Asking a subnet for its route table association
24
+ #
25
+ # == Enumerating Associations
26
+ #
27
+ # Given a route table:
28
+ #
29
+ # route_table.associations.each do |assoc|
30
+ # if assoc.main? # main association does not have a subnet
31
+ # puts "#{assoc.id} : main association"
32
+ # else
33
+ # puts "#{assoc.id} : #{assoc.subnet.id}"
34
+ # end
35
+ # end
36
+ #
37
+ # == Getting a Subnet Route Table Association
38
+ #
39
+ # All subnets are associated with a route table. If the association
40
+ # was never explicitly created, then they are associated by default
41
+ # with the main route table.
42
+ #
43
+ # subnet.route_table_association #=> AWS::EC2::RouteTable::Association
44
+ #
45
+ # subnet.route_table_association.main? #=> true/false
46
+ #
47
+ # == Creating and Replacing a Route Table Association
48
+ #
49
+ # To replace a route table association start at the subnet end:
50
+ #
51
+ # subnet.route_table = some_other_route_table
52
+ #
53
+ # If this route table is associated (by default) to the main route
54
+ # table via the main (default) association a new association is created.
55
+ # If it was previously associated directly to a different route table
56
+ # then that association will be repalced.
57
+ #
58
+ # == Deleting an Association
59
+ #
60
+ # You can delete all but the main route table association. When you
61
+ # delete an association, the subnet becomes associated with the
62
+ # main route table.
63
+ #
64
+ # # delete all explicit route table associations -- as a result
65
+ # # all subnets will default to the main route table
66
+ # vpc.subnets.each do |subnet|
67
+ # assoc = subnet.route_table_association
68
+ # assoc.delete unless assoc.main?
69
+ # end
70
+ #
71
+ class Association
72
+
73
+ # @private
74
+ def initialize route_table, association_id, subnet_id
75
+ @route_table = route_table
76
+ @association_id = association_id
77
+ if subnet_id
78
+ @main = false
79
+ @subnet = Subnet.new(subnet_id,
80
+ :config => route_table.config)
81
+ else
82
+ @main = true
83
+ end
84
+ end
85
+
86
+ # @return [String] An identifier representing the association
87
+ # between the network ACL and subnet.
88
+ attr_reader :association_id
89
+
90
+ alias_method :id, :association_id
91
+
92
+ # @return [RouteTable]
93
+ attr_reader :route_table
94
+
95
+ # @return [Subnet,nil] Returns the subnet this association belongs.
96
+ # If this is the main (default) association, then this method
97
+ # returns nil.
98
+ attr_reader :subnet
99
+
100
+ # @return [Boolean] Returns true if this association is the main
101
+ # (default) association for all subnets within this route table's
102
+ # VPC.
103
+ attr_reader :main
104
+
105
+ alias_method :main?, :main
106
+
107
+ # Deletes the association between the route table and the subnet
108
+ # @return [nil]
109
+ def delete
110
+ route_table.client.disassociate_route_table(
111
+ :association_id => association_id)
112
+ nil
113
+ end
114
+ alias_method :disassociate, :delete
115
+
116
+ end
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,113 @@
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
+ # Represents a single route in a {RouteTable}.
18
+ #
19
+ # # enumerating routes within a route table
20
+ # ec2 = AWS::EC2.new
21
+ # route_table = ec2.route_tables.first
22
+ # route_table.routes.each do |route|
23
+ # # ...
24
+ # end
25
+ #
26
+ class RouteTable < Resource
27
+ class Route
28
+
29
+ def initialize route_table, details
30
+
31
+ @route_table = route_table
32
+
33
+ @destination_cidr_block = details.destination_cidr_block
34
+
35
+ if details.respond_to?(:gateway_id)
36
+ @internet_gateway = InternetGateway.new(
37
+ details.gateway_id,
38
+ :config => route_table.config)
39
+ end
40
+
41
+ if details.respond_to?(:instance_id)
42
+ @instance = Instance.new(details.instance_id,
43
+ :vpc_id => route_table.vpc_id,
44
+ :owner_id => details.instance_owner_id,
45
+ :config => route_table.config)
46
+ end
47
+
48
+ if details.respond_to?(:network_interface_id)
49
+ @network_interface = NetworkInterface.new(
50
+ details.network_interface_id,
51
+ :vpc_id => route_table.vpc_id,
52
+ :config => route_table.config)
53
+ end
54
+
55
+ @target = (internet_gateway || instance || network_interface)
56
+
57
+ @state = details.state.to_sym
58
+
59
+ end
60
+
61
+ # @return [RouteTable]
62
+ attr_reader :route_table
63
+
64
+ # @return [String] destination_cidr_block
65
+ attr_reader :destination_cidr_block
66
+
67
+ alias_method :cidr_block, :destination_cidr_block
68
+
69
+ # @return [InternetGateway,nil]
70
+ attr_reader :internet_gateway
71
+
72
+ # @return [Instance,nil]
73
+ attr_reader :instance
74
+
75
+ # @return [NetworkInterface,nil]
76
+ attr_reader :network_interface
77
+
78
+ # @return [Gateway,Instance,NetworkInterface] Returns the target
79
+ # of this route table. It will be a gateway id, instance or a
80
+ # network interface.
81
+ attr_reader :target
82
+
83
+ # @return [Symbol] Returns the state (:active or :blackhole).
84
+ attr_reader :state
85
+
86
+ # @param [Hash] options
87
+ #
88
+ # @option options [Gateway,String] :gateway A gateway (object or
89
+ # string id) to attach the route to.
90
+ #
91
+ # @option options [Instance,String] :instance An instance (object
92
+ # or string id) to attach the route to.
93
+ #
94
+ # @option options [NetworkInterface,String] :network_interface
95
+ # A network interface (object or string id) to attach the route
96
+ # to.
97
+ #
98
+ # @return [nil]
99
+ #
100
+ def replace options = {}
101
+ route_table.replace_route(destination_cidr_block, options)
102
+ end
103
+
104
+ # Deletes this route.
105
+ # @return [nil]
106
+ def delete
107
+ route_table.delete_route(destination_cidr_block)
108
+ end
109
+
110
+ end
111
+ end
112
+ end
113
+ end