aws 2.4.5 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/README.markdown +9 -75
  2. data/lib/acf/acf_interface.rb +6 -4
  3. data/lib/aws.rb +2 -1
  4. data/lib/awsbase/awsbase.rb +98 -65
  5. data/lib/awsbase/errors.rb +9 -5
  6. data/lib/awsbase/parsers.rb +226 -226
  7. data/lib/awsbase/utils.rb +255 -207
  8. data/lib/ec2/ec2.rb +243 -105
  9. data/lib/ec2/mon_interface.rb +2 -1
  10. data/lib/iam/iam.rb +31 -25
  11. data/lib/right_aws.rb +1 -1
  12. data/lib/s3/bucket.rb +7 -8
  13. data/lib/s3/grantee.rb +238 -238
  14. data/lib/s3/key.rb +281 -281
  15. data/lib/s3/s3.rb +2 -1
  16. data/lib/s3/s3_interface.rb +45 -35
  17. data/lib/sdb/active_sdb.rb +19 -22
  18. data/lib/sdb/sdb_interface.rb +4 -5
  19. data/lib/ses/ses.rb +123 -0
  20. data/lib/sqs/sqs.rb +5 -0
  21. data/lib/sqs/sqs_interface.rb +3 -3
  22. metadata +53 -104
  23. data/lib/awsbase/support.rb +0 -142
  24. data/test/acf/test_acf.rb +0 -148
  25. data/test/acf/test_helper.rb +0 -2
  26. data/test/ec2/test_ec2.rb +0 -205
  27. data/test/ec2/test_helper.rb +0 -2
  28. data/test/ec2/test_mon.rb +0 -17
  29. data/test/elb/test_elb.rb +0 -51
  30. data/test/http_connection.rb +0 -87
  31. data/test/iam/test_iam.rb +0 -36
  32. data/test/rds/test_rds.rb +0 -181
  33. data/test/s3/s3_test_base.rb +0 -23
  34. data/test/s3/test_helper.rb +0 -3
  35. data/test/s3/test_s3.rb +0 -162
  36. data/test/s3/test_s3_class.rb +0 -179
  37. data/test/s3/test_s3_rights.rb +0 -139
  38. data/test/s3/test_s3_stubbed.rb +0 -97
  39. data/test/sdb/test_active_sdb.rb +0 -338
  40. data/test/sdb/test_helper.rb +0 -3
  41. data/test/sdb/test_sdb.rb +0 -220
  42. data/test/sqs/test_helper.rb +0 -2
  43. data/test/sqs/test_sqs.rb +0 -232
  44. data/test/test_credentials.rb +0 -54
  45. data/test/ts_right_aws.rb +0 -13
@@ -2,7 +2,7 @@
2
2
 
3
3
  A Ruby gem for all Amazon Web Services.
4
4
 
5
- Brought to you by: [![Appoxy](http://www.simpledeployr.com/images/global/appoxy-small.png)](http://www.appoxy.com)
5
+ Brought to you by: [![Appoxy](https://lh5.googleusercontent.com/_-J9DSaseOX8/TX2Bq564w-I/AAAAAAAAxYU/xjeReyoxa8o/s800/appoxy-small%20%282%29.png)](http://www.appoxy.com)
6
6
 
7
7
  ## Discussion Group
8
8
 
@@ -10,7 +10,7 @@ Brought to you by: [![Appoxy](http://www.simpledeployr.com/images/global/appoxy-
10
10
 
11
11
  ## Documentation
12
12
 
13
- [http://rubydoc.info/gems/aws/](http://rubydoc.info/gems/aws/)
13
+ [Ruby Docs](http://rubydoc.info/gems/aws/2.4.5/frames)
14
14
 
15
15
  ## Appoxy Amazon Web Services Ruby Gems
16
16
 
@@ -20,21 +20,24 @@ Published by [Appoxy LLC](http://www.appoxy.com), under the MIT License. Special
20
20
 
21
21
  gem install aws
22
22
 
23
+ Then `require 'aws'` in your application.
23
24
 
24
25
  ## DESCRIPTION:
25
26
 
26
- The RightScale AWS gems have been designed to provide a robust, fast, and secure interface to Amazon EC2, EBS, S3, SQS, SDB, and CloudFront.
27
- These gems have been used in production by RightScale since late 2006 and are being maintained to track enhancements made by Amazon.
28
- The RightScale AWS gems comprise:
27
+ The AWS gems have been designed to provide a robust, fast, and secure interface to Amazon EC2, EBS, S3, SQS, SDB, and
28
+ CloudFront.
29
+ The AWS gems comprise:
29
30
 
30
31
  - Aws::Ec2 -- interface to Amazon EC2 (Elastic Compute Cloud) and the associated EBS (Elastic Block Store)
31
32
  - Aws::S3 and Aws::S3Interface -- interface to Amazon S3 (Simple Storage Service)
32
33
  - Aws::Sqs and Aws::SqsInterface -- interface to Amazon SQS (Simple Queue Service)
33
- - Aws::SdbInterface and Aws::ActiveSdb -- interface to Amazon SDB (SimpleDB)
34
+ - Aws::SdbInterface -- interface to Amazon SDB (SimpleDB). See [SimpleRecord for an ActiveRecord like gem](https://github.com/appoxy/simple_record).
34
35
  - Aws::AcfInterface -- interface to Amazon CloudFront, a content distribution service
35
36
  - Aws::ElbInterface -- interface to Amazon Load Balancing service
36
37
  - Aws::MonInterface -- interface to Amazon CloudWatch monitoring service
38
+ - Aws::Iam -- for AWS Identity and Access Management
37
39
 
40
+ To use a single piece intead of loading all of then, you can require it explicitly for example: `require 'aws/sqs'`.
38
41
 
39
42
  ## FEATURES:
40
43
 
@@ -91,75 +94,6 @@ By default, EC2/S3/SQS/SDB/ACF interface instances are created in per_request mo
91
94
  params[:connection_mode] to :per_thread in the initialization arguments to use
92
95
  multithreaded mode.
93
96
 
94
- ## GETTING STARTED:
95
-
96
- * For EC2 read Aws::Ec2 and consult the Amazon EC2 API documentation at
97
- http://developer.amazonwebservices.com/connect/kbcategory.jspa?categoryID=87
98
- * For S3 read Aws::S3 and consult the Amazon S3 API documentation at
99
- http://developer.amazonwebservices.com/connect/kbcategory.jspa?categoryID=48
100
- * For SQS read Aws::Sqs and consult the Amazon SQS API documentation at
101
- http://developer.amazonwebservices.com/connect/kbcategory.jspa?categoryID=31
102
-
103
- Amazon's Migration Guide for moving from first to second generation SQS is
104
- avalable at:
105
- http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1148
106
- * For SDB read Aws::SdbInterface, Aws::ActiveSdb, and consult the Amazon SDB API documentation at
107
- http://developer.amazonwebservices.com/connect/kbcategory.jspa?categoryID=141
108
- * For CloudFront (ACF) read Aws::AcfInterface and consult the Amazon CloudFront API documentation at
109
- http://developer.amazonwebservices.com/connect/kbcategory.jspa?categoryID=213
110
-
111
- ## KNOWN ISSUES:
112
-
113
- - 7/08: A user has reported that uploads of large files on Windows may be broken on some
114
- Win platforms due to a buggy File.lstat.size. Use the following monkey-patch at your own risk,
115
- as it has been proven to break Rails 2.0 on Windows:
116
-
117
- require 'win32/file'
118
- class File
119
- def lstat
120
- self.stat
121
- end
122
- end
123
-
124
-
125
- - Attempting to use the Gibberish plugin (used by the Beast forum app)
126
- will break right_aws as well as lots of other code. Gibberish
127
- changes the semantics of core Ruby (specifically, the String class) and thus presents a reliability
128
- problem for most Ruby programs.
129
-
130
- - 2/11/08: If you use Aws in conjunction with attachment_fu, the
131
- right_aws gem must be included (using the require statement) AFTER
132
- attachment_fu. If right_aws is loaded before attachment_fu, you'll
133
- encounter errors similar to:
134
-
135
- s3.amazonaws.com temporarily unavailable: (wrong number of arguments (5 for 4))
136
-
137
- or
138
-
139
- 'incompatible Net::HTTP monkey-patch'
140
-
141
- This is due to a conflict between the right_http_connection gem and another
142
- gem required by attachment_fu. It may be possible to require right_aws (and
143
- thus right_http_connection) in the .after_initialize method of the config object in
144
- environment.rb (check the docs for Rails::Configuration.after_initialize).
145
-
146
- - 8/07: Amazon has changed the semantics of the SQS service. A
147
- new queue may not be created within 60 seconds of the destruction of any
148
- older queue with the same name. Certain methods of Aws::Sqs and
149
- Aws::SqsInterface will fail with the message:
150
- "AWS.SimpleQueueService.QueueDeletedRecently: You must wait 60 seconds after deleting a queue before you can create another with the same name."
151
-
152
- ## REQUIREMENTS:
153
-
154
- Aws requires REXML and the http_connection gem.
155
- If libxml and its Ruby bindings (distributed in the libxml-ruby gem) are
156
- present, Aws can be configured to use them:
157
-
158
- Aws::AwsParser.xml_lib = 'libxml'
159
-
160
- Any error with the libxml installation will result in Aws failing-safe to
161
- REXML parsing.
162
-
163
97
 
164
98
  == LICENSE:
165
99
 
@@ -88,9 +88,11 @@ module Aws
88
88
  end
89
89
 
90
90
  @@bench = AwsBenchmarkingBlock.new
91
- def self.bench
91
+
92
+ def self.bench
92
93
  @@bench
93
94
  end
95
+
94
96
  def self.bench_xml
95
97
  @@bench.xml
96
98
  end
@@ -132,11 +134,11 @@ module Aws
132
134
  headers['content-type'] ||= 'text/xml' if body
133
135
  headers['date'] = Time.now.httpdate
134
136
  # Auth
135
- signature = AwsUtils::sign(@aws_secret_access_key, headers['date'])
137
+ signature = Utils::sign(@aws_secret_access_key, headers['date'])
136
138
  headers['Authorization'] = "AWS #{@aws_access_key_id}:#{signature}"
137
139
  # Request
138
140
  path = "#{@params[:default_service]}/#{API_VERSION}/#{path}"
139
- request = "Net::HTTP::#{method.capitalize}".constantize.new(path)
141
+ request = Net::HTTP.const_get(method.capitalize).new(path)
140
142
  request.body = body if body
141
143
  # Set request headers
142
144
  headers.each { |key, value| request[key.to_s] = value }
@@ -240,7 +242,7 @@ module Aws
240
242
  rootElement = streaming ? "StreamingDistributionConfig" : "DistributionConfig"
241
243
  # join CNAMES
242
244
  cnames_str = ''
243
- unless cnames.blank?
245
+ unless cnames.nil? || cnames.empty?
244
246
  cnames.to_a.each { |cname| cnames_str += "\n <CNAME>#{cname}</CNAME>" }
245
247
  end
246
248
  caller_reference ||= generate_call_reference
data/lib/aws.rb CHANGED
@@ -15,7 +15,6 @@ require 'right_http_connection'
15
15
  $:.unshift(File.dirname(__FILE__))
16
16
  require 'awsbase/require_relative'
17
17
  require 'awsbase/benchmark_fix'
18
- require 'awsbase/support'
19
18
  require 'awsbase/awsbase'
20
19
  require 'awsbase/aws_response_array'
21
20
  require 'ec2/ec2'
@@ -29,4 +28,6 @@ require 'acf/acf_interface'
29
28
  require 'elb/elb_interface'
30
29
  require 'rds/rds'
31
30
  require 'iam/iam'
31
+ require 'ses/ses'
32
+
32
33
 
@@ -28,7 +28,8 @@ module Aws
28
28
  require 'cgi'
29
29
  require 'uri'
30
30
  require 'xmlsimple'
31
- require 'active_support/core_ext'
31
+ require 'net/http'
32
+ # require 'active_support/core_ext'
32
33
 
33
34
  require_relative 'utils'
34
35
  require_relative 'errors'
@@ -42,7 +43,7 @@ module Aws
42
43
  # Benchmark::Tms instance for service (Ec2, S3, or SQS) access benchmarking.
43
44
  @service = Benchmark::Tms.new()
44
45
  # Benchmark::Tms instance for XML parsing benchmarking.
45
- @xml = Benchmark::Tms.new()
46
+ @xml = Benchmark::Tms.new()
46
47
  end
47
48
  end
48
49
 
@@ -55,15 +56,15 @@ module Aws
55
56
 
56
57
  # Text, if found in an error message returned by AWS, indicates that this may be a transient
57
58
  # error. Transient errors are automatically retried with exponential back-off.
58
- AMAZON_PROBLEMS = ['internal service error',
59
- 'is currently unavailable',
60
- 'no response from',
61
- 'Please try again',
62
- 'InternalError',
63
- 'ServiceUnavailable', #from SQS docs
64
- 'Unavailable',
65
- 'This application is not currently available',
66
- 'InsufficientInstanceCapacity'
59
+ AMAZON_PROBLEMS = ['internal service error',
60
+ 'is currently unavailable',
61
+ 'no response from',
62
+ 'Please try again',
63
+ 'InternalError',
64
+ 'ServiceUnavailable', #from SQS docs
65
+ 'Unavailable',
66
+ 'This application is not currently available',
67
+ 'InsufficientInstanceCapacity'
67
68
  ]
68
69
  @@amazon_problems = AMAZON_PROBLEMS
69
70
  # Returns a list of Amazon service responses which are known to be transient problems.
@@ -91,10 +92,6 @@ module Aws
91
92
  @@bench
92
93
  end
93
94
 
94
- def self.bench
95
- @@bench
96
- end
97
-
98
95
  def self.bench_xml
99
96
  @@bench.xml
100
97
  end
@@ -138,23 +135,24 @@ module Aws
138
135
 
139
136
  def init(service_info, aws_access_key_id, aws_secret_access_key, params={}) #:nodoc:
140
137
  @params = params
141
- raise AwsError.new("AWS access keys are required to operate on #{service_info[:name]}") \
142
- if aws_access_key_id.blank? || aws_secret_access_key.blank?
143
- @aws_access_key_id = aws_access_key_id
138
+ if Aws::Utils.blank?(aws_access_key_id) || Aws::Utils.blank?(aws_secret_access_key)
139
+ raise AwsError.new("AWS access keys are required to operate on #{service_info[:name]}")
140
+ end
141
+ @aws_access_key_id = aws_access_key_id
144
142
  @aws_secret_access_key = aws_secret_access_key
145
143
  # if the endpoint was explicitly defined - then use it
146
144
  if @params[:endpoint_url]
147
- @params[:server] = URI.parse(@params[:endpoint_url]).host
148
- @params[:port] = URI.parse(@params[:endpoint_url]).port
149
- @params[:service] = URI.parse(@params[:endpoint_url]).path
145
+ @params[:server] = URI.parse(@params[:endpoint_url]).host
146
+ @params[:port] = URI.parse(@params[:endpoint_url]).port
147
+ @params[:service] = URI.parse(@params[:endpoint_url]).path
150
148
  @params[:protocol] = URI.parse(@params[:endpoint_url]).scheme
151
- @params[:region] = nil
149
+ @params[:region] = nil
152
150
  else
153
151
  @params[:server] ||= service_info[:default_host]
154
152
  @params[:server] = "#{@params[:region]}.#{@params[:server]}" if @params[:region]
155
- @params[:port] ||= service_info[:default_port]
156
- @params[:service] ||= service_info[:default_service]
157
- @params[:protocol] ||= service_info[:default_protocol]
153
+ @params[:port] ||= service_info[:default_port]
154
+ @params[:service] ||= service_info[:default_service]
155
+ @params[:protocol] ||= service_info[:default_protocol]
158
156
  @params[:api_version] ||= service_info[:api_version]
159
157
  end
160
158
  if !@params[:multi_thread].nil? && @params[:connection_mode].nil? # user defined this
@@ -168,19 +166,19 @@ module Aws
168
166
  @logger = ::Rails.logger if !@logger && defined?(::Rails.logger)
169
167
  @logger = Logger.new(STDOUT) if !@logger
170
168
  @logger.info "New #{self.class.name} using #{@params[:connection_mode].to_s}-connection mode"
171
- @error_handler = nil
172
- @cache = {}
173
- @signature_version = (params[:signature_version] || DEFAULT_SIGNATURE_VERSION).to_s
169
+ @error_handler = nil
170
+ @cache = {}
171
+ @signature_version = (params[:signature_version] || service_info[:signature_version] || DEFAULT_SIGNATURE_VERSION).to_s
174
172
  end
175
173
 
176
174
  def signed_service_params(aws_secret_access_key, service_hash, http_verb=nil, host=nil, service=nil)
177
175
  case signature_version.to_s
178
176
  when '0' then
179
- AwsUtils::sign_request_v0(aws_secret_access_key, service_hash)
177
+ Utils::sign_request_v0(aws_secret_access_key, service_hash)
180
178
  when '1' then
181
- AwsUtils::sign_request_v1(aws_secret_access_key, service_hash)
179
+ Utils::sign_request_v1(aws_secret_access_key, service_hash)
182
180
  when '2' then
183
- AwsUtils::sign_request_v2(aws_secret_access_key, service_hash, http_verb, host, service)
181
+ Utils::sign_request_v2(aws_secret_access_key, service_hash, http_verb, host, service)
184
182
  else
185
183
  raise AwsError.new("Unknown signature version (#{signature_version.to_s}) requested")
186
184
  end
@@ -199,13 +197,25 @@ module Aws
199
197
  # end
200
198
  #params_string = params.to_a.collect{|key,val| key + "=#{CGI::escape(val.to_s)}" }.join("&")
201
199
  # prepare service data
202
- service = lib_params[:service]
203
- # puts 'service=' + service.to_s
204
- service_hash = {"Action" => action,
200
+ service = lib_params[:service]
201
+
202
+ now = Time.now.getutc
203
+ service_hash = {"Action" => action,
205
204
  "AWSAccessKeyId" => aws_access_key}
206
205
  service_hash.update("Version" => api_version) if api_version
207
206
  service_hash.update(user_params)
208
- service_params = signed_service_params(aws_secret_key, service_hash, :get, lib_params[:server], lib_params[:service])
207
+ headers = {}
208
+ if signature_version == '3'
209
+ service_hash["Timestamp"] = now.iso8601
210
+ service_params = escape_params(service_hash)
211
+ signature, algorithm = Aws::Utils.signature_version3(aws_secret_key, now)
212
+ headers['X-Amzn-Authorization'] = "AWS3-HTTPS AWSAccessKeyId=#{aws_access_key}, Algorithm=#{algorithm.upcase}, Signature=#{signature}"
213
+ headers['Date'] = now.httpdate
214
+ else
215
+ # puts 'service=' + service.to_s
216
+ service_params = signed_service_params(aws_secret_key, service_hash, :get, lib_params[:server], lib_params[:service])
217
+ end
218
+
209
219
  #
210
220
  # use POST method if the length of the query string is too large
211
221
  # see http://docs.amazonwebservices.com/AmazonSimpleDB/2007-11-07/DeveloperGuide/MakingRESTRequests.html
@@ -214,23 +224,34 @@ module Aws
214
224
  # resign the request because HTTP verb is included into signature
215
225
  service_params = signed_service_params(aws_secret_key, service_hash, :post, lib_params[:server], service)
216
226
  end
217
- request = Net::HTTP::Post.new(service)
218
- request.body = service_params
227
+ request = Net::HTTP::Post.new(service)
228
+ request.body = service_params
219
229
  request['Content-Type'] = 'application/x-www-form-urlencoded; charset=utf-8'
220
230
  else
221
231
  request = Net::HTTP::Get.new("#{service}?#{service_params}")
222
232
  end
233
+ headers.each_pair do |k, v|
234
+ request[k] = v
235
+ end
236
+ puts "header=" + request['X-Amzn-Authorization']
223
237
 
224
238
  #puts "\n\n --------------- QUERY REQUEST TO AWS -------------- \n\n"
225
239
  #puts "#{@params[:service]}?#{service_params}\n\n"
226
240
 
227
241
  # prepare output hash
228
- {:request => request,
229
- :server => lib_params[:server],
230
- :port => lib_params[:port],
242
+ {:request => request,
243
+ :server => lib_params[:server],
244
+ :port => lib_params[:port],
231
245
  :protocol => lib_params[:protocol]}
232
246
  end
233
247
 
248
+ def escape_params(service_hash)
249
+ canonical_string = service_hash.keys.sort.map do |key|
250
+ "#{Aws::Utils.amz_escape(key)}=#{Aws::Utils.amz_escape(service_hash[key])}"
251
+ end.join('&')
252
+ canonical_string
253
+ end
254
+
234
255
  def get_conn(connection_name, lib_params, logger)
235
256
  # thread = lib_params[:multi_thread] ? Thread.current : Thread.main
236
257
  # thread[connection_name] ||= Rightscale::HttpConnection.new(:exception => Aws::AwsError, :logger => logger)
@@ -239,20 +260,23 @@ module Aws
239
260
  http_conn = nil
240
261
  conn_mode = lib_params[:connection_mode]
241
262
 
242
- # Slice all parameters accepted by Rightscale::HttpConnection#new
243
- params = lib_params.slice(
244
- :user_agent, :ca_file, :http_connection_retry_count, :http_connection_open_timeout,
245
- :http_connection_read_timeout, :http_connection_retry_delay
246
- )
247
- params.merge!(:exception => AwsError, :logger => logger)
263
+ params = { :exception => AwsError, :logger => logger }
264
+
265
+ # Adds all parameters accepted by Rightscale::HttpConnection#new
266
+ [ :user_agent, :ca_file, :http_connection_retry_count,
267
+ :http_connection_open_timeout, :http_connection_read_timeout,
268
+ :http_connection_retry_delay
269
+ ].each do |key|
270
+ params[key] = lib_params[key] if lib_params.has_key?(key)
271
+ end
248
272
 
249
273
  if conn_mode == :per_request
250
274
  http_conn = Rightscale::HttpConnection.new(params)
251
275
 
252
276
  elsif conn_mode == :per_thread || conn_mode == :single
253
- thread = conn_mode == :per_thread ? Thread.current : Thread.main
277
+ thread = conn_mode == :per_thread ? Thread.current : Thread.main
254
278
  thread[connection_name] ||= Rightscale::HttpConnection.new(params)
255
- http_conn = thread[connection_name]
279
+ http_conn = thread[connection_name]
256
280
  # ret = request_info_impl(http_conn, bench, request, parser, &block)
257
281
  end
258
282
  return http_conn
@@ -280,13 +304,13 @@ module Aws
280
304
 
281
305
 
282
306
  def request_info2(request, parser, lib_params, connection_name, logger, bench, options={}, &block) #:nodoc:
283
- ret = nil
307
+ ret = nil
284
308
  # puts 'OPTIONS=' + options.inspect
285
309
  http_conn = get_conn(connection_name, lib_params, logger)
286
310
  begin
287
311
  # todo: this QueryTimeout retry should go into a SimpleDbErrorHandler, not here
288
312
  retry_count = 1
289
- count = 0
313
+ count = 0
290
314
  while count <= retry_count
291
315
  puts 'RETRYING QUERY due to QueryTimeout...' if count > 0
292
316
  begin
@@ -325,19 +349,19 @@ module Aws
325
349
 
326
350
  connection = get_conn(connection_name, lib_params, logger)
327
351
  begin
328
- @last_request = request[:request]
352
+ @last_request = request[:request]
329
353
  @last_response = nil
330
354
 
331
- response = connection.request(request)
355
+ response = connection.request(request)
332
356
  # puts "response=" + response.body
333
357
  # benchblock.service.add!{ response = connection.request(request) }
334
358
  # check response for errors...
335
359
  @last_response = response
336
360
  if response.is_a?(Net::HTTPSuccess)
337
- @error_handler = nil
361
+ @error_handler = nil
338
362
  # benchblock.xml.add! { parser.parse(response) }
339
363
  # return parser.result
340
- force_array = params[:force_array] || false
364
+ force_array = params[:force_array] || false
341
365
  # Force_array and group_tags don't work nice together so going to force array manually
342
366
  xml_simple_options = {"KeyToSymbol"=>false, 'ForceArray' => false}
343
367
  xml_simple_options["GroupTags"] = params[:group_tags] if params[:group_tags]
@@ -358,7 +382,7 @@ module Aws
358
382
  parsed = symbolize(parsed, force_array)
359
383
  # puts 'parsed=' + parsed.inspect
360
384
  if params[:pull_out_array]
361
- ret = Aws::AwsResponseArray.new(parsed[:response_metadata])
385
+ ret = Aws::AwsResponseArray.new(parsed[:response_metadata])
362
386
  level_hash = parsed
363
387
  params[:pull_out_array].each do |x|
364
388
  level_hash = level_hash[x]
@@ -373,7 +397,7 @@ module Aws
373
397
  end
374
398
  elsif params[:pull_out_single]
375
399
  # returns a single object
376
- ret = AwsResponseObjectHash.new(parsed[:response_metadata])
400
+ ret = AwsResponseObjectHash.new(parsed[:response_metadata])
377
401
  level_hash = parsed
378
402
  params[:pull_out_single].each do |x|
379
403
  level_hash = level_hash[x]
@@ -400,6 +424,15 @@ module Aws
400
424
 
401
425
  end
402
426
 
427
+ # This is the latest and greatest now. Service must have connection_name defined.
428
+ def request_info_xml_simple3(service_interface, request, options)
429
+ request_info_xml_simple(service_interface.class.connection_name,
430
+ service_interface.params,
431
+ request,
432
+ service_interface.logger,
433
+ options)
434
+ end
435
+
403
436
  def symbolize(hash, force_array)
404
437
  ret = {}
405
438
  hash.keys.each do |key|
@@ -412,7 +445,7 @@ module Aws
412
445
  elsif val.is_a? Array
413
446
  val = val.collect { |x| symbolize(x, force_array) }
414
447
  end
415
- ret[key.underscore.to_sym] = val
448
+ ret[Aws::Utils.underscore(key).to_sym] = val
416
449
  end
417
450
  ret
418
451
  end
@@ -430,17 +463,17 @@ module Aws
430
463
  def cache_hits?(function, response, do_raise=:raise)
431
464
  result = false
432
465
  if caching?
433
- function = function.to_sym
466
+ function = function.to_sym
434
467
  # get rid of requestId (this bad boy was added for API 2008-08-08+ and it is uniq for every response)
435
- response = response.sub(%r{<requestId>.+?</requestId>}, '')
468
+ response = response.sub(%r{<requestId>.+?</requestId>}, '')
436
469
  response_md5 =Digest::MD5.hexdigest(response).to_s
437
470
  # check for changes
438
471
  unless @cache[function] && @cache[function][:response_md5] == response_md5
439
472
  # well, the response is new, reset cache data
440
473
  update_cache(function, {:response_md5 => response_md5,
441
- :timestamp => Time.now,
442
- :hits => 0,
443
- :parsed => nil})
474
+ :timestamp => Time.now,
475
+ :hits => 0,
476
+ :parsed => nil})
444
477
  else
445
478
  # aha, cache hits, update the data and throw an exception if needed
446
479
  @cache[function][:hits] += 1
@@ -472,10 +505,10 @@ module Aws
472
505
 
473
506
 
474
507
  def request_info_impl(connection, benchblock, request, parser, options={}, &block) #:nodoc:
475
- connection = connection
476
- @last_request = request[:request]
508
+ connection = connection
509
+ @last_request = request[:request]
477
510
  @last_response = nil
478
- response =nil
511
+ response =nil
479
512
  blockexception = nil
480
513
 
481
514
  # puts 'OPTIONS2=' + options.inspect