aws-sdk 1.5.8 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/aws.rb +2 -0
- data/lib/aws/api_config/Route53-2012-02-29.yml +348 -0
- data/lib/aws/auto_scaling/client.rb +362 -588
- data/lib/aws/cloud_formation/client.rb +155 -224
- data/lib/aws/cloud_watch/client.rb +156 -229
- data/lib/aws/core.rb +67 -52
- data/lib/aws/core/client.rb +81 -82
- data/lib/aws/core/collection/with_limit_and_next_token.rb +2 -2
- data/lib/aws/core/configuration.rb +75 -72
- data/lib/aws/core/http/net_http_handler.rb +3 -3
- data/lib/aws/core/http/request.rb +107 -138
- data/lib/aws/core/inflection.rb +3 -3
- data/lib/aws/core/json_client.rb +106 -0
- data/lib/aws/core/option_grammar.rb +10 -1
- data/lib/aws/core/options/validator.rb +140 -0
- data/lib/aws/core/options/xml_serializer.rb +98 -0
- data/lib/aws/core/query_client.rb +131 -0
- data/lib/aws/core/rest_client.rb +90 -0
- data/lib/aws/core/rest_client/input_handler.rb +145 -0
- data/lib/aws/core/rest_client/output_handler.rb +43 -0
- data/lib/aws/core/signature/version_2.rb +7 -7
- data/lib/aws/core/signature/version_3.rb +5 -1
- data/lib/aws/core/signature/version_3_https.rb +51 -0
- data/lib/aws/core/signature/version_4.rb +5 -22
- data/lib/aws/core/signer.rb +1 -1
- data/lib/aws/core/uri_escape.rb +2 -0
- data/lib/aws/core/xml/frame.rb +8 -8
- data/lib/aws/core/xml/grammar.rb +8 -3
- data/lib/aws/dynamo_db/client.rb +600 -662
- data/lib/aws/ec2/client.rb +2688 -3492
- data/lib/aws/ec2/request.rb +0 -1
- data/lib/aws/elb/client.rb +280 -407
- data/lib/aws/emr/client.rb +7 -7
- data/lib/aws/iam/client.rb +822 -1268
- data/lib/aws/route_53.rb +71 -0
- data/lib/aws/route_53/client.rb +272 -0
- data/lib/aws/route_53/config.rb +18 -0
- data/lib/aws/route_53/errors.rb +22 -0
- data/lib/aws/route_53/request.rb +23 -0
- data/lib/aws/s3/object_version_collection.rb +6 -6
- data/lib/aws/s3/paginated_collection.rb +1 -1
- data/lib/aws/s3/request.rb +10 -5
- data/lib/aws/simple_db/client.rb +184 -234
- data/lib/aws/simple_email_service/client.rb +147 -238
- data/lib/aws/simple_workflow/client.rb +997 -1191
- data/lib/aws/sns/client.rb +176 -264
- data/lib/aws/sqs/client.rb +162 -253
- data/lib/aws/sqs/queue.rb +1 -1
- data/lib/aws/sqs/request.rb +4 -0
- data/lib/aws/sts/client.rb +57 -66
- metadata +95 -71
- data/lib/aws/core/client/query_json.rb +0 -112
- data/lib/aws/core/client/query_xml.rb +0 -122
data/lib/aws/core/inflection.rb
CHANGED
@@ -23,9 +23,9 @@ module AWS
|
|
23
23
|
|
24
24
|
key.
|
25
25
|
sub(/^.*:/, ''). # strip namespace
|
26
|
-
gsub(/([A-Z0-9]+)([A-Z][a-z])/, '\1_\2'). # split acronyms
|
27
|
-
scan(/[a-z]+|\d+|[A-Z0-9]+[a-z]*/). # split
|
28
|
-
join('_').downcase # join parts
|
26
|
+
gsub(/([A-Z0-9]+)([A-Z][a-z])/, '\1_\2'). # split acronyms
|
27
|
+
scan(/[a-z]+|\d+|[A-Z0-9]+[a-z]*/). # split words
|
28
|
+
join('_').downcase # join parts
|
29
29
|
|
30
30
|
end
|
31
31
|
|
@@ -0,0 +1,106 @@
|
|
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 'json'
|
15
|
+
|
16
|
+
module AWS
|
17
|
+
module Core
|
18
|
+
|
19
|
+
# = AWS::Core::Client::JSON
|
20
|
+
#
|
21
|
+
# Clients extend this module if the service they represent are
|
22
|
+
# AWS Query services that accept and return JSON.
|
23
|
+
#
|
24
|
+
module JSONClient
|
25
|
+
|
26
|
+
# Constructs the option grammars, one per service operation.
|
27
|
+
# @private
|
28
|
+
def self.extended base
|
29
|
+
base.send(:include, ErrorParser)
|
30
|
+
base.send(:define_grammars)
|
31
|
+
end
|
32
|
+
|
33
|
+
# @return [Hash<Symbol,OptionGrammar>] Returns a hash option
|
34
|
+
# grammars. Keys are method names (operations) and values are
|
35
|
+
# request option grammars that convert a ruby hash of options
|
36
|
+
# into a JSON document.
|
37
|
+
# @private
|
38
|
+
def option_grammars
|
39
|
+
@option_grammars ||= {}
|
40
|
+
end
|
41
|
+
|
42
|
+
protected
|
43
|
+
|
44
|
+
# Enumerates through the operations specified in the API
|
45
|
+
# configuration (yaml configuration file found in lib/api_config/)
|
46
|
+
# and defines one request method per operation.
|
47
|
+
def define_grammars
|
48
|
+
api_config[:operations].each do |op|
|
49
|
+
option_grammars[op[:method]] = OptionGrammar.customize(op[:inputs])
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def define_client_method method_name, operation
|
54
|
+
add_client_request_method(method_name) do
|
55
|
+
|
56
|
+
configure_request do |request, options|
|
57
|
+
|
58
|
+
parser = self.class.option_grammars[method_name]
|
59
|
+
x_amz_target = self.class::TARGET_PREFIX + operation
|
60
|
+
|
61
|
+
request.headers["content-type"] = "application/x-amz-json-1.0"
|
62
|
+
request.headers["x-amz-target"] = x_amz_target
|
63
|
+
request.body = parser.to_json(options)
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
process_response do |response|
|
68
|
+
response_body = response.http_response.body
|
69
|
+
response_body = "{}" if response_body == ""
|
70
|
+
data = ::JSON.load(response_body)
|
71
|
+
MetaUtils.extend_method(response, :data) { data }
|
72
|
+
end
|
73
|
+
|
74
|
+
simulate_response do |response|
|
75
|
+
data = {}
|
76
|
+
MetaUtils.extend_method(response, :data) { data }
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
module ErrorParser
|
83
|
+
|
84
|
+
def extract_error_details response
|
85
|
+
if
|
86
|
+
response.http_response.status >= 300 and
|
87
|
+
body = response.http_response.body and
|
88
|
+
json = (::JSON.load(body) rescue nil) and
|
89
|
+
type = json["__type"] and
|
90
|
+
matches = type.match(/\#(.*)$/)
|
91
|
+
then
|
92
|
+
code = matches[1]
|
93
|
+
if code == 'RequestEntityTooLarge'
|
94
|
+
message = 'Request body must be less than 1 MB'
|
95
|
+
else
|
96
|
+
message = json['message']
|
97
|
+
end
|
98
|
+
[code, message]
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -211,8 +211,17 @@ module AWS
|
|
211
211
|
def apply(option, member_descriptors)
|
212
212
|
super(option)
|
213
213
|
member_option = option.member_option if option.respond_to?(:member_option)
|
214
|
+
|
215
|
+
# ignoring member name descriptors for lists, only useful for rest
|
216
|
+
descriptors = []
|
217
|
+
member_descriptors.each do |descriptor|
|
218
|
+
unless descriptor.is_a?(Hash) and descriptor[:member_name]
|
219
|
+
descriptors << descriptor
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
214
223
|
member_option ||= ListMember.new
|
215
|
-
member_option = member_option.extend_with_config(*
|
224
|
+
member_option = member_option.extend_with_config(*descriptors)
|
216
225
|
MetaUtils.extend_method(option, :member_option) { member_option }
|
217
226
|
end
|
218
227
|
|
@@ -0,0 +1,140 @@
|
|
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
|
+
module Core
|
16
|
+
module Options
|
17
|
+
|
18
|
+
# Given a hash of validation rules, a validator validate request
|
19
|
+
# options. Validations support:
|
20
|
+
#
|
21
|
+
# * rejecting unknown options
|
22
|
+
# * ensuring presence of required options
|
23
|
+
# * validating expected option types (e.g. hash, array, string,
|
24
|
+
# integer, etc).
|
25
|
+
#
|
26
|
+
# After validating, a hash of request options is returned with
|
27
|
+
# with normalized values (with converted types).
|
28
|
+
class Validator
|
29
|
+
|
30
|
+
# @param [Hash] rules A hash of option rules to validate against.
|
31
|
+
def initialize rules
|
32
|
+
@rules = rules
|
33
|
+
end
|
34
|
+
|
35
|
+
# @return [Hash]
|
36
|
+
attr_reader :rules
|
37
|
+
|
38
|
+
# @overload validate!(request_options)
|
39
|
+
# @param [Hash] request_options The hash of options to validate.
|
40
|
+
# @raise [ArgumentError] Raised when the options do not validate.
|
41
|
+
# @return [Hash]
|
42
|
+
def validate! request_options, rules = @rules
|
43
|
+
|
44
|
+
# Verify all required options are present.
|
45
|
+
rules.each_pair do |opt_name, opt_rules|
|
46
|
+
if opt_rules[:required]
|
47
|
+
unless request_options.key?(opt_name)
|
48
|
+
raise ArgumentError, "missing required option :#{opt_name}"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
request_options.inject({}) do |options, (opt_name, value)|
|
54
|
+
|
55
|
+
# Ensure this is a valid/accepted option
|
56
|
+
unless rules.key?(opt_name)
|
57
|
+
raise ArgumentError, "unexpected option #{opt_name.inspect}"
|
58
|
+
end
|
59
|
+
|
60
|
+
# Validate and convert the value
|
61
|
+
valid_value = validate_value(rules[opt_name], value, opt_name)
|
62
|
+
|
63
|
+
options.merge(opt_name => valid_value)
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
protected
|
69
|
+
|
70
|
+
# Proxies calls to the correct validation method based on the
|
71
|
+
# rules[:type].
|
72
|
+
def validate_value *args
|
73
|
+
send("validate_#{args.first[:type]}", *args)
|
74
|
+
end
|
75
|
+
|
76
|
+
# Ensures the value is a hash and validates the hash context.
|
77
|
+
def validate_hash rules, value, opt_name, context = nil
|
78
|
+
unless value.respond_to?(:to_hash)
|
79
|
+
format_error('hash value', opt_name, context)
|
80
|
+
end
|
81
|
+
validate!(value.to_hash, rules[:members])
|
82
|
+
end
|
83
|
+
|
84
|
+
# Ensures the value is an array (or at least enumerable) and
|
85
|
+
# that the yielded values are valid.
|
86
|
+
def validate_array rules, value, opt_name, context = nil
|
87
|
+
unless value.respond_to?(:each)
|
88
|
+
format_error('enumerable value', opt_name, context)
|
89
|
+
end
|
90
|
+
values = []
|
91
|
+
value.each do |v|
|
92
|
+
context = "member #{values.size} of :#{opt_name}"
|
93
|
+
values << validate_value(rules[:members], v, opt_name, context)
|
94
|
+
end
|
95
|
+
values
|
96
|
+
end
|
97
|
+
|
98
|
+
# Ensures the value is a string.
|
99
|
+
def validate_string rules, value, opt_name, context = nil
|
100
|
+
|
101
|
+
unless value.respond_to?(:to_str)
|
102
|
+
format_error('string value', opt_name, context)
|
103
|
+
end
|
104
|
+
|
105
|
+
rules[:lstrip] ?
|
106
|
+
value.to_str.sub(/^#{rules[:lstrip]}/, '') :
|
107
|
+
value.to_str
|
108
|
+
end
|
109
|
+
|
110
|
+
# Ensures the value is a boolean.
|
111
|
+
def validate_boolean rules, value, opt_name, context = nil
|
112
|
+
unless [true, false].include?(value)
|
113
|
+
format_error('true or false', opt_name, context)
|
114
|
+
end
|
115
|
+
value
|
116
|
+
end
|
117
|
+
|
118
|
+
# Ensures the value is an integer.
|
119
|
+
def validate_integer rules, value, opt_name, context = nil
|
120
|
+
unless value.respond_to?(:to_int)
|
121
|
+
format_error('integer value', opt_name, context)
|
122
|
+
end
|
123
|
+
value.to_int
|
124
|
+
end
|
125
|
+
|
126
|
+
# Ensures the value is a timestamp.
|
127
|
+
def validate_timestamp rules, value, opt_name, context = nil
|
128
|
+
# TODO : add validation to timestamps values
|
129
|
+
value.to_s
|
130
|
+
end
|
131
|
+
|
132
|
+
def format_error description, opt_name, context
|
133
|
+
context = context || "option :#{opt_name}"
|
134
|
+
raise ArgumentError, "expected #{description} for #{context}"
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,98 @@
|
|
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 'builder'
|
15
|
+
|
16
|
+
module AWS
|
17
|
+
module Core
|
18
|
+
module Options
|
19
|
+
|
20
|
+
# Given a hash of serialization rules, an XMLSerializer can convert
|
21
|
+
# a hash of request options into XML. The request options are
|
22
|
+
# validated before returning XML.
|
23
|
+
class XMLSerializer
|
24
|
+
|
25
|
+
# @param [String] namespace
|
26
|
+
# @param [String] operation_name
|
27
|
+
# @param [Hash] rules A hash of option rules to validate against.
|
28
|
+
def initialize namespace, operation_name, rules
|
29
|
+
@namespace = namespace
|
30
|
+
@operation_name = operation_name
|
31
|
+
@rules = rules
|
32
|
+
@validator = Validator.new(rules)
|
33
|
+
end
|
34
|
+
|
35
|
+
# @return [String] Returns the name of the API operation.
|
36
|
+
attr_reader :operation_name
|
37
|
+
|
38
|
+
# @return [String]
|
39
|
+
attr_reader :namespace
|
40
|
+
|
41
|
+
# @return [Hash]
|
42
|
+
attr_reader :rules
|
43
|
+
|
44
|
+
# @return [Validator]
|
45
|
+
attr_reader :validator
|
46
|
+
|
47
|
+
# @overload serialize!(request_options)
|
48
|
+
# @param [Hash] request_options A hash of already validated
|
49
|
+
# request options with normalized values.
|
50
|
+
# @return [String] Returns an string of the request parameters
|
51
|
+
# serialized into XML.
|
52
|
+
def serialize request_options
|
53
|
+
xml = []
|
54
|
+
builder = Builder::XmlMarkup.new(:target => xml, :indent => 2)
|
55
|
+
builder.tag!("#{operation_name}Request", :xmlns => namespace) do
|
56
|
+
request_options.each_pair do |opt_name, opt_value|
|
57
|
+
to_xml(builder, opt_name, rules[opt_name], opt_value)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
xml.join
|
61
|
+
end
|
62
|
+
|
63
|
+
protected
|
64
|
+
|
65
|
+
# @param [Builder::XmlMarkup] builder An XML builder object that should
|
66
|
+
# be used to build the xml.
|
67
|
+
# @param [String,Symbol] opt_name The name of the input option.
|
68
|
+
# @param [Hash] rules The hash to XML conversion rules.
|
69
|
+
# @param [Mixed] value
|
70
|
+
# @return [String] Returns an XML string.
|
71
|
+
def to_xml builder, opt_name, rules, value
|
72
|
+
|
73
|
+
xml_name = rules[:name]
|
74
|
+
xml_name ||= opt_name.is_a?(String) ?
|
75
|
+
opt_name : Inflection.class_name(opt_name.to_s)
|
76
|
+
|
77
|
+
case value
|
78
|
+
when Hash
|
79
|
+
builder.tag!(xml_name) do
|
80
|
+
value.each_pair do |m_name, m_value|
|
81
|
+
to_xml(builder, m_name, rules[:members][m_name], m_value)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
when Array
|
85
|
+
builder.tag!(xml_name) do
|
86
|
+
value.each do |member_value|
|
87
|
+
to_xml(builder, 'member', rules[:members], member_value)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
else builder.tag!(xml_name, value)
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,131 @@
|
|
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
|
+
#me Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
15
|
+
#
|
16
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
17
|
+
# may not use this file except in compliance with the License. A copy of
|
18
|
+
# the License is located at
|
19
|
+
#
|
20
|
+
# http://aws.amazon.com/apache2.0/
|
21
|
+
#
|
22
|
+
# or in the "license" file accompanying this file. This file is
|
23
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
24
|
+
# ANY KIND, either express or implied. See the License for the specific
|
25
|
+
# language governing permissions and limitations under the License.
|
26
|
+
|
27
|
+
module AWS
|
28
|
+
module Core
|
29
|
+
|
30
|
+
# When a client class extends this module, its API configuration
|
31
|
+
# is parsed. For each operation in the API configuration, one
|
32
|
+
# client method is added.
|
33
|
+
#
|
34
|
+
# Clients extending Query all have in common their method
|
35
|
+
# of serializing request (input) paramters and parsing response
|
36
|
+
# (output) XML.
|
37
|
+
#
|
38
|
+
module QueryClient
|
39
|
+
|
40
|
+
# @private
|
41
|
+
def self.extended base
|
42
|
+
base.send(:include, ErrorParser)
|
43
|
+
base.send(:define_parsers)
|
44
|
+
end
|
45
|
+
|
46
|
+
# @return [Hash<Symbol,OptionGrammar>] Returns a hash option
|
47
|
+
# parsers. Hash keys are client method names and hash
|
48
|
+
# values are {OptionGrammar} objects.
|
49
|
+
# @private
|
50
|
+
def option_parsers
|
51
|
+
@option_parsers ||= {}
|
52
|
+
end
|
53
|
+
|
54
|
+
# @return [Hash<Symbol,XML::Parser>] Returns a hash of xml
|
55
|
+
# parsers. Hash keys are client method names and hash
|
56
|
+
# values are {XML::Parser} objects.
|
57
|
+
# @private
|
58
|
+
def xml_parsers
|
59
|
+
@xml_parsers ||= {}
|
60
|
+
end
|
61
|
+
|
62
|
+
protected
|
63
|
+
|
64
|
+
# Enumerates through the operations specified in the API
|
65
|
+
# configuration (yaml configuration file found in lib/api_config/)
|
66
|
+
# and defines one request method per operation.
|
67
|
+
def define_parsers
|
68
|
+
api_config[:operations].each do |op|
|
69
|
+
|
70
|
+
method_name = op[:method]
|
71
|
+
|
72
|
+
option_parsers[method_name] = OptionGrammar.customize(op[:inputs])
|
73
|
+
xml_parsers[method_name] = XML::Parser.new(op[:outputs])
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def define_client_method method_name, operation_name
|
79
|
+
add_client_request_method(method_name) do
|
80
|
+
|
81
|
+
configure_request do |request, options|
|
82
|
+
|
83
|
+
now = Time.now.utc.strftime('%Y-%m-%dT%H:%M:%SZ')
|
84
|
+
|
85
|
+
request.headers['Content-Type'] =
|
86
|
+
"application/x-www-form-urlencoded; charset=utf-8"
|
87
|
+
|
88
|
+
request.add_param 'Timestamp', now
|
89
|
+
request.add_param 'Version', self.class::API_VERSION
|
90
|
+
request.add_param 'Action', operation_name
|
91
|
+
|
92
|
+
parser = self.class.option_parsers[method_name]
|
93
|
+
parser.request_params(options).each do |param|
|
94
|
+
request.add_param(param)
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
process_response do |response|
|
100
|
+
parser = self.class.xml_parsers[method_name]
|
101
|
+
response.data = parser.parse(response.http_response.body)
|
102
|
+
end
|
103
|
+
|
104
|
+
simulate_response do |response|
|
105
|
+
parser = self.class.xml_parsers[method_name]
|
106
|
+
response.data = parser.simulate
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
module ErrorParser
|
113
|
+
|
114
|
+
protected
|
115
|
+
|
116
|
+
def extract_error_details response
|
117
|
+
if
|
118
|
+
response.http_response.status >= 300 and
|
119
|
+
body = response.http_response.body and
|
120
|
+
error = errors_module::GRAMMAR.parse(body) and
|
121
|
+
error[:code]
|
122
|
+
then
|
123
|
+
[error[:code], error[:message]]
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|