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