aws-sdk-core 2.0.0.rc15 → 2.0.0.rc16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/apis/DynamoDB.paginators.json +0 -1
  3. data/apis/EC2.resources.json +16 -0
  4. data/apis/ElasticBeanstalk.api.json +4 -1
  5. data/apis/Glacier.resources.json +5 -9
  6. data/apis/IAM.resources.json +1 -1
  7. data/apis/Kinesis.api.json +158 -0
  8. data/apis/Kinesis.paginators.json +0 -6
  9. data/apis/OpsWorks.api.json +36 -5
  10. data/apis/OpsWorks.resources.json +181 -0
  11. data/apis/S3.resources.json +13 -2
  12. data/apis/SQS.resources.json +0 -10
  13. data/bin/aws.rb +9 -0
  14. data/lib/aws.rb +30 -1
  15. data/lib/aws/api/docstrings.rb +35 -0
  16. data/lib/aws/api/documenter.rb +31 -28
  17. data/lib/aws/client.rb +83 -0
  18. data/lib/aws/credential_provider_chain.rb +3 -1
  19. data/lib/aws/errors.rb +16 -7
  20. data/lib/aws/pageable_response.rb +1 -1
  21. data/lib/aws/plugins/csd_conditional_signing.rb +5 -0
  22. data/lib/aws/plugins/response_paging.rb +9 -3
  23. data/lib/aws/plugins/s3_url_encoded_keys.rb +7 -7
  24. data/lib/aws/query/handler.rb +4 -5
  25. data/lib/aws/version.rb +1 -1
  26. data/lib/aws/waiters/errors.rb +30 -0
  27. data/lib/aws/waiters/null_provider.rb +12 -0
  28. data/lib/aws/waiters/provider.rb +54 -0
  29. data/lib/aws/waiters/waiter.rb +194 -0
  30. data/lib/aws/xml/default_list.rb +10 -0
  31. data/lib/aws/xml/parser.rb +6 -1
  32. data/lib/seahorse.rb +0 -2
  33. data/lib/seahorse/client/base.rb +45 -20
  34. data/lib/seahorse/client/handler_list.rb +7 -0
  35. data/lib/seahorse/client/param_converter.rb +2 -2
  36. data/lib/seahorse/client/plugins/restful_bindings.rb +1 -1
  37. data/lib/seahorse/client/request.rb +1 -1
  38. data/lib/seahorse/client/response.rb +0 -2
  39. data/lib/seahorse/model/shapes.rb +6 -2
  40. metadata +15 -11
  41. data/LICENSE.txt +0 -12
  42. data/README.md +0 -301
  43. data/lib/seahorse/client/plugins/api.rb +0 -11
@@ -0,0 +1,181 @@
1
+ {
2
+ "service": {
3
+ "actions": {
4
+ "CreateStack": {
5
+ "request": {
6
+ "operation": "CreateStack"
7
+ },
8
+ "resource": {
9
+ "type": "Stack",
10
+ "identifiers": [
11
+ {
12
+ "target": "Id",
13
+ "sourceType": "responsePath",
14
+ "source": "StackId"
15
+ }
16
+ ]
17
+ }
18
+ }
19
+ },
20
+ "hasMany": {
21
+ "Stacks": {
22
+ "request": {
23
+ "operation": "DescribeStacks"
24
+ },
25
+ "resource": {
26
+ "type": "Stack",
27
+ "identifiers": [
28
+ {
29
+ "target": "Id",
30
+ "sourceType": "responsePath",
31
+ "source": "Stacks[].StackId"
32
+ }
33
+ ]
34
+ },
35
+ "path": "Stacks[]"
36
+ }
37
+ }
38
+ },
39
+ "resources": {
40
+ "Layer": {
41
+ "identifiers": [
42
+ { "name": "Id" }
43
+ ],
44
+ "shape": "Layer",
45
+ "load": {
46
+ "request": {
47
+ "operation": "DescribeLayers",
48
+ "params": [
49
+ {
50
+ "target": "LayerIds[]",
51
+ "sourceType": "identifier",
52
+ "source": "Id"
53
+ }
54
+ ]
55
+ },
56
+ "path": "Layers[0]"
57
+ },
58
+ "actions": {
59
+ "Delete": {
60
+ "request": {
61
+ "operation": "DeleteLayer",
62
+ "params": [
63
+ {
64
+ "target": "LayerId",
65
+ "sourceType": "identifier",
66
+ "source": "Id"
67
+ }
68
+ ]
69
+ }
70
+ }
71
+ },
72
+ "hasOne": {
73
+ "Stack": {
74
+ "resource": {
75
+ "type": "Stack",
76
+ "identifiers": [
77
+ {
78
+ "target": "Id",
79
+ "sourceType": "dataMember",
80
+ "source": "StackId"
81
+ }
82
+ ]
83
+ }
84
+ }
85
+ }
86
+ },
87
+ "Stack": {
88
+ "identifiers": [
89
+ { "name": "Id" }
90
+ ],
91
+ "shape": "Stack",
92
+ "load": {
93
+ "request": {
94
+ "operation": "DescribeStacks",
95
+ "params": [
96
+ {
97
+ "target": "StackIds[]",
98
+ "sourceType": "identifier",
99
+ "source": "Id"
100
+ }
101
+ ]
102
+ },
103
+ "path": "Stacks[0]"
104
+ },
105
+ "actions": {
106
+ "CreateLayer": {
107
+ "request": {
108
+ "operation": "CreateLayer",
109
+ "params": [
110
+ {
111
+ "target": "StackId",
112
+ "sourceType": "identifier",
113
+ "source": "Id"
114
+ }
115
+ ]
116
+ },
117
+ "resource": {
118
+ "type": "Layer",
119
+ "identifiers": [
120
+ {
121
+ "target": "Id",
122
+ "sourceType": "responsePath",
123
+ "source": "LayerId"
124
+ }
125
+ ]
126
+ }
127
+ },
128
+ "GetSummary": {
129
+ "request": {
130
+ "operation": "DescribeStackSummary",
131
+ "params": [
132
+ {
133
+ "target": "StackId",
134
+ "sourceType": "identifier",
135
+ "source": "Id"
136
+ }
137
+ ]
138
+ },
139
+ "path": "StackSummary"
140
+ },
141
+ "Delete": {
142
+ "request": {
143
+ "operation": "DeleteStack",
144
+ "params": [
145
+ {
146
+ "target": "StackId",
147
+ "sourceType": "identifier",
148
+ "source": "Id"
149
+ }
150
+ ]
151
+ }
152
+ }
153
+ },
154
+ "hasMany": {
155
+ "Layers": {
156
+ "request": {
157
+ "operation": "DescribeLayers",
158
+ "params": [
159
+ {
160
+ "target": "StackId",
161
+ "sourceType": "identifier",
162
+ "source": "Id"
163
+ }
164
+ ]
165
+ },
166
+ "resource": {
167
+ "type": "Layer",
168
+ "identifiers": [
169
+ {
170
+ "target": "Id",
171
+ "sourceType": "responsePath",
172
+ "source": "Layers[].LayerId"
173
+ }
174
+ ]
175
+ },
176
+ "path": "Layers[]"
177
+ }
178
+ }
179
+ }
180
+ }
181
+ }
@@ -521,7 +521,7 @@
521
521
  },
522
522
  "InitiateMultipartUpload": {
523
523
  "request": {
524
- "operation": "InitiateMultipartUpload",
524
+ "operation": "CreateMultipartUpload",
525
525
  "params": [
526
526
  { "target":"Bucket", "sourceType":"identifier", "source":"BucketName" },
527
527
  { "target":"Key", "sourceType":"identifier", "source":"Key" }
@@ -547,7 +547,7 @@
547
547
  },
548
548
  "CopyFrom": {
549
549
  "request": {
550
- "operation": "PutObjectCopy",
550
+ "operation": "CopyObject",
551
551
  "params": [
552
552
  { "target":"Bucket", "sourceType":"identifier", "source":"BucketName" },
553
553
  { "target":"Key", "sourceType":"identifier", "source":"Key" }
@@ -564,6 +564,17 @@
564
564
  }
565
565
  }
566
566
  },
567
+ "batchActions": {
568
+ "Delete": {
569
+ "request": {
570
+ "operation": "DeleteObjects",
571
+ "params": [
572
+ { "target":"Bucket", "sourceType":"identifier", "source":"BucketName" },
573
+ { "target":"Delete.Objects[].Key", "sourceType":"identifier", "source":"Key" }
574
+ ]
575
+ }
576
+ }
577
+ },
567
578
  "subResources": {
568
579
  "resources": [
569
580
  "ObjectAcl",
@@ -169,16 +169,6 @@
169
169
  ]
170
170
  }
171
171
  }
172
- },
173
- "hasOne": {
174
- "Queue": {
175
- "resource": {
176
- "type":"Queue",
177
- "identifiers": [
178
- { "target":"Url", "sourceType":"identifier", "source":"QueueUrl" }
179
- ]
180
- }
181
- }
182
172
  }
183
173
  }
184
174
  }
data/bin/aws.rb CHANGED
@@ -94,6 +94,15 @@ end
94
94
 
95
95
  require 'aws-sdk-core'
96
96
 
97
+ begin
98
+ # attempt to load aws-sdk-resources, checking first for source from
99
+ # a relative path in the repo, otherwise will check for the installed gem
100
+ lib = File.join(File.dirname(__FILE__), '..', '..', 'aws-sdk-resources', 'lib')
101
+ $LOAD_PATH.unshift(lib) if File.directory?(lib)
102
+ require 'aws-sdk-resources'
103
+ rescue LoadError
104
+ end
105
+
97
106
  # configure the aws-sdk gem
98
107
 
99
108
  cfg = {}
data/lib/aws.rb CHANGED
@@ -33,6 +33,7 @@ module Aws
33
33
  module Api
34
34
  autoload :Customizer, "#{SRC}/api/customizer"
35
35
  autoload :Documenter, "#{SRC}/api/documenter"
36
+ autoload :Docstrings, "#{SRC}/api/docstrings"
36
37
  autoload :Manifest, "#{SRC}/api/manifest"
37
38
  autoload :ManifestBuilder, "#{SRC}/api/manifest_builder"
38
39
  autoload :OperationDocumenter, "#{SRC}/api/operation_documenter"
@@ -115,9 +116,17 @@ module Aws
115
116
  autoload :V4, "#{SRC}/signers/v4"
116
117
  end
117
118
 
119
+ module Waiters
120
+ autoload :Errors, "#{SRC}/waiters/errors"
121
+ autoload :NullProvider, "#{SRC}/waiters/null_provider"
122
+ autoload :Provider, "#{SRC}/waiters/provider"
123
+ autoload :Waiter, "#{SRC}/waiters/waiter"
124
+ end
125
+
118
126
  # @api private
119
127
  module Xml
120
128
  autoload :Builder, "#{SRC}/xml/builder"
129
+ autoload :DefaultList, "#{SRC}/xml/default_list"
121
130
  autoload :ErrorHandler, "#{SRC}/xml/error_handler"
122
131
  autoload :Parser, "#{SRC}/xml/parser"
123
132
  autoload :RestHandler, "#{SRC}/xml/rest_handler"
@@ -176,7 +185,6 @@ module Aws
176
185
 
177
186
  # @api private
178
187
  def load_json(path)
179
- path = File.join(GEM_ROOT, path) unless path.match(/^#{File::SEPARATOR}/)
180
188
  MultiJson.load(File.open(path, 'r', encoding: 'UTF-8') { |f| f.read })
181
189
  end
182
190
 
@@ -246,6 +254,27 @@ module Aws
246
254
  svc_module.const_get(:Client).paginators = paginators
247
255
  end
248
256
 
257
+ # build service paginators
258
+ service_added do |name, svc_module, options|
259
+ waiters = options[:waiters]
260
+ waiters = case waiters
261
+ when Waiters::Provider then waiters
262
+ when Hash then Waiters::Provider.new(waiters)
263
+ when String then Waiters::Provider.new(Aws.load_json(waiters))
264
+ when nil then Waiters::NullProvider.new
265
+ else raise ArgumentError, 'invalid :waiters option'
266
+ end
267
+ if name == 'S3'
268
+ # temporary workaround for issue with S3 waiter definition
269
+ defs = waiters.instance_variable_get("@definitions")
270
+ defs[:bucket_exists]['ignore_errors'] = ['NotFound']
271
+ defs[:object_exists]['ignore_errors'] = ['NotFound']
272
+ defs[:bucket_not_exists]['success_value'] = 'NotFound'
273
+ defs[:object_not_exists]['success_value'] = 'NotFound'
274
+ end
275
+ svc_module.const_get(:Client).waiters = waiters
276
+ end
277
+
249
278
  # deprecated = define helper method for client class, this will be
250
279
  # replaced eventually with a helper that returns a resource object
251
280
  # for the service.
@@ -0,0 +1,35 @@
1
+ module Aws
2
+ module Api
3
+ # @api private
4
+ # This module loads the API documentation for the given API.
5
+ module Docstrings
6
+
7
+ def self.apply(client_class, path)
8
+ api = client_class.api.definition
9
+ docs = File.open(path, 'r', encoding: 'UTF-8') { |f| f.read }
10
+ docs = MultiJson.load(docs)
11
+
12
+ api['documentation'] = docs['service']
13
+
14
+ docs['operations'].each do |operation, doc|
15
+ api['operations'][operation]['documentation'] = doc
16
+ end
17
+
18
+ docs['shapes'].each do |shape_name, shape|
19
+ api['shapes'][shape_name]['documentation'] = shape['base']
20
+ shape['refs'].each do |ref,doc|
21
+ target_shape_name, member = ref.split('$')
22
+ target_shape = api['shapes'][target_shape_name]
23
+ case target_shape['type']
24
+ when 'structure' then target_shape['members'][member]['documentation'] = doc
25
+ when 'list' then target_shape[member]['documentation'] = doc
26
+ when 'map' then target_shape[member]['documentation'] = doc
27
+ else raise 'not handled'
28
+ end
29
+ end
30
+ end
31
+ client_class.set_api(Seahorse::Model::Api.new(api))
32
+ end
33
+ end
34
+ end
35
+ end
@@ -9,12 +9,12 @@ module Aws
9
9
  @svc_module = svc_module
10
10
  @svc_name = svc_module.name.split('::').last
11
11
  @client_class = svc_module.const_get(:Client)
12
+ Aws::Api::Docstrings.apply(@client_class, docs_path)
12
13
  @api = @client_class.api
13
14
  @full_name = @api.metadata('serviceFullName')
14
15
  @error_names = @api.operations.map {|_,o| o.errors.map(&:name) }
15
16
  @error_names = @error_names.flatten.uniq.sort
16
17
  @namespace = YARD::Registry['Aws']
17
- apply_docstrings(docs_path)
18
18
  end
19
19
 
20
20
  def apply
@@ -73,6 +73,7 @@ module Aws
73
73
  yard_class.docstring = client_docstring
74
74
  document_client_constructor(yard_class)
75
75
  document_client_operations(yard_class)
76
+ document_client_waiters(yard_class)
76
77
  end
77
78
 
78
79
  def client_docstring
@@ -167,6 +168,35 @@ Constructs an API client.
167
168
  DOCSTRING
168
169
  end
169
170
 
171
+ def document_client_waiters(yard_class)
172
+ m = YARD::CodeObjects::MethodObject.new(yard_class, :wait_until)
173
+ m.scope = :instance
174
+ m.parameters << ['waiter_name', nil]
175
+ m.parameters << ['params', '{}']
176
+ m.docstring = YARD::Registry['Aws::Client#wait_until'].docstring
177
+
178
+ waiters = @client_class.waiters.waiter_names.sort.inject('') do |w,name|
179
+ operation = @client_class.waiters.waiter(name).send(:operation_name)
180
+ w << "<tr><td><tt>:#{name}</tt></td><td>{##{operation}}</td></tr>"
181
+ end
182
+ docstring = <<-DOCSTRING
183
+ Returns the list of supported waiters. The following table lists the supported
184
+ waiters and the client method they call:
185
+ <table>
186
+ <thead>
187
+ <tr><th>Waiter Name</th><th>Client Method</th></tr>
188
+ </thead>
189
+ <tbody>
190
+ #{waiters}
191
+ </tbody>
192
+ </table>
193
+ @return [Array<Symbol>] the list of supported waiters.
194
+ DOCSTRING
195
+ m = YARD::CodeObjects::MethodObject.new(yard_class, :waiter_names)
196
+ m.scope = :instance
197
+ m.docstring = docstring
198
+ end
199
+
170
200
  class Tabulator
171
201
 
172
202
  def initialize
@@ -202,33 +232,6 @@ Constructs an API client.
202
232
 
203
233
  end
204
234
 
205
- def apply_docstrings(path)
206
- docs = MultiJson.load(read(path))
207
- api = @api.definition
208
-
209
- api['documentation'] = docs['service']
210
-
211
- docs['operations'].each do |operation, doc|
212
- api['operations'][operation]['documentation'] = doc
213
- end
214
-
215
- docs['shapes'].each do |shape_name, shape|
216
- api['shapes'][shape_name]['documentation'] = shape['base']
217
- shape['refs'].each do |ref,doc|
218
- target_shape_name, member = ref.split('$')
219
- target_shape = api['shapes'][target_shape_name]
220
- case target_shape['type']
221
- when 'structure' then target_shape['members'][member]['documentation'] = doc
222
- when 'list' then target_shape[member]['documentation'] = doc
223
- when 'map' then target_shape[member]['documentation'] = doc
224
- else raise 'not handled'
225
- end
226
- end
227
- end
228
-
229
- @api = Seahorse::Model::Api.new(api)
230
- end
231
-
232
235
  def read(path)
233
236
  File.open(path, 'r', encoding: 'UTF-8') { |f| f.read }
234
237
  end
data/lib/aws/client.rb CHANGED
@@ -2,6 +2,85 @@ module Aws
2
2
 
3
3
  # Base class for all {Aws} service clients.
4
4
  class Client < Seahorse::Client::Base
5
+
6
+ # Waits until a particular condition is satisfied. This works by
7
+ # polling a client request and checking for particular response
8
+ # data or errors. Waiters each have a default duration max attempts
9
+ # which are configurable. Additionally, you can register callbacks
10
+ # and stop waiters by throwing `:success` or `:failure`.
11
+ #
12
+ # @example Basic usage
13
+ # client.wait_until(:waiter_name)
14
+ #
15
+ # @example Configuring interval and maximum attempts
16
+ # client.wait_until(:waiter_name) do |w|
17
+ # w.interval = 10 # number of seconds to sleep between attempts
18
+ # w.max_attempts = 6 # maximum number of polling attempts
19
+ # end
20
+ #
21
+ # @example Rescuing a failed wait
22
+ # begin
23
+ # client.wait_until(:waiter_name)
24
+ # rescue Aws::Waiters::Errors::WaiterFailed
25
+ # # gave up waiting
26
+ # end
27
+ #
28
+ # @example Waiting with progress callbacks
29
+ # client.wait_until(:waiter_name) do |w|
30
+ #
31
+ # # yields just before polling for change
32
+ # w.before_attempt do |attempt|
33
+ # # attempts - number of previous attempts made
34
+ # end
35
+ #
36
+ # # yields before sleeping
37
+ # w.before_wait do |attempt, prev_response|
38
+ # # attempts - number of previous attempts made
39
+ # # prev_response - the last client response received
40
+ # end
41
+ # end
42
+ #
43
+ # @example Throw :success or :failure to terminate early
44
+ # # wait for an hour, not for a number of requests
45
+ # client.wait_until(:waiter_name) do |waiter|
46
+ # one_hour = Time.now + 3600
47
+ # waiter.max_attempts = nil
48
+ # waiter.before_attempt do |attempt|
49
+ # throw(:failure, 'waited to long') if Time.now > one_hour
50
+ # end
51
+ # end
52
+ #
53
+ # @param [Symbol] waiter_name The name of the waiter. See {#waiter_names}
54
+ # for a full list of supported waiters.
55
+ # @param [Hash] params Additional request parameters. See the {#waiter_names}
56
+ # for a list of supported waiters and what request they call. The
57
+ # called request determines the list of accepted parameters.
58
+ # @return [Seahorse::Client::Response] Returns the client response from
59
+ # the successful polling request. If `:success` is thrown from a callback,
60
+ # then the 2nd argument to `#throw` is returned.
61
+ # @yieldparam [Waiters::Waiter] waiter Yields a {Waiters::Waiter Waiter}
62
+ # object that can be configured prior to waiting.
63
+ # @raise [Waiters::Errors::NoSuchWaiter] Raised when the named waiter
64
+ # is not defined.
65
+ # @raise [Waiters::Errors::WaiterFailed] Raised when one of the
66
+ # following conditions is met:
67
+ #
68
+ # * A failure condition is detected
69
+ # * The maximum number of attempts has been made without success
70
+ # * `:failure` is thrown from a callback
71
+ #
72
+ def wait_until(waiter_name, params = {}, &block)
73
+ waiter = self.class.waiters.waiter(waiter_name)
74
+ yield(waiter) if block_given?
75
+ waiter.wait(self, params)
76
+ end
77
+
78
+ # Returns the list of supported waiters.
79
+ # @return [Array<Symbol>]
80
+ def waiter_names
81
+ self.class.waiters.waiter_names
82
+ end
83
+
5
84
  class << self
6
85
 
7
86
  # @return [Symbol]
@@ -12,6 +91,10 @@ module Aws
12
91
  # @api private
13
92
  attr_accessor :paginators
14
93
 
94
+ # @return [Waiters::Provider]
95
+ # @api private
96
+ attr_accessor :waiters
97
+
15
98
  # @api private
16
99
  def define(svc_name, options)
17
100
  client_class = Class.new(self)