qingstor-sdk 2.2.1 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +48 -4
- data/lib/qingstor/sdk/general/config.rb +2 -2
- data/lib/qingstor/sdk/general/logger.rb +1 -1
- data/lib/qingstor/sdk/request/preprocessor.rb +19 -1
- data/lib/qingstor/sdk/request/request.rb +5 -2
- data/lib/qingstor/sdk/request/signer.rb +5 -4
- data/lib/qingstor/sdk/service/bucket.rb +888 -73
- data/lib/qingstor/sdk/service/object.rb +300 -44
- data/lib/qingstor/sdk/service/qingstor.rb +13 -7
- data/lib/qingstor/sdk/version.rb +1 -1
- metadata +47 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cb83b84c4cd53131d0092b26061348057db9f2af57d1d4670bc5cef3b36c12b8
|
4
|
+
data.tar.gz: 0c2d01a2a0d134540e57e11cdeaef5f5547cb613b3b8a1ee5a2e531302391a15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf9f6e59304fa869921e5300b57560f5fae7728b9bb521a6ffc2d1d1d03783871dc03b68b9f08ffa875afef7a0210b237d518f8fd30d24260e6db14a766ce7ad
|
7
|
+
data.tar.gz: 394b4f14aea92f46e8b511dbbd283a4e08a9f7d28ef1f5f71e87e0eae63ee32c4bd30a172266638efd9a715fe81a70c91c7dec0c738dabec2eed1175c5376c45
|
data/README.md
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
# QingStor::SDK
|
2
2
|
|
3
|
-
|
4
|
-
[![Build Status](https://travis-ci.org/yunify/qingstor-sdk-ruby.svg?branch=master)](https://travis-ci.org/yunify/qingstor-sdk-ruby)
|
3
|
+
[![Build Status](https://github.com/qingstor/qingstor-sdk-ruby/workflows/Unit%20Test/badge.svg?branch=master)](https://github.com/qingstor/qingstor-sdk-ruby/actions?query=workflow%3A%22Unit+Test%22)
|
5
4
|
[![Gem Version](https://badge.fury.io/rb/qingstor-sdk.svg)](http://badge.fury.io/rb/qingstor-sdk)
|
6
5
|
[![API Reference](http://img.shields.io/badge/api-reference-green.svg)](https://docs.qingcloud.com/qingstor/)
|
7
6
|
[![License](http://img.shields.io/badge/license-apache%20v2-blue.svg)](https://github.com/yunify/qingstor-sdk-ruby/blob/master/LICENSE)
|
8
|
-
|
7
|
+
[![Join the chat](https://img.shields.io/badge/chat-online-blue?style=flat&logo=zulip)](https://qingstor.zulipchat.com/join/odapi42t7xhqc7v4gb2wfgjx/)
|
9
8
|
|
10
9
|
The official QingStor SDK for Ruby programming language.
|
11
10
|
|
@@ -169,11 +168,52 @@ log_level: 'warn'
|
|
169
168
|
## Change Log
|
170
169
|
All notable changes to QingStor SDK for Ruby will be documented here.
|
171
170
|
|
171
|
+
### [v2.4.0] - 2021-01-05
|
172
|
+
|
173
|
+
### Added
|
174
|
+
|
175
|
+
- Support to set x-qs-metadata-directive header (#29)
|
176
|
+
- Add support for bucket replication (#45)
|
177
|
+
|
178
|
+
### Changed
|
179
|
+
|
180
|
+
- ci: Transfer ci into github action (#30)
|
181
|
+
|
182
|
+
### Fixed
|
183
|
+
|
184
|
+
- Fix metadata added into signature when empty (#44)
|
185
|
+
|
186
|
+
### [v2.3.0] - 2020-05-11
|
187
|
+
|
188
|
+
### Added
|
189
|
+
|
190
|
+
- Add support for lifecycle and notification.
|
191
|
+
- Add support for bucket logging, bucket cname and append object. (#24)
|
192
|
+
|
193
|
+
### Fixed
|
194
|
+
|
195
|
+
- Modify content-type check for application/json. (#21)
|
196
|
+
- Fix sub-resources not be recognized when generate signature. (#25)
|
197
|
+
- Fix meta data not work as intended. (#26)
|
198
|
+
- Reverse fix of empty map in template, should not compact empty hash when sign. (#28)
|
199
|
+
|
200
|
+
### [v2.2.3] - 2017-03-28
|
201
|
+
|
202
|
+
### Fixed
|
203
|
+
|
204
|
+
- Fix status code of DELETE CORS API.
|
205
|
+
|
206
|
+
### [v2.2.2] - 2017-03-10
|
207
|
+
|
208
|
+
### Fixed
|
209
|
+
|
210
|
+
- Resource is not mandatory in bucket policy statement.
|
211
|
+
|
172
212
|
### [v2.2.1] - 2017-03-10
|
173
213
|
|
174
214
|
#### Added
|
175
215
|
|
176
|
-
- Allow user to append additional info to User-Agent
|
216
|
+
- Allow user to append additional info to User-Agent.
|
177
217
|
|
178
218
|
### [v2.2.0] - 2017-02-28
|
179
219
|
|
@@ -234,6 +274,10 @@ All notable changes to QingStor SDK for Ruby will be documented here.
|
|
234
274
|
The Apache License (Version 2.0, January 2004).
|
235
275
|
|
236
276
|
[compatible]: https://github.com/yunify/qingstor-sdk-ruby/tree/compatible
|
277
|
+
[v2.4.0]: https://github.com/yunify/qingstor-sdk-ruby/compare/v2.3.0...v2.4.0
|
278
|
+
[v2.3.0]: https://github.com/yunify/qingstor-sdk-ruby/compare/v2.2.3...v2.3.0
|
279
|
+
[v2.2.3]: https://github.com/yunify/qingstor-sdk-ruby/compare/v2.2.2...v2.2.3
|
280
|
+
[v2.2.2]: https://github.com/yunify/qingstor-sdk-ruby/compare/v2.2.1...v2.2.2
|
237
281
|
[v2.2.1]: https://github.com/yunify/qingstor-sdk-ruby/compare/v2.2.0...v2.2.1
|
238
282
|
[v2.2.0]: https://github.com/yunify/qingstor-sdk-ruby/compare/v2.1.1...v2.2.0
|
239
283
|
[v2.1.1]: https://github.com/yunify/qingstor-sdk-ruby/compare/v2.1.0...v2.1.1
|
@@ -29,7 +29,7 @@ module QingStor
|
|
29
29
|
def self.init(access_key_id, secret_access_key)
|
30
30
|
initial_config = {
|
31
31
|
access_key_id: access_key_id,
|
32
|
-
secret_access_key: secret_access_key
|
32
|
+
secret_access_key: secret_access_key
|
33
33
|
}
|
34
34
|
Config.new(initial_config)
|
35
35
|
end
|
@@ -47,7 +47,7 @@ module QingStor
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def check
|
50
|
-
[
|
50
|
+
%i[access_key_id secret_access_key host port protocol].each do |x|
|
51
51
|
if !self[x] || self[x].to_s.empty?
|
52
52
|
raise ConfigurationError, "#{x.to_sym} not specified"
|
53
53
|
end
|
@@ -23,7 +23,7 @@ module QingStor
|
|
23
23
|
@@level = :warn
|
24
24
|
|
25
25
|
def self.set_level(level)
|
26
|
-
index = %w
|
26
|
+
index = %w[debug info warn error fatal].find_index level.to_s
|
27
27
|
@@logger.level = index.nil? ? 0 : index
|
28
28
|
@@level = level.to_sym
|
29
29
|
end
|
@@ -102,6 +102,24 @@ module QingStor
|
|
102
102
|
input[:request_headers][:'Content-MD5'] = Base64.encode64(Digest::MD5.digest(input[:request_body])).strip
|
103
103
|
end
|
104
104
|
|
105
|
+
unless input[:request_headers][:'X-QS-MetaData'].nil?
|
106
|
+
if input[:request_headers][:'X-QS-MetaData'].is_a?(Hash) && !input[:request_headers][:'X-QS-MetaData'].empty?
|
107
|
+
prefix = 'x-qs-meta-'
|
108
|
+
input[:request_headers][:'X-QS-MetaData'].each do |k, v|
|
109
|
+
k = k.to_s
|
110
|
+
# check whether meta header has prefix
|
111
|
+
if k.downcase.start_with? prefix
|
112
|
+
suffix_len = prefix.size - k.size
|
113
|
+
k = prefix + k[suffix_len, -suffix_len]
|
114
|
+
else
|
115
|
+
k = prefix + k
|
116
|
+
end
|
117
|
+
input[:request_headers][:"#{k}"] = v
|
118
|
+
end
|
119
|
+
end
|
120
|
+
input[:request_headers].delete :'X-QS-MetaData'
|
121
|
+
end
|
122
|
+
|
105
123
|
input[:request_headers].map do |k, v|
|
106
124
|
input[:request_headers][k] = escape v.to_s unless v.to_s.ascii_only?
|
107
125
|
end
|
@@ -127,7 +145,7 @@ module QingStor
|
|
127
145
|
def self.compact(object)
|
128
146
|
object.each do |k, v|
|
129
147
|
object[k] = compact v if v.is_a? Hash
|
130
|
-
object.delete k if v.nil? || v == ''
|
148
|
+
object.delete k if v.nil? || v == '' || v == []
|
131
149
|
end
|
132
150
|
object
|
133
151
|
end
|
@@ -62,7 +62,10 @@ module QingStor
|
|
62
62
|
|
63
63
|
def build
|
64
64
|
params = input[:request_params].map { |k, v| "#{k}=#{v}" }
|
65
|
-
query_string =
|
65
|
+
query_string = params.join '&'
|
66
|
+
if query_string && !query_string.empty?
|
67
|
+
query_string = "#{input[:request_uri].include?('?') ? '&' : '?'}#{query_string}"
|
68
|
+
end
|
66
69
|
self.request_url = "#{input[:request_endpoint]}#{input[:request_uri]}#{query_string}"
|
67
70
|
|
68
71
|
request = new_http_request input[:request_method], request_url
|
@@ -77,7 +80,7 @@ module QingStor
|
|
77
80
|
output['status_code'] = http_response.code.to_i
|
78
81
|
|
79
82
|
http_response.each_header { |k, v| output[k.tr('-', '_')] = v }
|
80
|
-
if http_response['Content-Type']
|
83
|
+
if http_response['Content-Type'].include? 'application/json'
|
81
84
|
unless http_response.body.nil?
|
82
85
|
JSON.parse(http_response.body).each { |k, v| output[k] = v }
|
83
86
|
end
|
@@ -83,7 +83,7 @@ module QingStor
|
|
83
83
|
def self.canonicalized_headers(input)
|
84
84
|
h = {}
|
85
85
|
input[:request_headers].each { |k, v| h[k.to_s.strip.downcase] = v.to_s.strip }
|
86
|
-
h.keys.sort.
|
86
|
+
h.keys.sort.select { |k| k.start_with? 'x-qs-' }.map { |k| "#{k}:#{h[k]}\n" }.join ''
|
87
87
|
end
|
88
88
|
|
89
89
|
def self.canonicalized_resource(input)
|
@@ -98,11 +98,12 @@ module QingStor
|
|
98
98
|
end
|
99
99
|
|
100
100
|
def self.sub_resource?(key)
|
101
|
-
%w
|
102
|
-
acl cors delete
|
101
|
+
%w[
|
102
|
+
acl append cname cors delete image lifecycle logging mirror
|
103
|
+
notification part_number policy position stats upload_id uploads
|
103
104
|
response-expires response-cache-control response-content-type
|
104
105
|
response-content-language response-content-encoding response-content-disposition
|
105
|
-
|
106
|
+
].include? key
|
106
107
|
end
|
107
108
|
end
|
108
109
|
end
|
@@ -47,9 +47,10 @@ module QingStor
|
|
47
47
|
request_elements: {
|
48
48
|
},
|
49
49
|
request_body: nil,
|
50
|
+
|
50
51
|
status_code: [
|
51
|
-
204
|
52
|
-
]
|
52
|
+
204
|
53
|
+
]
|
53
54
|
}
|
54
55
|
|
55
56
|
delete_bucket_input_validate input
|
@@ -64,6 +65,50 @@ module QingStor
|
|
64
65
|
|
65
66
|
public
|
66
67
|
|
68
|
+
# delete_bucket_cname: Delete bucket CNAME setting of the bucket.
|
69
|
+
# Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/cname/delete_cname.html
|
70
|
+
def delete_cname(domain: '')
|
71
|
+
request = delete_cname_request domain: domain
|
72
|
+
request.send
|
73
|
+
end
|
74
|
+
|
75
|
+
def delete_cname_request(domain: '')
|
76
|
+
input = {
|
77
|
+
config: config,
|
78
|
+
properties: properties,
|
79
|
+
api_name: 'DELETE Bucket CNAME',
|
80
|
+
request_method: 'DELETE',
|
81
|
+
request_uri: '/<bucket-name>?cname',
|
82
|
+
request_params: {
|
83
|
+
},
|
84
|
+
request_headers: {
|
85
|
+
},
|
86
|
+
request_elements: {
|
87
|
+
'domain' => domain
|
88
|
+
},
|
89
|
+
request_body: nil,
|
90
|
+
|
91
|
+
status_code: [
|
92
|
+
204
|
93
|
+
]
|
94
|
+
}
|
95
|
+
|
96
|
+
delete_bucket_cname_input_validate input
|
97
|
+
Request.new input
|
98
|
+
end
|
99
|
+
|
100
|
+
private
|
101
|
+
|
102
|
+
def delete_bucket_cname_input_validate(input)
|
103
|
+
input.deep_stringify_keys!
|
104
|
+
|
105
|
+
unless !input['request_elements']['domain'].nil? && !input['request_elements']['domain'].to_s.empty?
|
106
|
+
raise ParameterRequiredError.new('domain', 'DeleteBucketCNAMEInput')
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
public
|
111
|
+
|
67
112
|
# delete_bucket_cors: Delete CORS information of the bucket.
|
68
113
|
# Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/cors/delete_cors.html
|
69
114
|
def delete_cors
|
@@ -85,9 +130,10 @@ module QingStor
|
|
85
130
|
request_elements: {
|
86
131
|
},
|
87
132
|
request_body: nil,
|
133
|
+
|
88
134
|
status_code: [
|
89
|
-
|
90
|
-
]
|
135
|
+
204
|
136
|
+
]
|
91
137
|
}
|
92
138
|
|
93
139
|
delete_bucket_cors_input_validate input
|
@@ -123,9 +169,10 @@ module QingStor
|
|
123
169
|
request_elements: {
|
124
170
|
},
|
125
171
|
request_body: nil,
|
172
|
+
|
126
173
|
status_code: [
|
127
|
-
204
|
128
|
-
]
|
174
|
+
204
|
175
|
+
]
|
129
176
|
}
|
130
177
|
|
131
178
|
delete_bucket_external_mirror_input_validate input
|
@@ -140,6 +187,123 @@ module QingStor
|
|
140
187
|
|
141
188
|
public
|
142
189
|
|
190
|
+
# delete_bucket_lifecycle: Delete Lifecycle information of the bucket.
|
191
|
+
# Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/lifecycle/delete_lifecycle.html
|
192
|
+
def delete_lifecycle
|
193
|
+
request = delete_lifecycle_request
|
194
|
+
request.send
|
195
|
+
end
|
196
|
+
|
197
|
+
def delete_lifecycle_request
|
198
|
+
input = {
|
199
|
+
config: config,
|
200
|
+
properties: properties,
|
201
|
+
api_name: 'DELETE Bucket Lifecycle',
|
202
|
+
request_method: 'DELETE',
|
203
|
+
request_uri: '/<bucket-name>?lifecycle',
|
204
|
+
request_params: {
|
205
|
+
},
|
206
|
+
request_headers: {
|
207
|
+
},
|
208
|
+
request_elements: {
|
209
|
+
},
|
210
|
+
request_body: nil,
|
211
|
+
|
212
|
+
status_code: [
|
213
|
+
204
|
214
|
+
]
|
215
|
+
}
|
216
|
+
|
217
|
+
delete_bucket_lifecycle_input_validate input
|
218
|
+
Request.new input
|
219
|
+
end
|
220
|
+
|
221
|
+
private
|
222
|
+
|
223
|
+
def delete_bucket_lifecycle_input_validate(input)
|
224
|
+
input.deep_stringify_keys!
|
225
|
+
end
|
226
|
+
|
227
|
+
public
|
228
|
+
|
229
|
+
# delete_bucket_logging: Delete bucket logging setting of the bucket.
|
230
|
+
# Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/logging/delete_logging.html
|
231
|
+
def delete_logging
|
232
|
+
request = delete_logging_request
|
233
|
+
request.send
|
234
|
+
end
|
235
|
+
|
236
|
+
def delete_logging_request
|
237
|
+
input = {
|
238
|
+
config: config,
|
239
|
+
properties: properties,
|
240
|
+
api_name: 'DELETE Bucket Logging',
|
241
|
+
request_method: 'DELETE',
|
242
|
+
request_uri: '/<bucket-name>?logging',
|
243
|
+
request_params: {
|
244
|
+
},
|
245
|
+
request_headers: {
|
246
|
+
},
|
247
|
+
request_elements: {
|
248
|
+
},
|
249
|
+
request_body: nil,
|
250
|
+
|
251
|
+
status_code: [
|
252
|
+
204
|
253
|
+
]
|
254
|
+
}
|
255
|
+
|
256
|
+
delete_bucket_logging_input_validate input
|
257
|
+
Request.new input
|
258
|
+
end
|
259
|
+
|
260
|
+
private
|
261
|
+
|
262
|
+
def delete_bucket_logging_input_validate(input)
|
263
|
+
input.deep_stringify_keys!
|
264
|
+
end
|
265
|
+
|
266
|
+
public
|
267
|
+
|
268
|
+
# delete_bucket_notification: Delete Notification information of the bucket.
|
269
|
+
# Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/notification/delete_notification.html
|
270
|
+
def delete_notification
|
271
|
+
request = delete_notification_request
|
272
|
+
request.send
|
273
|
+
end
|
274
|
+
|
275
|
+
def delete_notification_request
|
276
|
+
input = {
|
277
|
+
config: config,
|
278
|
+
properties: properties,
|
279
|
+
api_name: 'DELETE Bucket Notification',
|
280
|
+
request_method: 'DELETE',
|
281
|
+
request_uri: '/<bucket-name>?notification',
|
282
|
+
request_params: {
|
283
|
+
},
|
284
|
+
request_headers: {
|
285
|
+
},
|
286
|
+
request_elements: {
|
287
|
+
},
|
288
|
+
request_body: nil,
|
289
|
+
|
290
|
+
status_code: [
|
291
|
+
204
|
292
|
+
]
|
293
|
+
}
|
294
|
+
|
295
|
+
delete_bucket_notification_input_validate input
|
296
|
+
Request.new input
|
297
|
+
end
|
298
|
+
|
299
|
+
private
|
300
|
+
|
301
|
+
def delete_bucket_notification_input_validate(input)
|
302
|
+
input.deep_stringify_keys!
|
303
|
+
end
|
304
|
+
|
305
|
+
public
|
306
|
+
|
143
307
|
# delete_bucket_policy: Delete policy information of the bucket.
|
144
308
|
# Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/policy/delete_policy.html
|
145
309
|
def delete_policy
|
@@ -161,9 +325,10 @@ module QingStor
|
|
161
325
|
request_elements: {
|
162
326
|
},
|
163
327
|
request_body: nil,
|
328
|
+
|
164
329
|
status_code: [
|
165
|
-
204
|
166
|
-
]
|
330
|
+
204
|
331
|
+
]
|
167
332
|
}
|
168
333
|
|
169
334
|
delete_bucket_policy_input_validate input
|
@@ -178,6 +343,45 @@ module QingStor
|
|
178
343
|
|
179
344
|
public
|
180
345
|
|
346
|
+
# delete_bucket_replication: Delete Replication information of the bucket.
|
347
|
+
# Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/replication/delete_replication.html
|
348
|
+
def delete_replication
|
349
|
+
request = delete_replication_request
|
350
|
+
request.send
|
351
|
+
end
|
352
|
+
|
353
|
+
def delete_replication_request
|
354
|
+
input = {
|
355
|
+
config: config,
|
356
|
+
properties: properties,
|
357
|
+
api_name: 'DELETE Bucket Replication',
|
358
|
+
request_method: 'DELETE',
|
359
|
+
request_uri: '/<bucket-name>?replication',
|
360
|
+
request_params: {
|
361
|
+
},
|
362
|
+
request_headers: {
|
363
|
+
},
|
364
|
+
request_elements: {
|
365
|
+
},
|
366
|
+
request_body: nil,
|
367
|
+
|
368
|
+
status_code: [
|
369
|
+
204
|
370
|
+
]
|
371
|
+
}
|
372
|
+
|
373
|
+
delete_bucket_replication_input_validate input
|
374
|
+
Request.new input
|
375
|
+
end
|
376
|
+
|
377
|
+
private
|
378
|
+
|
379
|
+
def delete_bucket_replication_input_validate(input)
|
380
|
+
input.deep_stringify_keys!
|
381
|
+
end
|
382
|
+
|
383
|
+
public
|
384
|
+
|
181
385
|
# delete_multiple_objects: Delete multiple objects from the bucket.
|
182
386
|
# Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/delete_multiple.html
|
183
387
|
def delete_multiple_objects(objects: [],
|
@@ -201,12 +405,13 @@ module QingStor
|
|
201
405
|
},
|
202
406
|
request_elements: {
|
203
407
|
'objects' => objects,
|
204
|
-
'quiet' => quiet
|
408
|
+
'quiet' => quiet
|
205
409
|
},
|
206
410
|
request_body: nil,
|
411
|
+
|
207
412
|
status_code: [
|
208
|
-
200
|
209
|
-
]
|
413
|
+
200
|
414
|
+
]
|
210
415
|
}
|
211
416
|
|
212
417
|
delete_multiple_objects_input_validate input
|
@@ -218,7 +423,7 @@ module QingStor
|
|
218
423
|
def delete_multiple_objects_input_validate(input)
|
219
424
|
input.deep_stringify_keys!
|
220
425
|
|
221
|
-
unless !input['request_elements']['objects'].nil? && !input['request_elements']['objects'].
|
426
|
+
unless !input['request_elements']['objects'].nil? && !input['request_elements']['objects'].empty?
|
222
427
|
raise ParameterRequiredError.new('objects', 'DeleteMultipleObjectsInput')
|
223
428
|
end
|
224
429
|
|
@@ -249,9 +454,10 @@ module QingStor
|
|
249
454
|
request_elements: {
|
250
455
|
},
|
251
456
|
request_body: nil,
|
457
|
+
|
252
458
|
status_code: [
|
253
|
-
200
|
254
|
-
]
|
459
|
+
200
|
460
|
+
]
|
255
461
|
}
|
256
462
|
|
257
463
|
get_bucket_acl_input_validate input
|
@@ -266,6 +472,57 @@ module QingStor
|
|
266
472
|
|
267
473
|
public
|
268
474
|
|
475
|
+
# get_bucket_cname: Get bucket CNAME setting of the bucket.
|
476
|
+
# Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/cname/get_cname.html
|
477
|
+
def get_cname(type: '')
|
478
|
+
request = get_cname_request type: type
|
479
|
+
request.send
|
480
|
+
end
|
481
|
+
|
482
|
+
def get_cname_request(type: '')
|
483
|
+
input = {
|
484
|
+
config: config,
|
485
|
+
properties: properties,
|
486
|
+
api_name: 'GET Bucket CNAME',
|
487
|
+
request_method: 'GET',
|
488
|
+
request_uri: '/<bucket-name>?cname',
|
489
|
+
request_params: {
|
490
|
+
'type' => type
|
491
|
+
},
|
492
|
+
request_headers: {
|
493
|
+
},
|
494
|
+
request_elements: {
|
495
|
+
},
|
496
|
+
request_body: nil,
|
497
|
+
|
498
|
+
status_code: [
|
499
|
+
200
|
500
|
+
]
|
501
|
+
}
|
502
|
+
|
503
|
+
get_bucket_cname_input_validate input
|
504
|
+
Request.new input
|
505
|
+
end
|
506
|
+
|
507
|
+
private
|
508
|
+
|
509
|
+
def get_bucket_cname_input_validate(input)
|
510
|
+
input.deep_stringify_keys!
|
511
|
+
|
512
|
+
if input['request_params']['type'] && !input['request_params']['type'].to_s.empty?
|
513
|
+
type_valid_values = %w[website normal]
|
514
|
+
unless type_valid_values.include? input['request_params']['type'].to_s
|
515
|
+
raise ParameterValueNotAllowedError.new(
|
516
|
+
'type',
|
517
|
+
input['request_params']['type'],
|
518
|
+
type_valid_values,
|
519
|
+
)
|
520
|
+
end
|
521
|
+
end
|
522
|
+
end
|
523
|
+
|
524
|
+
public
|
525
|
+
|
269
526
|
# get_bucket_cors: Get CORS information of the bucket.
|
270
527
|
# Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/cors/get_cors.html
|
271
528
|
def get_cors
|
@@ -287,9 +544,10 @@ module QingStor
|
|
287
544
|
request_elements: {
|
288
545
|
},
|
289
546
|
request_body: nil,
|
547
|
+
|
290
548
|
status_code: [
|
291
|
-
200
|
292
|
-
]
|
549
|
+
200
|
550
|
+
]
|
293
551
|
}
|
294
552
|
|
295
553
|
get_bucket_cors_input_validate input
|
@@ -325,9 +583,10 @@ module QingStor
|
|
325
583
|
request_elements: {
|
326
584
|
},
|
327
585
|
request_body: nil,
|
586
|
+
|
328
587
|
status_code: [
|
329
|
-
200
|
330
|
-
]
|
588
|
+
200
|
589
|
+
]
|
331
590
|
}
|
332
591
|
|
333
592
|
get_bucket_external_mirror_input_validate input
|
@@ -342,6 +601,123 @@ module QingStor
|
|
342
601
|
|
343
602
|
public
|
344
603
|
|
604
|
+
# get_bucket_lifecycle: Get Lifecycle information of the bucket.
|
605
|
+
# Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/lifecycle/get_lifecycle.html
|
606
|
+
def get_lifecycle
|
607
|
+
request = get_lifecycle_request
|
608
|
+
request.send
|
609
|
+
end
|
610
|
+
|
611
|
+
def get_lifecycle_request
|
612
|
+
input = {
|
613
|
+
config: config,
|
614
|
+
properties: properties,
|
615
|
+
api_name: 'GET Bucket Lifecycle',
|
616
|
+
request_method: 'GET',
|
617
|
+
request_uri: '/<bucket-name>?lifecycle',
|
618
|
+
request_params: {
|
619
|
+
},
|
620
|
+
request_headers: {
|
621
|
+
},
|
622
|
+
request_elements: {
|
623
|
+
},
|
624
|
+
request_body: nil,
|
625
|
+
|
626
|
+
status_code: [
|
627
|
+
200
|
628
|
+
]
|
629
|
+
}
|
630
|
+
|
631
|
+
get_bucket_lifecycle_input_validate input
|
632
|
+
Request.new input
|
633
|
+
end
|
634
|
+
|
635
|
+
private
|
636
|
+
|
637
|
+
def get_bucket_lifecycle_input_validate(input)
|
638
|
+
input.deep_stringify_keys!
|
639
|
+
end
|
640
|
+
|
641
|
+
public
|
642
|
+
|
643
|
+
# get_bucket_logging: Get bucket logging setting of the bucket.
|
644
|
+
# Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/logging/get_logging.html
|
645
|
+
def get_logging
|
646
|
+
request = get_logging_request
|
647
|
+
request.send
|
648
|
+
end
|
649
|
+
|
650
|
+
def get_logging_request
|
651
|
+
input = {
|
652
|
+
config: config,
|
653
|
+
properties: properties,
|
654
|
+
api_name: 'GET Bucket Logging',
|
655
|
+
request_method: 'GET',
|
656
|
+
request_uri: '/<bucket-name>?logging',
|
657
|
+
request_params: {
|
658
|
+
},
|
659
|
+
request_headers: {
|
660
|
+
},
|
661
|
+
request_elements: {
|
662
|
+
},
|
663
|
+
request_body: nil,
|
664
|
+
|
665
|
+
status_code: [
|
666
|
+
200
|
667
|
+
]
|
668
|
+
}
|
669
|
+
|
670
|
+
get_bucket_logging_input_validate input
|
671
|
+
Request.new input
|
672
|
+
end
|
673
|
+
|
674
|
+
private
|
675
|
+
|
676
|
+
def get_bucket_logging_input_validate(input)
|
677
|
+
input.deep_stringify_keys!
|
678
|
+
end
|
679
|
+
|
680
|
+
public
|
681
|
+
|
682
|
+
# get_bucket_notification: Get Notification information of the bucket.
|
683
|
+
# Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/notification/get_notification.html
|
684
|
+
def get_notification
|
685
|
+
request = get_notification_request
|
686
|
+
request.send
|
687
|
+
end
|
688
|
+
|
689
|
+
def get_notification_request
|
690
|
+
input = {
|
691
|
+
config: config,
|
692
|
+
properties: properties,
|
693
|
+
api_name: 'GET Bucket Notification',
|
694
|
+
request_method: 'GET',
|
695
|
+
request_uri: '/<bucket-name>?notification',
|
696
|
+
request_params: {
|
697
|
+
},
|
698
|
+
request_headers: {
|
699
|
+
},
|
700
|
+
request_elements: {
|
701
|
+
},
|
702
|
+
request_body: nil,
|
703
|
+
|
704
|
+
status_code: [
|
705
|
+
200
|
706
|
+
]
|
707
|
+
}
|
708
|
+
|
709
|
+
get_bucket_notification_input_validate input
|
710
|
+
Request.new input
|
711
|
+
end
|
712
|
+
|
713
|
+
private
|
714
|
+
|
715
|
+
def get_bucket_notification_input_validate(input)
|
716
|
+
input.deep_stringify_keys!
|
717
|
+
end
|
718
|
+
|
719
|
+
public
|
720
|
+
|
345
721
|
# get_bucket_policy: Get policy information of the bucket.
|
346
722
|
# Documentation URL: https://https://docs.qingcloud.com/qingstor/api/bucket/policy/get_policy.html
|
347
723
|
def get_policy
|
@@ -349,13 +725,52 @@ module QingStor
|
|
349
725
|
request.send
|
350
726
|
end
|
351
727
|
|
352
|
-
def get_policy_request
|
728
|
+
def get_policy_request
|
729
|
+
input = {
|
730
|
+
config: config,
|
731
|
+
properties: properties,
|
732
|
+
api_name: 'GET Bucket Policy',
|
733
|
+
request_method: 'GET',
|
734
|
+
request_uri: '/<bucket-name>?policy',
|
735
|
+
request_params: {
|
736
|
+
},
|
737
|
+
request_headers: {
|
738
|
+
},
|
739
|
+
request_elements: {
|
740
|
+
},
|
741
|
+
request_body: nil,
|
742
|
+
|
743
|
+
status_code: [
|
744
|
+
200
|
745
|
+
]
|
746
|
+
}
|
747
|
+
|
748
|
+
get_bucket_policy_input_validate input
|
749
|
+
Request.new input
|
750
|
+
end
|
751
|
+
|
752
|
+
private
|
753
|
+
|
754
|
+
def get_bucket_policy_input_validate(input)
|
755
|
+
input.deep_stringify_keys!
|
756
|
+
end
|
757
|
+
|
758
|
+
public
|
759
|
+
|
760
|
+
# get_bucket_replication: Get Replication information of the bucket.
|
761
|
+
# Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/replication/get_replication.html
|
762
|
+
def get_replication
|
763
|
+
request = get_replication_request
|
764
|
+
request.send
|
765
|
+
end
|
766
|
+
|
767
|
+
def get_replication_request
|
353
768
|
input = {
|
354
769
|
config: config,
|
355
770
|
properties: properties,
|
356
|
-
api_name: 'GET Bucket
|
771
|
+
api_name: 'GET Bucket Replication',
|
357
772
|
request_method: 'GET',
|
358
|
-
request_uri: '/<bucket-name>?
|
773
|
+
request_uri: '/<bucket-name>?replication',
|
359
774
|
request_params: {
|
360
775
|
},
|
361
776
|
request_headers: {
|
@@ -363,18 +778,19 @@ module QingStor
|
|
363
778
|
request_elements: {
|
364
779
|
},
|
365
780
|
request_body: nil,
|
781
|
+
|
366
782
|
status_code: [
|
367
|
-
200
|
368
|
-
]
|
783
|
+
200
|
784
|
+
]
|
369
785
|
}
|
370
786
|
|
371
|
-
|
787
|
+
get_bucket_replication_input_validate input
|
372
788
|
Request.new input
|
373
789
|
end
|
374
790
|
|
375
791
|
private
|
376
792
|
|
377
|
-
def
|
793
|
+
def get_bucket_replication_input_validate(input)
|
378
794
|
input.deep_stringify_keys!
|
379
795
|
end
|
380
796
|
|
@@ -401,9 +817,10 @@ module QingStor
|
|
401
817
|
request_elements: {
|
402
818
|
},
|
403
819
|
request_body: nil,
|
820
|
+
|
404
821
|
status_code: [
|
405
|
-
200
|
406
|
-
]
|
822
|
+
200
|
823
|
+
]
|
407
824
|
}
|
408
825
|
|
409
826
|
get_bucket_statistics_input_validate input
|
@@ -439,9 +856,10 @@ module QingStor
|
|
439
856
|
request_elements: {
|
440
857
|
},
|
441
858
|
request_body: nil,
|
859
|
+
|
442
860
|
status_code: [
|
443
|
-
200
|
444
|
-
]
|
861
|
+
200
|
862
|
+
]
|
445
863
|
}
|
446
864
|
|
447
865
|
head_bucket_input_validate input
|
@@ -459,20 +877,23 @@ module QingStor
|
|
459
877
|
# list_multipart_uploads: List multipart uploads in the bucket.
|
460
878
|
# Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/list_multipart_uploads.html
|
461
879
|
def list_multipart_uploads(delimiter: '',
|
880
|
+
key_marker: '',
|
462
881
|
limit: nil,
|
463
|
-
|
464
|
-
|
465
|
-
request = list_multipart_uploads_request delimiter:
|
466
|
-
|
467
|
-
|
468
|
-
prefix:
|
882
|
+
prefix: '',
|
883
|
+
upload_id_marker: '')
|
884
|
+
request = list_multipart_uploads_request delimiter: delimiter,
|
885
|
+
key_marker: key_marker,
|
886
|
+
limit: limit,
|
887
|
+
prefix: prefix,
|
888
|
+
upload_id_marker: upload_id_marker
|
469
889
|
request.send
|
470
890
|
end
|
471
891
|
|
472
892
|
def list_multipart_uploads_request(delimiter: '',
|
893
|
+
key_marker: '',
|
473
894
|
limit: nil,
|
474
|
-
|
475
|
-
|
895
|
+
prefix: '',
|
896
|
+
upload_id_marker: '')
|
476
897
|
input = {
|
477
898
|
config: config,
|
478
899
|
properties: properties,
|
@@ -480,19 +901,21 @@ module QingStor
|
|
480
901
|
request_method: 'GET',
|
481
902
|
request_uri: '/<bucket-name>?uploads',
|
482
903
|
request_params: {
|
483
|
-
'delimiter'
|
484
|
-
'
|
485
|
-
'
|
486
|
-
'prefix'
|
904
|
+
'delimiter' => delimiter,
|
905
|
+
'key_marker' => key_marker,
|
906
|
+
'limit' => limit,
|
907
|
+
'prefix' => prefix,
|
908
|
+
'upload_id_marker' => upload_id_marker
|
487
909
|
},
|
488
910
|
request_headers: {
|
489
911
|
},
|
490
912
|
request_elements: {
|
491
913
|
},
|
492
914
|
request_body: nil,
|
915
|
+
|
493
916
|
status_code: [
|
494
|
-
200
|
495
|
-
]
|
917
|
+
200
|
918
|
+
]
|
496
919
|
}
|
497
920
|
|
498
921
|
list_multipart_uploads_input_validate input
|
@@ -534,16 +957,17 @@ module QingStor
|
|
534
957
|
'delimiter' => delimiter,
|
535
958
|
'limit' => limit,
|
536
959
|
'marker' => marker,
|
537
|
-
'prefix' => prefix
|
960
|
+
'prefix' => prefix
|
538
961
|
},
|
539
962
|
request_headers: {
|
540
963
|
},
|
541
964
|
request_elements: {
|
542
965
|
},
|
543
966
|
request_body: nil,
|
967
|
+
|
544
968
|
status_code: [
|
545
|
-
200
|
546
|
-
]
|
969
|
+
200
|
970
|
+
]
|
547
971
|
}
|
548
972
|
|
549
973
|
list_objects_input_validate input
|
@@ -579,9 +1003,10 @@ module QingStor
|
|
579
1003
|
request_elements: {
|
580
1004
|
},
|
581
1005
|
request_body: nil,
|
1006
|
+
|
582
1007
|
status_code: [
|
583
|
-
201
|
584
|
-
]
|
1008
|
+
201
|
1009
|
+
]
|
585
1010
|
}
|
586
1011
|
|
587
1012
|
put_bucket_input_validate input
|
@@ -615,12 +1040,13 @@ module QingStor
|
|
615
1040
|
request_headers: {
|
616
1041
|
},
|
617
1042
|
request_elements: {
|
618
|
-
'acl' => acl
|
1043
|
+
'acl' => acl
|
619
1044
|
},
|
620
1045
|
request_body: nil,
|
1046
|
+
|
621
1047
|
status_code: [
|
622
|
-
200
|
623
|
-
]
|
1048
|
+
200
|
1049
|
+
]
|
624
1050
|
}
|
625
1051
|
|
626
1052
|
put_bucket_acl_input_validate input
|
@@ -632,7 +1058,7 @@ module QingStor
|
|
632
1058
|
def put_bucket_acl_input_validate(input)
|
633
1059
|
input.deep_stringify_keys!
|
634
1060
|
|
635
|
-
unless !input['request_elements']['acl'].nil? && !input['request_elements']['acl'].
|
1061
|
+
unless !input['request_elements']['acl'].nil? && !input['request_elements']['acl'].empty?
|
636
1062
|
raise ParameterRequiredError.new('acl', 'PutBucketACLInput')
|
637
1063
|
end
|
638
1064
|
|
@@ -644,7 +1070,7 @@ module QingStor
|
|
644
1070
|
end
|
645
1071
|
|
646
1072
|
if x['grantee']['type'] && !x['grantee']['type'].to_s.empty?
|
647
|
-
type_valid_values = %w
|
1073
|
+
type_valid_values = %w[user group]
|
648
1074
|
unless type_valid_values.include? x['grantee']['type'].to_s
|
649
1075
|
raise ParameterValueNotAllowedError.new(
|
650
1076
|
'type',
|
@@ -656,15 +1082,19 @@ module QingStor
|
|
656
1082
|
|
657
1083
|
end
|
658
1084
|
|
659
|
-
|
1085
|
+
if x['grantee'].nil?
|
1086
|
+
raise ParameterRequiredError.new('grantee', 'acl')
|
1087
|
+
end
|
660
1088
|
|
661
1089
|
unless !x['permission'].nil? && !x['permission'].to_s.empty?
|
662
1090
|
raise ParameterRequiredError.new('permission', 'acl')
|
663
1091
|
end
|
664
1092
|
|
665
1093
|
next unless x['permission'] && !x['permission'].to_s.empty?
|
666
|
-
|
1094
|
+
|
1095
|
+
permission_valid_values = %w[READ WRITE FULL_CONTROL]
|
667
1096
|
next if permission_valid_values.include? x['permission'].to_s
|
1097
|
+
|
668
1098
|
raise ParameterValueNotAllowedError.new(
|
669
1099
|
'permission',
|
670
1100
|
x['permission'],
|
@@ -675,6 +1105,65 @@ module QingStor
|
|
675
1105
|
|
676
1106
|
public
|
677
1107
|
|
1108
|
+
# put_bucket_cname: Set bucket CNAME of the bucket.
|
1109
|
+
# Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/cname/put_cname.html
|
1110
|
+
def put_cname(domain: '',
|
1111
|
+
type: '')
|
1112
|
+
request = put_cname_request domain: domain,
|
1113
|
+
type: type
|
1114
|
+
request.send
|
1115
|
+
end
|
1116
|
+
|
1117
|
+
def put_cname_request(domain: '',
|
1118
|
+
type: '')
|
1119
|
+
input = {
|
1120
|
+
config: config,
|
1121
|
+
properties: properties,
|
1122
|
+
api_name: 'PUT Bucket CNAME',
|
1123
|
+
request_method: 'PUT',
|
1124
|
+
request_uri: '/<bucket-name>?cname',
|
1125
|
+
request_params: {
|
1126
|
+
},
|
1127
|
+
request_headers: {
|
1128
|
+
},
|
1129
|
+
request_elements: {
|
1130
|
+
'domain' => domain,
|
1131
|
+
'type' => type
|
1132
|
+
},
|
1133
|
+
request_body: nil,
|
1134
|
+
|
1135
|
+
status_code: [
|
1136
|
+
200
|
1137
|
+
]
|
1138
|
+
}
|
1139
|
+
|
1140
|
+
put_bucket_cname_input_validate input
|
1141
|
+
Request.new input
|
1142
|
+
end
|
1143
|
+
|
1144
|
+
private
|
1145
|
+
|
1146
|
+
def put_bucket_cname_input_validate(input)
|
1147
|
+
input.deep_stringify_keys!
|
1148
|
+
|
1149
|
+
unless !input['request_elements']['domain'].nil? && !input['request_elements']['domain'].to_s.empty?
|
1150
|
+
raise ParameterRequiredError.new('domain', 'PutBucketCNAMEInput')
|
1151
|
+
end
|
1152
|
+
|
1153
|
+
if input['request_elements']['type'] && !input['request_elements']['type'].to_s.empty?
|
1154
|
+
type_valid_values = %w[normal website]
|
1155
|
+
unless type_valid_values.include? input['request_elements']['type'].to_s
|
1156
|
+
raise ParameterValueNotAllowedError.new(
|
1157
|
+
'type',
|
1158
|
+
input['request_elements']['type'],
|
1159
|
+
type_valid_values,
|
1160
|
+
)
|
1161
|
+
end
|
1162
|
+
end
|
1163
|
+
end
|
1164
|
+
|
1165
|
+
public
|
1166
|
+
|
678
1167
|
# put_bucket_cors: Set CORS information of the bucket.
|
679
1168
|
# Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/cors/put_cors.html
|
680
1169
|
def put_cors(cors_rules: [])
|
@@ -694,12 +1183,13 @@ module QingStor
|
|
694
1183
|
request_headers: {
|
695
1184
|
},
|
696
1185
|
request_elements: {
|
697
|
-
'cors_rules' => cors_rules
|
1186
|
+
'cors_rules' => cors_rules
|
698
1187
|
},
|
699
1188
|
request_body: nil,
|
1189
|
+
|
700
1190
|
status_code: [
|
701
|
-
200
|
702
|
-
]
|
1191
|
+
200
|
1192
|
+
]
|
703
1193
|
}
|
704
1194
|
|
705
1195
|
put_bucket_cors_input_validate input
|
@@ -711,12 +1201,12 @@ module QingStor
|
|
711
1201
|
def put_bucket_cors_input_validate(input)
|
712
1202
|
input.deep_stringify_keys!
|
713
1203
|
|
714
|
-
unless !input['request_elements']['cors_rules'].nil? && !input['request_elements']['cors_rules'].
|
1204
|
+
unless !input['request_elements']['cors_rules'].nil? && !input['request_elements']['cors_rules'].empty?
|
715
1205
|
raise ParameterRequiredError.new('cors_rules', 'PutBucketCORSInput')
|
716
1206
|
end
|
717
1207
|
|
718
1208
|
input['request_elements']['cors_rules'].each do |x|
|
719
|
-
unless !x['allowed_methods'].nil? && !x['allowed_methods'].
|
1209
|
+
unless !x['allowed_methods'].nil? && !x['allowed_methods'].empty?
|
720
1210
|
raise ParameterRequiredError.new('allowed_methods', 'cors_rule')
|
721
1211
|
end
|
722
1212
|
|
@@ -747,12 +1237,13 @@ module QingStor
|
|
747
1237
|
request_headers: {
|
748
1238
|
},
|
749
1239
|
request_elements: {
|
750
|
-
'source_site' => source_site
|
1240
|
+
'source_site' => source_site
|
751
1241
|
},
|
752
1242
|
request_body: nil,
|
1243
|
+
|
753
1244
|
status_code: [
|
754
|
-
200
|
755
|
-
]
|
1245
|
+
200
|
1246
|
+
]
|
756
1247
|
}
|
757
1248
|
|
758
1249
|
put_bucket_external_mirror_input_validate input
|
@@ -771,6 +1262,230 @@ module QingStor
|
|
771
1262
|
|
772
1263
|
public
|
773
1264
|
|
1265
|
+
# put_bucket_lifecycle: Set Lifecycle information of the bucket.
|
1266
|
+
# Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/lifecycle/put_lifecycle.html
|
1267
|
+
def put_lifecycle(rule: [])
|
1268
|
+
request = put_lifecycle_request rule: rule
|
1269
|
+
request.send
|
1270
|
+
end
|
1271
|
+
|
1272
|
+
def put_lifecycle_request(rule: [])
|
1273
|
+
input = {
|
1274
|
+
config: config,
|
1275
|
+
properties: properties,
|
1276
|
+
api_name: 'PUT Bucket Lifecycle',
|
1277
|
+
request_method: 'PUT',
|
1278
|
+
request_uri: '/<bucket-name>?lifecycle',
|
1279
|
+
request_params: {
|
1280
|
+
},
|
1281
|
+
request_headers: {
|
1282
|
+
},
|
1283
|
+
request_elements: {
|
1284
|
+
'rule' => rule
|
1285
|
+
},
|
1286
|
+
request_body: nil,
|
1287
|
+
|
1288
|
+
status_code: [
|
1289
|
+
200
|
1290
|
+
]
|
1291
|
+
}
|
1292
|
+
|
1293
|
+
put_bucket_lifecycle_input_validate input
|
1294
|
+
Request.new input
|
1295
|
+
end
|
1296
|
+
|
1297
|
+
private
|
1298
|
+
|
1299
|
+
def put_bucket_lifecycle_input_validate(input)
|
1300
|
+
input.deep_stringify_keys!
|
1301
|
+
|
1302
|
+
unless !input['request_elements']['rule'].nil? && !input['request_elements']['rule'].empty?
|
1303
|
+
raise ParameterRequiredError.new('rule', 'PutBucketLifecycleInput')
|
1304
|
+
end
|
1305
|
+
|
1306
|
+
input['request_elements']['rule'].each do |x|
|
1307
|
+
unless x['abort_incomplete_multipart_upload'].nil?
|
1308
|
+
|
1309
|
+
unless !x['abort_incomplete_multipart_upload']['days_after_initiation'].nil? && !x['abort_incomplete_multipart_upload']['days_after_initiation'].to_s.empty?
|
1310
|
+
raise ParameterRequiredError.new('days_after_initiation', 'abort_incomplete_multipart_upload')
|
1311
|
+
end
|
1312
|
+
|
1313
|
+
end
|
1314
|
+
|
1315
|
+
unless x['expiration'].nil?
|
1316
|
+
|
1317
|
+
end
|
1318
|
+
|
1319
|
+
unless x['filter'].nil?
|
1320
|
+
|
1321
|
+
unless !x['filter']['prefix'].nil? && !x['filter']['prefix'].to_s.empty?
|
1322
|
+
raise ParameterRequiredError.new('prefix', 'filter')
|
1323
|
+
end
|
1324
|
+
|
1325
|
+
end
|
1326
|
+
|
1327
|
+
if x['filter'].nil?
|
1328
|
+
raise ParameterRequiredError.new('filter', 'rule')
|
1329
|
+
end
|
1330
|
+
|
1331
|
+
unless !x['id'].nil? && !x['id'].to_s.empty?
|
1332
|
+
raise ParameterRequiredError.new('id', 'rule')
|
1333
|
+
end
|
1334
|
+
|
1335
|
+
unless !x['status'].nil? && !x['status'].to_s.empty?
|
1336
|
+
raise ParameterRequiredError.new('status', 'rule')
|
1337
|
+
end
|
1338
|
+
|
1339
|
+
if x['status'] && !x['status'].to_s.empty?
|
1340
|
+
status_valid_values = %w[enabled disabled]
|
1341
|
+
unless status_valid_values.include? x['status'].to_s
|
1342
|
+
raise ParameterValueNotAllowedError.new(
|
1343
|
+
'status',
|
1344
|
+
x['status'],
|
1345
|
+
status_valid_values,
|
1346
|
+
)
|
1347
|
+
end
|
1348
|
+
end
|
1349
|
+
|
1350
|
+
next if x['transition'].nil?
|
1351
|
+
|
1352
|
+
unless !x['transition']['storage_class'].nil? && !x['transition']['storage_class'].to_s.empty?
|
1353
|
+
raise ParameterRequiredError.new('storage_class', 'transition')
|
1354
|
+
end
|
1355
|
+
end
|
1356
|
+
end
|
1357
|
+
|
1358
|
+
public
|
1359
|
+
|
1360
|
+
# put_bucket_logging: Set bucket logging of the bucket.
|
1361
|
+
# Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/logging/put_logging.html
|
1362
|
+
def put_logging(target_bucket: '',
|
1363
|
+
target_prefix: '')
|
1364
|
+
request = put_logging_request target_bucket: target_bucket,
|
1365
|
+
target_prefix: target_prefix
|
1366
|
+
request.send
|
1367
|
+
end
|
1368
|
+
|
1369
|
+
def put_logging_request(target_bucket: '',
|
1370
|
+
target_prefix: '')
|
1371
|
+
input = {
|
1372
|
+
config: config,
|
1373
|
+
properties: properties,
|
1374
|
+
api_name: 'PUT Bucket Logging',
|
1375
|
+
request_method: 'PUT',
|
1376
|
+
request_uri: '/<bucket-name>?logging',
|
1377
|
+
request_params: {
|
1378
|
+
},
|
1379
|
+
request_headers: {
|
1380
|
+
},
|
1381
|
+
request_elements: {
|
1382
|
+
'target_bucket' => target_bucket,
|
1383
|
+
'target_prefix' => target_prefix
|
1384
|
+
},
|
1385
|
+
request_body: nil,
|
1386
|
+
|
1387
|
+
status_code: [
|
1388
|
+
200
|
1389
|
+
]
|
1390
|
+
}
|
1391
|
+
|
1392
|
+
put_bucket_logging_input_validate input
|
1393
|
+
Request.new input
|
1394
|
+
end
|
1395
|
+
|
1396
|
+
private
|
1397
|
+
|
1398
|
+
def put_bucket_logging_input_validate(input)
|
1399
|
+
input.deep_stringify_keys!
|
1400
|
+
|
1401
|
+
unless !input['request_elements']['target_bucket'].nil? && !input['request_elements']['target_bucket'].to_s.empty?
|
1402
|
+
raise ParameterRequiredError.new('target_bucket', 'PutBucketLoggingInput')
|
1403
|
+
end
|
1404
|
+
|
1405
|
+
unless !input['request_elements']['target_prefix'].nil? && !input['request_elements']['target_prefix'].to_s.empty?
|
1406
|
+
raise ParameterRequiredError.new('target_prefix', 'PutBucketLoggingInput')
|
1407
|
+
end
|
1408
|
+
end
|
1409
|
+
|
1410
|
+
public
|
1411
|
+
|
1412
|
+
# put_bucket_notification: Set Notification information of the bucket.
|
1413
|
+
# Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/notification/put_notification.html
|
1414
|
+
def put_notification(notifications: [])
|
1415
|
+
request = put_notification_request notifications: notifications
|
1416
|
+
request.send
|
1417
|
+
end
|
1418
|
+
|
1419
|
+
def put_notification_request(notifications: [])
|
1420
|
+
input = {
|
1421
|
+
config: config,
|
1422
|
+
properties: properties,
|
1423
|
+
api_name: 'PUT Bucket Notification',
|
1424
|
+
request_method: 'PUT',
|
1425
|
+
request_uri: '/<bucket-name>?notification',
|
1426
|
+
request_params: {
|
1427
|
+
},
|
1428
|
+
request_headers: {
|
1429
|
+
},
|
1430
|
+
request_elements: {
|
1431
|
+
'notifications' => notifications
|
1432
|
+
},
|
1433
|
+
request_body: nil,
|
1434
|
+
|
1435
|
+
status_code: [
|
1436
|
+
200
|
1437
|
+
]
|
1438
|
+
}
|
1439
|
+
|
1440
|
+
put_bucket_notification_input_validate input
|
1441
|
+
Request.new input
|
1442
|
+
end
|
1443
|
+
|
1444
|
+
private
|
1445
|
+
|
1446
|
+
def put_bucket_notification_input_validate(input)
|
1447
|
+
input.deep_stringify_keys!
|
1448
|
+
|
1449
|
+
unless !input['request_elements']['notifications'].nil? && !input['request_elements']['notifications'].empty?
|
1450
|
+
raise ParameterRequiredError.new('notifications', 'PutBucketNotificationInput')
|
1451
|
+
end
|
1452
|
+
|
1453
|
+
input['request_elements']['notifications'].each do |x|
|
1454
|
+
unless !x['cloudfunc'].nil? && !x['cloudfunc'].to_s.empty?
|
1455
|
+
raise ParameterRequiredError.new('cloudfunc', 'notification')
|
1456
|
+
end
|
1457
|
+
|
1458
|
+
if x['cloudfunc'] && !x['cloudfunc'].to_s.empty?
|
1459
|
+
cloudfunc_valid_values = %w[tupu-porn notifier image]
|
1460
|
+
unless cloudfunc_valid_values.include? x['cloudfunc'].to_s
|
1461
|
+
raise ParameterValueNotAllowedError.new(
|
1462
|
+
'cloudfunc',
|
1463
|
+
x['cloudfunc'],
|
1464
|
+
cloudfunc_valid_values,
|
1465
|
+
)
|
1466
|
+
end
|
1467
|
+
end
|
1468
|
+
|
1469
|
+
unless x['cloudfunc_args'].nil?
|
1470
|
+
|
1471
|
+
unless !x['cloudfunc_args']['action'].nil? && !x['cloudfunc_args']['action'].to_s.empty?
|
1472
|
+
raise ParameterRequiredError.new('action', 'cloudfunc_args')
|
1473
|
+
end
|
1474
|
+
|
1475
|
+
end
|
1476
|
+
|
1477
|
+
unless !x['event_types'].nil? && !x['event_types'].empty?
|
1478
|
+
raise ParameterRequiredError.new('event_types', 'notification')
|
1479
|
+
end
|
1480
|
+
|
1481
|
+
unless !x['id'].nil? && !x['id'].to_s.empty?
|
1482
|
+
raise ParameterRequiredError.new('id', 'notification')
|
1483
|
+
end
|
1484
|
+
end
|
1485
|
+
end
|
1486
|
+
|
1487
|
+
public
|
1488
|
+
|
774
1489
|
# put_bucket_policy: Set policy information of the bucket.
|
775
1490
|
# Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/policy/put_policy.html
|
776
1491
|
def put_policy(statement: [])
|
@@ -790,12 +1505,13 @@ module QingStor
|
|
790
1505
|
request_headers: {
|
791
1506
|
},
|
792
1507
|
request_elements: {
|
793
|
-
'statement' => statement
|
1508
|
+
'statement' => statement
|
794
1509
|
},
|
795
1510
|
request_body: nil,
|
1511
|
+
|
796
1512
|
status_code: [
|
797
|
-
200
|
798
|
-
]
|
1513
|
+
200
|
1514
|
+
]
|
799
1515
|
}
|
800
1516
|
|
801
1517
|
put_bucket_policy_input_validate input
|
@@ -807,12 +1523,12 @@ module QingStor
|
|
807
1523
|
def put_bucket_policy_input_validate(input)
|
808
1524
|
input.deep_stringify_keys!
|
809
1525
|
|
810
|
-
unless !input['request_elements']['statement'].nil? && !input['request_elements']['statement'].
|
1526
|
+
unless !input['request_elements']['statement'].nil? && !input['request_elements']['statement'].empty?
|
811
1527
|
raise ParameterRequiredError.new('statement', 'PutBucketPolicyInput')
|
812
1528
|
end
|
813
1529
|
|
814
1530
|
input['request_elements']['statement'].each do |x|
|
815
|
-
unless !x['action'].nil? && !x['action'].
|
1531
|
+
unless !x['action'].nil? && !x['action'].empty?
|
816
1532
|
raise ParameterRequiredError.new('action', 'statement')
|
817
1533
|
end
|
818
1534
|
|
@@ -845,7 +1561,7 @@ module QingStor
|
|
845
1561
|
end
|
846
1562
|
|
847
1563
|
if x['effect'] && !x['effect'].to_s.empty?
|
848
|
-
effect_valid_values = %w
|
1564
|
+
effect_valid_values = %w[allow deny]
|
849
1565
|
unless effect_valid_values.include? x['effect'].to_s
|
850
1566
|
raise ParameterValueNotAllowedError.new(
|
851
1567
|
'effect',
|
@@ -859,13 +1575,112 @@ module QingStor
|
|
859
1575
|
raise ParameterRequiredError.new('id', 'statement')
|
860
1576
|
end
|
861
1577
|
|
862
|
-
unless !x['
|
863
|
-
raise ParameterRequiredError.new('
|
1578
|
+
unless !x['user'].nil? && !x['user'].empty?
|
1579
|
+
raise ParameterRequiredError.new('user', 'statement')
|
864
1580
|
end
|
1581
|
+
end
|
1582
|
+
end
|
865
1583
|
|
866
|
-
|
867
|
-
|
1584
|
+
public
|
1585
|
+
|
1586
|
+
# put_bucket_replication: Set Replication information of the bucket.
|
1587
|
+
# Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/replication/put_replication.html
|
1588
|
+
def put_replication(rules: [])
|
1589
|
+
request = put_replication_request rules: rules
|
1590
|
+
request.send
|
1591
|
+
end
|
1592
|
+
|
1593
|
+
def put_replication_request(rules: [])
|
1594
|
+
input = {
|
1595
|
+
config: config,
|
1596
|
+
properties: properties,
|
1597
|
+
api_name: 'PUT Bucket Replication',
|
1598
|
+
request_method: 'PUT',
|
1599
|
+
request_uri: '/<bucket-name>?replication',
|
1600
|
+
request_params: {
|
1601
|
+
},
|
1602
|
+
request_headers: {
|
1603
|
+
},
|
1604
|
+
request_elements: {
|
1605
|
+
'rules' => rules
|
1606
|
+
},
|
1607
|
+
request_body: nil,
|
1608
|
+
|
1609
|
+
status_code: [
|
1610
|
+
200
|
1611
|
+
]
|
1612
|
+
}
|
1613
|
+
|
1614
|
+
put_bucket_replication_input_validate input
|
1615
|
+
Request.new input
|
1616
|
+
end
|
1617
|
+
|
1618
|
+
private
|
1619
|
+
|
1620
|
+
def put_bucket_replication_input_validate(input)
|
1621
|
+
input.deep_stringify_keys!
|
1622
|
+
|
1623
|
+
unless !input['request_elements']['rules'].nil? && !input['request_elements']['rules'].empty?
|
1624
|
+
raise ParameterRequiredError.new('rules', 'PutBucketReplicationInput')
|
1625
|
+
end
|
1626
|
+
|
1627
|
+
input['request_elements']['rules'].each do |x|
|
1628
|
+
if x['delete_marker'] && !x['delete_marker'].to_s.empty?
|
1629
|
+
delete_marker_valid_values = %w[enabled disabled]
|
1630
|
+
unless delete_marker_valid_values.include? x['delete_marker'].to_s
|
1631
|
+
raise ParameterValueNotAllowedError.new(
|
1632
|
+
'delete_marker',
|
1633
|
+
x['delete_marker'],
|
1634
|
+
delete_marker_valid_values,
|
1635
|
+
)
|
1636
|
+
end
|
1637
|
+
end
|
1638
|
+
|
1639
|
+
unless x['destination'].nil?
|
1640
|
+
|
1641
|
+
unless !x['destination']['bucket'].nil? && !x['destination']['bucket'].to_s.empty?
|
1642
|
+
raise ParameterRequiredError.new('bucket', 'destination')
|
1643
|
+
end
|
1644
|
+
|
1645
|
+
end
|
1646
|
+
|
1647
|
+
if x['destination'].nil?
|
1648
|
+
raise ParameterRequiredError.new('destination', 'rules')
|
1649
|
+
end
|
1650
|
+
|
1651
|
+
unless x['filters'].nil?
|
1652
|
+
|
1653
|
+
end
|
1654
|
+
|
1655
|
+
if x['filters'].nil?
|
1656
|
+
raise ParameterRequiredError.new('filters', 'rules')
|
1657
|
+
end
|
1658
|
+
|
1659
|
+
unless !x['id'].nil? && !x['id'].to_s.empty?
|
1660
|
+
raise ParameterRequiredError.new('id', 'rules')
|
1661
|
+
end
|
1662
|
+
|
1663
|
+
if x['status'] && !x['status'].to_s.empty?
|
1664
|
+
status_valid_values = %w[enabled disabled]
|
1665
|
+
unless status_valid_values.include? x['status'].to_s
|
1666
|
+
raise ParameterValueNotAllowedError.new(
|
1667
|
+
'status',
|
1668
|
+
x['status'],
|
1669
|
+
status_valid_values,
|
1670
|
+
)
|
1671
|
+
end
|
868
1672
|
end
|
1673
|
+
|
1674
|
+
next unless x['sync_marker'] && !x['sync_marker'].to_s.empty?
|
1675
|
+
|
1676
|
+
sync_marker_valid_values = %w[enabled disabled]
|
1677
|
+
next if sync_marker_valid_values.include? x['sync_marker'].to_s
|
1678
|
+
|
1679
|
+
raise ParameterValueNotAllowedError.new(
|
1680
|
+
'sync_marker',
|
1681
|
+
x['sync_marker'],
|
1682
|
+
sync_marker_valid_values,
|
1683
|
+
)
|
869
1684
|
end
|
870
1685
|
end
|
871
1686
|
|