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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +13 -7
  3. data/.yardopts +1 -0
  4. data/Gemfile +5 -1
  5. data/README.md +26 -0
  6. data/apis/AutoScaling-2011-01-01.json +57 -0
  7. data/apis/CloudFormation-2010-05-15.json +29 -0
  8. data/apis/CloudFront-2012-05-05.json +33 -0
  9. data/apis/CloudFront-2013-05-12.json +33 -0
  10. data/apis/CloudFront-2013-08-26.json +33 -0
  11. data/apis/CloudSearch-2011-02-01.json +1 -0
  12. data/apis/CloudWatch-2010-08-01.json +22 -0
  13. data/apis/DataPipeline-2012-10-29.json +25 -0
  14. data/apis/DirectConnect-2012-10-25.json +1 -0
  15. data/apis/DynamoDB-2011-12-05.json +29 -0
  16. data/apis/DynamoDB-2012-08-10.json +29 -0
  17. data/apis/EC2-2013-06-15.json +29 -0
  18. data/apis/EC2-2013-10-01.json +29 -0
  19. data/apis/EMR-2009-03-31.json +958 -40
  20. data/apis/ElastiCache-2012-11-15.json +72 -0
  21. data/apis/ElastiCache-2013-06-15.json +72 -0
  22. data/apis/ElasticBeanstalk-2010-12-01.json +8 -0
  23. data/apis/ElasticLoadBalancing-2012-06-01.json +8 -0
  24. data/apis/ElasticTranscoder-2012-09-25.json +16 -3
  25. data/apis/Glacier-2012-06-01.json +35 -0
  26. data/apis/IAM-2010-05-08.json +129 -0
  27. data/apis/ImportExport-2010-06-01.json +9 -0
  28. data/apis/Kinesis-2013-12-02.json +409 -0
  29. data/apis/OpsWorks-2013-02-18.json +1 -0
  30. data/apis/RDS-2013-01-10.json +106 -0
  31. data/apis/RDS-2013-02-12.json +120 -0
  32. data/apis/RDS-2013-05-15.json +120 -0
  33. data/apis/Redshift-2012-12-01.json +90 -1
  34. data/apis/Route53-2012-12-12.json +27 -0
  35. data/apis/S3-2006-03-01.json +34 -0
  36. data/apis/SDB-2009-04-15.json +16 -0
  37. data/apis/SES-2010-12-01.json +8 -0
  38. data/apis/SNS-2010-03-31.json +22 -0
  39. data/apis/SQS-2012-11-05.json +1 -0
  40. data/apis/STS-2011-06-15.json +3 -1
  41. data/apis/SWF-2012-01-25.json +52 -1
  42. data/apis/StorageGateway-2012-06-30.json +15 -0
  43. data/apis/StorageGateway-2013-06-30.json +15 -0
  44. data/apis/Support-2013-04-15.json +15 -0
  45. data/apis/configuration/endpoints.json +88 -23
  46. data/apis/source/elasticmapreduce-2009-03-31.json +1529 -126
  47. data/apis/source/elasticmapreduce-2009-03-31.paginators.json +25 -0
  48. data/apis/source/importexport-2010-06-01.paginators.json +1 -0
  49. data/apis/source/kinesis-2013-12-02.json +894 -0
  50. data/apis/source/kinesis-2013-12-02.paginators.json +18 -0
  51. data/apis/source/rds-2013-01-10.paginators.json +1 -0
  52. data/apis/source/rds-2013-02-12.paginators.json +1 -0
  53. data/apis/source/rds-2013-05-15.paginators.json +1 -0
  54. data/apis/source/redshift-2012-12-01.paginators.json +1 -0
  55. data/apis/source/s3-2006-03-01.paginators.json +1 -1
  56. data/aws-sdk-core.gemspec +1 -0
  57. data/doc-src/plugins/stability.rb +1 -0
  58. data/features/glacier/client.feature +5 -0
  59. data/features/glacier/step_definitions.rb +56 -5
  60. data/features/kinesis/client.feature +18 -0
  61. data/features/kinesis/setup.rb +6 -0
  62. data/features/s3/buckets.feature +10 -0
  63. data/features/s3/objects.feature +9 -0
  64. data/features/s3/step_definitions.rb +29 -0
  65. data/lib/aws.rb +13 -2
  66. data/lib/aws/api/pagination_translator.rb +71 -0
  67. data/lib/aws/api/service_translators/glacier.rb +0 -7
  68. data/lib/aws/api/translator.rb +10 -3
  69. data/lib/aws/error_handler.rb +1 -1
  70. data/lib/aws/json/builder.rb +4 -2
  71. data/lib/aws/pageable_response.rb +230 -0
  72. data/lib/aws/plugins/glacier_checksums.rb +10 -29
  73. data/lib/aws/plugins/response_paging.rb +18 -0
  74. data/lib/aws/plugins/retry_errors.rb +3 -1
  75. data/lib/aws/plugins/s3_complete_multipart_upload_fix.rb +1 -1
  76. data/lib/aws/plugins/s3_get_bucket_location_fix.rb +9 -3
  77. data/lib/aws/plugins/signature_v4.rb +2 -1
  78. data/lib/aws/plugins/sqs_queue_urls.rb +7 -4
  79. data/lib/aws/plugins/user_agent.rb +3 -3
  80. data/lib/aws/response_handler.rb +1 -1
  81. data/lib/aws/signers/s3.rb +1 -1
  82. data/lib/aws/tree_hash.rb +69 -0
  83. data/lib/aws/version.rb +1 -1
  84. data/spec/aws/json/builder_spec.rb +12 -0
  85. data/spec/aws/pageable_response_spec.rb +195 -0
  86. data/spec/aws/plugins/retry_errors_spec.rb +13 -0
  87. data/spec/aws/plugins/signature_v4_spec.rb +65 -0
  88. data/spec/aws/plugins/sqs_queue_urls_spec.rb +41 -0
  89. data/spec/aws_spec.rb +4 -0
  90. data/spec/fixtures/operations/glacier/get_job_output.yml +23 -0
  91. data/spec/fixtures/operations/s3/get_bucket_policy.yml +8 -0
  92. data/tasks/endpoints.rake +15 -0
  93. data/tasks/handlers.rake +1 -1
  94. data/vendor/seahorse/lib/seahorse/client.rb +1 -0
  95. data/vendor/seahorse/lib/seahorse/client/base.rb +6 -0
  96. data/vendor/seahorse/lib/seahorse/client/configuration.rb +1 -1
  97. data/vendor/seahorse/lib/seahorse/client/handler_builder.rb +3 -3
  98. data/vendor/seahorse/lib/seahorse/client/handler_list.rb +2 -2
  99. data/vendor/seahorse/lib/seahorse/client/http/error.rb +17 -0
  100. data/vendor/seahorse/lib/seahorse/client/http/plain_string_io.rb +10 -0
  101. data/vendor/seahorse/lib/seahorse/client/logging/handler.rb +1 -1
  102. data/vendor/seahorse/lib/seahorse/client/net_http/handler.rb +13 -2
  103. data/vendor/seahorse/lib/seahorse/client/plugins/json_simple.rb +1 -1
  104. data/vendor/seahorse/lib/seahorse/client/plugins/operation_methods.rb +4 -2
  105. data/vendor/seahorse/lib/seahorse/client/plugins/restful_bindings.rb +9 -1
  106. data/vendor/seahorse/lib/seahorse/client/request.rb +14 -0
  107. data/vendor/seahorse/lib/seahorse/client/response.rb +8 -38
  108. data/vendor/seahorse/lib/seahorse/model/shapes/shape.rb +11 -3
  109. data/vendor/seahorse/spec/seahorse/client/configuration_spec.rb +13 -0
  110. data/vendor/seahorse/spec/seahorse/client/net_http/handler_spec.rb +6 -0
  111. data/vendor/seahorse/spec/seahorse/client/response_spec.rb +9 -63
  112. metadata +41 -3
@@ -9,7 +9,7 @@ module Aws
9
9
  attr_accessor :handler
10
10
 
11
11
  def call(context)
12
- @handler.call(context).on_success do |response|
12
+ @handler.call(context).on(200..299) do |response|
13
13
  rules = context.operation.output
14
14
  response.error = nil
15
15
  response.data = case
@@ -131,7 +131,7 @@ module Aws
131
131
  # in the canonicalized resource prefixed by a forward slash.
132
132
  if bucket = params[:bucket]
133
133
  ssl = request.endpoint.https?
134
- if Plugins::S3BucketDns.dns_compatible?(bucket.name, ssl)
134
+ if Plugins::S3BucketDns.dns_compatible?(bucket.value, ssl)
135
135
  parts << "/#{bucket.value}"
136
136
  end
137
137
  end
@@ -0,0 +1,69 @@
1
+ require 'openssl'
2
+
3
+ module Aws
4
+
5
+ # Used for computing a tree hash SHA256 checksum of an object.
6
+ #
7
+ # tree_hash = TreeHash.new
8
+ # tree_hash.update(file.read(1024 * 1024)) until file.eof?
9
+ # tree_hash.digest
10
+ #
11
+ # == Limitations and Notes
12
+ #
13
+ # There are two main limitations to be aware of when using TreeHash:
14
+ #
15
+ # * TreeHash is not thread safe. Use multiple TreeHash objects to concurrently
16
+ # compute a tree hash of a large object. Join their hashes at the end into
17
+ # a single TreeHash and then call {#digest}
18
+ #
19
+ # TreeHash.new(tree_hashes.map(&:hashes).flatten)
20
+ #
21
+ # * You must call {#update} with 1MB chunks of data. Only the final
22
+ # chunk may be smaller than 1MB.
23
+ #
24
+ # If you have a large object/file, and you would like to compute the
25
+ # chunks concurrently, you must break the original file/data into sections
26
+ # that are evenly divisible by 1MB. Each section of data requires
27
+ # a seperate TreeHash object to compute hashes. Once all sections of
28
+ # data are complete, you can rejoin their {#hashes} in sequential order
29
+ # into a single TreeHash, then call {#digest} on the final tree hash.
30
+ #
31
+ class TreeHash
32
+
33
+ def initialize(hashes = [])
34
+ @digest = OpenSSL::Digest::Digest.new('sha256')
35
+ @hashes = hashes
36
+ end
37
+
38
+ # @return [Array<String>] The built up list of hashes. Each hash is
39
+ # a sha255 digest of a 1MB chunk.
40
+ attr_accessor :hashes
41
+
42
+ # @param [String] chunk
43
+ # @return [String] Returns the computed SHA256 digest of the chunk.
44
+ def update(chunk)
45
+ @hashes << @digest.update(chunk).digest
46
+ @digest.reset
47
+ @hashes.last
48
+ end
49
+
50
+ def digest
51
+ hashes = @hashes
52
+ digest = OpenSSL::Digest::Digest.new('sha256')
53
+ until hashes.count == 1
54
+ hashes = hashes.each_slice(2).map do |h1,h2|
55
+ digest.reset
56
+ if h2
57
+ digest.update(h1)
58
+ digest.update(h2)
59
+ digest.digest
60
+ else
61
+ h1
62
+ end
63
+ end
64
+ end
65
+ hashes.first.bytes.map{|x| x.to_i.to_s(16).rjust(2, '0')}.join('')
66
+ end
67
+
68
+ end
69
+ end
@@ -1,3 +1,3 @@
1
1
  module Aws
2
- VERSION = '2.0.0.rc2'
2
+ VERSION = '2.0.0.rc3'
3
3
  end
@@ -44,6 +44,18 @@ module Aws
44
44
  expect(json(abc: { mno: 'xyz' })).to eq('{"abc":{"MNO":"xyz"}}')
45
45
  end
46
46
 
47
+ it 'does not serialize nil members' do
48
+ rules['members'] = {
49
+ 'cfg' => {
50
+ 'type' => 'structure',
51
+ 'members' => {
52
+ 'data' => { 'type' => 'blob' },
53
+ }
54
+ }
55
+ }
56
+ expect(json(cfg: { data: nil })).to eq('{"cfg":{}}')
57
+ end
58
+
47
59
  end
48
60
 
49
61
  describe 'lists' do
@@ -0,0 +1,195 @@
1
+ require 'spec_helper'
2
+
3
+ module Aws
4
+ describe PageableResponse do
5
+
6
+ let(:resp) { Seahorse::Client::Response.new }
7
+
8
+ let(:operation) { double('operation', metadata: { 'paging' => paging }) }
9
+
10
+ let(:pager) { PageableResponse.new(resp) }
11
+
12
+ let(:paging) { nil }
13
+
14
+ before(:each) do
15
+ resp.context.operation = operation
16
+ end
17
+
18
+ # If an operation has no paging metadata, then it is considered
19
+ # un-pageable and will always treat a response as the last page.
20
+ describe 'unpageable-operation' do
21
+
22
+ it 'returns true from #last_page?' do
23
+ expect(pager.last_page?).to be(true)
24
+ expect(pager.next_page?).to be(false)
25
+ end
26
+
27
+ it 'raises a LastPageError when calling next_page' do
28
+ expect { pager.next_page }.to raise_error(PageableResponse::LastPageError)
29
+ end
30
+
31
+ it 'popualtes the error with the response' do
32
+ begin
33
+ pager.next_page
34
+ rescue => error
35
+ expect(error.response).to eq(resp)
36
+ end
37
+ end
38
+
39
+ end
40
+
41
+ # When paging is configured with tokens, the token keys are treated
42
+ # as request parameters and the values are treated as response data
43
+ # elements to map into the next request.
44
+ describe 'paging with tokens' do
45
+
46
+ let(:paging) {{
47
+ 'tokens' => {
48
+ 'offset' => 'next_token'
49
+ }
50
+ }}
51
+
52
+ it 'returns false from last page if the paging token value is present' do
53
+ resp.data = { 'next_token' => 'OFFSET' }
54
+ expect(pager.last_page?).to be(false)
55
+ expect(pager.next_page?).to be(true)
56
+ end
57
+
58
+ it 'is not pageable if response data does not contain tokens' do
59
+ resp.data = { }
60
+ expect(pager.last_page?).to be(true)
61
+ expect(pager.next_page?).to be(false)
62
+ end
63
+
64
+ it 'responds to #next_page by sending a new request with tokens applied' do
65
+ client = double('client')
66
+ new_request = double('new-request')
67
+
68
+ resp.data = { 'next_token' => 'OFFSET' }
69
+ resp.context.client = client
70
+ resp.context.operation_name = 'operation-name'
71
+
72
+ expect(client).to receive(:build_request).
73
+ with('operation-name', { :offset => 'OFFSET' }).
74
+ and_return(new_request)
75
+
76
+ expect(new_request).to receive(:send_request).
77
+ and_return(Seahorse::Client::Response.new)
78
+
79
+ pager.next_page
80
+ end
81
+
82
+ end
83
+
84
+ describe 'paging with multiple tokens' do
85
+
86
+ let(:paging) {{
87
+ 'tokens' => {
88
+ 'offset_a' => 'group',
89
+ 'offset_b' => 'value',
90
+ }
91
+ }}
92
+
93
+ it 'returns false from last page if all paging tokens are present' do
94
+ resp.data = { 'group' => 'a', 'value' => 'b' }
95
+ expect(pager.last_page?).to be(false)
96
+ expect(pager.next_page?).to be(true)
97
+ end
98
+
99
+ it 'returns false from last page if ANY paging token is present' do
100
+ resp.data = { 'group' => 'a' }
101
+ expect(pager.last_page?).to be(false)
102
+ expect(pager.next_page?).to be(true)
103
+ end
104
+
105
+ it 'returns true from last page if NO paging tokens are present' do
106
+ resp.data = { }
107
+ expect(pager.last_page?).to be(true)
108
+ expect(pager.next_page?).to be(false)
109
+ end
110
+
111
+ it 'sends any tokens found a request params' do
112
+ client = double('client')
113
+ new_request = double('new-request', send_request: nil)
114
+
115
+ resp.data = { 'group' => 'a' }
116
+ resp.context.client = client
117
+ resp.context.operation_name = 'operation-name'
118
+
119
+ expect(client).to receive(:build_request).
120
+ with('operation-name', { :offset_a => 'a' }).
121
+ and_return(new_request)
122
+
123
+ allow(new_request).to receive(:send_request).and_return(resp)
124
+
125
+ pager.next_page
126
+ end
127
+
128
+ end
129
+
130
+ describe 'paging with truncation indicator' do
131
+
132
+ let(:paging) {{
133
+ 'tokens' => { 'marker' => 'next_marker' },
134
+ 'truncated_if' => 'is_truncated'
135
+ }}
136
+
137
+ it 'returns false from last page if the truncation marker is true' do
138
+ resp.data = { 'is_truncated' => true }
139
+ expect(pager.last_page?).to be(false)
140
+ expect(pager.next_page?).to be(true)
141
+ end
142
+
143
+ it 'returns true from last page if the truncation marker is false' do
144
+ resp.data = { 'is_truncated' => false }
145
+ expect(pager.last_page?).to be(true)
146
+ expect(pager.next_page?).to be(false)
147
+ end
148
+
149
+ end
150
+
151
+ describe 'custom paging rules' do
152
+
153
+ let(:paging) {{ 'tokens' => { 'offset' => 'next_token' } }}
154
+
155
+ it 'can be constructed with an empty set of rules to disable paging' do
156
+ pager = PageableResponse.new(resp, paging_rules: {})
157
+ expect(pager.last_page?).to be(true)
158
+ expect(pager.next_page?).to be(false)
159
+ end
160
+
161
+ end
162
+
163
+ describe '#each_page' do
164
+
165
+ let(:paging) {{
166
+ 'tokens' => {
167
+ 'offset' => 'next_token'
168
+ }
169
+ }}
170
+
171
+ it 'yields once per paging result' do
172
+ client = double('client')
173
+ new_request = double('new-request')
174
+
175
+ resp.data = { 'next_token' => 'OFFSET' }
176
+ resp.context.client = client
177
+ resp.context.operation_name = 'operation-name'
178
+
179
+ resp2 = Seahorse::Client::Response.new
180
+ resp2.data = {}
181
+
182
+ allow(client).to receive(:build_request).
183
+ with('operation-name', { :offset => 'OFFSET' }).
184
+ and_return(new_request)
185
+
186
+ allow(new_request).to receive(:send_request).and_return(resp2)
187
+
188
+ pages = []
189
+ pager.each { |r| pages << r }
190
+ expect(pages).to eq([resp, resp2])
191
+ end
192
+
193
+ end
194
+ end
195
+ end
@@ -145,6 +145,12 @@ module Aws
145
145
  expect(inspector(error, 307).networking?).to be(false)
146
146
  end
147
147
 
148
+ it 'returns true if the error is wrapped in a Http::Error' do
149
+ error = StandardError.new('oops')
150
+ error = Seahorse::Client::Http::Error.new(error)
151
+ expect(inspector(error, 200).networking?).to be(true)
152
+ end
153
+
148
154
  end
149
155
  end
150
156
 
@@ -247,6 +253,13 @@ module Aws
247
253
  expect(resp.context.retries).to eq(3)
248
254
  end
249
255
 
256
+ it 'retries Seahorse::Client::Http::Errors' do
257
+ error = RuntimeError.new('random-runtime-error')
258
+ resp.error = Seahorse::Client::Http::Error.new(error)
259
+ handle { |context| resp }
260
+ expect(resp.context.retries).to eq(3)
261
+ end
262
+
250
263
  end
251
264
  end
252
265
  end
@@ -0,0 +1,65 @@
1
+ require 'spec_helper'
2
+
3
+ module Aws
4
+ module Plugins
5
+ describe SignatureV4 do
6
+
7
+ let(:plugin) { SignatureV4.new }
8
+
9
+ let(:api) {
10
+ api = Seahorse::Model::Api.new
11
+ api.metadata['endpoint_prefix'] = 'svc-name'
12
+ api
13
+ }
14
+
15
+ let(:config) {
16
+ cfg = Seahorse::Client::Configuration.new
17
+ cfg.add_option(:endpoint, 'svc-name.us-west-2.amazonaws.com')
18
+ cfg.add_option(:api, api)
19
+ cfg.add_option(:region)
20
+ cfg
21
+ }
22
+
23
+ describe 'sigv4 signing name' do
24
+
25
+ it 'accepts a sigv4 signing name configuration option' do
26
+ plugin.add_options(config)
27
+ expect(config.build!(sigv4_name: 'name').sigv4_name).to eq('name')
28
+ end
29
+
30
+ it 'defaults the sigv4 name to the endpoint prefix' do
31
+ plugin.add_options(config)
32
+ expect(config.build!.sigv4_name).to eq('svc-name')
33
+ end
34
+
35
+ it 'prefers the signing_name metdata to endpoint_prefix' do
36
+ api.metadata['signing_name'] = 'signing-name'
37
+ plugin.add_options(config)
38
+ expect(config.build!.sigv4_name).to eq('signing-name')
39
+ end
40
+
41
+ end
42
+
43
+ describe 'sigv4 signing region' do
44
+
45
+ it 'extracts the region from standard endpoints' do
46
+ plugin.add_options(config)
47
+ expect(config.build!.sigv4_region).to eq('us-west-2')
48
+ end
49
+
50
+ it 'defaults to us-east-1 for global endpoints' do
51
+ plugin.add_options(config)
52
+ cfg = config.build!(endpoint: 'svc-name.amazonaws.com')
53
+ expect(cfg.sigv4_region).to eq('us-east-1')
54
+ end
55
+
56
+ it 'defaults to configured region if it can not be extract' do
57
+ plugin.add_options(config)
58
+ cfg = config.build!(region: 'eu-west-1', endpoint: 'localhost' )
59
+ expect(cfg.sigv4_region).to eq('eu-west-1')
60
+ end
61
+
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ module Aws
4
+ module Plugins
5
+ describe SQSQueueUrls do
6
+
7
+ let(:config) {
8
+ cfg = Seahorse::Client::Configuration.new
9
+ cfg.add_option(:region)
10
+ cfg.add_option(:sigv4_region)
11
+ cfg
12
+ }
13
+
14
+ let(:params) {{ queue_url: 'http://foo.com' }}
15
+
16
+ def send_request
17
+ call_handler(SQSQueueUrls::Handler, params:params, config:config)
18
+ end
19
+
20
+ it 'moves the queue url param to the http request endpoint' do
21
+ resp = send_request
22
+ expect(resp.http_request.endpoint).to eq('http://foo.com/')
23
+ end
24
+
25
+ it 'resets the configured region based on the queue url' do
26
+ params[:queue_url] = 'http://sqs.us-west-2.amazonaws.com/url'
27
+ resp = send_request
28
+ expect(resp.context.config.region).to eq('us-west-2')
29
+ expect(resp.context.config.sigv4_region).to eq('us-west-2')
30
+ end
31
+
32
+ it 'raises an argument error for invalid queue urls' do
33
+ params[:queue_url] = 'oops'
34
+ expect {
35
+ send_request
36
+ }.to raise_error(ArgumentError, "invalid queue url `oops'")
37
+ end
38
+
39
+ end
40
+ end
41
+ end
@@ -15,6 +15,10 @@ module Aws
15
15
  expect(Aws.config).to eq({})
16
16
  end
17
17
 
18
+ it 'does not allow assigning config object to non-hash objects' do
19
+ expect(-> { Aws.config = [1,2,3] }).to raise_error(ArgumentError)
20
+ end
21
+
18
22
  end
19
23
 
20
24
  describe 'add_plugin' do