aws-sdk 1.6.9 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/README.rdoc +1 -1
  2. data/lib/aws.rb +8 -0
  3. data/lib/aws/api_config/CloudSearch-2011-02-01.yml +681 -0
  4. data/lib/aws/api_config/DynamoDB-2011-12-05.yml +4 -0
  5. data/lib/aws/api_config/EMR-2009-03-31.yml +18 -0
  6. data/lib/aws/api_config/ElastiCache-2012-03-09.yml +777 -0
  7. data/lib/aws/api_config/ElasticBeanstalk-2010-12-01.yml +823 -0
  8. data/lib/aws/api_config/RDS-2012-07-31.yml +1621 -0
  9. data/lib/aws/cloud_search.rb +31 -0
  10. data/lib/aws/cloud_search/client.rb +558 -0
  11. data/lib/aws/cloud_search/config.rb +18 -0
  12. data/lib/aws/cloud_search/errors.rb +22 -0
  13. data/lib/aws/cloud_search/request.rb +23 -0
  14. data/lib/aws/cloud_watch/alarm.rb +1 -1
  15. data/lib/aws/cloud_watch/metric.rb +3 -3
  16. data/lib/aws/core.rb +18 -3
  17. data/lib/aws/core/configuration.rb +11 -0
  18. data/lib/aws/core/inflection.rb +1 -0
  19. data/lib/aws/core/service_interface.rb +1 -1
  20. data/lib/aws/dynamo_db/batch_get.rb +19 -12
  21. data/lib/aws/dynamo_db/client.rb +27 -1
  22. data/lib/aws/dynamo_db/config.rb +2 -0
  23. data/lib/aws/dynamo_db/item_collection.rb +2 -2
  24. data/lib/aws/dynamo_db/table.rb +8 -2
  25. data/lib/aws/ec2/reserved_instances.rb +3 -0
  26. data/lib/aws/ec2/reserved_instances_offering.rb +3 -1
  27. data/lib/aws/elastic_beanstalk.rb +48 -0
  28. data/lib/aws/elastic_beanstalk/client.rb +867 -0
  29. data/lib/aws/elastic_beanstalk/config.rb +18 -0
  30. data/lib/aws/elastic_beanstalk/errors.rb +22 -0
  31. data/lib/aws/elastic_beanstalk/request.rb +23 -0
  32. data/lib/aws/elasticache.rb +48 -0
  33. data/lib/aws/elasticache/client.rb +758 -0
  34. data/lib/aws/elasticache/config.rb +18 -0
  35. data/lib/aws/elasticache/errors.rb +22 -0
  36. data/lib/aws/elasticache/request.rb +23 -0
  37. data/lib/aws/emr/client.rb +30 -6
  38. data/lib/aws/emr/job_flow.rb +10 -0
  39. data/lib/aws/rds.rb +69 -0
  40. data/lib/aws/rds/client.rb +1592 -0
  41. data/lib/aws/rds/config.rb +18 -0
  42. data/lib/aws/rds/db_instance.rb +201 -0
  43. data/lib/aws/rds/db_instance_collection.rb +75 -0
  44. data/lib/aws/rds/db_snapshot.rb +163 -0
  45. data/lib/aws/rds/db_snapshot_collection.rb +89 -0
  46. data/lib/aws/rds/errors.rb +22 -0
  47. data/lib/aws/rds/request.rb +23 -0
  48. data/lib/aws/s3/bucket_tag_collection.rb +1 -1
  49. data/lib/aws/s3/client.rb +4 -2
  50. data/lib/aws/s3/errors.rb +0 -1
  51. data/lib/aws/s3/object_collection.rb +40 -22
  52. data/lib/aws/s3/object_version.rb +7 -2
  53. data/lib/aws/s3/request.rb +1 -1
  54. data/lib/aws/s3/s3_object.rb +35 -11
  55. data/lib/aws/version.rb +1 -1
  56. metadata +33 -2
@@ -0,0 +1,18 @@
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
+ AWS::Core::Configuration.module_eval do
15
+
16
+ add_service 'CloudSearch', 'cloud_search', 'cloudsearch.us-east-1.amazonaws.com'
17
+
18
+ end
@@ -0,0 +1,22 @@
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 CloudSearch
16
+ module Errors
17
+
18
+ extend Core::LazyErrorClasses
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,23 @@
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 CloudSearch
16
+
17
+ # @private
18
+ class Request < Core::Http::Request
19
+ include Core::Signature::Version2
20
+ end
21
+
22
+ end
23
+ end
@@ -23,7 +23,7 @@ module AWS
23
23
  # @attr_reader [Boolean] enabled Indicates whether actions
24
24
  # should be executed during any changes to the alarm's state.
25
25
  #
26
- # @attr_reader [Array<String>] actions The list of actions to execute
26
+ # @attr_reader [Array<String>] alarm_actions The list of actions to execute
27
27
  # when this alarm transitions into an ALARM state from any other
28
28
  # state.
29
29
  #
@@ -106,7 +106,7 @@ module AWS
106
106
  options[:period] ||= 60
107
107
 
108
108
  resp = client.get_metric_statistics(options)
109
-
109
+
110
110
  MetricStatistics.new(self, resp[:label], resp[:datapoints])
111
111
 
112
112
  end
@@ -120,8 +120,8 @@ module AWS
120
120
 
121
121
  def resource_identifiers
122
122
  [
123
- [:namespace, namespace],
124
- [:metric_item, metric_name],
123
+ [:namespace, namespace],
124
+ [:metric_name, metric_name],
125
125
  [:dimensions, dimensions],
126
126
  ]
127
127
  end
@@ -23,12 +23,16 @@ require 'aws/core/autoloader'
23
23
  #
24
24
  # * {AWS::AutoScaling}
25
25
  # * {AWS::CloudFormation}
26
+ # * {AWS::CloudSearch}
26
27
  # * {AWS::CloudWatch}
27
28
  # * {AWS::DynamoDB}
28
29
  # * {AWS::EC2}
30
+ # * {AWS::ElastiCache}
31
+ # * {AWS::ElasticBeanstalk}
29
32
  # * {AWS::ELB}
30
33
  # * {AWS::EMR}
31
34
  # * {AWS::IAM}
35
+ # * {AWS::RDS}
32
36
  # * {AWS::Route53}
33
37
  # * {AWS::S3}
34
38
  # * {AWS::SNS}
@@ -221,6 +225,9 @@ module AWS
221
225
  # @option options [String] :cloud_formation_endpoint ('cloudformation.us-east-1.amazonaws.com')
222
226
  # The service endpoint for AWS CloudFormation.
223
227
  #
228
+ # @option options [String] :cloud_search ('cloudsearch.us-east-1.amazonaws.com')
229
+ # The service endpoint for Amazon CloudSearch.
230
+ #
224
231
  # @option options [String] :cloud_watch_endpoint ('monitoring.us-east-1.amazonaws.com')
225
232
  # The service endpoint for Amazon CloudWatch.
226
233
  #
@@ -228,7 +235,7 @@ module AWS
228
235
  # {DynamoDB} will convert number values returned by {DynamoDB::Client}
229
236
  # from strings to BigDecimal objects. If you set this to +false+,
230
237
  # they will be convereted from strings into floats (with a potential
231
- # # backwards to test xml ordering loss of precision).
238
+ # loss of precision).
232
239
  #
233
240
  # @option options [String] :dynamo_db_endpoint ('dynamodb.amazonaws.com')
234
241
  # The service endpoint for Amazon DynamoDB.
@@ -240,6 +247,11 @@ module AWS
240
247
  # @option options [String] :ec2_endpoint ('ec2.amazonaws.com') The
241
248
  # service endpoint for Amazon EC2.
242
249
  #
250
+ # @option options [String] :elasticache_endpoint ('elasticache.us-east-1.amazonaws.com')
251
+ #
252
+ # @option options [String] :elastic_beanstalk_endpoint ('elasticbeanstalk.us-east-1.amazonaws.com')
253
+ # The service endpoint for AWS Elastic Beanstalk.
254
+ #
243
255
  # @option options [String] :elb_endpoint ('elasticloadbalancing.us-east-1.amazonaws.com')
244
256
  # The service endpoint for Elastic Load Balancing.
245
257
  #
@@ -310,12 +322,15 @@ module AWS
310
322
  #
311
323
  # AWS.config(:proxy_uri => 'https://user:password@my.proxy:443/path?query')
312
324
  #
313
- # @option options [String] :s3_endpoint ('s3.amazonaws.com') The
314
- # service endpoint for Amazon S3.
325
+ # @option options [String] :rds_endpoint ('rds.us-east-1.amazonaws.com')
326
+ # The service endpoint for Amazon Relational Database Service (RDS).
315
327
  #
316
328
  # @option options [String] :route_53_endpoint ('route53.amazonaws.com')
317
329
  # The service endpoint for Amazon Route 53.
318
330
  #
331
+ # @option options [String] :s3_endpoint ('s3.amazonaws.com') The
332
+ # service endpoint for Amazon S3.
333
+ #
319
334
  # @option options [Boolean] :s3_force_path_style (false) When
320
335
  # +true+, requests will always use path style. This can be useful
321
336
  # for testing environments.
@@ -69,6 +69,9 @@ module AWS
69
69
  # @attr_reader [String] cloud_formation_endpoint ('cloudformation.us-east-1.amazonaws.com')
70
70
  # The service endpoint for AWS CloudFormation.
71
71
  #
72
+ # @attr_reader [String] cloud_search ('cloudsearch.us-east-1.amazonaws.com')
73
+ # The service endpoint for Amazon CloudSearch.
74
+ #
72
75
  # @attr_reader [String] cloud_watch_endpoint ('monitoring.us-east-1.amazonaws.com')
73
76
  # The service endpoint for Amazon CloudWatch.
74
77
  #
@@ -88,6 +91,11 @@ module AWS
88
91
  # @attr_reader [String] ec2_endpoint ('ec2.amazonaws.com')
89
92
  # The service endpoint for Amazon EC2.
90
93
  #
94
+ # @attr_reader [String] elasticache_endpoint ('elasticache.us-east-1.amazonaws.com')
95
+ #
96
+ # @attr_reader [String] elastic_beanstalk_endpoint ('elasticbeanstalk.us-east-1.amazonaws.com')
97
+ # The service endpoint for AWS Elastic Beanstalk.
98
+ #
91
99
  # @attr_reader [String] elb_endpoint ('elasticloadbalancing.us-east-1.amazonaws.com')
92
100
  # The service endpoint for Elastic Load Balancing.
93
101
  #
@@ -130,6 +138,9 @@ module AWS
130
138
  # @attr_reader [URI,nil] route_53_endpoint ('route53.amazonaws.com')
131
139
  # The service endpoint for Amazon Route 53.
132
140
  #
141
+ # @attr_reader [URI,nil] rds_endpoint ('rds.us-east-1.amazonaws.com')
142
+ # The service endpoint for Amazon Relational Database Service (RDS).
143
+ #
133
144
  # @attr_reader [String] s3_endpoint ('s3.amazonaws.com')
134
145
  # The service endpoint for Amazon S3.
135
146
  #
@@ -35,6 +35,7 @@ module AWS
35
35
  inflector['s3Key'] = 's3_key'
36
36
  inflector['Ec2KeyName'] = 'ec2_key_name'
37
37
  inflector['Ec2SubnetId'] = 'ec2_subnet_id'
38
+ inflector['ElastiCache'] = 'elasticache'
38
39
  inflector['NotificationARNs'] = 'notification_arns'
39
40
 
40
41
  inflector[aws_name]
@@ -48,7 +48,7 @@ module AWS
48
48
  options = options.dup
49
49
  @config = (options.delete(:config) || AWS.config)
50
50
  @config = @config.with(options)
51
- @client = @config.send(Inflection.ruby_name(self.class.to_s) + '_client')
51
+ @client = @config.send(Inflection.ruby_name(self.class.name.split('::').last) + '_client')
52
52
  end
53
53
 
54
54
  # @return [String]
@@ -13,7 +13,7 @@
13
13
 
14
14
  module AWS
15
15
  class DynamoDB
16
-
16
+
17
17
  # A utility class for configuring a list of tables, attributes and
18
18
  # items to request information for.
19
19
  #
@@ -31,7 +31,7 @@ module AWS
31
31
  @request_items = {}
32
32
  end
33
33
 
34
- # Add a list of items to fetch in this batch.
34
+ # Add a list of items to fetch in this batch.
35
35
  #
36
36
  # @param [Table,String] table The name of the table to fetch attributes
37
37
  # from.
@@ -61,9 +61,15 @@ module AWS
61
61
  #
62
62
  # batch_get.table('mytable', :all, [%w(hk1 rk1), %w(hk1 rk2), ...])
63
63
  #
64
+ # @param [Hash] options
65
+ #
66
+ # @option options [Boolean] :consistent_read (false) When +true+, items
67
+ # are read from this table with consistent reads. When +false+, reads
68
+ # are eventually consistent.
69
+ #
64
70
  # @return [nil]
65
71
  #
66
- def table table, attributes, items
72
+ def table table, attributes, items, options = {}
67
73
 
68
74
  table = table.is_a?(Table) ? table.name : table.to_s
69
75
 
@@ -72,7 +78,7 @@ module AWS
72
78
  keys = items.collect do |item|
73
79
  case item
74
80
  when Item then item_key_hash(item)
75
- when Array
81
+ when Array
76
82
  {
77
83
  :hash_key_element => format_attribute_value(item[0]),
78
84
  :range_key_element => format_attribute_value(item[1]),
@@ -85,8 +91,8 @@ module AWS
85
91
  ## ensure we don't receive 2 different lists of attributes for
86
92
  ## the same table
87
93
 
88
- if
89
- @request_items.has_key?(table) and
94
+ if
95
+ @request_items.has_key?(table) and
90
96
  @request_items[table][:attributes_to_get] != attributes
91
97
  then
92
98
  msg = "When batch getting attributes, you may only provide " +
@@ -97,9 +103,10 @@ module AWS
97
103
 
98
104
  ## merge attributes and items with the request items
99
105
 
100
- @request_items[table] ||= { :keys => [] }
106
+ @request_items[table] ||= { :keys => [] }
101
107
  @request_items[table][:attributes_to_get] = attributes if attributes
102
108
  @request_items[table][:keys] += keys
109
+ @request_items[table].merge!(options)
103
110
 
104
111
  nil
105
112
 
@@ -123,7 +130,7 @@ module AWS
123
130
  # batch_get.table('mytable', ['name', 'size'], items)
124
131
  #
125
132
  # @param [Item] items One or more {Item} objects to fetch attributes
126
- # for. These items may come from any number of different tables.
133
+ # for. These items may come from any number of different tables.
127
134
  #
128
135
  def items attributes, *items
129
136
  [items].flatten.each do |item|
@@ -156,7 +163,7 @@ module AWS
156
163
  end
157
164
 
158
165
  # Yields only attribute hashes. This removes the outer hash that
159
- # normally provides the :table_name and :attributes keys. This is
166
+ # normally provides the :table_name and :attributes keys. This is
160
167
  # useful when your batch get requested items from a single table.
161
168
  def each_attributes
162
169
  each do |table_name, attributes|
@@ -166,16 +173,16 @@ module AWS
166
173
 
167
174
  protected
168
175
  def convert_unprocessed_keys response
169
-
176
+
170
177
  return nil if response.data['UnprocessedKeys'].empty?
171
-
178
+
172
179
  # convert the json response keys into symbolized keys
173
180
  str2sym = lambda do |key_desc|
174
181
  type, value = key_desc.to_a.flatten
175
182
  case type
176
183
  when "S" then { :s => value }
177
184
  when "N" then { :n => value }
178
- else
185
+ else
179
186
  raise "unhandled key type: #{type}"
180
187
  end
181
188
  end
@@ -11,6 +11,8 @@
11
11
  # ANY KIND, either express or implied. See the License for the specific
12
12
  # language governing permissions and limitations under the License.
13
13
 
14
+ require 'zlib'
15
+
14
16
  module AWS
15
17
  class DynamoDB
16
18
 
@@ -66,6 +68,7 @@ module AWS
66
68
  # * +:ns+ - (Array<String>) A set of numbers.
67
69
  # * +:bs+ - (Array<String>) A set of binary attributes.
68
70
  # * +:attributes_to_get+ - (Array<String>)
71
+ # * +:consistent_read+ - (Boolean)
69
72
  # @return [Core::Response]
70
73
  # The #data method of the response object returns
71
74
  # a hash with the following structure:
@@ -95,6 +98,7 @@ module AWS
95
98
  # * +NS+ - (Array<String>)
96
99
  # * +BS+ - (Array<Blob>)
97
100
  # * +AttributesToGet+ - (Array<String>)
101
+ # * +ConsistentRead+ - (Boolean)
98
102
 
99
103
  # @!method batch_write_item(options = {})
100
104
  # Calls the BatchWriteItem API operation.
@@ -839,14 +843,19 @@ module AWS
839
843
  def extract_error_details response
840
844
  if response.http_response.status == 413
841
845
  ['RequestEntityTooLarge', 'Request entity too large']
846
+ elsif crc32_is_valid?(response) == false
847
+ ['CRC32CheckFailed', 'CRC32 integrity check failed']
842
848
  else
843
849
  super
844
850
  end
845
851
  end
846
852
 
847
853
  def retryable_error? response
848
- if response.error.is_a?(Errors::ProvisionedThroughputExceededException)
854
+ case response.error
855
+ when Errors::ProvisionedThroughputExceededException
849
856
  config.dynamo_db_retry_throughput_errors?
857
+ when Errors::CRC32CheckFailed
858
+ true
850
859
  else
851
860
  super
852
861
  end
@@ -873,6 +882,23 @@ module AWS
873
882
 
874
883
  end
875
884
 
885
+ private
886
+
887
+ # @return [Boolean] whether the CRC32 response header matches the body.
888
+ # @return [nil] if no CRC32 header is present or we are not verifying CRC32
889
+ def crc32_is_valid? response
890
+ return nil unless config.dynamo_db_crc32
891
+ if crcs = response.http_response.headers['x-amz-crc32']
892
+ crcs[0].to_i == calculate_crc32(response)
893
+ else
894
+ nil
895
+ end
896
+ end
897
+
898
+ def calculate_crc32 response
899
+ Zlib.crc32(response.http_response.body)
900
+ end
901
+
876
902
  end
877
903
  end
878
904
  end
@@ -19,4 +19,6 @@ AWS::Core::Configuration.module_eval do
19
19
 
20
20
  add_option :dynamo_db_big_decimals, true, :boolean => true
21
21
 
22
+ add_option :dynamo_db_crc32, true, :boolean => true
23
+
22
24
  end
@@ -75,10 +75,10 @@ module AWS
75
75
  # end
76
76
  #
77
77
  # If you want item data objects with all attributes just call select
78
- # without any arguments:
78
+ # without a list of attributes (#select still accepts options).
79
79
  #
80
80
  # # request a maximum of 10 items from Amazon DynamoDB
81
- # table.items.select.limit(10).each do |item_data|
81
+ # table.items.select(:limit => 10).each do |item_data|
82
82
  # item_data.attributes #=> { 'id' => 'abc', 'category' => 'foo', ... }
83
83
  # end
84
84
  #
@@ -390,14 +390,20 @@ module AWS
390
390
  # * an array of hash and range key value pairs (nested arrays)
391
391
  # * an array of {Item} objects
392
392
  #
393
+ # @param [Hash] options
394
+ #
395
+ # @option options [Boolean] :consistent_read (false) When +true+, items
396
+ # are read from this table with consistent reads. When +false+, reads
397
+ # are eventually consistent.
398
+ #
393
399
  # @yield [Hash] Yields a hash of attributes for each item.
394
400
  #
395
401
  # @return [Enumerable] Returns an enumerable object that yields
396
402
  # hashes of attributes.
397
403
  #
398
- def batch_get attributes, items, &block
404
+ def batch_get attributes, items, options = {}, &block
399
405
  batch = BatchGet.new(:config => config)
400
- batch.table(name, attributes, items)
406
+ batch.table(name, attributes, items, options)
401
407
  enum = batch.to_enum(:each_attributes)
402
408
  block_given? ? enum.each(&block) : enum
403
409
  end
@@ -26,6 +26,9 @@ module AWS
26
26
  :product_description,
27
27
  :instance_tenancy,
28
28
  :currency_code,
29
+ :recurring_charges,
30
+ :offering_type,
31
+ :state,
29
32
  ]
30
33
 
31
34
  include TaggedItem
@@ -24,6 +24,8 @@ module AWS
24
24
  :product_description,
25
25
  :instance_tenancy,
26
26
  :currency_code,
27
+ :recurring_charges,
28
+ :offering_type,
27
29
  ]
28
30
 
29
31
  include TaggedItem
@@ -48,7 +50,7 @@ module AWS
48
50
 
49
51
  def purchase options = {}
50
52
  options[:instance_count] = 1 unless options[:instance_count]
51
- options[:reserved_instances_offering_id] = id
53
+ options[:reserved_instances_offering_id] = id
52
54
  response = client.purchase_reserved_instances_offering(options)
53
55
  ReservedInstances.new(response.reserved_instances_id, :config => config)
54
56
  end