aws-sdk-s3 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/lib/aws-sdk-s3.rb +66 -0
  3. data/lib/aws-sdk-s3/bucket.rb +595 -0
  4. data/lib/aws-sdk-s3/bucket_acl.rb +168 -0
  5. data/lib/aws-sdk-s3/bucket_cors.rb +146 -0
  6. data/lib/aws-sdk-s3/bucket_lifecycle.rb +164 -0
  7. data/lib/aws-sdk-s3/bucket_logging.rb +142 -0
  8. data/lib/aws-sdk-s3/bucket_notification.rb +187 -0
  9. data/lib/aws-sdk-s3/bucket_policy.rb +138 -0
  10. data/lib/aws-sdk-s3/bucket_region_cache.rb +79 -0
  11. data/lib/aws-sdk-s3/bucket_request_payment.rb +128 -0
  12. data/lib/aws-sdk-s3/bucket_tagging.rb +143 -0
  13. data/lib/aws-sdk-s3/bucket_versioning.rb +188 -0
  14. data/lib/aws-sdk-s3/bucket_website.rb +177 -0
  15. data/lib/aws-sdk-s3/client.rb +3171 -0
  16. data/lib/aws-sdk-s3/client_api.rb +1991 -0
  17. data/lib/aws-sdk-s3/customizations.rb +29 -0
  18. data/lib/aws-sdk-s3/customizations/bucket.rb +127 -0
  19. data/lib/aws-sdk-s3/customizations/multipart_upload.rb +42 -0
  20. data/lib/aws-sdk-s3/customizations/object.rb +257 -0
  21. data/lib/aws-sdk-s3/customizations/object_summary.rb +65 -0
  22. data/lib/aws-sdk-s3/customizations/types/list_object_versions_output.rb +11 -0
  23. data/lib/aws-sdk-s3/encryption.rb +19 -0
  24. data/lib/aws-sdk-s3/encryption/client.rb +369 -0
  25. data/lib/aws-sdk-s3/encryption/decrypt_handler.rb +178 -0
  26. data/lib/aws-sdk-s3/encryption/default_cipher_provider.rb +63 -0
  27. data/lib/aws-sdk-s3/encryption/default_key_provider.rb +38 -0
  28. data/lib/aws-sdk-s3/encryption/encrypt_handler.rb +50 -0
  29. data/lib/aws-sdk-s3/encryption/errors.rb +13 -0
  30. data/lib/aws-sdk-s3/encryption/io_auth_decrypter.rb +50 -0
  31. data/lib/aws-sdk-s3/encryption/io_decrypter.rb +29 -0
  32. data/lib/aws-sdk-s3/encryption/io_encrypter.rb +69 -0
  33. data/lib/aws-sdk-s3/encryption/key_provider.rb +29 -0
  34. data/lib/aws-sdk-s3/encryption/kms_cipher_provider.rb +71 -0
  35. data/lib/aws-sdk-s3/encryption/materials.rb +58 -0
  36. data/lib/aws-sdk-s3/encryption/utils.rb +79 -0
  37. data/lib/aws-sdk-s3/errors.rb +23 -0
  38. data/lib/aws-sdk-s3/file_part.rb +75 -0
  39. data/lib/aws-sdk-s3/file_uploader.rb +58 -0
  40. data/lib/aws-sdk-s3/legacy_signer.rb +186 -0
  41. data/lib/aws-sdk-s3/multipart_file_uploader.rb +187 -0
  42. data/lib/aws-sdk-s3/multipart_upload.rb +287 -0
  43. data/lib/aws-sdk-s3/multipart_upload_error.rb +16 -0
  44. data/lib/aws-sdk-s3/multipart_upload_part.rb +314 -0
  45. data/lib/aws-sdk-s3/object.rb +942 -0
  46. data/lib/aws-sdk-s3/object_acl.rb +214 -0
  47. data/lib/aws-sdk-s3/object_copier.rb +99 -0
  48. data/lib/aws-sdk-s3/object_multipart_copier.rb +179 -0
  49. data/lib/aws-sdk-s3/object_summary.rb +794 -0
  50. data/lib/aws-sdk-s3/object_version.rb +406 -0
  51. data/lib/aws-sdk-s3/plugins/accelerate.rb +92 -0
  52. data/lib/aws-sdk-s3/plugins/bucket_dns.rb +89 -0
  53. data/lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb +23 -0
  54. data/lib/aws-sdk-s3/plugins/dualstack.rb +70 -0
  55. data/lib/aws-sdk-s3/plugins/expect_100_continue.rb +29 -0
  56. data/lib/aws-sdk-s3/plugins/get_bucket_location_fix.rb +23 -0
  57. data/lib/aws-sdk-s3/plugins/http_200_errors.rb +47 -0
  58. data/lib/aws-sdk-s3/plugins/location_constraint.rb +33 -0
  59. data/lib/aws-sdk-s3/plugins/md5s.rb +79 -0
  60. data/lib/aws-sdk-s3/plugins/redirects.rb +41 -0
  61. data/lib/aws-sdk-s3/plugins/s3_signer.rb +208 -0
  62. data/lib/aws-sdk-s3/plugins/sse_cpk.rb +68 -0
  63. data/lib/aws-sdk-s3/plugins/url_encoded_keys.rb +94 -0
  64. data/lib/aws-sdk-s3/presigned_post.rb +647 -0
  65. data/lib/aws-sdk-s3/presigner.rb +160 -0
  66. data/lib/aws-sdk-s3/resource.rb +96 -0
  67. data/lib/aws-sdk-s3/types.rb +5750 -0
  68. data/lib/aws-sdk-s3/waiters.rb +178 -0
  69. metadata +154 -0
@@ -0,0 +1,79 @@
1
+ require 'thread'
2
+
3
+ module Aws
4
+ module S3
5
+ class BucketRegionCache
6
+
7
+ def initialize
8
+ @regions = {}
9
+ @listeners = []
10
+ @mutex = Mutex.new
11
+ end
12
+
13
+ # Registers a block as a callback. This listener is called when a
14
+ # new bucket/region pair is added to the cache.
15
+ #
16
+ # S3::BUCKET_REGIONS.bucket_added do |bucket_name, region_name|
17
+ # # ...
18
+ # end
19
+ #
20
+ # This happens when a request is made against the classic endpoint,
21
+ # "s3.amazonaws.com" and an error is returned requiring the request
22
+ # to be resent with Signature Version 4. At this point, multiple
23
+ # requests are made to discover the bucket region so that a v4
24
+ # signature can be generated.
25
+ #
26
+ # An application can register listeners here to avoid these extra
27
+ # requests in the future. By constructing an {S3::Client} with
28
+ # the proper region, a proper signature can be generated and redirects
29
+ # avoided.
30
+ # @return [void]
31
+ def bucket_added(&block)
32
+ if block
33
+ @mutex.synchronize { @listeners << block }
34
+ else
35
+ raise ArgumentError, 'missing required block'
36
+ end
37
+ end
38
+
39
+ # @param [String] bucket_name
40
+ # @return [String,nil] Returns the cached region for the named bucket.
41
+ # Returns `nil` if the bucket is not in the cache.
42
+ # @api private
43
+ def [](bucket_name)
44
+ @mutex.synchronize { @regions[bucket_name] }
45
+ end
46
+
47
+ # Caches a bucket's region. Calling this method will trigger each
48
+ # of the {#bucket_added} listener callbacks.
49
+ # @param [String] bucket_name
50
+ # @param [String] region_name
51
+ # @return [void]
52
+ # @api private
53
+ def []=(bucket_name, region_name)
54
+ @mutex.synchronize do
55
+ @regions[bucket_name] = region_name
56
+ @listeners.each { |block| block.call(bucket_name, region_name) }
57
+ end
58
+ end
59
+
60
+ # @api private
61
+ def clear
62
+ @mutex.synchronize { @regions = {} }
63
+ end
64
+
65
+ # @return [Hash] Returns a hash of cached bucket names and region names.
66
+ def to_hash
67
+ @mutex.synchronize do
68
+ @regions.dup
69
+ end
70
+ end
71
+ alias to_h to_hash
72
+
73
+ end
74
+
75
+ # @api private
76
+ BUCKET_REGIONS = BucketRegionCache.new
77
+
78
+ end
79
+ end
@@ -0,0 +1,128 @@
1
+ # WARNING ABOUT GENERATED CODE
2
+ #
3
+ # This file is generated. See the contributing for info on making contributions:
4
+ # https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
5
+ #
6
+ # WARNING ABOUT GENERATED CODE
7
+
8
+ module Aws
9
+ module S3
10
+ class BucketRequestPayment
11
+
12
+ extend Aws::Deprecations
13
+
14
+ # @overload def initialize(bucket_name, options = {})
15
+ # @param [String] bucket_name
16
+ # @option options [Client] :client
17
+ # @overload def initialize(options = {})
18
+ # @option options [required, String] :bucket_name
19
+ # @option options [Client] :client
20
+ def initialize(*args)
21
+ options = Hash === args.last ? args.pop.dup : {}
22
+ @bucket_name = extract_bucket_name(args, options)
23
+ @data = options.delete(:data)
24
+ @client = options.delete(:client) || Client.new(options)
25
+ end
26
+
27
+ # @!group Read-Only Attributes
28
+
29
+ # @return [String]
30
+ def bucket_name
31
+ @bucket_name
32
+ end
33
+
34
+ # Specifies who pays for the download and request fees.
35
+ # @return [String]
36
+ def payer
37
+ data.payer
38
+ end
39
+
40
+ # @!endgroup
41
+
42
+ # @return [Client]
43
+ def client
44
+ @client
45
+ end
46
+
47
+ # Loads, or reloads {#data} for the current {BucketRequestPayment}.
48
+ # Returns `self` making it possible to chain methods.
49
+ #
50
+ # bucket_request_payment.reload.data
51
+ #
52
+ # @return [self]
53
+ def load
54
+ resp = @client.get_bucket_request_payment(bucket: @bucket_name)
55
+ @data = resp.data
56
+ self
57
+ end
58
+ alias :reload :load
59
+
60
+ # @return [Types::GetBucketRequestPaymentOutput]
61
+ # Returns the data for this {BucketRequestPayment}. Calls
62
+ # {Client#get_bucket_request_payment} if {#data_loaded?} is `false`.
63
+ def data
64
+ load unless @data
65
+ @data
66
+ end
67
+
68
+ # @return [Boolean]
69
+ # Returns `true` if this resource is loaded. Accessing attributes or
70
+ # {#data} on an unloaded resource will trigger a call to {#load}.
71
+ def data_loaded?
72
+ !!@data
73
+ end
74
+
75
+ # @!group Actions
76
+
77
+ # @example Request syntax with placeholder values
78
+ #
79
+ # bucket_request_payment.put({
80
+ # content_md5: "ContentMD5",
81
+ # request_payment_configuration: { # required
82
+ # payer: "Requester", # required, accepts Requester, BucketOwner
83
+ # },
84
+ # })
85
+ # @param [Hash] options ({})
86
+ # @option options [String] :content_md5
87
+ # @option options [required, Types::RequestPaymentConfiguration] :request_payment_configuration
88
+ # @return [EmptyStructure]
89
+ def put(options = {})
90
+ options = options.merge(bucket: @bucket_name)
91
+ resp = @client.put_bucket_request_payment(options)
92
+ resp.data
93
+ end
94
+
95
+ # @!group Associations
96
+
97
+ # @return [Bucket]
98
+ def bucket
99
+ Bucket.new(
100
+ name: @bucket_name,
101
+ client: @client
102
+ )
103
+ end
104
+
105
+ # @deprecated
106
+ # @api private
107
+ def identifiers
108
+ { bucket_name: @bucket_name }
109
+ end
110
+ deprecated(:identifiers)
111
+
112
+ private
113
+
114
+ def extract_bucket_name(args, options)
115
+ value = args[0] || options.delete(:bucket_name)
116
+ case value
117
+ when String then value
118
+ when nil then raise ArgumentError, "missing required option :bucket_name"
119
+ else
120
+ msg = "expected :bucket_name to be a String, got #{value.class}"
121
+ raise ArgumentError, msg
122
+ end
123
+ end
124
+
125
+ class Collection < Aws::Resources::Collection; end
126
+ end
127
+ end
128
+ end
@@ -0,0 +1,143 @@
1
+ # WARNING ABOUT GENERATED CODE
2
+ #
3
+ # This file is generated. See the contributing for info on making contributions:
4
+ # https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
5
+ #
6
+ # WARNING ABOUT GENERATED CODE
7
+
8
+ module Aws
9
+ module S3
10
+ class BucketTagging
11
+
12
+ extend Aws::Deprecations
13
+
14
+ # @overload def initialize(bucket_name, options = {})
15
+ # @param [String] bucket_name
16
+ # @option options [Client] :client
17
+ # @overload def initialize(options = {})
18
+ # @option options [required, String] :bucket_name
19
+ # @option options [Client] :client
20
+ def initialize(*args)
21
+ options = Hash === args.last ? args.pop.dup : {}
22
+ @bucket_name = extract_bucket_name(args, options)
23
+ @data = options.delete(:data)
24
+ @client = options.delete(:client) || Client.new(options)
25
+ end
26
+
27
+ # @!group Read-Only Attributes
28
+
29
+ # @return [String]
30
+ def bucket_name
31
+ @bucket_name
32
+ end
33
+
34
+ # @return [Array<Types::Tag>]
35
+ def tag_set
36
+ data.tag_set
37
+ end
38
+
39
+ # @!endgroup
40
+
41
+ # @return [Client]
42
+ def client
43
+ @client
44
+ end
45
+
46
+ # Loads, or reloads {#data} for the current {BucketTagging}.
47
+ # Returns `self` making it possible to chain methods.
48
+ #
49
+ # bucket_tagging.reload.data
50
+ #
51
+ # @return [self]
52
+ def load
53
+ resp = @client.get_bucket_tagging(bucket: @bucket_name)
54
+ @data = resp.data
55
+ self
56
+ end
57
+ alias :reload :load
58
+
59
+ # @return [Types::GetBucketTaggingOutput]
60
+ # Returns the data for this {BucketTagging}. Calls
61
+ # {Client#get_bucket_tagging} if {#data_loaded?} is `false`.
62
+ def data
63
+ load unless @data
64
+ @data
65
+ end
66
+
67
+ # @return [Boolean]
68
+ # Returns `true` if this resource is loaded. Accessing attributes or
69
+ # {#data} on an unloaded resource will trigger a call to {#load}.
70
+ def data_loaded?
71
+ !!@data
72
+ end
73
+
74
+ # @!group Actions
75
+
76
+ # @example Request syntax with placeholder values
77
+ #
78
+ # bucket_tagging.delete()
79
+ # @param [Hash] options ({})
80
+ # @return [EmptyStructure]
81
+ def delete(options = {})
82
+ options = options.merge(bucket: @bucket_name)
83
+ resp = @client.delete_bucket_tagging(options)
84
+ resp.data
85
+ end
86
+
87
+ # @example Request syntax with placeholder values
88
+ #
89
+ # bucket_tagging.put({
90
+ # content_md5: "ContentMD5",
91
+ # tagging: { # required
92
+ # tag_set: [ # required
93
+ # {
94
+ # key: "ObjectKey", # required
95
+ # value: "Value", # required
96
+ # },
97
+ # ],
98
+ # },
99
+ # })
100
+ # @param [Hash] options ({})
101
+ # @option options [String] :content_md5
102
+ # @option options [required, Types::Tagging] :tagging
103
+ # @return [EmptyStructure]
104
+ def put(options = {})
105
+ options = options.merge(bucket: @bucket_name)
106
+ resp = @client.put_bucket_tagging(options)
107
+ resp.data
108
+ end
109
+
110
+ # @!group Associations
111
+
112
+ # @return [Bucket]
113
+ def bucket
114
+ Bucket.new(
115
+ name: @bucket_name,
116
+ client: @client
117
+ )
118
+ end
119
+
120
+ # @deprecated
121
+ # @api private
122
+ def identifiers
123
+ { bucket_name: @bucket_name }
124
+ end
125
+ deprecated(:identifiers)
126
+
127
+ private
128
+
129
+ def extract_bucket_name(args, options)
130
+ value = args[0] || options.delete(:bucket_name)
131
+ case value
132
+ when String then value
133
+ when nil then raise ArgumentError, "missing required option :bucket_name"
134
+ else
135
+ msg = "expected :bucket_name to be a String, got #{value.class}"
136
+ raise ArgumentError, msg
137
+ end
138
+ end
139
+
140
+ class Collection < Aws::Resources::Collection; end
141
+ end
142
+ end
143
+ end
@@ -0,0 +1,188 @@
1
+ # WARNING ABOUT GENERATED CODE
2
+ #
3
+ # This file is generated. See the contributing for info on making contributions:
4
+ # https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
5
+ #
6
+ # WARNING ABOUT GENERATED CODE
7
+
8
+ module Aws
9
+ module S3
10
+ class BucketVersioning
11
+
12
+ extend Aws::Deprecations
13
+
14
+ # @overload def initialize(bucket_name, options = {})
15
+ # @param [String] bucket_name
16
+ # @option options [Client] :client
17
+ # @overload def initialize(options = {})
18
+ # @option options [required, String] :bucket_name
19
+ # @option options [Client] :client
20
+ def initialize(*args)
21
+ options = Hash === args.last ? args.pop.dup : {}
22
+ @bucket_name = extract_bucket_name(args, options)
23
+ @data = options.delete(:data)
24
+ @client = options.delete(:client) || Client.new(options)
25
+ end
26
+
27
+ # @!group Read-Only Attributes
28
+
29
+ # @return [String]
30
+ def bucket_name
31
+ @bucket_name
32
+ end
33
+
34
+ # The versioning state of the bucket.
35
+ # @return [String]
36
+ def status
37
+ data.status
38
+ end
39
+
40
+ # Specifies whether MFA delete is enabled in the bucket versioning
41
+ # configuration. This element is only returned if the bucket has been
42
+ # configured with MFA delete. If the bucket has never been so
43
+ # configured, this element is not returned.
44
+ # @return [String]
45
+ def mfa_delete
46
+ data.mfa_delete
47
+ end
48
+
49
+ # @!endgroup
50
+
51
+ # @return [Client]
52
+ def client
53
+ @client
54
+ end
55
+
56
+ # Loads, or reloads {#data} for the current {BucketVersioning}.
57
+ # Returns `self` making it possible to chain methods.
58
+ #
59
+ # bucket_versioning.reload.data
60
+ #
61
+ # @return [self]
62
+ def load
63
+ resp = @client.get_bucket_versioning(bucket: @bucket_name)
64
+ @data = resp.data
65
+ self
66
+ end
67
+ alias :reload :load
68
+
69
+ # @return [Types::GetBucketVersioningOutput]
70
+ # Returns the data for this {BucketVersioning}. Calls
71
+ # {Client#get_bucket_versioning} if {#data_loaded?} is `false`.
72
+ def data
73
+ load unless @data
74
+ @data
75
+ end
76
+
77
+ # @return [Boolean]
78
+ # Returns `true` if this resource is loaded. Accessing attributes or
79
+ # {#data} on an unloaded resource will trigger a call to {#load}.
80
+ def data_loaded?
81
+ !!@data
82
+ end
83
+
84
+ # @!group Actions
85
+
86
+ # @example Request syntax with placeholder values
87
+ #
88
+ # bucket_versioning.enable({
89
+ # content_md5: "ContentMD5",
90
+ # mfa: "MFA",
91
+ # })
92
+ # @param [Hash] options ({})
93
+ # @option options [String] :content_md5
94
+ # @option options [String] :mfa
95
+ # The concatenation of the authentication device's serial number, a
96
+ # space, and the value that is displayed on your authentication device.
97
+ # @return [EmptyStructure]
98
+ def enable(options = {})
99
+ options = Aws::Util.deep_merge(options,
100
+ bucket: @bucket_name,
101
+ versioning_configuration: {
102
+ status: "Enabled"
103
+ }
104
+ )
105
+ resp = @client.put_bucket_versioning(options)
106
+ resp.data
107
+ end
108
+
109
+ # @example Request syntax with placeholder values
110
+ #
111
+ # bucket_versioning.put({
112
+ # content_md5: "ContentMD5",
113
+ # mfa: "MFA",
114
+ # versioning_configuration: { # required
115
+ # mfa_delete: "Enabled", # accepts Enabled, Disabled
116
+ # status: "Enabled", # accepts Enabled, Suspended
117
+ # },
118
+ # })
119
+ # @param [Hash] options ({})
120
+ # @option options [String] :content_md5
121
+ # @option options [String] :mfa
122
+ # The concatenation of the authentication device's serial number, a
123
+ # space, and the value that is displayed on your authentication device.
124
+ # @option options [required, Types::VersioningConfiguration] :versioning_configuration
125
+ # @return [EmptyStructure]
126
+ def put(options = {})
127
+ options = options.merge(bucket: @bucket_name)
128
+ resp = @client.put_bucket_versioning(options)
129
+ resp.data
130
+ end
131
+
132
+ # @example Request syntax with placeholder values
133
+ #
134
+ # bucket_versioning.suspend({
135
+ # content_md5: "ContentMD5",
136
+ # mfa: "MFA",
137
+ # })
138
+ # @param [Hash] options ({})
139
+ # @option options [String] :content_md5
140
+ # @option options [String] :mfa
141
+ # The concatenation of the authentication device's serial number, a
142
+ # space, and the value that is displayed on your authentication device.
143
+ # @return [EmptyStructure]
144
+ def suspend(options = {})
145
+ options = Aws::Util.deep_merge(options,
146
+ bucket: @bucket_name,
147
+ versioning_configuration: {
148
+ status: "Suspended"
149
+ }
150
+ )
151
+ resp = @client.put_bucket_versioning(options)
152
+ resp.data
153
+ end
154
+
155
+ # @!group Associations
156
+
157
+ # @return [Bucket]
158
+ def bucket
159
+ Bucket.new(
160
+ name: @bucket_name,
161
+ client: @client
162
+ )
163
+ end
164
+
165
+ # @deprecated
166
+ # @api private
167
+ def identifiers
168
+ { bucket_name: @bucket_name }
169
+ end
170
+ deprecated(:identifiers)
171
+
172
+ private
173
+
174
+ def extract_bucket_name(args, options)
175
+ value = args[0] || options.delete(:bucket_name)
176
+ case value
177
+ when String then value
178
+ when nil then raise ArgumentError, "missing required option :bucket_name"
179
+ else
180
+ msg = "expected :bucket_name to be a String, got #{value.class}"
181
+ raise ArgumentError, msg
182
+ end
183
+ end
184
+
185
+ class Collection < Aws::Resources::Collection; end
186
+ end
187
+ end
188
+ end