ruby-aws 1.7.1 → 1.7.2
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/History.md +5 -0
- data/Manifest.txt +0 -28
- data/Rakefile +3 -4
- data/lib/ruby-aws.rb +2 -1
- data/lib/ruby-aws/version.rb +2 -2
- metadata +7 -49
- metadata.gz.sig +0 -0
- data/lib/amazon/util.rb +0 -10
- data/lib/amazon/util/binder.rb +0 -48
- data/lib/amazon/util/data_reader.rb +0 -169
- data/lib/amazon/util/filter_chain.rb +0 -79
- data/lib/amazon/util/hash_nesting.rb +0 -93
- data/lib/amazon/util/lazy_results.rb +0 -59
- data/lib/amazon/util/logging.rb +0 -23
- data/lib/amazon/util/paginated_iterator.rb +0 -70
- data/lib/amazon/util/proactive_results.rb +0 -116
- data/lib/amazon/util/threadpool.rb +0 -129
- data/lib/amazon/util/user_data_store.rb +0 -100
- data/lib/amazon/webservices/mechanical_turk.rb +0 -123
- data/lib/amazon/webservices/mechanical_turk_requester.rb +0 -285
- data/lib/amazon/webservices/mturk/mechanical_turk_error_handler.rb +0 -153
- data/lib/amazon/webservices/mturk/question_generator.rb +0 -58
- data/lib/amazon/webservices/util/amazon_authentication_relay.rb +0 -72
- data/lib/amazon/webservices/util/command_line.rb +0 -157
- data/lib/amazon/webservices/util/convenience_wrapper.rb +0 -90
- data/lib/amazon/webservices/util/filter_proxy.rb +0 -45
- data/lib/amazon/webservices/util/mock_transport.rb +0 -70
- data/lib/amazon/webservices/util/request_signer.rb +0 -42
- data/lib/amazon/webservices/util/rest_transport.rb +0 -120
- data/lib/amazon/webservices/util/soap_simplifier.rb +0 -48
- data/lib/amazon/webservices/util/soap_transport.rb +0 -20
- data/lib/amazon/webservices/util/soap_transport_header_handler.rb +0 -27
- data/lib/amazon/webservices/util/unknown_result_exception.rb +0 -27
- data/lib/amazon/webservices/util/validation_exception.rb +0 -55
- data/lib/amazon/webservices/util/xml_simplifier.rb +0 -61
@@ -1,45 +0,0 @@
|
|
1
|
-
# Copyright:: Copyright (c) 2007 Amazon Technologies, Inc.
|
2
|
-
# License:: Apache License, Version 2.0
|
3
|
-
|
4
|
-
require 'amazon/util/filter_chain'
|
5
|
-
|
6
|
-
module Amazon
|
7
|
-
module WebServices
|
8
|
-
module Util
|
9
|
-
|
10
|
-
# Filter proxy is a class that can filter argument input before passing onto a proxy object
|
11
|
-
# == Usage
|
12
|
-
# Initialize with standard argument block, pass the class or pre-initialized object as the :FilterProxy parameter.
|
13
|
-
# All parameters will be passed along to the contructor of the passed class.
|
14
|
-
# FilterProxy exposes a FilterChain object, with all the magic which that class provides.
|
15
|
-
class FilterProxy
|
16
|
-
|
17
|
-
attr_accessor :filter_chain
|
18
|
-
|
19
|
-
def initialize(args)
|
20
|
-
@filter_chain = Amazon::Util::FilterChain.new
|
21
|
-
end
|
22
|
-
|
23
|
-
def configure(args)
|
24
|
-
@proxy = case args[:FilterProxy]
|
25
|
-
when Class
|
26
|
-
args[:FilterProxy].new( args )
|
27
|
-
when nil
|
28
|
-
raise "No FilterProxy or DefaultOverride defined!" unless args[:DefaultOverride].is_a? Proc
|
29
|
-
args[:DefaultOverride].call( args )
|
30
|
-
else
|
31
|
-
args[:FilterProxy]
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def method_missing(method, *args)
|
36
|
-
@filter_chain.execute(method, args) { |method,args|
|
37
|
-
@proxy.send(method,*args)
|
38
|
-
}
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
end # Amazon::WebServices::Util
|
44
|
-
end # Amazon::WebServices
|
45
|
-
end # Amazon
|
@@ -1,70 +0,0 @@
|
|
1
|
-
# Copyright:: Copyright (c) 2007 Amazon Technologies, Inc.
|
2
|
-
# License:: Apache License, Version 2.0
|
3
|
-
|
4
|
-
module Amazon
|
5
|
-
module WebServices
|
6
|
-
module Util
|
7
|
-
|
8
|
-
class MockTransport
|
9
|
-
include Enumerable
|
10
|
-
|
11
|
-
class MethodCall
|
12
|
-
|
13
|
-
def initialize( name, args )
|
14
|
-
@name = name
|
15
|
-
@args = args
|
16
|
-
@request = args[:Request][0]
|
17
|
-
end
|
18
|
-
|
19
|
-
attr_reader :name, :args, :request
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
def initialize( args={} )
|
24
|
-
@call_buffer = []
|
25
|
-
@index = 0
|
26
|
-
@listener = nil
|
27
|
-
@mock_reply = args[:MockReply] || { :MockResult => { :Mock => true, :Request => {} }, :OperationRequest => {} }
|
28
|
-
@listener = args[:MockListener] if args[:MockListener].is_a? Proc
|
29
|
-
end
|
30
|
-
|
31
|
-
attr_reader :call_buffer
|
32
|
-
attr_accessor :mock_reply
|
33
|
-
|
34
|
-
def flush
|
35
|
-
@call_buffer = []
|
36
|
-
@index = 0
|
37
|
-
end
|
38
|
-
|
39
|
-
def next
|
40
|
-
return nil if @index >= @call_buffer.size
|
41
|
-
ret = @call_buffer[@index]
|
42
|
-
@index += 1
|
43
|
-
ret
|
44
|
-
end
|
45
|
-
|
46
|
-
def each(&block) # :yields: method_call
|
47
|
-
@call_buffer[@index..-1].each { |item| yield item }
|
48
|
-
# yield self.next until @index >= @call_buffer.size
|
49
|
-
end
|
50
|
-
|
51
|
-
def listen(&block) # :yields: method_call
|
52
|
-
@listener = block
|
53
|
-
end
|
54
|
-
|
55
|
-
def method_missing(method,*args)
|
56
|
-
raise "only support one parameter" unless args.size <= 1
|
57
|
-
the_method = MethodCall.new( method, args[0] )
|
58
|
-
@call_buffer << the_method
|
59
|
-
listen_result = @listener.call( the_method ) unless @listener.nil?
|
60
|
-
response = @mock_reply.dup
|
61
|
-
response[:MockResult][:Request] = the_method.request unless response[:MockResult].nil?
|
62
|
-
response.merge!(listen_result) if listen_result.is_a? Hash
|
63
|
-
response
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
end # Amazon::Webservices::Util
|
69
|
-
end # Amazon::Webservices
|
70
|
-
end # Amazon
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# Copyright:: Copyright (c) 2007 Amazon Technologies, Inc.
|
2
|
-
# License:: Apache License, Version 2.0
|
3
|
-
|
4
|
-
require 'base64'
|
5
|
-
require 'digest/sha1'
|
6
|
-
|
7
|
-
module Amazon
|
8
|
-
module WebServices
|
9
|
-
module Util
|
10
|
-
|
11
|
-
module RequestSigner
|
12
|
-
|
13
|
-
def RequestSigner.sign(service,method,time,key)
|
14
|
-
msg = "#{service}#{method}#{time}"
|
15
|
-
return hmac_sha1( key, msg )
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def RequestSigner.hmac_sha1(key, s)
|
22
|
-
ipad = [].fill(0x36, 0, 64)
|
23
|
-
opad = [].fill(0x5C, 0, 64)
|
24
|
-
key = key.unpack("C*")
|
25
|
-
key += [].fill(0, 0, 64-key.length) if key.length < 64
|
26
|
-
|
27
|
-
inner = []
|
28
|
-
64.times { |i| inner.push(key[i] ^ ipad[i]) }
|
29
|
-
inner += s.unpack("C*")
|
30
|
-
|
31
|
-
outer = []
|
32
|
-
64.times { |i| outer.push(key[i] ^ opad[i]) }
|
33
|
-
outer = outer.pack("c*")
|
34
|
-
outer += Digest::SHA1.digest(inner.pack("c*"))
|
35
|
-
|
36
|
-
return Base64::encode64(Digest::SHA1.digest(outer)).chomp
|
37
|
-
end
|
38
|
-
|
39
|
-
end # Amazon::MTS::Util::RequestSigner
|
40
|
-
end # Amazon::MTS::Util
|
41
|
-
end # Amazon::MTS
|
42
|
-
end # Amazon
|
@@ -1,120 +0,0 @@
|
|
1
|
-
# Copyright:: Copyright (c) 2007 Amazon Technologies, Inc.
|
2
|
-
# License:: Apache License, Version 2.0
|
3
|
-
|
4
|
-
require 'cgi'
|
5
|
-
require 'net/https'
|
6
|
-
require 'rubygems'
|
7
|
-
require 'nokogiri'
|
8
|
-
require 'amazon/webservices/util/xml_simplifier'
|
9
|
-
|
10
|
-
module Amazon
|
11
|
-
module WebServices
|
12
|
-
module Util
|
13
|
-
|
14
|
-
class RESTTransport
|
15
|
-
|
16
|
-
REQUIRED_PARAMETERS = [:Endpoint]
|
17
|
-
|
18
|
-
def self.canPost?
|
19
|
-
Net::HTTP.respond_to? :post_form
|
20
|
-
end
|
21
|
-
|
22
|
-
def initialize( args )
|
23
|
-
missing_parameters = REQUIRED_PARAMETERS - args.keys
|
24
|
-
raise "Missing paramters: #{missing_parameters.join(',')}" unless missing_parameters.empty?
|
25
|
-
@uri = URI.parse( args[:Endpoint] )
|
26
|
-
@httpMethod = resolveHTTPMethod( args[:RestStyle] )
|
27
|
-
@version = args[:Version]
|
28
|
-
@ssl = (@uri.scheme == 'https') || (@uri.port == 443) || args[:UseSSL]
|
29
|
-
@skip_ssl_verify = args[:SkipSSLCheck]
|
30
|
-
|
31
|
-
agent = RubyAWS::agent( args[:SoftwareName] )
|
32
|
-
@headers = {
|
33
|
-
'User-Agent' => agent,
|
34
|
-
'X-Amazon-Software' => agent,
|
35
|
-
'Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8',
|
36
|
-
}
|
37
|
-
end
|
38
|
-
|
39
|
-
def resolveHTTPMethod( method )
|
40
|
-
case method.to_s.upcase
|
41
|
-
when "GET"
|
42
|
-
return :GET
|
43
|
-
when "POST"
|
44
|
-
raise "Your version of Ruby does not support HTTP Post" unless RESTTransport.canPost?
|
45
|
-
return :POST
|
46
|
-
else
|
47
|
-
return ( RESTTransport.canPost? ? :POST : :GET )
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def method_missing( method, *args )
|
52
|
-
params = { :Operation => method, :Version => @version }
|
53
|
-
params.merge!( args[0].delete( :Request )[0] )
|
54
|
-
params.merge!( args[0] )
|
55
|
-
|
56
|
-
http = Net::HTTP.new( @uri.host, @uri.port )
|
57
|
-
if @ssl
|
58
|
-
http.use_ssl = true
|
59
|
-
if @skip_ssl_verify
|
60
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
61
|
-
else
|
62
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
req = nil
|
67
|
-
if @httpMethod == :GET
|
68
|
-
req = Net::HTTP::Get.new( @uri.request_uri + toQueryString(params), @headers )
|
69
|
-
else
|
70
|
-
req = Net::HTTP::Post.new( @uri.request_uri, @headers )
|
71
|
-
req.form_data = toPostParams( params )
|
72
|
-
req['Content-Type'] = @headers['Content-Type'] # necessary because req.form_data resets Content-Type header
|
73
|
-
end
|
74
|
-
|
75
|
-
res = http.start { |conn|
|
76
|
-
conn.request(req)
|
77
|
-
}.body
|
78
|
-
|
79
|
-
xml = Nokogiri::XML( res )
|
80
|
-
XMLSimplifier.simplify xml
|
81
|
-
end
|
82
|
-
|
83
|
-
private
|
84
|
-
|
85
|
-
def toQueryString(params)
|
86
|
-
queryString = ""
|
87
|
-
each_http_param(params) { |key,value|
|
88
|
-
queryString << ( '&' + key + '=' + CGI.escape(value) )
|
89
|
-
}
|
90
|
-
return queryString
|
91
|
-
end
|
92
|
-
|
93
|
-
def toPostParams(params)
|
94
|
-
postParams = {}
|
95
|
-
each_http_param(params) { |key,value|
|
96
|
-
postParams[key] = value }
|
97
|
-
return postParams
|
98
|
-
end
|
99
|
-
|
100
|
-
def each_http_param(params,&block)
|
101
|
-
params.each {|k,v| each_http_param_helper( k, v, false, &block ) unless v.nil? }
|
102
|
-
end
|
103
|
-
|
104
|
-
def each_http_param_helper(key,value,num=false,&block)
|
105
|
-
key = key.to_s
|
106
|
-
case value.class.to_s
|
107
|
-
when 'Array'
|
108
|
-
value.each_with_index { |v,i| each_http_param_helper( "#{key}.#{i+1}", v, true, &block ) unless v.nil? }
|
109
|
-
when 'Hash'
|
110
|
-
value.each { |k,v| each_http_param_helper( "#{key}#{num ? '.' : '.1.'}#{k}", v, false, &block ) unless v.nil? }
|
111
|
-
else
|
112
|
-
yield key, value.to_s
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
end # RESTTransport
|
117
|
-
|
118
|
-
end # Amazon::WebServices::Util
|
119
|
-
end # Amazon::WebServices
|
120
|
-
end # Amazon
|
@@ -1,48 +0,0 @@
|
|
1
|
-
# Copyright:: Copyright (c) 2007 Amazon Technologies, Inc.
|
2
|
-
# License:: Apache License, Version 2.0
|
3
|
-
|
4
|
-
module Amazon
|
5
|
-
module WebServices
|
6
|
-
module Util
|
7
|
-
|
8
|
-
class SOAPSimplifier
|
9
|
-
|
10
|
-
# simplify(item) -- convert a soap object into a simple nested hash
|
11
|
-
def self.simplify(item)
|
12
|
-
case item.class.to_s
|
13
|
-
when 'SOAP::Mapping::Object'
|
14
|
-
simple = {}
|
15
|
-
item.__xmlattr.each {|name,at| simple["*#{name}*"] = simplify(at)}
|
16
|
-
item.__xmlele.each { |element|
|
17
|
-
# element consists of a QName and a payload
|
18
|
-
name = element[0].name
|
19
|
-
payload = simplify(element[1])
|
20
|
-
simple[name.to_sym] = payload
|
21
|
-
}
|
22
|
-
simple
|
23
|
-
when 'Array'
|
24
|
-
item.collect {|i| simplify(i) }
|
25
|
-
else
|
26
|
-
str = item.to_s
|
27
|
-
case str
|
28
|
-
when /^(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+)Z$/
|
29
|
-
Time.gm($1,$2,$3,$4,$5,$6)
|
30
|
-
when /^\d+$/
|
31
|
-
if str.to_i.to_s == str
|
32
|
-
str.to_i
|
33
|
-
else
|
34
|
-
str
|
35
|
-
end
|
36
|
-
when /^\d+\.\d+$/
|
37
|
-
str.to_f
|
38
|
-
else
|
39
|
-
str
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
end # Amazon::WebServices::Util::SoapSimplifier
|
45
|
-
|
46
|
-
end # Amazon::WebServices::Util
|
47
|
-
end # Amazon::WebServices
|
48
|
-
end # Amazon
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# Copyright:: Copyright (c) 2007 Amazon Technologies, Inc.
|
2
|
-
# License:: Apache License, Version 2.0
|
3
|
-
|
4
|
-
module Amazon
|
5
|
-
module WebServices
|
6
|
-
module Util
|
7
|
-
|
8
|
-
class SOAPTransport
|
9
|
-
|
10
|
-
def initialize(args)
|
11
|
-
raise 'SOAP no longer supported'
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.canSOAP? ; false ; end
|
15
|
-
|
16
|
-
end # SOAPTransport
|
17
|
-
|
18
|
-
end # Amazon::WebServices::Util
|
19
|
-
end # Amazon::WebServices
|
20
|
-
end # Amazon
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# Copyright:: Copyright (c) 2007 Amazon Technologies, Inc.
|
2
|
-
# License:: Apache License, Version 2.0
|
3
|
-
|
4
|
-
require 'soap/header/simplehandler.rb'
|
5
|
-
require 'xsd/qname.rb'
|
6
|
-
|
7
|
-
module Amazon
|
8
|
-
module WebServices
|
9
|
-
module Util
|
10
|
-
|
11
|
-
class SOAPTransportHeaderHandler < SOAP::Header::SimpleHandler
|
12
|
-
|
13
|
-
def initialize(ns, tag, value)
|
14
|
-
super(XSD::QName.new(ns, tag))
|
15
|
-
@tag = tag
|
16
|
-
@value = value
|
17
|
-
end
|
18
|
-
|
19
|
-
def on_simple_outbound
|
20
|
-
@value
|
21
|
-
end
|
22
|
-
|
23
|
-
end # SOAPTransportHeaderHandler
|
24
|
-
|
25
|
-
end # Amazon::WebServices::Util
|
26
|
-
end # Amazon::WebServices
|
27
|
-
end # Amazon
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# Copyright:: Copyright (c) 2007 Amazon Technologies, Inc.
|
2
|
-
# License:: Apache License, Version 2.0
|
3
|
-
|
4
|
-
module Amazon
|
5
|
-
module WebServices
|
6
|
-
module Util
|
7
|
-
|
8
|
-
# This exception is thrown when we don't know if a service call succeeded or not
|
9
|
-
class UnknownResultException < RuntimeError
|
10
|
-
|
11
|
-
attr_reader :method, :args, :exception
|
12
|
-
|
13
|
-
def initialize( exception, method, args={} )
|
14
|
-
@method = method
|
15
|
-
@args = args
|
16
|
-
@exception = exception
|
17
|
-
end
|
18
|
-
|
19
|
-
def to_s
|
20
|
-
"UnknownResultException: got #{@exception} calling #{@method}"
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
end # Amazon::WebServices::Util
|
26
|
-
end # Amazon::WebServices
|
27
|
-
end # Amazon
|
@@ -1,55 +0,0 @@
|
|
1
|
-
# Copyright:: Copyright (c) 2007 Amazon Technologies, Inc.
|
2
|
-
# License:: Apache License, Version 2.0
|
3
|
-
|
4
|
-
module Amazon
|
5
|
-
module WebServices
|
6
|
-
module Util
|
7
|
-
|
8
|
-
class ValidationException < RuntimeError
|
9
|
-
|
10
|
-
attr_reader :message, :description, :result
|
11
|
-
|
12
|
-
def initialize( result, message=nil )
|
13
|
-
@result = result
|
14
|
-
|
15
|
-
@message = [
|
16
|
-
message,
|
17
|
-
get_nested_key( result, :OperationRequest, :Errors, :Error, :Code ),
|
18
|
-
get_nested_key( result, :Request, :Errors, :Error, :Code ),
|
19
|
-
get_nested_key( result, :Errors, :Error, :Code ),
|
20
|
-
].detect { |v| !v.nil? }
|
21
|
-
|
22
|
-
@description = [
|
23
|
-
get_nested_key( result, :OperationRequest, :Errors, :Error, :Message ),
|
24
|
-
get_nested_key( result, :Request, :Errors, :Error, :Message ),
|
25
|
-
get_nested_key( result, :Errors, :Error, :Message ),
|
26
|
-
].detect { |v| !v.nil? }
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
def to_s
|
31
|
-
"ValidationException: #{message}"
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def get_nested_key( hash, *keys )
|
37
|
-
return nil unless hash.kind_of?(Hash)
|
38
|
-
result = hash
|
39
|
-
if hash.key? keys.first
|
40
|
-
keys.each do |key|
|
41
|
-
return nil unless result.kind_of?(Hash)
|
42
|
-
result = result[key]
|
43
|
-
end
|
44
|
-
return result
|
45
|
-
else
|
46
|
-
nested = hash.collect { |k,v| get_nested_key( v, *keys ) }
|
47
|
-
return ([nested].flatten - [nil]).first
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
end # Amazon::WebServices::Util
|
54
|
-
end # Amazon::WebServices
|
55
|
-
end # Amazon
|