aws-sdk-core 2.0.0.rc1 → 2.0.0.rc2

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.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -0
  3. data/README.md +6 -3
  4. data/Rakefile +2 -0
  5. data/apis/AutoScaling-2011-01-01.json +1 -0
  6. data/apis/CloudFormation-2010-05-15.json +75 -0
  7. data/apis/CloudFront-2012-05-05.json +1 -0
  8. data/apis/CloudFront-2013-05-12.json +1 -0
  9. data/apis/CloudFront-2013-08-26.json +1 -0
  10. data/apis/CloudSearch-2011-02-01.json +1 -0
  11. data/apis/CloudWatch-2010-08-01.json +1 -0
  12. data/apis/DataPipeline-2012-10-29.json +1 -0
  13. data/apis/DirectConnect-2012-10-25.json +1 -0
  14. data/apis/DynamoDB-2011-12-05.json +1 -0
  15. data/apis/DynamoDB-2012-08-10.json +1 -0
  16. data/apis/EC2-2013-06-15.json +1 -0
  17. data/apis/EC2-2013-10-01.json +1 -0
  18. data/apis/EMR-2009-03-31.json +1 -0
  19. data/apis/ElastiCache-2012-11-15.json +1 -0
  20. data/apis/ElastiCache-2013-06-15.json +1 -0
  21. data/apis/ElasticBeanstalk-2010-12-01.json +1 -0
  22. data/apis/ElasticLoadBalancing-2012-06-01.json +73 -0
  23. data/apis/ElasticTranscoder-2012-09-25.json +231 -0
  24. data/apis/Glacier-2012-06-01.json +2 -0
  25. data/apis/IAM-2010-05-08.json +1 -0
  26. data/apis/ImportExport-2010-06-01.json +1 -0
  27. data/apis/OpsWorks-2013-02-18.json +1 -0
  28. data/apis/RDS-2013-01-10.json +1 -0
  29. data/apis/RDS-2013-02-12.json +1 -0
  30. data/apis/RDS-2013-05-15.json +1 -0
  31. data/apis/Redshift-2012-12-01.json +1 -0
  32. data/apis/Route53-2012-12-12.json +1 -0
  33. data/apis/S3-2006-03-01.json +5 -0
  34. data/apis/SDB-2009-04-15.json +1 -0
  35. data/apis/SES-2010-12-01.json +1 -0
  36. data/apis/SNS-2010-03-31.json +1 -0
  37. data/apis/SQS-2012-11-05.json +1 -0
  38. data/apis/STS-2011-06-15.json +1 -0
  39. data/apis/SWF-2012-01-25.json +1 -0
  40. data/apis/StorageGateway-2012-06-30.json +1 -0
  41. data/apis/StorageGateway-2013-06-30.json +2018 -0
  42. data/apis/Support-2013-04-15.json +1 -0
  43. data/apis/source/cloudformation-2010-05-15.json +118 -12
  44. data/apis/source/elasticloadbalancing-2012-06-01.json +347 -220
  45. data/apis/source/elastictranscoder-2012-09-25.json +315 -5
  46. data/apis/source/s3-2006-03-01.json +3 -0
  47. data/apis/source/storagegateway-2013-06-30.json +12560 -0
  48. data/apis/source/storagegateway-2013-06-30.paginators.json +28 -0
  49. data/doc-src/plugins/apis.rb +44 -1
  50. data/doc-src/templates/default/fulldoc/html/setup.rb +1 -1
  51. data/features/common/step_definitions.rb +3 -5
  52. data/features/env.rb +2 -0
  53. data/features/glacier/client.feature +8 -0
  54. data/features/glacier/step_definitions.rb +7 -7
  55. data/features/s3/step_definitions.rb +2 -3
  56. data/lib/aws.rb +75 -69
  57. data/lib/aws/api/service_translators/glacier.rb +1 -0
  58. data/lib/aws/api/translator.rb +13 -8
  59. data/lib/aws/credentials.rb +5 -5
  60. data/lib/aws/instance_profile_credentials.rb +113 -0
  61. data/lib/aws/plugins/credentials.rb +2 -1
  62. data/lib/aws/plugins/glacier_account_id.rb +11 -0
  63. data/lib/aws/plugins/glacier_checksums.rb +7 -3
  64. data/lib/aws/plugins/instance_profile_credentials.rb +14 -0
  65. data/lib/aws/plugins/s3_bucket_dns.rb +17 -14
  66. data/lib/aws/plugins/s3_md5s.rb +3 -3
  67. data/lib/aws/service.rb +10 -9
  68. data/lib/aws/signers/s3.rb +2 -2
  69. data/lib/aws/signers/v2.rb +1 -1
  70. data/lib/aws/signers/v4.rb +2 -2
  71. data/lib/aws/version.rb +1 -1
  72. data/lib/aws/xml/serializer.rb +1 -1
  73. data/spec/aws/instance_profile_credentials_spec.rb +94 -0
  74. data/spec/aws/operations_spec.rb +1 -1
  75. data/spec/aws/plugins/credentials_spec.rb +2 -2
  76. data/spec/fixtures/operations/glacier/account_id_param.yml +13 -0
  77. data/spec/fixtures/operations/glacier/custom_account_id.yml +11 -0
  78. data/spec/fixtures/operations/glacier/default_account_id.yml +10 -0
  79. data/spec/fixtures/operations/s3/content_type_header.yml +12 -0
  80. data/spec/fixtures/operations/s3/md5_checksum_disabled.yml +1 -1
  81. data/tasks/apis.rake +2 -2
  82. data/tasks/docs.rake +2 -1
  83. data/tasks/handlers.rake +30 -0
  84. data/vendor/seahorse/lib/seahorse/client.rb +1 -0
  85. data/vendor/seahorse/lib/seahorse/client/base.rb +0 -18
  86. data/vendor/seahorse/lib/seahorse/client/block_io.rb +0 -7
  87. data/vendor/seahorse/lib/seahorse/client/configuration.rb +57 -37
  88. data/vendor/seahorse/lib/seahorse/client/handler_list.rb +115 -78
  89. data/vendor/seahorse/lib/seahorse/client/http/endpoint.rb +19 -15
  90. data/vendor/seahorse/lib/seahorse/client/http/request.rb +0 -15
  91. data/vendor/seahorse/lib/seahorse/client/logging/formatter.rb +0 -7
  92. data/vendor/seahorse/lib/seahorse/client/managed_file.rb +14 -0
  93. data/vendor/seahorse/lib/seahorse/client/net_http/handler.rb +1 -3
  94. data/vendor/seahorse/lib/seahorse/client/plugins/content_length.rb +1 -1
  95. data/vendor/seahorse/lib/seahorse/client/plugins/endpoint.rb +81 -10
  96. data/vendor/seahorse/lib/seahorse/client/plugins/restful_bindings.rb +1 -71
  97. data/vendor/seahorse/lib/seahorse/client/request.rb +26 -3
  98. data/vendor/seahorse/spec/seahorse/client/base_spec.rb +1 -5
  99. data/vendor/seahorse/spec/seahorse/client/configuration_spec.rb +1 -10
  100. data/vendor/seahorse/spec/seahorse/client/handler_list_spec.rb +10 -10
  101. data/vendor/seahorse/spec/seahorse/client/http/endpoint_spec.rb +46 -14
  102. data/vendor/seahorse/spec/seahorse/client/http/request_spec.rb +1 -42
  103. data/vendor/seahorse/spec/seahorse/client/logging/formatter_spec.rb +1 -6
  104. data/vendor/seahorse/spec/seahorse/client/logging/handler_spec.rb +1 -1
  105. data/vendor/seahorse/spec/seahorse/client/net_http/handler_spec.rb +5 -4
  106. data/vendor/seahorse/spec/seahorse/client/param_converter_spec.rb +1 -0
  107. data/vendor/seahorse/spec/seahorse/client/plugins/{restful_bindings/uri_path_builder_spec.rb → endpoint/request_uri_builder_spec.rb} +3 -3
  108. data/vendor/seahorse/spec/seahorse/client/plugins/endpoint_spec.rb +1 -11
  109. data/vendor/seahorse/spec/seahorse/client/request_spec.rb +63 -13
  110. metadata +21 -3
@@ -16,24 +16,17 @@ module Seahorse
16
16
  # puts Endpoint.new('foo.com')
17
17
  # #=> 'https://foo.com'
18
18
  #
19
- # You can default to a HTTP endpoint by passing `:ssl_default` as `false`:
20
- #
21
- # puts Endpoint.new('foo.com', ssl_default: false)
22
- # #=> 'http://foo.com'
23
- #
24
19
  class Endpoint
25
20
 
26
21
  # @param [Endpoint, String] endpoint
27
- # @option options [Boolean] :ssl_default (true)
28
- def initialize(endpoint, options = {})
22
+ def initialize(endpoint)
29
23
  endpoint = endpoint.to_s
30
- unless endpoint =~ /^http/
31
- endpoint = apply_scheme(endpoint, options)
32
- end
24
+ endpoint = "https://#{endpoint}" unless endpoint =~ /^http/
33
25
  URI.parse(endpoint).tap do |uri|
34
26
  @scheme = uri.scheme
35
27
  @host = uri.host
36
28
  @port = uri.port
29
+ @request_uri = uri.request_uri
37
30
  @user = uri.user
38
31
  @password = uri.password
39
32
  end
@@ -48,12 +41,26 @@ module Seahorse
48
41
  # @return [Integer] Returns the endpoint port number (e.g. 443).
49
42
  attr_accessor :port
50
43
 
44
+ # @return [String] Returns the path and querystring,
45
+ # e.g. '/path?querystring'.
46
+ attr_accessor :request_uri
47
+
51
48
  # @return [String, nil]
52
49
  attr_accessor :user
53
50
 
54
51
  # @return [String, nil]
55
52
  attr_accessor :password
56
53
 
54
+ # @return [String]
55
+ def path
56
+ request_uri.split('?', 2)[0]
57
+ end
58
+
59
+ # @return [String, nil]
60
+ def querystring
61
+ request_uri.split('?', 2)[1]
62
+ end
63
+
57
64
  # @return [Boolean]
58
65
  def http?
59
66
  @scheme == 'http'
@@ -67,7 +74,8 @@ module Seahorse
67
74
  # @return [String]
68
75
  # @api private
69
76
  def inspect
70
- URI.parse("#{@scheme}://#{userpass}#{@host}:#{@port}").to_s
77
+ uri = "#{@scheme}://#{userpass}#{@host}:#{@port}#{@request_uri}"
78
+ URI.parse(uri).to_s
71
79
  end
72
80
  alias to_str inspect
73
81
  alias to_s inspect
@@ -81,10 +89,6 @@ module Seahorse
81
89
 
82
90
  private
83
91
 
84
- def apply_scheme(endpoint, options)
85
- "http#{options.fetch(:ssl_default, true) ? 's' : ''}://#{endpoint}"
86
- end
87
-
88
92
  def userpass
89
93
  [@user, @password].compact.join(':') + '@' if @user
90
94
  end
@@ -7,13 +7,11 @@ module Seahorse
7
7
 
8
8
  # @option options [Endpoint] :endpoint (nil)
9
9
  # @option options [String] :http_method ('GET')
10
- # @option options [String] :path ('/')
11
10
  # @option options [Headers] :headers (Headers.new)
12
11
  # @option options [Body] :body (StringIO.new)
13
12
  def initialize(options = {})
14
13
  self.endpoint = options[:endpoint] if options[:endpoint]
15
14
  self.http_method = options[:http_method] || 'GET'
16
- self.path = options[:path] || '/'
17
15
  self.headers = Headers.new(options[:headers] || {})
18
16
  self.headers['User-Agent'] ||= ua
19
17
  self.body = options[:body]
@@ -28,9 +26,6 @@ module Seahorse
28
26
  # @return [Headers] The hash of request headers.
29
27
  attr_accessor :headers
30
28
 
31
- # @return [String] The path name and querystring, e.g. `/abc?mno=xyz`.
32
- attr_accessor :path
33
-
34
29
  # @return [IO]
35
30
  attr_reader :body
36
31
 
@@ -46,16 +41,6 @@ module Seahorse
46
41
  contents
47
42
  end
48
43
 
49
- # @return [String]
50
- def pathname
51
- path.split('?', 2)[0]
52
- end
53
-
54
- # @return [String]
55
- def querystring
56
- path.split('?', 2)[1] || ''
57
- end
58
-
59
44
  # @param [#read, #size, #rewind] io
60
45
  def body=(io)
61
46
  @body = case io
@@ -53,9 +53,6 @@ module Seahorse
53
53
  #
54
54
  # * `:http_request_port` - The port number (e.g. '443' or '80').
55
55
  #
56
- # * `:http_request_path` - The full path (pathname plus querystring)
57
- # for the request, e.g., `/bucket_name/objects/key?versions`.
58
- #
59
56
  # * `:http_request_headers` - The http request headers, inspected.
60
57
  #
61
58
  # * `:http_request_body` - The http request payload.
@@ -157,10 +154,6 @@ module Seahorse
157
154
  response.context.http_request.http_method
158
155
  end
159
156
 
160
- def _http_request_path(response)
161
- response.context.http_request.path
162
- end
163
-
164
157
  def _http_request_headers(response)
165
158
  response.http_request.headers.inspect
166
159
  end
@@ -0,0 +1,14 @@
1
+ module Seahorse
2
+ module Client
3
+ # This utility class is used to track files opened by Seahorse.
4
+ # This allows Seahorse to know what files it needs to close.
5
+ class ManagedFile < File
6
+
7
+ # @return [Boolean]
8
+ def open?
9
+ !closed?
10
+ end
11
+
12
+ end
13
+ end
14
+ end
@@ -44,8 +44,6 @@ module Seahorse
44
44
  response.body.write(chunk)
45
45
  end
46
46
 
47
- response.body.rewind
48
-
49
47
  end
50
48
  end
51
49
  end
@@ -66,7 +64,7 @@ module Seahorse
66
64
  # @return [Net::HTTP::Request]
67
65
  def net_http_request(request)
68
66
  request_class = net_http_request_class(request)
69
- req = request_class.new(request.path, headers(request))
67
+ req = request_class.new(request.endpoint.request_uri, headers(request))
70
68
  req.body_stream = request.body
71
69
  req
72
70
  end
@@ -14,7 +14,7 @@ module Seahorse
14
14
 
15
15
  end
16
16
 
17
- handler(Handler, step: :sign, proiority: 0)
17
+ handler(Handler, step: :sign, priority: 0)
18
18
 
19
19
  end
20
20
  end
@@ -12,24 +12,95 @@ module Seahorse
12
12
  # 'http://example.com:123'
13
13
  #
14
14
  # This must include the host. It may also include the scheme and
15
- # port. When the scheme is not set it defaults to `https`
16
- # or `http` based on the `:ssl_default` option.
17
- #
18
- # @seahorse.client.option [Boolean] :ssl_default (true)
19
- # When `true`, endpoints without a scheme are prefixed by `http://`.
20
- # When `false`, endpoints without a scheme are prefixed by `http://`.
15
+ # port. When the scheme is not set it defaults to `https`.
21
16
  #
22
17
  class Endpoint < Plugin
23
18
 
24
19
  option(:endpoint) { |config| config.api.endpoint }
25
20
 
26
- option(:ssl_default, true)
21
+ class Handler < Client::Handler
22
+
23
+ def call(context)
24
+ endpoint = Http::Endpoint.new(context.config.endpoint)
25
+ apply_url_params(endpoint, context)
26
+ context.http_request.endpoint = endpoint
27
+ @handler.call(context)
28
+ end
29
+
30
+ def apply_url_params(endpoint, context)
31
+ prefix = endpoint.path.sub(/\/$/, '')
32
+ endpoint.request_uri = prefix + RequestUriBuilder.new(
33
+ context.operation.http_path || '/',
34
+ context.operation.input.uri_members,
35
+ ).path(context.params)
36
+ end
27
37
 
28
- handle_request(:EndpointHandler, priority: 90) do |context|
29
- context.http_request.endpoint = Http::Endpoint.new(
30
- context.config.endpoint, ssl_default: context.config.ssl_default)
31
38
  end
32
39
 
40
+ handle(Handler, priority: 90)
41
+
42
+ # @api private
43
+ class RequestUriBuilder
44
+
45
+ PLACEHOLDER_REGEX = /{\w+?}/
46
+
47
+ # @param [String] path_pattern
48
+ # @param [Hash<Model::Shapes::Shape>] rules
49
+ def initialize(path_pattern, rules)
50
+ @pattern = path_pattern
51
+ @rules = rules
52
+ end
53
+
54
+ # @param [Hash] params
55
+ # @return [String<URI path>]
56
+ def path(params)
57
+ path, querystring = @pattern.split('?')
58
+ path = escape_path_params(path, params)
59
+ if querystring
60
+ querystring = escape_querystring_params(querystring, params)
61
+ path = "#{path}?#{querystring}" unless querystring.empty?
62
+ end
63
+ path
64
+ end
65
+
66
+ private
67
+
68
+ def escape_path_params(path, params)
69
+ path.gsub(PLACEHOLDER_REGEX) do |placeholder|
70
+ param_value = params[param_name(placeholder)]
71
+ path_escape(param_value)
72
+ end
73
+ end
74
+
75
+ def escape_querystring_params(querystring, params)
76
+ parts = []
77
+ querystring.split('&').each do |part|
78
+ if match = part.match(PLACEHOLDER_REGEX)
79
+ placeholder = match[0]
80
+ param_value = params[param_name(placeholder)]
81
+ unless param_value.nil?
82
+ parts << part.sub(placeholder, escape(param_value.to_s))
83
+ end
84
+ else
85
+ parts << part # querystring param has no substitution
86
+ end
87
+ end
88
+ parts.join('&')
89
+ end
90
+
91
+ def param_name(placeholder)
92
+ placeholder[1..-2].to_sym
93
+ end
94
+
95
+ def path_escape(value)
96
+ escape(value).gsub('%2F', '/')
97
+ end
98
+
99
+ def escape(string)
100
+ CGI::escape(string.encode('UTF-8')).gsub('+', '%20').gsub('%7E', '~')
101
+ end
102
+
103
+ end
33
104
  end
34
105
  end
35
106
  end
@@ -19,7 +19,6 @@ module Seahorse
19
19
 
20
20
  def build_request(context)
21
21
  populate_method(context)
22
- populate_path(context)
23
22
  populate_headers(context)
24
23
  populate_body(context)
25
24
  end
@@ -28,13 +27,6 @@ module Seahorse
28
27
  context.http_request.http_method = context.operation.http_method
29
28
  end
30
29
 
31
- def populate_path(context)
32
- builder = UriPathBuilder.new(
33
- context.operation.http_path,
34
- context.operation.input.uri_members)
35
- context.http_request.path = builder.path(context.params)
36
- end
37
-
38
30
  def populate_headers(context)
39
31
  context.operation.input.header_members.each do |member_name, member|
40
32
  value = context.params[member_name]
@@ -78,7 +70,7 @@ module Seahorse
78
70
 
79
71
  def parse_response(response)
80
72
  output = response.context.operation.output
81
- response.data ||= Structure.new(output.members.keys)
73
+ response.data ||= Aws::Structure.new(output.members.keys)
82
74
  extract_headers(response)
83
75
  extract_body(response)
84
76
  end
@@ -137,68 +129,6 @@ module Seahorse
137
129
 
138
130
  handle(Handler, priority: 90)
139
131
 
140
- # @api private
141
- class UriPathBuilder
142
-
143
- PLACEHOLDER_REGEX = /{\w+?}/
144
-
145
- # @param [String] path_pattern
146
- # @param [Hash<Model::Shapes::Shape>] rules
147
- def initialize(path_pattern, rules)
148
- @pattern = path_pattern
149
- @rules = rules
150
- end
151
-
152
- # @param [Hash] params
153
- # @return [String<URI path>]
154
- def path(params)
155
- path, querystring = @pattern.split('?')
156
- path = escape_path_params(path, params)
157
- if querystring
158
- querystring = escape_querystring_params(querystring, params)
159
- path = "#{path}?#{querystring}" unless querystring.empty?
160
- end
161
- path
162
- end
163
-
164
- private
165
-
166
- def escape_path_params(path, params)
167
- path.gsub(PLACEHOLDER_REGEX) do |placeholder|
168
- param_value = params[param_name(placeholder)]
169
- path_escape(param_value)
170
- end
171
- end
172
-
173
- def escape_querystring_params(querystring, params)
174
- parts = []
175
- querystring.split('&').each do |part|
176
- if match = part.match(PLACEHOLDER_REGEX)
177
- placeholder = match[0]
178
- param_value = params[param_name(placeholder)]
179
- unless param_value.nil?
180
- parts << part.sub(placeholder, escape(param_value.to_s))
181
- end
182
- else
183
- parts << part # querystring param has no substitution
184
- end
185
- end
186
- parts.join('&')
187
- end
188
-
189
- def param_name(placeholder)
190
- placeholder[1..-2].to_sym
191
- end
192
-
193
- def path_escape(value)
194
- escape(value).gsub('%2F', '/')
195
- end
196
-
197
- def escape(string)
198
- CGI::escape(string.encode('UTF-8')).gsub('+', '%20').gsub('%7E', '~')
199
- end
200
-
201
- end
202
132
  end
203
133
  end
204
134
  end
@@ -52,9 +52,32 @@ module Seahorse
52
52
  #
53
53
  # @return [Response]
54
54
  def send_request(options = {}, &block)
55
- @context.http_response.body = BlockIO.new(&block) if block_given?
56
- @context.http_response.body = options[:target] if options[:target]
57
- @handlers.to_stack.call(@context)
55
+ set_target(options, &block)
56
+ resp = @handlers.to_stack.call(@context)
57
+ close_managed_files
58
+ resp
59
+ end
60
+
61
+ private
62
+
63
+ def set_target(options, &block)
64
+ if target = options[:target] || block
65
+ @context.http_response.body =
66
+ case target
67
+ when Proc then BlockIO.new(&target)
68
+ when String, Pathname then ManagedFile.new(target, 'wb')
69
+ else target
70
+ end
71
+ end
72
+ end
73
+
74
+ def close_managed_files
75
+ [
76
+ @context.http_request.body,
77
+ @context.http_response.body,
78
+ ].each do |io|
79
+ io.close if io.is_a?(ManagedFile) && io.open?
80
+ end
58
81
  end
59
82
 
60
83
  end
@@ -40,10 +40,6 @@ module Seahorse
40
40
  expect(client.config.endpoint).to eq(api['endpoint'])
41
41
  end
42
42
 
43
- it 'defaults ssl_default to true' do
44
- expect(client.config.ssl_default).to equal(true)
45
- end
46
-
47
43
  it 'passes constructor args to the config' do
48
44
  expect {
49
45
  client_class.new(foo: 'bar')
@@ -63,7 +59,7 @@ module Seahorse
63
59
  client_class.add_plugin(Plugins::NetHttp)
64
60
  expect(client.handlers.to_a).to eq([
65
61
  NetHttp::Handler,
66
- Plugins::Endpoint::EndpointHandler,
62
+ Plugins::Endpoint::Handler,
67
63
  ])
68
64
  end
69
65
 
@@ -64,7 +64,7 @@ module Seahorse
64
64
  it 'returns self so it can be chained' do
65
65
  c = config.add_option(:name).add_option(:color)
66
66
  expect(c).to be(config)
67
- expect(c.build!.members).to eq([:name, :color])
67
+ expect(c.build!.members).to eq([:color, :name])
68
68
  end
69
69
 
70
70
  end
@@ -75,15 +75,6 @@ module Seahorse
75
75
  expect(config.add_option(:opt).build!).to be_kind_of(Struct)
76
76
  end
77
77
 
78
- it 'returns a frozen structure' do
79
- config.add_option(:foo)
80
- c = config.build!
81
- expect(c).to be_frozen
82
- expect {
83
- c.foo = 'bar'
84
- }.to raise_error(/can't modify frozen/)
85
- end
86
-
87
78
  it 'accepts a hash of options' do
88
79
  config.add_option(:size, 'default')
89
80
  config.add_option(:color, 'default')