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.
Files changed (197) hide show
  1. checksums.yaml +4 -4
  2. data/apis/autoscaling/2011-01-01/api-2.json +636 -33
  3. data/apis/cloudhsm/2014-05-30/api-2.json +3 -6
  4. data/apis/ec2/2014-10-01/api-2.json +10267 -0
  5. data/apis/ec2/2014-10-01/paginators-1.json +125 -0
  6. data/apis/ec2/2014-10-01/resources-1.json +2289 -0
  7. data/apis/ec2/2014-10-01/waiters-2.json +453 -0
  8. data/apis/ec2/2015-03-01/api-2.json +11245 -0
  9. data/apis/ec2/2015-03-01/paginators-1.json +125 -0
  10. data/apis/ec2/2015-03-01/resources-1.json +2479 -0
  11. data/apis/ec2/2015-03-01/waiters-2.json +458 -0
  12. data/apis/ec2/2015-04-15/api-2.json +182 -2
  13. data/apis/ecs/2014-11-13/api-2.json +316 -7
  14. data/apis/ecs/2014-11-13/paginators-1.json +40 -0
  15. data/apis/ecs/2014-11-13/waiters-2.json +93 -0
  16. data/apis/redshift/2012-12-01/waiters-2.json +19 -0
  17. data/apis/s3/2006-03-01/api-2.json +1 -2
  18. data/apis/sqs/2012-11-05/api-2.json +5 -6
  19. data/ca-bundle.crt +3554 -0
  20. data/lib/aws-sdk-core.rb +127 -44
  21. data/lib/aws-sdk-core/api/builder.rb +95 -0
  22. data/lib/aws-sdk-core/api/customizations.rb +152 -0
  23. data/lib/aws-sdk-core/api/docs/builder.rb +220 -0
  24. data/lib/aws-sdk-core/api/docs/client_type_documenter.rb +109 -0
  25. data/lib/aws-sdk-core/api/docs/docstring_provider.rb +66 -0
  26. data/lib/aws-sdk-core/api/docs/operation_documenter.rb +107 -0
  27. data/lib/aws-sdk-core/api/docs/param_formatter.rb +163 -0
  28. data/lib/aws-sdk-core/api/docs/request_syntax_example.rb +22 -0
  29. data/lib/aws-sdk-core/api/docs/response_structure_example.rb +91 -0
  30. data/lib/aws-sdk-core/api/docs/utils.rb +133 -0
  31. data/lib/aws-sdk-core/api/shape_map.rb +140 -0
  32. data/lib/aws-sdk-core/assume_role_credentials.rb +9 -6
  33. data/lib/aws-sdk-core/client.rb +9 -6
  34. data/lib/aws-sdk-core/client_stubs.rb +127 -133
  35. data/lib/aws-sdk-core/client_waiters.rb +1 -1
  36. data/lib/aws-sdk-core/credential_provider.rb +44 -0
  37. data/lib/aws-sdk-core/credential_provider_chain.rb +3 -2
  38. data/lib/aws-sdk-core/credentials.rb +5 -0
  39. data/lib/aws-sdk-core/deprecations.rb +69 -0
  40. data/lib/aws-sdk-core/dynamodb.rb +12 -0
  41. data/lib/aws-sdk-core/eager_loader.rb +31 -0
  42. data/lib/aws-sdk-core/ecs.rb +2 -0
  43. data/lib/aws-sdk-core/empty_structure.rb +1 -82
  44. data/lib/aws-sdk-core/endpoint_provider.rb +1 -1
  45. data/lib/aws-sdk-core/instance_profile_credentials.rb +9 -10
  46. data/lib/aws-sdk-core/json.rb +56 -0
  47. data/lib/aws-sdk-core/json/builder.rb +33 -34
  48. data/lib/aws-sdk-core/json/error_handler.rb +2 -2
  49. data/lib/aws-sdk-core/json/handler.rb +67 -0
  50. data/lib/aws-sdk-core/json/json_engine.rb +15 -0
  51. data/lib/aws-sdk-core/json/oj_engine.rb +15 -0
  52. data/lib/aws-sdk-core/json/parser.rb +30 -38
  53. data/lib/aws-sdk-core/pageable_response.rb +9 -12
  54. data/lib/aws-sdk-core/pager.rb +69 -0
  55. data/lib/aws-sdk-core/param_converter.rb +203 -0
  56. data/lib/aws-sdk-core/param_validator.rb +148 -0
  57. data/lib/aws-sdk-core/plugins/dynamodb_simple_attributes.rb +21 -18
  58. data/lib/aws-sdk-core/plugins/glacier_account_id.rb +9 -1
  59. data/lib/aws-sdk-core/plugins/glacier_checksums.rb +2 -3
  60. data/lib/aws-sdk-core/plugins/param_converter.rb +27 -0
  61. data/lib/aws-sdk-core/plugins/param_validator.rb +28 -0
  62. data/lib/aws-sdk-core/plugins/protocols/json_rpc.rb +3 -7
  63. data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +1 -2
  64. data/lib/aws-sdk-core/plugins/protocols/rest_xml.rb +1 -1
  65. data/lib/aws-sdk-core/plugins/regional_endpoint.rb +1 -1
  66. data/lib/aws-sdk-core/plugins/request_signer.rb +5 -5
  67. data/lib/aws-sdk-core/plugins/response_paging.rb +20 -11
  68. data/lib/aws-sdk-core/plugins/s3_get_bucket_location_fix.rb +1 -1
  69. data/lib/aws-sdk-core/plugins/s3_request_signer.rb +1 -2
  70. data/lib/aws-sdk-core/plugins/stub_responses.rb +25 -27
  71. data/lib/aws-sdk-core/query/ec2_param_builder.rb +29 -34
  72. data/lib/aws-sdk-core/query/handler.rb +32 -18
  73. data/lib/aws-sdk-core/query/param_builder.rb +45 -53
  74. data/lib/aws-sdk-core/refreshing_credentials.rb +3 -15
  75. data/lib/aws-sdk-core/rest/handler.rb +22 -0
  76. data/lib/aws-sdk-core/rest/request/body.rb +58 -0
  77. data/lib/aws-sdk-core/rest/request/builder.rb +50 -0
  78. data/lib/aws-sdk-core/rest/request/endpoint.rb +70 -0
  79. data/lib/aws-sdk-core/rest/request/headers.rb +48 -0
  80. data/lib/aws-sdk-core/rest/response/body.rb +43 -0
  81. data/lib/aws-sdk-core/rest/response/headers.rb +60 -0
  82. data/lib/aws-sdk-core/rest/response/parser.rb +47 -0
  83. data/lib/aws-sdk-core/rest/response/status_code.rb +24 -0
  84. data/lib/aws-sdk-core/shared_credentials.rb +11 -6
  85. data/lib/aws-sdk-core/signers/base.rb +1 -1
  86. data/lib/aws-sdk-core/signers/s3.rb +2 -3
  87. data/lib/aws-sdk-core/signers/v2.rb +7 -4
  88. data/lib/aws-sdk-core/signers/v4.rb +11 -22
  89. data/lib/aws-sdk-core/structure.rb +26 -145
  90. data/lib/aws-sdk-core/stubbing/data_applicator.rb +46 -0
  91. data/lib/aws-sdk-core/stubbing/empty_stub.rb +53 -0
  92. data/lib/aws-sdk-core/stubbing/protocols/ec2.rb +49 -0
  93. data/lib/aws-sdk-core/stubbing/protocols/json.rb +40 -0
  94. data/lib/aws-sdk-core/stubbing/protocols/query.rb +40 -0
  95. data/lib/aws-sdk-core/stubbing/protocols/rest.rb +67 -0
  96. data/lib/aws-sdk-core/stubbing/protocols/rest_json.rb +25 -0
  97. data/lib/aws-sdk-core/stubbing/protocols/rest_xml.rb +38 -0
  98. data/lib/aws-sdk-core/stubbing/stub_data.rb +34 -0
  99. data/lib/aws-sdk-core/version.rb +1 -1
  100. data/lib/aws-sdk-core/xml/builder.rb +58 -52
  101. data/lib/aws-sdk-core/xml/default_map.rb +10 -0
  102. data/lib/aws-sdk-core/xml/doc_builder.rb +86 -0
  103. data/lib/aws-sdk-core/xml/error_handler.rb +7 -2
  104. data/lib/aws-sdk-core/xml/parser.rb +4 -4
  105. data/lib/aws-sdk-core/xml/parser/frame.rb +75 -70
  106. data/lib/aws-sdk-core/xml/parser/stack.rb +4 -4
  107. data/lib/seahorse.rb +0 -11
  108. data/lib/seahorse/client/base.rb +3 -12
  109. data/lib/seahorse/client/http/request.rb +9 -5
  110. data/lib/seahorse/client/plugins/endpoint.rb +5 -56
  111. data/lib/seahorse/client/plugins/restful_bindings.rb +38 -31
  112. data/lib/seahorse/client/request_context.rb +2 -2
  113. data/lib/seahorse/client/response.rb +6 -5
  114. data/lib/seahorse/model/api.rb +18 -61
  115. data/lib/seahorse/model/operation.rb +24 -54
  116. data/lib/seahorse/model/shapes.rb +120 -364
  117. data/lib/seahorse/util.rb +2 -6
  118. metadata +56 -109
  119. data/apis/autoscaling/2011-01-01/docs-2.json +0 -1246
  120. data/apis/cloudformation/2010-05-15/docs-2.json +0 -725
  121. data/apis/cloudfront/2014-11-06/docs-2.json +0 -1125
  122. data/apis/cloudhsm/2014-05-30/docs-2.json +0 -472
  123. data/apis/cloudsearch/2013-01-01/docs-2.json +0 -865
  124. data/apis/cloudsearchdomain/2013-01-01/docs-2.json +0 -311
  125. data/apis/cloudtrail/2013-11-01/docs-2.json +0 -328
  126. data/apis/codedeploy/2014-10-06/docs-2.json +0 -1261
  127. data/apis/cognito-identity/2014-06-30/docs-2.json +0 -506
  128. data/apis/cognito-sync/2014-06-30/docs-2.json +0 -582
  129. data/apis/config/2014-10-17/docs-2.json +0 -513
  130. data/apis/config/2014-11-12/docs-2.json +0 -514
  131. data/apis/datapipeline/2012-10-29/docs-2.json +0 -607
  132. data/apis/directconnect/2012-10-25/docs-2.json +0 -494
  133. data/apis/ds/2015-04-16/docs-2.json +0 -753
  134. data/apis/dynamodb/2011-12-05/api-2.json +0 -949
  135. data/apis/dynamodb/2011-12-05/docs-2.json +0 -606
  136. data/apis/dynamodb/2011-12-05/paginators-1.json +0 -26
  137. data/apis/dynamodb/2011-12-05/waiters-2.json +0 -35
  138. data/apis/dynamodb/2012-08-10/docs-2.json +0 -977
  139. data/apis/ec2/2015-04-15/docs-2.json +0 -5368
  140. data/apis/ecs/2014-11-13/docs-2.json +0 -791
  141. data/apis/elasticache/2015-02-02/docs-2.json +0 -1390
  142. data/apis/elasticbeanstalk/2010-12-01/docs-2.json +0 -1114
  143. data/apis/elasticfilesystem/2015-02-01/docs-2.json +0 -414
  144. data/apis/elasticloadbalancing/2012-06-01/docs-2.json +0 -1078
  145. data/apis/elasticmapreduce/2009-03-31/docs-2.json +0 -969
  146. data/apis/elastictranscoder/2012-09-25/docs-2.json +0 -1152
  147. data/apis/email/2010-12-01/docs-2.json +0 -441
  148. data/apis/glacier/2012-06-01/docs-2.json +0 -575
  149. data/apis/iam/2010-05-08/docs-2.json +0 -2138
  150. data/apis/importexport/2010-06-01/docs-2.json +0 -432
  151. data/apis/kinesis/2013-12-02/docs-2.json +0 -424
  152. data/apis/kms/2014-11-01/docs-2.json +0 -628
  153. data/apis/lambda/2014-11-11/docs-2.json +0 -303
  154. data/apis/lambda/2015-03-31/docs-2.json +0 -490
  155. data/apis/logs/2014-03-28/docs-2.json +0 -599
  156. data/apis/machinelearning/2014-12-12/docs-2.json +0 -1034
  157. data/apis/monitoring/2010-08-01/docs-2.json +0 -514
  158. data/apis/opsworks/2013-02-18/docs-2.json +0 -1592
  159. data/apis/rds/2014-10-31/docs-2.json +0 -2074
  160. data/apis/redshift/2012-12-01/docs-2.json +0 -1890
  161. data/apis/route53/2013-04-01/docs-2.json +0 -1159
  162. data/apis/route53domains/2014-05-15/docs-2.json +0 -620
  163. data/apis/s3/2006-03-01/docs-2.json +0 -2213
  164. data/apis/sdb/2009-04-15/docs-2.json +0 -339
  165. data/apis/sns/2010-03-31/docs-2.json +0 -564
  166. data/apis/sqs/2012-11-05/docs-2.json +0 -503
  167. data/apis/ssm/2014-11-06/docs-2.json +0 -440
  168. data/apis/storagegateway/2013-06-30/docs-2.json +0 -1331
  169. data/apis/sts/2011-06-15/docs-2.json +0 -351
  170. data/apis/support/2013-04-15/docs-2.json +0 -680
  171. data/apis/swf/2012-01-25/docs-2.json +0 -1569
  172. data/apis/workspaces/2015-04-08/docs-2.json +0 -457
  173. data/lib/aws-sdk-core/api/customizer.rb +0 -75
  174. data/lib/aws-sdk-core/api/docstrings.rb +0 -38
  175. data/lib/aws-sdk-core/api/documenter.rb +0 -241
  176. data/lib/aws-sdk-core/api/operation_documenter.rb +0 -173
  177. data/lib/aws-sdk-core/api/operation_example.rb +0 -133
  178. data/lib/aws-sdk-core/api/service_customizations.rb +0 -140
  179. data/lib/aws-sdk-core/client_paging.rb +0 -31
  180. data/lib/aws-sdk-core/json/rest_handler.rb +0 -20
  181. data/lib/aws-sdk-core/json/rpc_body_handler.rb +0 -38
  182. data/lib/aws-sdk-core/json/rpc_headers_handler.rb +0 -34
  183. data/lib/aws-sdk-core/json/simple_body_handler.rb +0 -34
  184. data/lib/aws-sdk-core/paging/null_pager.rb +0 -20
  185. data/lib/aws-sdk-core/paging/null_provider.rb +0 -13
  186. data/lib/aws-sdk-core/paging/pager.rb +0 -70
  187. data/lib/aws-sdk-core/paging/provider.rb +0 -22
  188. data/lib/aws-sdk-core/rest_body_handler.rb +0 -111
  189. data/lib/aws-sdk-core/signers/handler.rb +0 -18
  190. data/lib/aws-sdk-core/xml/rest_handler.rb +0 -20
  191. data/lib/seahorse/client/param_converter.rb +0 -207
  192. data/lib/seahorse/client/param_validator.rb +0 -139
  193. data/lib/seahorse/client/plugins/json_simple.rb +0 -33
  194. data/lib/seahorse/client/plugins/param_conversion.rb +0 -29
  195. data/lib/seahorse/client/plugins/param_validation.rb +0 -30
  196. data/lib/seahorse/client/xml/builder.rb +0 -91
  197. data/lib/seahorse/model/shape_map.rb +0 -47
@@ -0,0 +1,22 @@
1
+ module Aws
2
+ module Rest
3
+ class Handler < Seahorse::Client::Handler
4
+
5
+ def call(context)
6
+ Rest::Request::Builder.new.apply(context)
7
+ resp = @handler.call(context)
8
+ resp.on(200..299) { |response| Response::Parser.new.apply(response) }
9
+ resp.on(200..599) { |response| apply_request_id(context) }
10
+ resp
11
+ end
12
+
13
+ private
14
+
15
+ def apply_request_id(context)
16
+ h = context.http_response.headers
17
+ context[:request_id] = h['x-amz-request-id'] || h['x-amzn-requestid']
18
+ end
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,58 @@
1
+ module Aws
2
+ module Rest
3
+ module Request
4
+ class Body
5
+
6
+ include Seahorse::Model::Shapes
7
+
8
+ # @param [Class] serializer_class
9
+ # @param [Seahorse::Model::ShapeRef] rules
10
+ def initialize(serializer_class, rules)
11
+ @serializer_class = serializer_class
12
+ @rules = rules
13
+ end
14
+
15
+ # @param [Seahorse::Client::Http::Request] http_req
16
+ # @param [Hash] params
17
+ def apply(http_req, params)
18
+ http_req.body = build_body(params)
19
+ end
20
+
21
+ private
22
+
23
+ def build_body(params)
24
+ if streaming?
25
+ params[@rules[:payload]]
26
+ elsif @rules[:payload]
27
+ params = params[@rules[:payload]]
28
+ serialize(@rules[:payload_member], params) if params
29
+ else
30
+ params = body_params(params)
31
+ serialize(@rules, params) unless params.empty?
32
+ end
33
+ end
34
+
35
+ def streaming?
36
+ @rules[:payload] && (
37
+ BlobShape === @rules[:payload_member].shape ||
38
+ StringShape === @rules[:payload_member].shape
39
+ )
40
+ end
41
+
42
+ def serialize(rules, params)
43
+ @serializer_class.new(rules).serialize(params)
44
+ end
45
+
46
+ def body_params(params)
47
+ @rules.shape.members.inject({}) do |hash, (member_name, member_ref)|
48
+ if !member_ref.location && params.key?(member_name)
49
+ hash[member_name] = params[member_name]
50
+ end
51
+ hash
52
+ end
53
+ end
54
+
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,50 @@
1
+ module Aws
2
+ module Rest
3
+ module Request
4
+ class Builder
5
+
6
+ def apply(context)
7
+ populate_http_method(context)
8
+ populate_endpoint(context)
9
+ populate_headers(context)
10
+ populate_body(context)
11
+ end
12
+
13
+ private
14
+
15
+ def populate_http_method(context)
16
+ context.http_request.http_method = context.operation.http_method
17
+ end
18
+
19
+ def populate_endpoint(context)
20
+ context.http_request.endpoint = Endpoint.new(
21
+ context.operation.input,
22
+ context.operation.http_request_uri,
23
+ ).uri(context.http_request.endpoint, context.params)
24
+ end
25
+
26
+ def populate_headers(context)
27
+ headers = Headers.new(context.operation.input)
28
+ headers.apply(context.http_request, context.params)
29
+ end
30
+
31
+ def populate_body(context)
32
+ Body.new(
33
+ serializer_class(context),
34
+ context.operation.input,
35
+ ).apply(context.http_request, context.params)
36
+ end
37
+
38
+ def serializer_class(context)
39
+ protocol = context.config.api.metadata['protocol']
40
+ case protocol
41
+ when 'rest-xml' then Xml::Builder
42
+ when 'rest-json' then Json::Builder
43
+ else raise "unsupported protocol #{protocol}"
44
+ end
45
+ end
46
+
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,70 @@
1
+ require 'uri'
2
+
3
+ module Aws
4
+ module Rest
5
+ module Request
6
+ class Endpoint
7
+
8
+ # @param [Seahorse::Model::Shapes::ShapeRef]
9
+ # @param [String] request_uri_pattern
10
+ def initialize(rules, request_uri_pattern)
11
+ @rules = rules
12
+ request_uri_pattern.split('?').tap do |path_part, query_part|
13
+ @path_pattern = path_part
14
+ @query_pattern = query_part
15
+ end
16
+ end
17
+
18
+ # @param [URI::HTTPS,URI::HTTP] base_uri
19
+ # @param [Hash,Struct] params
20
+ # @return [URI::HTTPS,URI::HTTP]
21
+ def uri(base_uri, params)
22
+ uri = URI.parse(base_uri.to_s)
23
+ apply_path_params(uri, params)
24
+ apply_querystring_params(uri, params)
25
+ uri
26
+ end
27
+
28
+ private
29
+
30
+ def apply_path_params(uri, params)
31
+ path = uri.path.sub(/\/$/, '') + @path_pattern.split('?')[0]
32
+ uri.path = path.gsub(/{\w+\+?}/) do |placeholder|
33
+ param_value_for_placeholder(placeholder, params)
34
+ end
35
+ end
36
+
37
+ def param_value_for_placeholder(placeholder, params)
38
+ value = params[param_name(placeholder)]
39
+ placeholder.include?('+') ?
40
+ value.gsub(/[^\/]+/) { |v| escape(v) } :
41
+ escape(value)
42
+ end
43
+
44
+ def param_name(placeholder)
45
+ location_name = placeholder.gsub(/[{}+]/,'')
46
+ param_name, _ = @rules.shape.member_by_location_name(location_name)
47
+ param_name
48
+ end
49
+
50
+ def apply_querystring_params(uri, params)
51
+ parts = []
52
+ parts << @query_pattern if @query_pattern
53
+ @rules.shape.members.each do |member_name, member|
54
+ if member.location == 'querystring' && !params[member_name].nil?
55
+ param_name = member.location_name
56
+ param_value = params[member_name]
57
+ parts << "#{param_name}=#{escape(param_value.to_s)}"
58
+ end
59
+ end
60
+ uri.query = parts.empty? ? nil : parts.join('&')
61
+ end
62
+
63
+ def escape(string)
64
+ Seahorse::Util.uri_escape(string)
65
+ end
66
+
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,48 @@
1
+ require 'time'
2
+
3
+ module Aws
4
+ module Rest
5
+ module Request
6
+ class Headers
7
+
8
+ include Seahorse::Model::Shapes
9
+
10
+ # @param [Seahorse::Model::ShapeRef] rules
11
+ def initialize(rules)
12
+ @rules = rules
13
+ end
14
+
15
+ # @param [Seahorse::Client::Http::Request] http_req
16
+ # @param [Hash] params
17
+ def apply(http_req, params)
18
+ @rules.shape.members.each do |name, ref|
19
+ value = params[name]
20
+ next if value.nil?
21
+ case ref.location
22
+ when 'header' then apply_header_value(http_req.headers, ref, value)
23
+ when 'headers' then apply_header_map(http_req.headers, ref, value)
24
+ end
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def apply_header_value(headers, ref, value)
31
+ headers[ref.location_name] =
32
+ case ref.shape
33
+ when TimestampShape then value.utc.httpdate
34
+ else value.to_s
35
+ end
36
+ end
37
+
38
+ def apply_header_map(headers, ref, values)
39
+ prefix = ref.location_name || ''
40
+ values.each_pair do |name, value|
41
+ headers["#{prefix}#{name}"] = value.to_s
42
+ end
43
+ end
44
+
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,43 @@
1
+ module Aws
2
+ module Rest
3
+ module Response
4
+ class Body
5
+
6
+ include Seahorse::Model::Shapes
7
+
8
+ # @param [Class] parser_class
9
+ # @param [Seahorse::Model::ShapeRef] rules
10
+ def initialize(parser_class, rules)
11
+ @parser_class = parser_class
12
+ @rules = rules
13
+ end
14
+
15
+ # @param [IO] body
16
+ # @param [Hash, Struct] data
17
+ def apply(body, data)
18
+ if streaming?
19
+ data[@rules[:payload]] = body
20
+ elsif @rules[:payload]
21
+ data[@rules[:payload]] = parse(body.read, @rules[:payload_member])
22
+ else
23
+ parse(body.read, @rules, data)
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def streaming?
30
+ @rules[:payload] && (
31
+ BlobShape === @rules[:payload_member].shape ||
32
+ StringShape === @rules[:payload_member].shape
33
+ )
34
+ end
35
+
36
+ def parse(body, rules, target = nil)
37
+ @parser_class.new(rules).parse(body, target) if body.size > 0
38
+ end
39
+
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,60 @@
1
+ module Aws
2
+ module Rest
3
+ module Response
4
+ class Headers
5
+
6
+ include Seahorse::Model::Shapes
7
+
8
+ # @param [Seahorse::Model::ShapeRef] rules
9
+ def initialize(rules)
10
+ @rules = rules
11
+ end
12
+
13
+ # @param [Seahorse::Client::Http::Response] http_resp
14
+ # @param [Hash, Struct] target
15
+ def apply(http_resp, target)
16
+ headers = http_resp.headers
17
+ @rules.shape.members.each do |name, ref|
18
+ case ref.location
19
+ when 'header' then extract_header_value(headers, name, ref, target)
20
+ when 'headers' then extract_header_map(headers, name, ref, target)
21
+ end
22
+ end
23
+ end
24
+
25
+ def extract_header_value(headers, name, ref, data)
26
+ if headers.key?(ref.location_name)
27
+ data[name] = cast_value(ref, headers[ref.location_name])
28
+ end
29
+ end
30
+
31
+ def cast_value(ref, value)
32
+ case ref.shape
33
+ when StringShape then value
34
+ when IntegerShape then value.to_i
35
+ when FloatShape then value.to_f
36
+ when BooleanShape then value == 'true'
37
+ when TimestampShape
38
+ if value =~ /\d+(\.\d*)/
39
+ Time.at(value.to_f)
40
+ else
41
+ Time.parse(value)
42
+ end
43
+ else raise "unsupported shape #{ref.shape.class}"
44
+ end
45
+ end
46
+
47
+ def extract_header_map(headers, name, ref, data)
48
+ data[name] = {}
49
+ prefix = ref.location_name || ''
50
+ headers.each do |header_name, header_value|
51
+ if match = header_name.match(/^#{prefix}(.+)/i)
52
+ data[name][match[1]] = header_value
53
+ end
54
+ end
55
+ end
56
+
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,47 @@
1
+ module Aws
2
+ module Rest
3
+ module Response
4
+ class Parser
5
+
6
+ def apply(response)
7
+ # TODO : remove this unless check once response stubbing is fixed
8
+ unless response.data
9
+ response.data = response.context.operation.output[:struct_class].new
10
+ end
11
+ extract_status_code(response)
12
+ extract_headers(response)
13
+ extract_body(response)
14
+ end
15
+
16
+ private
17
+
18
+ def extract_status_code(response)
19
+ status_code = StatusCode.new(response.context.operation.output)
20
+ status_code.apply(response.context.http_response, response.data)
21
+ end
22
+
23
+ def extract_headers(response)
24
+ headers = Headers.new(response.context.operation.output)
25
+ headers.apply(response.context.http_response, response.data)
26
+ end
27
+
28
+ def extract_body(response)
29
+ Body.new(
30
+ parser_class(response),
31
+ response.context.operation.output,
32
+ ).apply(response.context.http_response.body, response.data)
33
+ end
34
+
35
+ def parser_class(response)
36
+ protocol = response.context.config.api.metadata['protocol']
37
+ case protocol
38
+ when 'rest-xml' then Xml::Parser
39
+ when 'rest-json' then Json::Parser
40
+ else raise "unsupported protocol #{protocol}"
41
+ end
42
+ end
43
+
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,24 @@
1
+ module Aws
2
+ module Rest
3
+ module Response
4
+ class StatusCode
5
+
6
+ # @param [Seahorse::Model::Shapes::ShapeRef] rules
7
+ def initialize(rules)
8
+ @rules = rules
9
+ end
10
+
11
+ # @param [Seahorse::Client::Http::Response] http_resp
12
+ # @param [Hash, Struct] data
13
+ def apply(http_resp, data)
14
+ @rules.shape.members.each do |member_name, member_ref|
15
+ if member_ref.location == 'statusCode'
16
+ data[member_name] = http_resp.status_code
17
+ end
18
+ end
19
+ end
20
+
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,5 +1,7 @@
1
1
  module Aws
2
- class SharedCredentials < Credentials
2
+ class SharedCredentials
3
+
4
+ include CredentialProvider
3
5
 
4
6
  # @api private
5
7
  KEY_MAP = {
@@ -33,6 +35,9 @@ module Aws
33
35
  # @return [String]
34
36
  attr_reader :profile_name
35
37
 
38
+ # @return [Credentials]
39
+ attr_reader :credentials
40
+
36
41
  # @api private
37
42
  def inspect
38
43
  parts = [
@@ -62,11 +67,11 @@ module Aws
62
67
 
63
68
  def load_from_path
64
69
  profile = load_profile
65
- KEY_MAP.each do |source, target|
66
- if profile.key?(source)
67
- instance_variable_set("@#{target}", profile[source])
68
- end
69
- end
70
+ @credentials = Credentials.new(
71
+ profile['aws_access_key_id'],
72
+ profile['aws_secret_access_key'],
73
+ profile['aws_session_token']
74
+ )
70
75
  end
71
76
 
72
77
  def load_profile