aws-sdk-core 2.0.48 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/apis/autoscaling/2011-01-01/api-2.json +636 -33
- data/apis/cloudhsm/2014-05-30/api-2.json +3 -6
- data/apis/ec2/2014-10-01/api-2.json +10267 -0
- data/apis/ec2/2014-10-01/paginators-1.json +125 -0
- data/apis/ec2/2014-10-01/resources-1.json +2289 -0
- data/apis/ec2/2014-10-01/waiters-2.json +453 -0
- data/apis/ec2/2015-03-01/api-2.json +11245 -0
- data/apis/ec2/2015-03-01/paginators-1.json +125 -0
- data/apis/ec2/2015-03-01/resources-1.json +2479 -0
- data/apis/ec2/2015-03-01/waiters-2.json +458 -0
- data/apis/ec2/2015-04-15/api-2.json +182 -2
- data/apis/ecs/2014-11-13/api-2.json +316 -7
- data/apis/ecs/2014-11-13/paginators-1.json +40 -0
- data/apis/ecs/2014-11-13/waiters-2.json +93 -0
- data/apis/redshift/2012-12-01/waiters-2.json +19 -0
- data/apis/s3/2006-03-01/api-2.json +1 -2
- data/apis/sqs/2012-11-05/api-2.json +5 -6
- data/ca-bundle.crt +3554 -0
- data/lib/aws-sdk-core.rb +127 -44
- data/lib/aws-sdk-core/api/builder.rb +95 -0
- data/lib/aws-sdk-core/api/customizations.rb +152 -0
- data/lib/aws-sdk-core/api/docs/builder.rb +220 -0
- data/lib/aws-sdk-core/api/docs/client_type_documenter.rb +109 -0
- data/lib/aws-sdk-core/api/docs/docstring_provider.rb +66 -0
- data/lib/aws-sdk-core/api/docs/operation_documenter.rb +107 -0
- data/lib/aws-sdk-core/api/docs/param_formatter.rb +163 -0
- data/lib/aws-sdk-core/api/docs/request_syntax_example.rb +22 -0
- data/lib/aws-sdk-core/api/docs/response_structure_example.rb +91 -0
- data/lib/aws-sdk-core/api/docs/utils.rb +133 -0
- data/lib/aws-sdk-core/api/shape_map.rb +140 -0
- data/lib/aws-sdk-core/assume_role_credentials.rb +9 -6
- data/lib/aws-sdk-core/client.rb +9 -6
- data/lib/aws-sdk-core/client_stubs.rb +127 -133
- data/lib/aws-sdk-core/client_waiters.rb +1 -1
- data/lib/aws-sdk-core/credential_provider.rb +44 -0
- data/lib/aws-sdk-core/credential_provider_chain.rb +3 -2
- data/lib/aws-sdk-core/credentials.rb +5 -0
- data/lib/aws-sdk-core/deprecations.rb +69 -0
- data/lib/aws-sdk-core/dynamodb.rb +12 -0
- data/lib/aws-sdk-core/eager_loader.rb +31 -0
- data/lib/aws-sdk-core/ecs.rb +2 -0
- data/lib/aws-sdk-core/empty_structure.rb +1 -82
- data/lib/aws-sdk-core/endpoint_provider.rb +1 -1
- data/lib/aws-sdk-core/instance_profile_credentials.rb +9 -10
- data/lib/aws-sdk-core/json.rb +56 -0
- data/lib/aws-sdk-core/json/builder.rb +33 -34
- data/lib/aws-sdk-core/json/error_handler.rb +2 -2
- data/lib/aws-sdk-core/json/handler.rb +67 -0
- data/lib/aws-sdk-core/json/json_engine.rb +15 -0
- data/lib/aws-sdk-core/json/oj_engine.rb +15 -0
- data/lib/aws-sdk-core/json/parser.rb +30 -38
- data/lib/aws-sdk-core/pageable_response.rb +9 -12
- data/lib/aws-sdk-core/pager.rb +69 -0
- data/lib/aws-sdk-core/param_converter.rb +203 -0
- data/lib/aws-sdk-core/param_validator.rb +148 -0
- data/lib/aws-sdk-core/plugins/dynamodb_simple_attributes.rb +21 -18
- data/lib/aws-sdk-core/plugins/glacier_account_id.rb +9 -1
- data/lib/aws-sdk-core/plugins/glacier_checksums.rb +2 -3
- data/lib/aws-sdk-core/plugins/param_converter.rb +27 -0
- data/lib/aws-sdk-core/plugins/param_validator.rb +28 -0
- data/lib/aws-sdk-core/plugins/protocols/json_rpc.rb +3 -7
- data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +1 -2
- data/lib/aws-sdk-core/plugins/protocols/rest_xml.rb +1 -1
- data/lib/aws-sdk-core/plugins/regional_endpoint.rb +1 -1
- data/lib/aws-sdk-core/plugins/request_signer.rb +5 -5
- data/lib/aws-sdk-core/plugins/response_paging.rb +20 -11
- data/lib/aws-sdk-core/plugins/s3_get_bucket_location_fix.rb +1 -1
- data/lib/aws-sdk-core/plugins/s3_request_signer.rb +1 -2
- data/lib/aws-sdk-core/plugins/stub_responses.rb +25 -27
- data/lib/aws-sdk-core/query/ec2_param_builder.rb +29 -34
- data/lib/aws-sdk-core/query/handler.rb +32 -18
- data/lib/aws-sdk-core/query/param_builder.rb +45 -53
- data/lib/aws-sdk-core/refreshing_credentials.rb +3 -15
- data/lib/aws-sdk-core/rest/handler.rb +22 -0
- data/lib/aws-sdk-core/rest/request/body.rb +58 -0
- data/lib/aws-sdk-core/rest/request/builder.rb +50 -0
- data/lib/aws-sdk-core/rest/request/endpoint.rb +70 -0
- data/lib/aws-sdk-core/rest/request/headers.rb +48 -0
- data/lib/aws-sdk-core/rest/response/body.rb +43 -0
- data/lib/aws-sdk-core/rest/response/headers.rb +60 -0
- data/lib/aws-sdk-core/rest/response/parser.rb +47 -0
- data/lib/aws-sdk-core/rest/response/status_code.rb +24 -0
- data/lib/aws-sdk-core/shared_credentials.rb +11 -6
- data/lib/aws-sdk-core/signers/base.rb +1 -1
- data/lib/aws-sdk-core/signers/s3.rb +2 -3
- data/lib/aws-sdk-core/signers/v2.rb +7 -4
- data/lib/aws-sdk-core/signers/v4.rb +11 -22
- data/lib/aws-sdk-core/structure.rb +26 -145
- data/lib/aws-sdk-core/stubbing/data_applicator.rb +46 -0
- data/lib/aws-sdk-core/stubbing/empty_stub.rb +53 -0
- data/lib/aws-sdk-core/stubbing/protocols/ec2.rb +49 -0
- data/lib/aws-sdk-core/stubbing/protocols/json.rb +40 -0
- data/lib/aws-sdk-core/stubbing/protocols/query.rb +40 -0
- data/lib/aws-sdk-core/stubbing/protocols/rest.rb +67 -0
- data/lib/aws-sdk-core/stubbing/protocols/rest_json.rb +25 -0
- data/lib/aws-sdk-core/stubbing/protocols/rest_xml.rb +38 -0
- data/lib/aws-sdk-core/stubbing/stub_data.rb +34 -0
- data/lib/aws-sdk-core/version.rb +1 -1
- data/lib/aws-sdk-core/xml/builder.rb +58 -52
- data/lib/aws-sdk-core/xml/default_map.rb +10 -0
- data/lib/aws-sdk-core/xml/doc_builder.rb +86 -0
- data/lib/aws-sdk-core/xml/error_handler.rb +7 -2
- data/lib/aws-sdk-core/xml/parser.rb +4 -4
- data/lib/aws-sdk-core/xml/parser/frame.rb +75 -70
- data/lib/aws-sdk-core/xml/parser/stack.rb +4 -4
- data/lib/seahorse.rb +0 -11
- data/lib/seahorse/client/base.rb +3 -12
- data/lib/seahorse/client/http/request.rb +9 -5
- data/lib/seahorse/client/plugins/endpoint.rb +5 -56
- data/lib/seahorse/client/plugins/restful_bindings.rb +38 -31
- data/lib/seahorse/client/request_context.rb +2 -2
- data/lib/seahorse/client/response.rb +6 -5
- data/lib/seahorse/model/api.rb +18 -61
- data/lib/seahorse/model/operation.rb +24 -54
- data/lib/seahorse/model/shapes.rb +120 -364
- data/lib/seahorse/util.rb +2 -6
- metadata +56 -109
- data/apis/autoscaling/2011-01-01/docs-2.json +0 -1246
- data/apis/cloudformation/2010-05-15/docs-2.json +0 -725
- data/apis/cloudfront/2014-11-06/docs-2.json +0 -1125
- data/apis/cloudhsm/2014-05-30/docs-2.json +0 -472
- data/apis/cloudsearch/2013-01-01/docs-2.json +0 -865
- data/apis/cloudsearchdomain/2013-01-01/docs-2.json +0 -311
- data/apis/cloudtrail/2013-11-01/docs-2.json +0 -328
- data/apis/codedeploy/2014-10-06/docs-2.json +0 -1261
- data/apis/cognito-identity/2014-06-30/docs-2.json +0 -506
- data/apis/cognito-sync/2014-06-30/docs-2.json +0 -582
- data/apis/config/2014-10-17/docs-2.json +0 -513
- data/apis/config/2014-11-12/docs-2.json +0 -514
- data/apis/datapipeline/2012-10-29/docs-2.json +0 -607
- data/apis/directconnect/2012-10-25/docs-2.json +0 -494
- data/apis/ds/2015-04-16/docs-2.json +0 -753
- data/apis/dynamodb/2011-12-05/api-2.json +0 -949
- data/apis/dynamodb/2011-12-05/docs-2.json +0 -606
- data/apis/dynamodb/2011-12-05/paginators-1.json +0 -26
- data/apis/dynamodb/2011-12-05/waiters-2.json +0 -35
- data/apis/dynamodb/2012-08-10/docs-2.json +0 -977
- data/apis/ec2/2015-04-15/docs-2.json +0 -5368
- data/apis/ecs/2014-11-13/docs-2.json +0 -791
- data/apis/elasticache/2015-02-02/docs-2.json +0 -1390
- data/apis/elasticbeanstalk/2010-12-01/docs-2.json +0 -1114
- data/apis/elasticfilesystem/2015-02-01/docs-2.json +0 -414
- data/apis/elasticloadbalancing/2012-06-01/docs-2.json +0 -1078
- data/apis/elasticmapreduce/2009-03-31/docs-2.json +0 -969
- data/apis/elastictranscoder/2012-09-25/docs-2.json +0 -1152
- data/apis/email/2010-12-01/docs-2.json +0 -441
- data/apis/glacier/2012-06-01/docs-2.json +0 -575
- data/apis/iam/2010-05-08/docs-2.json +0 -2138
- data/apis/importexport/2010-06-01/docs-2.json +0 -432
- data/apis/kinesis/2013-12-02/docs-2.json +0 -424
- data/apis/kms/2014-11-01/docs-2.json +0 -628
- data/apis/lambda/2014-11-11/docs-2.json +0 -303
- data/apis/lambda/2015-03-31/docs-2.json +0 -490
- data/apis/logs/2014-03-28/docs-2.json +0 -599
- data/apis/machinelearning/2014-12-12/docs-2.json +0 -1034
- data/apis/monitoring/2010-08-01/docs-2.json +0 -514
- data/apis/opsworks/2013-02-18/docs-2.json +0 -1592
- data/apis/rds/2014-10-31/docs-2.json +0 -2074
- data/apis/redshift/2012-12-01/docs-2.json +0 -1890
- data/apis/route53/2013-04-01/docs-2.json +0 -1159
- data/apis/route53domains/2014-05-15/docs-2.json +0 -620
- data/apis/s3/2006-03-01/docs-2.json +0 -2213
- data/apis/sdb/2009-04-15/docs-2.json +0 -339
- data/apis/sns/2010-03-31/docs-2.json +0 -564
- data/apis/sqs/2012-11-05/docs-2.json +0 -503
- data/apis/ssm/2014-11-06/docs-2.json +0 -440
- data/apis/storagegateway/2013-06-30/docs-2.json +0 -1331
- data/apis/sts/2011-06-15/docs-2.json +0 -351
- data/apis/support/2013-04-15/docs-2.json +0 -680
- data/apis/swf/2012-01-25/docs-2.json +0 -1569
- data/apis/workspaces/2015-04-08/docs-2.json +0 -457
- data/lib/aws-sdk-core/api/customizer.rb +0 -75
- data/lib/aws-sdk-core/api/docstrings.rb +0 -38
- data/lib/aws-sdk-core/api/documenter.rb +0 -241
- data/lib/aws-sdk-core/api/operation_documenter.rb +0 -173
- data/lib/aws-sdk-core/api/operation_example.rb +0 -133
- data/lib/aws-sdk-core/api/service_customizations.rb +0 -140
- data/lib/aws-sdk-core/client_paging.rb +0 -31
- data/lib/aws-sdk-core/json/rest_handler.rb +0 -20
- data/lib/aws-sdk-core/json/rpc_body_handler.rb +0 -38
- data/lib/aws-sdk-core/json/rpc_headers_handler.rb +0 -34
- data/lib/aws-sdk-core/json/simple_body_handler.rb +0 -34
- data/lib/aws-sdk-core/paging/null_pager.rb +0 -20
- data/lib/aws-sdk-core/paging/null_provider.rb +0 -13
- data/lib/aws-sdk-core/paging/pager.rb +0 -70
- data/lib/aws-sdk-core/paging/provider.rb +0 -22
- data/lib/aws-sdk-core/rest_body_handler.rb +0 -111
- data/lib/aws-sdk-core/signers/handler.rb +0 -18
- data/lib/aws-sdk-core/xml/rest_handler.rb +0 -20
- data/lib/seahorse/client/param_converter.rb +0 -207
- data/lib/seahorse/client/param_validator.rb +0 -139
- data/lib/seahorse/client/plugins/json_simple.rb +0 -33
- data/lib/seahorse/client/plugins/param_conversion.rb +0 -29
- data/lib/seahorse/client/plugins/param_validation.rb +0 -30
- data/lib/seahorse/client/xml/builder.rb +0 -91
- data/lib/seahorse/model/shape_map.rb +0 -47
@@ -6,10 +6,11 @@ module Aws
|
|
6
6
|
@config = config
|
7
7
|
end
|
8
8
|
|
9
|
+
# @return [CredentialProvider, nil]
|
9
10
|
def resolve
|
10
11
|
providers.each do |method_name, options|
|
11
|
-
|
12
|
-
return
|
12
|
+
provider = send(method_name, options.merge(config: @config))
|
13
|
+
return provider if provider && provider.set?
|
13
14
|
end
|
14
15
|
nil
|
15
16
|
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Aws
|
2
|
+
|
3
|
+
# A utility module that provides a class method that wraps
|
4
|
+
# a method such that it generates a deprecation warning when called.
|
5
|
+
# Given the following class:
|
6
|
+
#
|
7
|
+
# class Example
|
8
|
+
#
|
9
|
+
# def do_something
|
10
|
+
# end
|
11
|
+
#
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
# If you want to deprecate the `#do_something` method, you can extend
|
15
|
+
# this module and then call `deprecated` on the method (after it
|
16
|
+
# has been defined).
|
17
|
+
#
|
18
|
+
# class Example
|
19
|
+
#
|
20
|
+
# extend Aws::Deprecations
|
21
|
+
#
|
22
|
+
# def do_something
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# def do_something_else
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# deprecated :do_something
|
29
|
+
#
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# The `#do_something` method will continue to function, but will
|
33
|
+
# generate a deprecation warning when called.
|
34
|
+
#
|
35
|
+
# @api private
|
36
|
+
module Deprecations
|
37
|
+
|
38
|
+
# @param [Symbol] method_name The name of the deprecated method.
|
39
|
+
#
|
40
|
+
# @option options [String] :message The warning message to issue
|
41
|
+
# when the deprecated method is called.
|
42
|
+
#
|
43
|
+
# @option options [Symbol] :use The name of an use
|
44
|
+
# method that should be used.
|
45
|
+
#
|
46
|
+
def deprecated(method_name, options = {})
|
47
|
+
|
48
|
+
deprecation_msg = options[:message] || begin
|
49
|
+
msg = "DEPRECATION WARNING: called deprecated method `#{method_name}' "
|
50
|
+
msg << "of an #{self}"
|
51
|
+
msg << ", use #{options[:use]} instead" if options[:use]
|
52
|
+
msg
|
53
|
+
end
|
54
|
+
|
55
|
+
alias_method(:"deprecated_#{method_name}", method_name)
|
56
|
+
|
57
|
+
warned = false # we only want to issue this warning once
|
58
|
+
|
59
|
+
define_method(method_name) do |*args,&block|
|
60
|
+
unless warned
|
61
|
+
warned = true
|
62
|
+
warn(deprecation_msg + "\n" + caller.join("\n"))
|
63
|
+
end
|
64
|
+
send("deprecated_#{method_name}", *args, &block)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
@@ -9,5 +9,17 @@ Aws.add_service(:DynamoDB, {
|
|
9
9
|
module Aws
|
10
10
|
module DynamoDB
|
11
11
|
autoload :AttributeValue, 'aws-sdk-core/dynamodb/attribute_value'
|
12
|
+
|
13
|
+
class Client
|
14
|
+
def data_to_http_resp(operation_name, data)
|
15
|
+
api = config.api
|
16
|
+
operation = api.operation(operation_name)
|
17
|
+
translator = Plugins::DynamoDBSimpleAttributes::ValueTranslator
|
18
|
+
translator = translator.new(operation.output, :marshal)
|
19
|
+
data = translator.apply(data)
|
20
|
+
ParamValidator.validate!(operation.output, data)
|
21
|
+
protocol_helper.stub_data(api, operation, data)
|
22
|
+
end
|
23
|
+
end
|
12
24
|
end
|
13
25
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
module Aws
|
4
|
+
# @api private
|
5
|
+
class EagerLoader
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@loaded = Set.new
|
9
|
+
end
|
10
|
+
|
11
|
+
# @return [Set<Module>]
|
12
|
+
attr_reader :loaded
|
13
|
+
|
14
|
+
# @param [Module] klass_or_module
|
15
|
+
# @return [self]
|
16
|
+
def load(klass_or_module)
|
17
|
+
@loaded << klass_or_module
|
18
|
+
klass_or_module.constants.each do |const_name|
|
19
|
+
path = klass_or_module.autoload?(const_name)
|
20
|
+
require(path) if path
|
21
|
+
const = klass_or_module.const_get(const_name)
|
22
|
+
if const.is_a?(Module)
|
23
|
+
unless @loaded.include?(const)
|
24
|
+
load(const)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
self
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/aws-sdk-core/ecs.rb
CHANGED
@@ -1,84 +1,3 @@
|
|
1
1
|
module Aws
|
2
|
-
|
3
|
-
|
4
|
-
def self.new
|
5
|
-
super([])
|
6
|
-
end
|
7
|
-
|
8
|
-
def ==(other)
|
9
|
-
other.is_a?(EmptyStructure)
|
10
|
-
end
|
11
|
-
|
12
|
-
def [](member_name)
|
13
|
-
raise NameError, "no member '#{member_name}' in struct"
|
14
|
-
end
|
15
|
-
|
16
|
-
def []=(member_name, value)
|
17
|
-
raise NameError, "no member '#{member_name}' in struct"
|
18
|
-
end
|
19
|
-
|
20
|
-
def each(&block)
|
21
|
-
unless block_given?
|
22
|
-
[].to_enum
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def each_pair(&block)
|
27
|
-
unless block_given?
|
28
|
-
{}.to_enum
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def eql?(other)
|
33
|
-
other.is_a?(EmptyStructure)
|
34
|
-
end
|
35
|
-
|
36
|
-
# @api private
|
37
|
-
def inspect
|
38
|
-
'#<struct>'
|
39
|
-
end
|
40
|
-
|
41
|
-
# @api private
|
42
|
-
def pretty_print(q)
|
43
|
-
q.text(inspect)
|
44
|
-
end
|
45
|
-
|
46
|
-
def length
|
47
|
-
0
|
48
|
-
end
|
49
|
-
|
50
|
-
def members
|
51
|
-
[]
|
52
|
-
end
|
53
|
-
|
54
|
-
def select(&block)
|
55
|
-
[]
|
56
|
-
end
|
57
|
-
|
58
|
-
def size
|
59
|
-
0
|
60
|
-
end
|
61
|
-
|
62
|
-
def to_a
|
63
|
-
[]
|
64
|
-
end
|
65
|
-
|
66
|
-
def to_h
|
67
|
-
{}
|
68
|
-
end
|
69
|
-
|
70
|
-
def values
|
71
|
-
[]
|
72
|
-
end
|
73
|
-
|
74
|
-
def values_at(*selector)
|
75
|
-
if selector.empty?
|
76
|
-
[]
|
77
|
-
else
|
78
|
-
offset = selector.first
|
79
|
-
raise IndexError, "offset #{offset} too large for struct(size:0)"
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
2
|
+
EmptyStructure = Class.new(Structure.new('AwsEmptyStructure'))
|
84
3
|
end
|
@@ -2,8 +2,9 @@ require 'time'
|
|
2
2
|
require 'net/http'
|
3
3
|
|
4
4
|
module Aws
|
5
|
-
class InstanceProfileCredentials
|
5
|
+
class InstanceProfileCredentials
|
6
6
|
|
7
|
+
include CredentialProvider
|
7
8
|
include RefreshingCredentials
|
8
9
|
|
9
10
|
# @api private
|
@@ -64,15 +65,13 @@ module Aws
|
|
64
65
|
end
|
65
66
|
|
66
67
|
def refresh
|
67
|
-
|
68
|
-
@
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
@expiration = nil
|
75
|
-
end
|
68
|
+
c = Json.load(get_credentials)
|
69
|
+
@credentials = Credentials.new(
|
70
|
+
c['AccessKeyId'],
|
71
|
+
c['SecretAccessKey'],
|
72
|
+
c['Token']
|
73
|
+
)
|
74
|
+
@expiration = c['Expiration'] ? Time.parse(c['Expiration']) : nil
|
76
75
|
end
|
77
76
|
|
78
77
|
def get_credentials
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Aws
|
2
|
+
# @api private
|
3
|
+
module Json
|
4
|
+
|
5
|
+
autoload :Builder, 'aws-sdk-core/json/builder'
|
6
|
+
autoload :ErrorHandler, 'aws-sdk-core/json/error_handler'
|
7
|
+
autoload :Handler, 'aws-sdk-core/json/handler'
|
8
|
+
autoload :Parser, 'aws-sdk-core/json/parser'
|
9
|
+
|
10
|
+
class ParseError < StandardError
|
11
|
+
|
12
|
+
def initialize(error)
|
13
|
+
@error = error
|
14
|
+
super(error.message)
|
15
|
+
end
|
16
|
+
|
17
|
+
attr_reader :error
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
class << self
|
22
|
+
|
23
|
+
def load(json)
|
24
|
+
ENGINE.load(json)
|
25
|
+
rescue ENGINE_ERROR => e
|
26
|
+
raise ParseError.new(e)
|
27
|
+
end
|
28
|
+
|
29
|
+
def load_file(path)
|
30
|
+
self.load(File.open(path, 'r', encoding: 'UTF-8') { |f| f.read })
|
31
|
+
end
|
32
|
+
|
33
|
+
def dump(value)
|
34
|
+
ENGINE.dump(value)
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def oj_engine
|
40
|
+
require 'oj'
|
41
|
+
[Oj, Oj::ParseError]
|
42
|
+
rescue LoadError
|
43
|
+
false
|
44
|
+
end
|
45
|
+
|
46
|
+
def json_engine
|
47
|
+
require 'json'
|
48
|
+
[JSON, JSON::ParserError]
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
ENGINE, ENGINE_ERROR = oj_engine || json_engine
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
@@ -4,58 +4,57 @@ module Aws
|
|
4
4
|
module Json
|
5
5
|
class Builder
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
include Seahorse::Model::Shapes
|
8
|
+
|
9
|
+
def initialize(rules)
|
10
|
+
@rules = rules
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_json(params)
|
14
|
+
Json.dump(format(@rules, params))
|
12
15
|
end
|
16
|
+
alias serialize to_json
|
13
17
|
|
14
18
|
private
|
15
19
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
name = member_shape.location_name || key
|
24
|
-
data[name] = format(member_shape, value)
|
20
|
+
def structure(ref, values)
|
21
|
+
shape = ref.shape
|
22
|
+
values.each_pair.with_object({}) do |(key, value), data|
|
23
|
+
if shape.member?(key) && !value.nil?
|
24
|
+
member_ref = shape.member(key)
|
25
|
+
member_name = member_ref.location_name || key
|
26
|
+
data[member_name] = format(member_ref, value)
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
def list(list, values)
|
33
|
-
values.collect { |value| format(list.member, value) }
|
31
|
+
def list(ref, values)
|
32
|
+
member_ref = ref.shape.member
|
33
|
+
values.collect { |value| format(member_ref, value) }
|
34
34
|
end
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
# @return [Hash]
|
39
|
-
def map(map, values)
|
36
|
+
def map(ref, values)
|
37
|
+
value_ref = ref.shape.value
|
40
38
|
values.each.with_object({}) do |(key, value), data|
|
41
|
-
data[key] = format(
|
39
|
+
data[key] = format(value_ref, value)
|
42
40
|
end
|
43
41
|
end
|
44
42
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
when
|
51
|
-
when
|
52
|
-
when 'map' then map(shape, value)
|
53
|
-
when 'timestamp' then shape.format_time(value, 'unixTimestamp')
|
54
|
-
when 'blob' then Base64.strict_encode64(value.read)
|
43
|
+
def format(ref, value)
|
44
|
+
case ref.shape
|
45
|
+
when StructureShape then structure(ref, value)
|
46
|
+
when ListShape then list(ref, value)
|
47
|
+
when MapShape then map(ref, value)
|
48
|
+
when TimestampShape then value.to_i
|
49
|
+
when BlobShape then encode(value)
|
55
50
|
else value
|
56
51
|
end
|
57
52
|
end
|
58
53
|
|
54
|
+
def encode(blob)
|
55
|
+
Base64.strict_encode64(String === blob ? blob : blob.read)
|
56
|
+
end
|
57
|
+
|
59
58
|
end
|
60
59
|
end
|
61
60
|
end
|
@@ -14,11 +14,11 @@ module Aws
|
|
14
14
|
private
|
15
15
|
|
16
16
|
def extract_error(body, context)
|
17
|
-
json =
|
17
|
+
json = Json.load(body)
|
18
18
|
code = error_code(json, context)
|
19
19
|
message = error_message(code, json)
|
20
20
|
[code, message]
|
21
|
-
rescue
|
21
|
+
rescue Json::ParseError
|
22
22
|
[http_status_error_code(context), '']
|
23
23
|
end
|
24
24
|
|