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,42 +0,0 @@
1
- module Aws
2
- module S3
3
- class MultipartUpload
4
-
5
- alias_method :basic_complete, :complete
6
-
7
- # Completes the upload, requires a list of completed parts. You can
8
- # provide the list of parts with `:part_number` and `:etag` values.
9
- #
10
- # upload.complete(multipart_upload: { parts: [
11
- # { part_number: 1, etag:'etag1' },
12
- # { part_number: 2, etag:'etag2' },
13
- # ...
14
- # ]})
15
- #
16
- # Alternatively, you can pass **`compute_parts: true`** and the part
17
- # list will be computed by calling {Client#list_parts}.
18
- #
19
- # upload.complete(compute_parts: true)
20
- #
21
- # @option options [Boolean] :compute_parts (false) When `true`,
22
- # the {Client#list_parts} method will be called to determine
23
- # the list of required part numbers and their ETags.
24
- #
25
- def complete(options = {})
26
- if options.delete(:compute_parts)
27
- options[:multipart_upload] = { parts: compute_parts }
28
- end
29
- basic_complete(options)
30
- end
31
-
32
- private
33
-
34
- def compute_parts
35
- parts.sort_by(&:part_number).each.with_object([]) do |part, part_list|
36
- part_list << { part_number: part.part_number, etag: part.etag }
37
- end
38
- end
39
-
40
- end
41
- end
42
- end
@@ -1,16 +0,0 @@
1
- module Aws
2
- module S3
3
- class MultipartUploadError < StandardError
4
-
5
- def initialize(message, errors)
6
- @errors = errors
7
- super(message)
8
- end
9
-
10
- # @return [Array<StandardError>] The list of errors encountered
11
- # when uploading or aborting the upload.
12
- attr_reader :errors
13
-
14
- end
15
- end
16
- end
@@ -1,290 +0,0 @@
1
- module Aws
2
- module S3
3
- class Object
4
-
5
- alias size content_length
6
-
7
- # Copies another object to this object. Use `multipart_copy: true`
8
- # for large objects. This is required for objects that exceed 5GB.
9
- #
10
- # @param [S3::Object, S3::ObjectVersion, S3::ObjectSummary, String, Hash] source
11
- # Where to copy object data from. `source` must be one of the following:
12
- #
13
- # * {Aws::S3::Object}
14
- # * {Aws::S3::ObjectSummary}
15
- # * {Aws::S3::ObjectVersion}
16
- # * Hash - with `:bucket` and `:key` and optional `:version_id`
17
- # * String - formatted like `"source-bucket-name/uri-escaped-key"`
18
- # or `"source-bucket-name/uri-escaped-key?versionId=version-id"`
19
- #
20
- # @option options [Boolean] :multipart_copy (false) When `true`,
21
- # the object will be copied using the multipart APIs. This is
22
- # necessary for objects larger than 5GB and can provide
23
- # performance improvements on large objects. Amazon S3 does
24
- # not accept multipart copies for objects smaller than 5MB.
25
- #
26
- # @option options [Integer] :content_length Only used when
27
- # `:multipart_copy` is `true`. Passing this options avoids a HEAD
28
- # request to query the source object size.
29
- #
30
- # @option options [S3::Client] :copy_source_client Only used when
31
- # `:multipart_copy` is `true` and the source object is in a
32
- # different region. You do not need to specify this option
33
- # if you have provided `:content_length`.
34
- #
35
- # @option options [String] :copy_source_region Only used when
36
- # `:multipart_copy` is `true` and the source object is in a
37
- # different region. You do not need to specify this option
38
- # if you have provided a `:source_client` or a `:content_length`.
39
- #
40
- # @example Basic object copy
41
- #
42
- # bucket = Aws::S3::Bucket.new('target-bucket')
43
- # object = bucket.object('target-key')
44
- #
45
- # # source as String
46
- # object.copy_from('source-bucket/source-key')
47
- #
48
- # # source as Hash
49
- # object.copy_from(bucket:'source-bucket', key:'source-key')
50
- #
51
- # # source as Aws::S3::Object
52
- # object.copy_from(bucket.object('source-key'))
53
- #
54
- # @example Managed copy of large objects
55
- #
56
- # # uses multipart upload APIs to copy object
57
- # object.copy_from('src-bucket/src-key', multipart_copy: true)
58
- #
59
- # @see #copy_to
60
- #
61
- def copy_from(source, options = {})
62
- if Hash === source && source[:copy_source]
63
- # for backwards compatibility
64
- @client.copy_object(source.merge(bucket: bucket_name, key: key))
65
- else
66
- ObjectCopier.new(self, options).copy_from(source, options)
67
- end
68
- end
69
-
70
- # Copies this object to another object. Use `multipart_copy: true`
71
- # for large objects. This is required for objects that exceed 5GB.
72
- #
73
- # @note If you need to copy to a bucket in a different region, use
74
- # {#copy_from}.
75
- #
76
- # @param [S3::Object, String, Hash] target Where to copy the object
77
- # data to. `target` must be one of the following:
78
- #
79
- # * {Aws::S3::Object}
80
- # * Hash - with `:bucket` and `:key`
81
- # * String - formatted like `"target-bucket-name/target-key"`
82
- #
83
- # @example Basic object copy
84
- #
85
- # bucket = Aws::S3::Bucket.new('source-bucket')
86
- # object = bucket.object('source-key')
87
- #
88
- # # target as String
89
- # object.copy_to('target-bucket/target-key')
90
- #
91
- # # target as Hash
92
- # object.copy_to(bucket: 'target-bucket', key: 'target-key')
93
- #
94
- # # target as Aws::S3::Object
95
- # object.copy_to(bucket.object('target-key'))
96
- #
97
- # @example Managed copy of large objects
98
- #
99
- # # uses multipart upload APIs to copy object
100
- # object.copy_to('src-bucket/src-key', multipart_copy: true)
101
- #
102
- def copy_to(target, options = {})
103
- ObjectCopier.new(self, options).copy_to(target, options)
104
- end
105
-
106
- # Copies and deletes the current object. The object will only be
107
- # deleted if the copy operation succeeds.
108
- # @param (see Object#copy_to)
109
- # @option (see Object#copy_to)
110
- # @return [void]
111
- # @see Object#copy_to
112
- # @see Object#delete
113
- def move_to(target, options = {})
114
- copy_to(target, options)
115
- delete
116
- end
117
-
118
- # Creates a {PresignedPost} that makes it easy to upload a file from
119
- # a web browser direct to Amazon S3 using an HTML post form with
120
- # a file field.
121
- #
122
- # See the {PresignedPost} documentation for more information.
123
- #
124
- # @option (see PresignedPost#initialize)
125
- # @return [PresignedPost]
126
- # @see PresignedPost
127
- def presigned_post(options = {})
128
- PresignedPost.new(
129
- client.config.credentials,
130
- client.config.region,
131
- bucket_name,
132
- {
133
- key: key,
134
- url: bucket.url,
135
- }.merge(options)
136
- )
137
- end
138
-
139
- # Generates a pre-signed URL for this object.
140
- #
141
- # @example Pre-signed GET URL, valid for one hour
142
- #
143
- # obj.presigned_url(:get, expires_in: 3600)
144
- # #=> "https://bucket-name.s3.amazonaws.com/object-key?..."
145
- #
146
- # @example Pre-signed PUT with a canned ACL
147
- #
148
- # # the object uploaded using this URL will be publicly accessible
149
- # obj.presigned_url(:put, acl: 'public-read')
150
- # #=> "https://bucket-name.s3.amazonaws.com/object-key?..."
151
- #
152
- # @param [Symbol] http_method
153
- # The HTTP method to generate a presigned URL for. Valid values
154
- # are `:get`, `:put`, `:head`, and `:delete`.
155
- #
156
- # @param [Hash] params
157
- # Additional request parameters to use when generating the pre-signed
158
- # URL. See the related documentation in {Client} for accepted
159
- # params.
160
- #
161
- # | HTTP Method | Client Method |
162
- # |---------------|------------------------|
163
- # | `:get` | {Client#get_object} |
164
- # | `:put` | {Client#put_object} |
165
- # | `:head` | {Client#head_object} |
166
- # | `:delete` | {Client#delete_object} |
167
- #
168
- # @option params [Boolean] :virtual_host (false) When `true` the
169
- # presigned URL will use the bucket name as a virtual host.
170
- #
171
- # bucket = Aws::S3::Bucket.new('my.bucket.com')
172
- # bucket.object('key').presigned_url(virtual_host: true)
173
- # #=> "http://my.bucket.com/key?..."
174
- #
175
- # @option params [Integer] :expires_in (900) Number of seconds before
176
- # the pre-signed URL expires. This may not exceed one week (604800
177
- # seconds). Note that the pre-signed URL is also only valid as long as
178
- # credentials used to sign it are. For example, when using IAM roles,
179
- # temporary tokens generated for signing also have a default expiration
180
- # which will affect the effective expiration of the pre-signed URL.
181
- #
182
- # @raise [ArgumentError] Raised if `:expires_in` exceeds one week
183
- # (604800 seconds).
184
- #
185
- # @return [String]
186
- #
187
- def presigned_url(http_method, params = {})
188
- presigner = Presigner.new(client: client)
189
- presigner.presigned_url("#{http_method.downcase}_object", params.merge(
190
- bucket: bucket_name,
191
- key: key,
192
- ))
193
- end
194
-
195
- # Returns the public (un-signed) URL for this object.
196
- #
197
- # s3.bucket('bucket-name').object('obj-key').public_url
198
- # #=> "https://bucket-name.s3.amazonaws.com/obj-key"
199
- #
200
- # To use virtual hosted bucket url (disables https):
201
- #
202
- # s3.bucket('my.bucket.com').object('key').public_url(virtual_host: true)
203
- # #=> "http://my.bucket.com/key"
204
- #
205
- # @option options [Boolean] :virtual_host (false) When `true`, the bucket
206
- # name will be used as the host name. This is useful when you have
207
- # a CNAME configured for the bucket.
208
- #
209
- # @return [String]
210
- def public_url(options = {})
211
- url = URI.parse(bucket.url(options))
212
- url.path += '/' unless url.path[-1] == '/'
213
- url.path += key.gsub(/[^\/]+/) { |s| Seahorse::Util.uri_escape(s) }
214
- url.to_s
215
- end
216
-
217
- # Uploads a file from disk to the current object in S3.
218
- #
219
- # # small files are uploaded in a single API call
220
- # obj.upload_file('/path/to/file')
221
- #
222
- # Files larger than `:multipart_threshold` are uploaded using the
223
- # Amazon S3 multipart upload APIs.
224
- #
225
- # # large files are automatically split into parts
226
- # # and the parts are uploaded in parallel
227
- # obj.upload_file('/path/to/very_large_file')
228
- #
229
- # @param [String,Pathname,File,Tempfile] source A file or path to a file
230
- # on the local file system that should be uploaded to this object.
231
- # If you pass an open file object, then it is your responsibility
232
- # to close the file object once the upload completes.
233
- #
234
- # @option options [Integer] :multipart_threshold (15728640) Files larger
235
- # than `:multipart_threshold` are uploaded using the S3 multipart APIs.
236
- # Default threshold is 15MB.
237
- #
238
- # @raise [MultipartUploadError] If an object is being uploaded in
239
- # parts, and the upload can not be completed, then the upload is
240
- # aborted and this error is raised. The raised error has a `#errors`
241
- # method that returns the failures that caused the upload to be
242
- # aborted.
243
- #
244
- # @return [Boolean] Returns `true` when the object is uploaded
245
- # without any errors.
246
- #
247
- def upload_file(source, options = {})
248
- uploading_options = options.dup
249
- uploader = FileUploader.new(
250
- multipart_threshold: uploading_options.delete(:multipart_threshold),
251
- client: client)
252
- uploader.upload(source, uploading_options.merge(bucket: bucket_name, key: key))
253
- true
254
- end
255
-
256
- # Downloads a file in S3 to a path on disk.
257
- #
258
- # # small files (< 5MB) are downloaded in a single API call
259
- # obj.download_file('/path/to/file')
260
- #
261
- # Files larger than 5MB are downloaded using multipart method
262
- #
263
- # # large files are split into parts
264
- # # and the parts are downloaded in parallel
265
- # obj.download_file('/path/to/very_large_file')
266
- #
267
- # @param [String] destination Where to download the file to
268
- #
269
- # @option options [String] mode `auto`, `single_request`, `get_range`
270
- # `single_request` mode forces only 1 GET request is made in download,
271
- # `get_range` mode allows `chunk_size` parameter to configured in
272
- # customizing each range size in multipart_download,
273
- # By default, `auto` mode is enabled, which performs multipart_download
274
- #
275
- # @option options [String] chunk_size required in get_range mode
276
- #
277
- # @option options [String] thread_count Customize threads used in multipart
278
- # download, if not provided, 10 is default value
279
- #
280
- # @return [Boolean] Returns `true` when the file is downloaded
281
- # without any errors.
282
- def download_file(destination, options = {})
283
- downloader = FileDownloader.new(client: client)
284
- downloader.download(
285
- destination, options.merge(bucket: bucket_name, key: key))
286
- true
287
- end
288
- end
289
- end
290
- end
@@ -1,99 +0,0 @@
1
- require 'thread'
2
-
3
- module Aws
4
- module S3
5
- # @api private
6
- class ObjectCopier
7
-
8
- # @param [S3::Object] object
9
- def initialize(object, options = {})
10
- @object = object
11
- @options = options.merge(client: @object.client)
12
- end
13
-
14
- def copy_from(source, options = {})
15
- copy_object(source, @object, merge_options(source, options))
16
- end
17
-
18
- def copy_to(target, options = {})
19
- copy_object(@object, target, merge_options(target, options))
20
- end
21
-
22
- private
23
-
24
- def copy_object(source, target, options)
25
- target_bucket, target_key = copy_target(target)
26
- options[:bucket] = target_bucket
27
- options[:key] = target_key
28
- options[:copy_source] = copy_source(source)
29
- if options.delete(:multipart_copy)
30
- apply_source_client(source, options)
31
- ObjectMultipartCopier.new(@options).copy(options)
32
- else
33
- @object.client.copy_object(options)
34
- end
35
- end
36
-
37
- def copy_source(source)
38
- case source
39
- when String then source
40
- when Hash
41
- src = "#{source[:bucket]}/#{escape(source[:key])}"
42
- src += "?versionId=#{source[:version_id]}" if source.key?(:version_id)
43
- src
44
- when S3::Object, S3::ObjectSummary
45
- "#{source.bucket_name}/#{escape(source.key)}"
46
- when S3::ObjectVersion
47
- "#{source.bucket_name}/#{escape(source.object_key)}?versionId=#{source.id}"
48
- else
49
- msg = "expected source to be an Aws::S3::Object, Hash, or String"
50
- raise ArgumentError, msg
51
- end
52
- end
53
-
54
- def copy_target(target)
55
- case target
56
- when String then target.match(/([^\/]+?)\/(.+)/)[1,2]
57
- when Hash then target.values_at(:bucket, :key)
58
- when S3::Object then [target.bucket_name, target.key]
59
- else
60
- msg = "expected target to be an Aws::S3::Object, Hash, or String"
61
- raise ArgumentError, msg
62
- end
63
- end
64
-
65
- def merge_options(source_or_target, options)
66
- if Hash === source_or_target
67
- source_or_target.inject(options.dup) do |opts, (key, value)|
68
- opts[key] = value unless [:bucket, :key, :version_id].include?(key)
69
- opts
70
- end
71
- else
72
- options.dup
73
- end
74
- end
75
-
76
- def apply_source_client(source, options)
77
-
78
- if source.respond_to?(:client)
79
- options[:copy_source_client] ||= source.client
80
- end
81
-
82
- if options[:copy_source_region]
83
- config = @object.client.config
84
- config = config.each_pair.inject({}) { |h, (k,v)| h[k] = v; h }
85
- config[:region] = options.delete(:copy_source_region)
86
- options[:copy_source_client] ||= S3::Client.new(config)
87
- end
88
-
89
- options[:copy_source_client] ||= @object.client
90
-
91
- end
92
-
93
- def escape(str)
94
- Seahorse::Util.uri_path_escape(str)
95
- end
96
-
97
- end
98
- end
99
- end