qingstor-sdk 2.2.4 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a8062121127a0b59b8bc4fed69806437307a405579bca0414ace52576e40300d
4
- data.tar.gz: c35611b2ded99e65fdde787cf9abbb4404bb06b6d47014fa67e6400b2b59ff23
3
+ metadata.gz: f96fbe4a96c1158586ba3178388d9e1d718a87bc8a85dc948e1f93c39e5af9b5
4
+ data.tar.gz: ab161d6e76bf701a178189549f929c79838537faa8559a4af4ec4ffe11f8afbb
5
5
  SHA512:
6
- metadata.gz: 914c6b4166f5051070db12e4404cfe7a474be1278b038c947b51f06a86fef4b61b59109aee01853b75df26b2e0a92288454f62633280f60106d1f93da8ab7ff1
7
- data.tar.gz: f3130ce98410ee9479a5465c17cafbb3724850048dbcffff4e7924ac7e68b059b998d9a03c10a39496703c06d73195c451d75eed0da306baf6f54f41e6237511
6
+ metadata.gz: 56d0d535ce815915faf22f7e38a635a22b5d7009cf121a29b08b18c728b982d0d618fac8f9e2c2dcb767d2809f8a5b4a42cd494113c7aa85e01e1d0f402e1723
7
+ data.tar.gz: fef1d45a4891cadf79569fd44591f3a8adc747ff7c2f7dc0845fc3927d5d316e4a3a543928888436af97b78fb32dc70f6a74938479dd1b518f3fc12daff26559
data/README.md CHANGED
@@ -167,6 +167,20 @@ log_level: 'warn'
167
167
  ## Change Log
168
168
  All notable changes to QingStor SDK for Ruby will be documented here.
169
169
 
170
+ ### [v2.3.0] - 2020-05-11
171
+
172
+ ### Added
173
+
174
+ - Add support for lifecycle and notification.
175
+ - Add support for bucket logging, bucket cname and append object. (#24)
176
+
177
+ ### Fixed
178
+
179
+ - Modify content-type check for application/json. (#21)
180
+ - Fix sub-resources not be recognized when generate signature. (#25)
181
+ - Fix meta data not work as intended. (#26)
182
+ - Reverse fix of empty map in template, should not compact empty hash when sign. (#28)
183
+
170
184
  ### [v2.2.3] - 2017-03-28
171
185
 
172
186
  ### Fixed
@@ -244,6 +258,7 @@ All notable changes to QingStor SDK for Ruby will be documented here.
244
258
  The Apache License (Version 2.0, January 2004).
245
259
 
246
260
  [compatible]: https://github.com/yunify/qingstor-sdk-ruby/tree/compatible
261
+ [v2.3.0]: https://github.com/yunify/qingstor-sdk-ruby/compare/v2.2.3...v2.3.0
247
262
  [v2.2.3]: https://github.com/yunify/qingstor-sdk-ruby/compare/v2.2.2...v2.2.3
248
263
  [v2.2.2]: https://github.com/yunify/qingstor-sdk-ruby/compare/v2.2.1...v2.2.2
249
264
  [v2.2.1]: https://github.com/yunify/qingstor-sdk-ruby/compare/v2.2.0...v2.2.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
- %i(access_key_id secret_access_key host port protocol).each do |x|
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(debug info warn error fatal).find_index level.to_s
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,13 @@ module QingStor
102
102
  input[:request_headers][:'Content-MD5'] = Base64.encode64(Digest::MD5.digest(input[:request_body])).strip
103
103
  end
104
104
 
105
+ if input[:request_headers][:'X-QS-MetaData'].is_a?(Hash) && !input[:request_headers][:'X-QS-MetaData'].empty?
106
+ input[:request_headers][:'X-QS-MetaData'].each do |k, v|
107
+ input[:request_headers][:"#{k}"] = v
108
+ end
109
+ input[:request_headers].delete :'X-QS-MetaData'
110
+ end
111
+
105
112
  input[:request_headers].map do |k, v|
106
113
  input[:request_headers][k] = escape v.to_s unless v.to_s.ascii_only?
107
114
  end
@@ -127,7 +134,7 @@ module QingStor
127
134
  def self.compact(object)
128
135
  object.each do |k, v|
129
136
  object[k] = compact v if v.is_a? Hash
130
- object.delete k if v.nil? || v == ''
137
+ object.delete k if v.nil? || v == '' || v == []
131
138
  end
132
139
  object
133
140
  end
@@ -80,7 +80,7 @@ module QingStor
80
80
  output['status_code'] = http_response.code.to_i
81
81
 
82
82
  http_response.each_header { |k, v| output[k.tr('-', '_')] = v }
83
- if http_response['Content-Type'] == 'application/json'
83
+ if http_response['Content-Type'].include? 'application/json'
84
84
  unless http_response.body.nil?
85
85
  JSON.parse(http_response.body).each { |k, v| output[k] = v }
86
86
  end
@@ -98,11 +98,12 @@ module QingStor
98
98
  end
99
99
 
100
100
  def self.sub_resource?(key)
101
- %w(
102
- acl cors delete mirror part_number policy stats upload_id uploads
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
- ).include? key
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, # Bucket deleted
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
- 204, # OK
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, # No content
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, # No content
166
- ],
330
+ 204
331
+ ]
167
332
  }
168
333
 
169
334
  delete_bucket_policy_input_validate input
@@ -201,12 +366,13 @@ module QingStor
201
366
  },
202
367
  request_elements: {
203
368
  'objects' => objects,
204
- 'quiet' => quiet,
369
+ 'quiet' => quiet
205
370
  },
206
371
  request_body: nil,
372
+
207
373
  status_code: [
208
- 200, # OK
209
- ],
374
+ 200
375
+ ]
210
376
  }
211
377
 
212
378
  delete_multiple_objects_input_validate input
@@ -249,9 +415,10 @@ module QingStor
249
415
  request_elements: {
250
416
  },
251
417
  request_body: nil,
418
+
252
419
  status_code: [
253
- 200, # OK
254
- ],
420
+ 200
421
+ ]
255
422
  }
256
423
 
257
424
  get_bucket_acl_input_validate input
@@ -266,6 +433,57 @@ module QingStor
266
433
 
267
434
  public
268
435
 
436
+ # get_bucket_cname: Get bucket CNAME setting of the bucket.
437
+ # Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/cname/get_cname.html
438
+ def get_cname(type: '')
439
+ request = get_cname_request type: type
440
+ request.send
441
+ end
442
+
443
+ def get_cname_request(type: '')
444
+ input = {
445
+ config: config,
446
+ properties: properties,
447
+ api_name: 'GET Bucket CNAME',
448
+ request_method: 'GET',
449
+ request_uri: '/<bucket-name>?cname',
450
+ request_params: {
451
+ 'type' => type
452
+ },
453
+ request_headers: {
454
+ },
455
+ request_elements: {
456
+ },
457
+ request_body: nil,
458
+
459
+ status_code: [
460
+ 200
461
+ ]
462
+ }
463
+
464
+ get_bucket_cname_input_validate input
465
+ Request.new input
466
+ end
467
+
468
+ private
469
+
470
+ def get_bucket_cname_input_validate(input)
471
+ input.deep_stringify_keys!
472
+
473
+ if input['request_params']['type'] && !input['request_params']['type'].to_s.empty?
474
+ type_valid_values = %w[website normal]
475
+ unless type_valid_values.include? input['request_params']['type'].to_s
476
+ raise ParameterValueNotAllowedError.new(
477
+ 'type',
478
+ input['request_params']['type'],
479
+ type_valid_values,
480
+ )
481
+ end
482
+ end
483
+ end
484
+
485
+ public
486
+
269
487
  # get_bucket_cors: Get CORS information of the bucket.
270
488
  # Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/cors/get_cors.html
271
489
  def get_cors
@@ -287,9 +505,10 @@ module QingStor
287
505
  request_elements: {
288
506
  },
289
507
  request_body: nil,
508
+
290
509
  status_code: [
291
- 200, # OK
292
- ],
510
+ 200
511
+ ]
293
512
  }
294
513
 
295
514
  get_bucket_cors_input_validate input
@@ -325,9 +544,10 @@ module QingStor
325
544
  request_elements: {
326
545
  },
327
546
  request_body: nil,
547
+
328
548
  status_code: [
329
- 200, # OK
330
- ],
549
+ 200
550
+ ]
331
551
  }
332
552
 
333
553
  get_bucket_external_mirror_input_validate input
@@ -342,6 +562,123 @@ module QingStor
342
562
 
343
563
  public
344
564
 
565
+ # get_bucket_lifecycle: Get Lifecycle information of the bucket.
566
+ # Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/lifecycle/get_lifecycle.html
567
+ def get_lifecycle
568
+ request = get_lifecycle_request
569
+ request.send
570
+ end
571
+
572
+ def get_lifecycle_request
573
+ input = {
574
+ config: config,
575
+ properties: properties,
576
+ api_name: 'GET Bucket Lifecycle',
577
+ request_method: 'GET',
578
+ request_uri: '/<bucket-name>?lifecycle',
579
+ request_params: {
580
+ },
581
+ request_headers: {
582
+ },
583
+ request_elements: {
584
+ },
585
+ request_body: nil,
586
+
587
+ status_code: [
588
+ 200
589
+ ]
590
+ }
591
+
592
+ get_bucket_lifecycle_input_validate input
593
+ Request.new input
594
+ end
595
+
596
+ private
597
+
598
+ def get_bucket_lifecycle_input_validate(input)
599
+ input.deep_stringify_keys!
600
+ end
601
+
602
+ public
603
+
604
+ # get_bucket_logging: Get bucket logging setting of the bucket.
605
+ # Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/logging/get_logging.html
606
+ def get_logging
607
+ request = get_logging_request
608
+ request.send
609
+ end
610
+
611
+ def get_logging_request
612
+ input = {
613
+ config: config,
614
+ properties: properties,
615
+ api_name: 'GET Bucket Logging',
616
+ request_method: 'GET',
617
+ request_uri: '/<bucket-name>?logging',
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_logging_input_validate input
632
+ Request.new input
633
+ end
634
+
635
+ private
636
+
637
+ def get_bucket_logging_input_validate(input)
638
+ input.deep_stringify_keys!
639
+ end
640
+
641
+ public
642
+
643
+ # get_bucket_notification: Get Notification information of the bucket.
644
+ # Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/notification/get_notification.html
645
+ def get_notification
646
+ request = get_notification_request
647
+ request.send
648
+ end
649
+
650
+ def get_notification_request
651
+ input = {
652
+ config: config,
653
+ properties: properties,
654
+ api_name: 'GET Bucket Notification',
655
+ request_method: 'GET',
656
+ request_uri: '/<bucket-name>?notification',
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_notification_input_validate input
671
+ Request.new input
672
+ end
673
+
674
+ private
675
+
676
+ def get_bucket_notification_input_validate(input)
677
+ input.deep_stringify_keys!
678
+ end
679
+
680
+ public
681
+
345
682
  # get_bucket_policy: Get policy information of the bucket.
346
683
  # Documentation URL: https://https://docs.qingcloud.com/qingstor/api/bucket/policy/get_policy.html
347
684
  def get_policy
@@ -363,9 +700,10 @@ module QingStor
363
700
  request_elements: {
364
701
  },
365
702
  request_body: nil,
703
+
366
704
  status_code: [
367
- 200, # OK
368
- ],
705
+ 200
706
+ ]
369
707
  }
370
708
 
371
709
  get_bucket_policy_input_validate input
@@ -401,9 +739,10 @@ module QingStor
401
739
  request_elements: {
402
740
  },
403
741
  request_body: nil,
742
+
404
743
  status_code: [
405
- 200, # OK
406
- ],
744
+ 200
745
+ ]
407
746
  }
408
747
 
409
748
  get_bucket_statistics_input_validate input
@@ -439,9 +778,10 @@ module QingStor
439
778
  request_elements: {
440
779
  },
441
780
  request_body: nil,
781
+
442
782
  status_code: [
443
- 200, # OK
444
- ],
783
+ 200
784
+ ]
445
785
  }
446
786
 
447
787
  head_bucket_input_validate input
@@ -459,20 +799,23 @@ module QingStor
459
799
  # list_multipart_uploads: List multipart uploads in the bucket.
460
800
  # Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/list_multipart_uploads.html
461
801
  def list_multipart_uploads(delimiter: '',
802
+ key_marker: '',
462
803
  limit: nil,
463
- marker: '',
464
- prefix: '')
465
- request = list_multipart_uploads_request delimiter: delimiter,
466
- limit: limit,
467
- marker: marker,
468
- prefix: prefix
804
+ prefix: '',
805
+ upload_id_marker: '')
806
+ request = list_multipart_uploads_request delimiter: delimiter,
807
+ key_marker: key_marker,
808
+ limit: limit,
809
+ prefix: prefix,
810
+ upload_id_marker: upload_id_marker
469
811
  request.send
470
812
  end
471
813
 
472
814
  def list_multipart_uploads_request(delimiter: '',
815
+ key_marker: '',
473
816
  limit: nil,
474
- marker: '',
475
- prefix: '')
817
+ prefix: '',
818
+ upload_id_marker: '')
476
819
  input = {
477
820
  config: config,
478
821
  properties: properties,
@@ -480,19 +823,21 @@ module QingStor
480
823
  request_method: 'GET',
481
824
  request_uri: '/<bucket-name>?uploads',
482
825
  request_params: {
483
- 'delimiter' => delimiter,
484
- 'limit' => limit,
485
- 'marker' => marker,
486
- 'prefix' => prefix,
826
+ 'delimiter' => delimiter,
827
+ 'key_marker' => key_marker,
828
+ 'limit' => limit,
829
+ 'prefix' => prefix,
830
+ 'upload_id_marker' => upload_id_marker
487
831
  },
488
832
  request_headers: {
489
833
  },
490
834
  request_elements: {
491
835
  },
492
836
  request_body: nil,
837
+
493
838
  status_code: [
494
- 200, # OK
495
- ],
839
+ 200
840
+ ]
496
841
  }
497
842
 
498
843
  list_multipart_uploads_input_validate input
@@ -534,16 +879,17 @@ module QingStor
534
879
  'delimiter' => delimiter,
535
880
  'limit' => limit,
536
881
  'marker' => marker,
537
- 'prefix' => prefix,
882
+ 'prefix' => prefix
538
883
  },
539
884
  request_headers: {
540
885
  },
541
886
  request_elements: {
542
887
  },
543
888
  request_body: nil,
889
+
544
890
  status_code: [
545
- 200, # OK
546
- ],
891
+ 200
892
+ ]
547
893
  }
548
894
 
549
895
  list_objects_input_validate input
@@ -579,9 +925,10 @@ module QingStor
579
925
  request_elements: {
580
926
  },
581
927
  request_body: nil,
928
+
582
929
  status_code: [
583
- 201, # Bucket created
584
- ],
930
+ 201
931
+ ]
585
932
  }
586
933
 
587
934
  put_bucket_input_validate input
@@ -615,12 +962,13 @@ module QingStor
615
962
  request_headers: {
616
963
  },
617
964
  request_elements: {
618
- 'acl' => acl,
965
+ 'acl' => acl
619
966
  },
620
967
  request_body: nil,
968
+
621
969
  status_code: [
622
- 200, # OK
623
- ],
970
+ 200
971
+ ]
624
972
  }
625
973
 
626
974
  put_bucket_acl_input_validate input
@@ -644,7 +992,7 @@ module QingStor
644
992
  end
645
993
 
646
994
  if x['grantee']['type'] && !x['grantee']['type'].to_s.empty?
647
- type_valid_values = %w(user group)
995
+ type_valid_values = %w[user group]
648
996
  unless type_valid_values.include? x['grantee']['type'].to_s
649
997
  raise ParameterValueNotAllowedError.new(
650
998
  'type',
@@ -656,15 +1004,19 @@ module QingStor
656
1004
 
657
1005
  end
658
1006
 
659
- raise ParameterRequiredError.new('grantee', 'acl') if x['grantee'].nil?
1007
+ if x['grantee'].nil?
1008
+ raise ParameterRequiredError.new('grantee', 'acl')
1009
+ end
660
1010
 
661
1011
  unless !x['permission'].nil? && !x['permission'].to_s.empty?
662
1012
  raise ParameterRequiredError.new('permission', 'acl')
663
1013
  end
664
1014
 
665
1015
  next unless x['permission'] && !x['permission'].to_s.empty?
666
- permission_valid_values = %w(READ WRITE FULL_CONTROL)
1016
+
1017
+ permission_valid_values = %w[READ WRITE FULL_CONTROL]
667
1018
  next if permission_valid_values.include? x['permission'].to_s
1019
+
668
1020
  raise ParameterValueNotAllowedError.new(
669
1021
  'permission',
670
1022
  x['permission'],
@@ -675,6 +1027,65 @@ module QingStor
675
1027
 
676
1028
  public
677
1029
 
1030
+ # put_bucket_cname: Set bucket CNAME of the bucket.
1031
+ # Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/cname/put_cname.html
1032
+ def put_cname(domain: '',
1033
+ type: '')
1034
+ request = put_cname_request domain: domain,
1035
+ type: type
1036
+ request.send
1037
+ end
1038
+
1039
+ def put_cname_request(domain: '',
1040
+ type: '')
1041
+ input = {
1042
+ config: config,
1043
+ properties: properties,
1044
+ api_name: 'PUT Bucket CNAME',
1045
+ request_method: 'PUT',
1046
+ request_uri: '/<bucket-name>?cname',
1047
+ request_params: {
1048
+ },
1049
+ request_headers: {
1050
+ },
1051
+ request_elements: {
1052
+ 'domain' => domain,
1053
+ 'type' => type
1054
+ },
1055
+ request_body: nil,
1056
+
1057
+ status_code: [
1058
+ 200
1059
+ ]
1060
+ }
1061
+
1062
+ put_bucket_cname_input_validate input
1063
+ Request.new input
1064
+ end
1065
+
1066
+ private
1067
+
1068
+ def put_bucket_cname_input_validate(input)
1069
+ input.deep_stringify_keys!
1070
+
1071
+ unless !input['request_elements']['domain'].nil? && !input['request_elements']['domain'].to_s.empty?
1072
+ raise ParameterRequiredError.new('domain', 'PutBucketCNAMEInput')
1073
+ end
1074
+
1075
+ if input['request_elements']['type'] && !input['request_elements']['type'].to_s.empty?
1076
+ type_valid_values = %w[normal website]
1077
+ unless type_valid_values.include? input['request_elements']['type'].to_s
1078
+ raise ParameterValueNotAllowedError.new(
1079
+ 'type',
1080
+ input['request_elements']['type'],
1081
+ type_valid_values,
1082
+ )
1083
+ end
1084
+ end
1085
+ end
1086
+
1087
+ public
1088
+
678
1089
  # put_bucket_cors: Set CORS information of the bucket.
679
1090
  # Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/cors/put_cors.html
680
1091
  def put_cors(cors_rules: [])
@@ -694,12 +1105,13 @@ module QingStor
694
1105
  request_headers: {
695
1106
  },
696
1107
  request_elements: {
697
- 'cors_rules' => cors_rules,
1108
+ 'cors_rules' => cors_rules
698
1109
  },
699
1110
  request_body: nil,
1111
+
700
1112
  status_code: [
701
- 200, # OK
702
- ],
1113
+ 200
1114
+ ]
703
1115
  }
704
1116
 
705
1117
  put_bucket_cors_input_validate input
@@ -747,12 +1159,13 @@ module QingStor
747
1159
  request_headers: {
748
1160
  },
749
1161
  request_elements: {
750
- 'source_site' => source_site,
1162
+ 'source_site' => source_site
751
1163
  },
752
1164
  request_body: nil,
1165
+
753
1166
  status_code: [
754
- 200, # OK
755
- ],
1167
+ 200
1168
+ ]
756
1169
  }
757
1170
 
758
1171
  put_bucket_external_mirror_input_validate input
@@ -771,6 +1184,230 @@ module QingStor
771
1184
 
772
1185
  public
773
1186
 
1187
+ # put_bucket_lifecycle: Set Lifecycle information of the bucket.
1188
+ # Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/lifecycle/put_lifecycle.html
1189
+ def put_lifecycle(rule: [])
1190
+ request = put_lifecycle_request rule: rule
1191
+ request.send
1192
+ end
1193
+
1194
+ def put_lifecycle_request(rule: [])
1195
+ input = {
1196
+ config: config,
1197
+ properties: properties,
1198
+ api_name: 'PUT Bucket Lifecycle',
1199
+ request_method: 'PUT',
1200
+ request_uri: '/<bucket-name>?lifecycle',
1201
+ request_params: {
1202
+ },
1203
+ request_headers: {
1204
+ },
1205
+ request_elements: {
1206
+ 'rule' => rule
1207
+ },
1208
+ request_body: nil,
1209
+
1210
+ status_code: [
1211
+ 200
1212
+ ]
1213
+ }
1214
+
1215
+ put_bucket_lifecycle_input_validate input
1216
+ Request.new input
1217
+ end
1218
+
1219
+ private
1220
+
1221
+ def put_bucket_lifecycle_input_validate(input)
1222
+ input.deep_stringify_keys!
1223
+
1224
+ unless !input['request_elements']['rule'].nil? && !input['request_elements']['rule'].to_s.empty?
1225
+ raise ParameterRequiredError.new('rule', 'PutBucketLifecycleInput')
1226
+ end
1227
+
1228
+ input['request_elements']['rule'].each do |x|
1229
+ unless x['abort_incomplete_multipart_upload'].nil?
1230
+
1231
+ unless !x['abort_incomplete_multipart_upload']['days_after_initiation'].nil? && !x['abort_incomplete_multipart_upload']['days_after_initiation'].to_s.empty?
1232
+ raise ParameterRequiredError.new('days_after_initiation', 'abort_incomplete_multipart_upload')
1233
+ end
1234
+
1235
+ end
1236
+
1237
+ unless x['expiration'].nil?
1238
+
1239
+ end
1240
+
1241
+ unless x['filter'].nil?
1242
+
1243
+ unless !x['filter']['prefix'].nil? && !x['filter']['prefix'].to_s.empty?
1244
+ raise ParameterRequiredError.new('prefix', 'filter')
1245
+ end
1246
+
1247
+ end
1248
+
1249
+ if x['filter'].nil?
1250
+ raise ParameterRequiredError.new('filter', 'rule')
1251
+ end
1252
+
1253
+ unless !x['id'].nil? && !x['id'].to_s.empty?
1254
+ raise ParameterRequiredError.new('id', 'rule')
1255
+ end
1256
+
1257
+ unless !x['status'].nil? && !x['status'].to_s.empty?
1258
+ raise ParameterRequiredError.new('status', 'rule')
1259
+ end
1260
+
1261
+ if x['status'] && !x['status'].to_s.empty?
1262
+ status_valid_values = %w[enabled disabled]
1263
+ unless status_valid_values.include? x['status'].to_s
1264
+ raise ParameterValueNotAllowedError.new(
1265
+ 'status',
1266
+ x['status'],
1267
+ status_valid_values,
1268
+ )
1269
+ end
1270
+ end
1271
+
1272
+ next if x['transition'].nil?
1273
+
1274
+ unless !x['transition']['storage_class'].nil? && !x['transition']['storage_class'].to_s.empty?
1275
+ raise ParameterRequiredError.new('storage_class', 'transition')
1276
+ end
1277
+ end
1278
+ end
1279
+
1280
+ public
1281
+
1282
+ # put_bucket_logging: Set bucket logging of the bucket.
1283
+ # Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/logging/put_logging.html
1284
+ def put_logging(target_bucket: '',
1285
+ target_prefix: '')
1286
+ request = put_logging_request target_bucket: target_bucket,
1287
+ target_prefix: target_prefix
1288
+ request.send
1289
+ end
1290
+
1291
+ def put_logging_request(target_bucket: '',
1292
+ target_prefix: '')
1293
+ input = {
1294
+ config: config,
1295
+ properties: properties,
1296
+ api_name: 'PUT Bucket Logging',
1297
+ request_method: 'PUT',
1298
+ request_uri: '/<bucket-name>?logging',
1299
+ request_params: {
1300
+ },
1301
+ request_headers: {
1302
+ },
1303
+ request_elements: {
1304
+ 'target_bucket' => target_bucket,
1305
+ 'target_prefix' => target_prefix
1306
+ },
1307
+ request_body: nil,
1308
+
1309
+ status_code: [
1310
+ 200
1311
+ ]
1312
+ }
1313
+
1314
+ put_bucket_logging_input_validate input
1315
+ Request.new input
1316
+ end
1317
+
1318
+ private
1319
+
1320
+ def put_bucket_logging_input_validate(input)
1321
+ input.deep_stringify_keys!
1322
+
1323
+ unless !input['request_elements']['target_bucket'].nil? && !input['request_elements']['target_bucket'].to_s.empty?
1324
+ raise ParameterRequiredError.new('target_bucket', 'PutBucketLoggingInput')
1325
+ end
1326
+
1327
+ unless !input['request_elements']['target_prefix'].nil? && !input['request_elements']['target_prefix'].to_s.empty?
1328
+ raise ParameterRequiredError.new('target_prefix', 'PutBucketLoggingInput')
1329
+ end
1330
+ end
1331
+
1332
+ public
1333
+
1334
+ # put_bucket_notification: Set Notification information of the bucket.
1335
+ # Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/notification/put_notification.html
1336
+ def put_notification(notifications: [])
1337
+ request = put_notification_request notifications: notifications
1338
+ request.send
1339
+ end
1340
+
1341
+ def put_notification_request(notifications: [])
1342
+ input = {
1343
+ config: config,
1344
+ properties: properties,
1345
+ api_name: 'PUT Bucket Notification',
1346
+ request_method: 'PUT',
1347
+ request_uri: '/<bucket-name>?notification',
1348
+ request_params: {
1349
+ },
1350
+ request_headers: {
1351
+ },
1352
+ request_elements: {
1353
+ 'notifications' => notifications
1354
+ },
1355
+ request_body: nil,
1356
+
1357
+ status_code: [
1358
+ 200
1359
+ ]
1360
+ }
1361
+
1362
+ put_bucket_notification_input_validate input
1363
+ Request.new input
1364
+ end
1365
+
1366
+ private
1367
+
1368
+ def put_bucket_notification_input_validate(input)
1369
+ input.deep_stringify_keys!
1370
+
1371
+ unless !input['request_elements']['notifications'].nil? && !input['request_elements']['notifications'].to_s.empty?
1372
+ raise ParameterRequiredError.new('notifications', 'PutBucketNotificationInput')
1373
+ end
1374
+
1375
+ input['request_elements']['notifications'].each do |x|
1376
+ unless !x['cloudfunc'].nil? && !x['cloudfunc'].to_s.empty?
1377
+ raise ParameterRequiredError.new('cloudfunc', 'notification')
1378
+ end
1379
+
1380
+ if x['cloudfunc'] && !x['cloudfunc'].to_s.empty?
1381
+ cloudfunc_valid_values = %w[tupu-porn notifier image]
1382
+ unless cloudfunc_valid_values.include? x['cloudfunc'].to_s
1383
+ raise ParameterValueNotAllowedError.new(
1384
+ 'cloudfunc',
1385
+ x['cloudfunc'],
1386
+ cloudfunc_valid_values,
1387
+ )
1388
+ end
1389
+ end
1390
+
1391
+ unless x['cloudfunc_args'].nil?
1392
+
1393
+ unless !x['cloudfunc_args']['action'].nil? && !x['cloudfunc_args']['action'].to_s.empty?
1394
+ raise ParameterRequiredError.new('action', 'cloudfunc_args')
1395
+ end
1396
+
1397
+ end
1398
+
1399
+ unless !x['event_types'].nil? && !x['event_types'].to_s.empty?
1400
+ raise ParameterRequiredError.new('event_types', 'notification')
1401
+ end
1402
+
1403
+ unless !x['id'].nil? && !x['id'].to_s.empty?
1404
+ raise ParameterRequiredError.new('id', 'notification')
1405
+ end
1406
+ end
1407
+ end
1408
+
1409
+ public
1410
+
774
1411
  # put_bucket_policy: Set policy information of the bucket.
775
1412
  # Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/policy/put_policy.html
776
1413
  def put_policy(statement: [])
@@ -790,12 +1427,13 @@ module QingStor
790
1427
  request_headers: {
791
1428
  },
792
1429
  request_elements: {
793
- 'statement' => statement,
1430
+ 'statement' => statement
794
1431
  },
795
1432
  request_body: nil,
1433
+
796
1434
  status_code: [
797
- 200, # OK
798
- ],
1435
+ 200
1436
+ ]
799
1437
  }
800
1438
 
801
1439
  put_bucket_policy_input_validate input
@@ -845,7 +1483,7 @@ module QingStor
845
1483
  end
846
1484
 
847
1485
  if x['effect'] && !x['effect'].to_s.empty?
848
- effect_valid_values = %w(allow deny)
1486
+ effect_valid_values = %w[allow deny]
849
1487
  unless effect_valid_values.include? x['effect'].to_s
850
1488
  raise ParameterValueNotAllowedError.new(
851
1489
  'effect',