aws 2.4.5 → 2.5.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.
- data/README.markdown +9 -75
- data/lib/acf/acf_interface.rb +6 -4
- data/lib/aws.rb +2 -1
- data/lib/awsbase/awsbase.rb +98 -65
- data/lib/awsbase/errors.rb +9 -5
- data/lib/awsbase/parsers.rb +226 -226
- data/lib/awsbase/utils.rb +255 -207
- data/lib/ec2/ec2.rb +243 -105
- data/lib/ec2/mon_interface.rb +2 -1
- data/lib/iam/iam.rb +31 -25
- data/lib/right_aws.rb +1 -1
- data/lib/s3/bucket.rb +7 -8
- data/lib/s3/grantee.rb +238 -238
- data/lib/s3/key.rb +281 -281
- data/lib/s3/s3.rb +2 -1
- data/lib/s3/s3_interface.rb +45 -35
- data/lib/sdb/active_sdb.rb +19 -22
- data/lib/sdb/sdb_interface.rb +4 -5
- data/lib/ses/ses.rb +123 -0
- data/lib/sqs/sqs.rb +5 -0
- data/lib/sqs/sqs_interface.rb +3 -3
- metadata +53 -104
- data/lib/awsbase/support.rb +0 -142
- data/test/acf/test_acf.rb +0 -148
- data/test/acf/test_helper.rb +0 -2
- data/test/ec2/test_ec2.rb +0 -205
- data/test/ec2/test_helper.rb +0 -2
- data/test/ec2/test_mon.rb +0 -17
- data/test/elb/test_elb.rb +0 -51
- data/test/http_connection.rb +0 -87
- data/test/iam/test_iam.rb +0 -36
- data/test/rds/test_rds.rb +0 -181
- data/test/s3/s3_test_base.rb +0 -23
- data/test/s3/test_helper.rb +0 -3
- data/test/s3/test_s3.rb +0 -162
- data/test/s3/test_s3_class.rb +0 -179
- data/test/s3/test_s3_rights.rb +0 -139
- data/test/s3/test_s3_stubbed.rb +0 -97
- data/test/sdb/test_active_sdb.rb +0 -338
- data/test/sdb/test_helper.rb +0 -3
- data/test/sdb/test_sdb.rb +0 -220
- data/test/sqs/test_helper.rb +0 -2
- data/test/sqs/test_sqs.rb +0 -232
- data/test/test_credentials.rb +0 -54
- data/test/ts_right_aws.rb +0 -13
data/README.markdown
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
A Ruby gem for all Amazon Web Services.
|
4
4
|
|
5
|
-
Brought to you by: [](http://www.appoxy.com)
|
6
6
|
|
7
7
|
## Discussion Group
|
8
8
|
|
@@ -10,7 +10,7 @@ Brought to you by: [
|
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
|
27
|
-
|
28
|
-
The
|
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
|
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
|
|
data/lib/acf/acf_interface.rb
CHANGED
@@ -88,9 +88,11 @@ module Aws
|
|
88
88
|
end
|
89
89
|
|
90
90
|
@@bench = AwsBenchmarkingBlock.new
|
91
|
-
|
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 =
|
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 =
|
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.
|
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
|
|
data/lib/awsbase/awsbase.rb
CHANGED
@@ -28,7 +28,8 @@ module Aws
|
|
28
28
|
require 'cgi'
|
29
29
|
require 'uri'
|
30
30
|
require 'xmlsimple'
|
31
|
-
require '
|
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
|
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
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
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
|
-
|
142
|
-
|
143
|
-
|
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]
|
148
|
-
@params[:port]
|
149
|
-
@params[:service]
|
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]
|
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]
|
156
|
-
@params[:service]
|
157
|
-
@params[: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
|
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
|
-
|
177
|
+
Utils::sign_request_v0(aws_secret_access_key, service_hash)
|
180
178
|
when '1' then
|
181
|
-
|
179
|
+
Utils::sign_request_v1(aws_secret_access_key, service_hash)
|
182
180
|
when '2' then
|
183
|
-
|
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
|
203
|
-
|
204
|
-
|
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
|
-
|
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
|
218
|
-
request.body
|
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
|
229
|
-
:server
|
230
|
-
: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
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
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
|
277
|
+
thread = conn_mode == :per_thread ? Thread.current : Thread.main
|
254
278
|
thread[connection_name] ||= Rightscale::HttpConnection.new(params)
|
255
|
-
http_conn
|
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
|
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
|
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
|
352
|
+
@last_request = request[:request]
|
329
353
|
@last_response = nil
|
330
354
|
|
331
|
-
response
|
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
|
361
|
+
@error_handler = nil
|
338
362
|
# benchblock.xml.add! { parser.parse(response) }
|
339
363
|
# return parser.result
|
340
|
-
force_array
|
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
|
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
|
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[
|
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
|
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
|
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
|
442
|
-
:hits
|
443
|
-
:parsed
|
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
|
476
|
-
@last_request
|
508
|
+
connection = connection
|
509
|
+
@last_request = request[:request]
|
477
510
|
@last_response = nil
|
478
|
-
response
|
511
|
+
response =nil
|
479
512
|
blockexception = nil
|
480
513
|
|
481
514
|
# puts 'OPTIONS2=' + options.inspect
|