aws-sdk-resources 2.11.632 → 3.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +5 -5
  2. data/lib/aws-sdk-resources.rb +1 -91
  3. metadata +14 -85
  4. data/lib/aws-sdk-resources/batch.rb +0 -143
  5. data/lib/aws-sdk-resources/builder.rb +0 -85
  6. data/lib/aws-sdk-resources/builder_sources.rb +0 -105
  7. data/lib/aws-sdk-resources/collection.rb +0 -107
  8. data/lib/aws-sdk-resources/definition.rb +0 -331
  9. data/lib/aws-sdk-resources/documenter.rb +0 -70
  10. data/lib/aws-sdk-resources/documenter/base_operation_documenter.rb +0 -279
  11. data/lib/aws-sdk-resources/documenter/data_operation_documenter.rb +0 -25
  12. data/lib/aws-sdk-resources/documenter/has_many_operation_documenter.rb +0 -69
  13. data/lib/aws-sdk-resources/documenter/has_operation_documenter.rb +0 -66
  14. data/lib/aws-sdk-resources/documenter/operation_documenter.rb +0 -20
  15. data/lib/aws-sdk-resources/documenter/resource_operation_documenter.rb +0 -53
  16. data/lib/aws-sdk-resources/documenter/waiter_operation_documenter.rb +0 -77
  17. data/lib/aws-sdk-resources/errors.rb +0 -15
  18. data/lib/aws-sdk-resources/operation_methods.rb +0 -83
  19. data/lib/aws-sdk-resources/operations.rb +0 -280
  20. data/lib/aws-sdk-resources/options.rb +0 -17
  21. data/lib/aws-sdk-resources/request.rb +0 -39
  22. data/lib/aws-sdk-resources/request_params.rb +0 -140
  23. data/lib/aws-sdk-resources/resource.rb +0 -243
  24. data/lib/aws-sdk-resources/services/ec2.rb +0 -21
  25. data/lib/aws-sdk-resources/services/ec2/instance.rb +0 -29
  26. data/lib/aws-sdk-resources/services/iam.rb +0 -19
  27. data/lib/aws-sdk-resources/services/s3.rb +0 -21
  28. data/lib/aws-sdk-resources/services/s3/bucket.rb +0 -131
  29. data/lib/aws-sdk-resources/services/s3/encryption.rb +0 -24
  30. data/lib/aws-sdk-resources/services/s3/encryption/client.rb +0 -386
  31. data/lib/aws-sdk-resources/services/s3/encryption/decrypt_handler.rb +0 -225
  32. data/lib/aws-sdk-resources/services/s3/encryption/default_cipher_provider.rb +0 -101
  33. data/lib/aws-sdk-resources/services/s3/encryption/default_key_provider.rb +0 -40
  34. data/lib/aws-sdk-resources/services/s3/encryption/encrypt_handler.rb +0 -61
  35. data/lib/aws-sdk-resources/services/s3/encryption/errors.rb +0 -15
  36. data/lib/aws-sdk-resources/services/s3/encryption/io_auth_decrypter.rb +0 -58
  37. data/lib/aws-sdk-resources/services/s3/encryption/io_decrypter.rb +0 -37
  38. data/lib/aws-sdk-resources/services/s3/encryption/io_encrypter.rb +0 -71
  39. data/lib/aws-sdk-resources/services/s3/encryption/key_provider.rb +0 -31
  40. data/lib/aws-sdk-resources/services/s3/encryption/kms_cipher_provider.rb +0 -104
  41. data/lib/aws-sdk-resources/services/s3/encryption/materials.rb +0 -60
  42. data/lib/aws-sdk-resources/services/s3/encryption/utils.rb +0 -104
  43. data/lib/aws-sdk-resources/services/s3/encryptionV2/client.rb +0 -561
  44. data/lib/aws-sdk-resources/services/s3/encryptionV2/decrypt_handler.rb +0 -214
  45. data/lib/aws-sdk-resources/services/s3/encryptionV2/default_cipher_provider.rb +0 -170
  46. data/lib/aws-sdk-resources/services/s3/encryptionV2/default_key_provider.rb +0 -40
  47. data/lib/aws-sdk-resources/services/s3/encryptionV2/encrypt_handler.rb +0 -69
  48. data/lib/aws-sdk-resources/services/s3/encryptionV2/errors.rb +0 -37
  49. data/lib/aws-sdk-resources/services/s3/encryptionV2/io_auth_decrypter.rb +0 -58
  50. data/lib/aws-sdk-resources/services/s3/encryptionV2/io_decrypter.rb +0 -37
  51. data/lib/aws-sdk-resources/services/s3/encryptionV2/io_encrypter.rb +0 -73
  52. data/lib/aws-sdk-resources/services/s3/encryptionV2/key_provider.rb +0 -31
  53. data/lib/aws-sdk-resources/services/s3/encryptionV2/kms_cipher_provider.rb +0 -169
  54. data/lib/aws-sdk-resources/services/s3/encryptionV2/materials.rb +0 -60
  55. data/lib/aws-sdk-resources/services/s3/encryptionV2/utils.rb +0 -103
  56. data/lib/aws-sdk-resources/services/s3/encryption_v2.rb +0 -24
  57. data/lib/aws-sdk-resources/services/s3/file_downloader.rb +0 -169
  58. data/lib/aws-sdk-resources/services/s3/file_part.rb +0 -75
  59. data/lib/aws-sdk-resources/services/s3/file_uploader.rb +0 -58
  60. data/lib/aws-sdk-resources/services/s3/multipart_file_uploader.rb +0 -187
  61. data/lib/aws-sdk-resources/services/s3/multipart_upload.rb +0 -42
  62. data/lib/aws-sdk-resources/services/s3/multipart_upload_error.rb +0 -16
  63. data/lib/aws-sdk-resources/services/s3/object.rb +0 -290
  64. data/lib/aws-sdk-resources/services/s3/object_copier.rb +0 -99
  65. data/lib/aws-sdk-resources/services/s3/object_multipart_copier.rb +0 -180
  66. data/lib/aws-sdk-resources/services/s3/object_summary.rb +0 -73
  67. data/lib/aws-sdk-resources/services/s3/presigned_post.rb +0 -651
  68. data/lib/aws-sdk-resources/services/sns.rb +0 -7
  69. data/lib/aws-sdk-resources/services/sns/message_verifier.rb +0 -171
  70. data/lib/aws-sdk-resources/services/sqs.rb +0 -7
  71. data/lib/aws-sdk-resources/services/sqs/queue_poller.rb +0 -521
  72. data/lib/aws-sdk-resources/source.rb +0 -39
@@ -1,105 +0,0 @@
1
- module Aws
2
- module Resources
3
- module BuilderSources
4
-
5
- module Source
6
-
7
- def initialize(options)
8
- @source = options[:source]
9
- @target = options[:target].to_sym
10
- end
11
-
12
- # @return [String, nil]
13
- attr_reader :source
14
-
15
- # @return [Symbol]
16
- attr_reader :target
17
-
18
- # @return [Boolean]
19
- def plural?
20
- !!(@source && @source.include?('['))
21
- end
22
-
23
- end
24
-
25
- class Argument
26
-
27
- include Source
28
-
29
- # @option [required, String] :argument
30
- def extract(options)
31
- (options[:args] || [])[@source]
32
- end
33
-
34
- def plural?
35
- false
36
- end
37
-
38
- end
39
-
40
- # Extracts an identifier from a parent resource identifier. Used
41
- # when building a {Resource} from the context of another resource.
42
- class Identifier
43
-
44
- include Source
45
-
46
- # @option [required, Resource] :resource
47
- def extract(options)
48
- options[:resource].send(@source)
49
- end
50
-
51
- end
52
-
53
- # Extracts an identifier from the data of a parent resource. Used
54
- # when building a {Resource} from the context of another resource.
55
- class DataMember
56
-
57
- include Source
58
-
59
- # @option [required, Resource] :resource
60
- def extract(options)
61
- JMESPath.search(@source, options[:resource].data)
62
- end
63
-
64
- end
65
-
66
- # Extracts an identifier from the request parameters used to generate
67
- # a response. Used when building a {Resource} object from the response
68
- # of an operation.
69
- class RequestParameter
70
-
71
- include Source
72
-
73
- # @option [required, Seahorse::Client::Response] :response
74
- def extract(options)
75
- JMESPath.search(@source, options[:response].context.params)
76
- end
77
-
78
- end
79
-
80
- # Extracts an identifier from the data of a response. Used when
81
- # building a {Resource} object from the response of an operation.
82
- class ResponsePath
83
-
84
- include Source
85
-
86
- # @option [required, Seahorse::Client::Response] :response
87
- def extract(options)
88
- JMESPath.search(@source, options[:response].data)
89
- end
90
-
91
- end
92
-
93
- # Supplies a string literal.
94
- class StringLiteral
95
-
96
- include Source
97
-
98
- def extract(options)
99
- @source
100
- end
101
-
102
- end
103
- end
104
- end
105
- end
@@ -1,107 +0,0 @@
1
- module Aws
2
- module Resources
3
- class Collection
4
-
5
- include Enumerable
6
-
7
- # @param [HasManyOperation] operation
8
- # @option (see HasManyOperation#call)
9
- # @api private
10
- def initialize(operation, options)
11
- @operation = operation
12
- @options = options
13
- end
14
-
15
- # @return [Enumerator<Resource>]
16
- def each(&block)
17
- if block_given?
18
- batches.each { |batch| batch.each(&block) }
19
- else
20
- self
21
- end
22
- end
23
-
24
- # @api private
25
- # @return [Enumerator<Batch>]
26
- def batches(&block)
27
- @operation.batches(@options)
28
- end
29
-
30
- # Specifies the maximum number of items to enumerate.
31
- #
32
- # collection.limit(10).each do |resource|
33
- # # yields at most 10 times
34
- # end
35
- #
36
- # @param [Integer] limit The maximum number of items to yield
37
- # via {#each} or {#batches}.
38
- # @return [Collection]
39
- def limit(limit)
40
- self.class.new(@operation, @options.merge(limit: limit))
41
- end
42
-
43
- # Returns the first resource from the collection.
44
- #
45
- # resource = collection.first
46
- #
47
- # If you pass a count, then the first `count` resources are returned in
48
- # a single batch. See the resource specific batch documentation for
49
- # a list of supported batch methods.
50
- #
51
- # resources = collection.first(10)
52
- # resources.delete
53
- #
54
- # @return [Resource, Batch]
55
- def first(count = 1)
56
- if count == 1
57
- limit(1).to_a.first
58
- else
59
- Batch.new(resource_class, limit(count).to_a)
60
- end
61
- end
62
-
63
- # @api private
64
- def respond_to?(method_name, *args)
65
- if resource_class.batch_operation_names.include?(method_name.to_sym)
66
- true
67
- else
68
- super
69
- end
70
- end
71
-
72
- # @api private
73
- def method_missing(method_name, *args, &block)
74
- if respond_to?(method_name)
75
- Batch.validate_batch_args!(args)
76
- batches.each do |batch|
77
- batch.send(method_name, *args, &block)
78
- end
79
- else
80
- super
81
- end
82
- end
83
-
84
- # @api private
85
- def inspect
86
- parts = {}
87
- parts[:type] = resource_class.name
88
- parts[:limit] = @options[:limit]
89
- parts[:params] = @options[:params] || {}
90
- parts = parts.inject("") {|s,(k,v)| s << " #{k}=#{v.inspect}" }
91
- ['#<', self.class.name, parts, '>'].join
92
- end
93
-
94
- private
95
-
96
- # @api private
97
- def limit_key
98
- @operation.limit_key
99
- end
100
-
101
- def resource_class
102
- @operation.builder.resource_class
103
- end
104
-
105
- end
106
- end
107
- end
@@ -1,331 +0,0 @@
1
- require 'set'
2
-
3
- module Aws
4
- module Resources
5
-
6
- # Given a resource definition document, a {Definition} can build a set
7
- # of related resource classes.
8
- class Definition
9
-
10
- # @param [Hash] definition
11
- # @option options [String] :source_path
12
- def initialize(definition = {}, options = {})
13
- @source = definition
14
- @source_path = options[:source_path]
15
- end
16
-
17
- # @param [Module<Service>] namespace
18
- # @return [void]
19
- def apply(namespace)
20
- build_resource_classes(namespace)
21
- each_resource_class(namespace) do |resource, definition|
22
- define_load(namespace, resource, definition['load'])
23
- define_actions(namespace, resource, definition['actions'] || {})
24
- define_batch_actions(namespace, resource, definition['batchActions'] || {})
25
- define_waiters(namespace, resource, definition['waiters'] || {})
26
- define_has(namespace, resource, definition['has'] || {})
27
- define_has_many(namespace, resource, definition['hasMany'] || {})
28
- define_data_attributes(namespace, resource, definition)
29
- end
30
- end
31
-
32
- private
33
-
34
- def build_resource_classes(namespace)
35
- each_definition do |name, definition|
36
- resource_class = Class.new(Resource)
37
- resource_class.client_class = namespace::Client
38
- resource_class.resource_name = name
39
- (definition['identifiers'] || []).each do |identifier|
40
- resource_class.add_identifier(underscore(identifier['name']))
41
- end
42
- namespace.const_set(name, resource_class)
43
- end
44
- end
45
-
46
- def each_resource_class(namespace, &block)
47
- each_definition do |name, definition|
48
- yield(namespace.const_get(name), definition)
49
- end
50
- end
51
-
52
- def define_batch_actions(namespace, resource, batch_actions)
53
- batch_actions.each do |name, definition|
54
- method_name = "batch_" + underscore(name)
55
- method_name += '!' if dangerous?(name, definition)
56
- operation = build_operation(namespace, resource, definition)
57
- resource.add_batch_operation(method_name, operation)
58
- end
59
- end
60
-
61
- def dangerous?(name, definition)
62
- if
63
- name.match(/delete/i) ||
64
- name.match(/terminate/i) ||
65
- definition['request']['operation'].match(/delete/i) ||
66
- definition['request']['operation'].match(/terminate/i)
67
- then
68
- true
69
- else
70
- false
71
- end
72
- end
73
-
74
- def define_data_attributes(namespace, resource, definition)
75
- if shape_name = definition['shape']
76
- shape = resource.client_class.api.metadata['shapes'][shape_name]
77
- shape.member_names.each do |member_name|
78
- if
79
- resource.instance_methods.include?(member_name) ||
80
- data_attribute_is_an_identifier?(member_name, resource, definition)
81
- then
82
- next # some data attributes are duplicates to identifiers
83
- else
84
- resource.add_data_attribute(member_name)
85
- end
86
- end
87
- end
88
- end
89
-
90
- def data_attribute_is_an_identifier?(attr_name, resource, definition)
91
- resource.identifiers.include?(attr_name) ||
92
- definition['identifiers'].any? { |i| underscore(i['dataMember']) == attr_name.to_s }
93
- end
94
-
95
- def define_load(namespace, resource, definition)
96
- return unless definition
97
- resource.load_operation = Operations::LoadOperation.new(
98
- request: define_request(definition['request']),
99
- path: underscore(definition['path']),
100
- source: source(definition),
101
- )
102
- end
103
-
104
- def define_actions(namespace, resource, actions)
105
- actions.each do |name, action|
106
- operation = build_operation(namespace, resource, action)
107
- resource.add_operation(underscore(name), operation)
108
- end
109
- end
110
-
111
- def define_waiters(namespace, resource, waiters)
112
- waiters.each do |name, definition|
113
- operation = build_waiter_operation(namespace, resource, definition)
114
- resource.add_operation("wait_until_#{underscore(name)}", operation)
115
- end
116
- end
117
-
118
- def build_operation(namespace, resource, definition)
119
- if definition['resource']
120
- build_resource_action(namespace, resource, definition)
121
- else
122
- build_basic_action(namespace, resource, definition)
123
- end
124
- end
125
-
126
- def build_basic_action(namespace, resource, definition)
127
- Operations::Operation.new(
128
- request: define_request(definition['request']),
129
- source: source(definition)
130
- )
131
- end
132
-
133
- def build_resource_action(namespace, resource, definition)
134
- builder = define_builder(namespace, definition['resource'])
135
- if path = definition['resource']['path']
136
- builder.sources << BuilderSources::ResponsePath.new({
137
- source: underscore(path),
138
- target: :data,
139
- })
140
- end
141
- Operations::ResourceOperation.new(
142
- request: define_request(definition['request']),
143
- builder: builder,
144
- source: source(definition)
145
- )
146
- end
147
-
148
- def has_many(namespace, resource, definition)
149
- builder = define_builder(namespace, definition['resource'])
150
- if path = definition['resource']['path']
151
- builder.sources << BuilderSources::ResponsePath.new({
152
- source: underscore(path),
153
- target: :data,
154
- })
155
- end
156
- Operations::HasManyOperation.new(
157
- request: define_request(definition['request']),
158
- builder: builder,
159
- source: source(definition),
160
- limit_key: limit_key(resource, definition))
161
- end
162
-
163
- def build_waiter_operation(namespace, resource, definition)
164
- Operations::WaiterOperation.new(
165
- waiter_name: underscore(definition['waiterName']).to_sym,
166
- waiter_params: request_params(definition['params']),
167
- path: underscore(definition['path'])
168
- )
169
- end
170
-
171
- def limit_key(resource, definition)
172
- operation_name = definition['request']['operation']
173
- operation = resource.client_class.api.operation(underscore(operation_name))
174
- if operation[:pager]
175
- operation[:pager].limit_key
176
- else
177
- nil
178
- end
179
- end
180
-
181
- def define_request(definition)
182
- Request.new(
183
- method_name: underscore(definition['operation']),
184
- params: request_params(definition['params'] || [])
185
- )
186
- end
187
-
188
- def request_params(params)
189
- params.map do |definition|
190
- send("#{definition['source']}_request_param", definition)
191
- end
192
- end
193
-
194
- def identifier_request_param(definition)
195
- RequestParams::Identifier.new({
196
- target: underscore(definition['target']),
197
- name: underscore(definition['name']).to_sym,
198
- })
199
- end
200
-
201
- def data_request_param(definition)
202
- RequestParams::DataMember.new({
203
- target: underscore(definition['target']),
204
- path: underscore(definition['path']),
205
- })
206
- end
207
-
208
- def string_request_param(definition)
209
- RequestParams::Literal.new({
210
- target: underscore(definition['target']),
211
- value: definition['value'],
212
- })
213
- end
214
- alias integer_request_param string_request_param
215
- alias float_request_param string_request_param
216
- alias boolean_request_param string_request_param
217
- alias null_request_param string_request_param
218
-
219
- def define_has_many(namespace, resource, has_many)
220
- has_many.each do |name, definition|
221
- operation = has_many(namespace, resource, definition)
222
- resource.add_operation(underscore(name), operation)
223
- end
224
- end
225
-
226
- def define_has(namespace, resource, has)
227
- has.each do |name, definition|
228
- has_operation(namespace, resource, name, definition)
229
- end
230
- end
231
-
232
- def has_operation(namespace, resource, name, definition)
233
- builder = define_builder(namespace, definition['resource'])
234
- if path = definition['resource']['path']
235
- builder.sources << BuilderSources::DataMember.new({
236
- source: underscore(path),
237
- target: :data,
238
- })
239
- end
240
- operation = Operations::HasOperation.new(
241
- builder: builder,
242
- source: source(definition))
243
- resource.add_operation(underscore(name), operation)
244
- end
245
-
246
- def define_builder(namespace, definition)
247
- Builder.new(
248
- resource_class: namespace.const_get(definition['type']),
249
- sources: builder_sources(definition['identifiers'] || [])
250
- )
251
- end
252
-
253
- def builder_sources(sources)
254
- sources.map do |definition|
255
- send("#{definition['source']}_builder_source", definition, sources)
256
- end
257
- end
258
-
259
- def input_builder_source(definition, sources)
260
- arguments = sources.select { |s| s['source'] == 'input' }
261
- BuilderSources::Argument.new({
262
- source: arguments.index(definition),
263
- target: underscore(definition['target']),
264
- })
265
- end
266
-
267
- def identifier_builder_source(definition, _)
268
- BuilderSources::Identifier.new({
269
- source: underscore(definition['name']),
270
- target: underscore(definition['target']),
271
- })
272
- end
273
-
274
- def data_builder_source(definition, _)
275
- BuilderSources::DataMember.new({
276
- source: underscore(definition['path']),
277
- target: underscore(definition['target']),
278
- })
279
- end
280
-
281
- def requestParameter_builder_source(definition, _)
282
- BuilderSources::RequestParameter.new({
283
- source: underscore(definition['path']),
284
- target: underscore(definition['target']),
285
- })
286
- end
287
-
288
- def response_builder_source(definition, _)
289
- BuilderSources::ResponsePath.new({
290
- source: underscore(definition['path']),
291
- target: underscore(definition['target']),
292
- })
293
- end
294
-
295
- def string_builder_source(definition, _)
296
- BuilderSources::ResponsePath.new({
297
- source: underscore(definition['value']),
298
- target: underscore(definition['target']),
299
- })
300
- end
301
-
302
- def svc_definition
303
- @source['service'] || {}
304
- end
305
-
306
- def resource_definitions
307
- @source['resources'] || {}
308
- end
309
-
310
- def each_definition(&block)
311
- yield('Resource', svc_definition)
312
- resource_definitions.each(&block)
313
- end
314
-
315
- def underscore(str)
316
- if str
317
- str.gsub(/\w+/) { |part| Seahorse::Util.underscore(part) }
318
- end
319
- end
320
-
321
- def source(definition)
322
- if ENV['SOURCE']
323
- Source.new(definition, @source_path)
324
- else
325
- nil
326
- end
327
- end
328
-
329
- end
330
- end
331
- end