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.
@@ -37,16 +37,17 @@ module QingStor
37
37
  request_method: 'DELETE',
38
38
  request_uri: '/<bucket-name>/<object-key>',
39
39
  request_params: {
40
- 'upload_id' => upload_id,
40
+ 'upload_id' => upload_id
41
41
  },
42
42
  request_headers: {
43
43
  },
44
44
  request_elements: {
45
45
  },
46
46
  request_body: nil,
47
+
47
48
  status_code: [
48
- 204, # Object multipart deleted
49
- ],
49
+ 204
50
+ ]
50
51
  }
51
52
 
52
53
  abort_multipart_upload_input_validate input
@@ -65,6 +66,78 @@ module QingStor
65
66
 
66
67
  public
67
68
 
69
+ # append_object: Append the Object.
70
+ # Documentation URL: https://docs.qingcloud.com/qingstor/api/object/append.html
71
+ def append_object(object_key, position: nil, content_length: nil,
72
+ content_md5: '',
73
+ content_type: '',
74
+ x_qs_storage_class: '',
75
+ body: nil)
76
+ request = append_object_request object_key, position: position, content_length: content_length,
77
+ content_md5: content_md5,
78
+ content_type: content_type,
79
+ x_qs_storage_class: x_qs_storage_class,
80
+ body: body
81
+ request.send
82
+ end
83
+
84
+ def append_object_request(object_key, position: nil, content_length: nil,
85
+ content_md5: '',
86
+ content_type: '',
87
+ x_qs_storage_class: '',
88
+ body: nil)
89
+ properties[:'object-key'] = object_key
90
+ input = {
91
+ config: config,
92
+ properties: properties,
93
+ api_name: 'Append Object',
94
+ request_method: 'POST',
95
+ request_uri: '/<bucket-name>/<object-key>?append',
96
+ request_params: {
97
+ 'position' => position
98
+ },
99
+ request_headers: {
100
+ 'Content-Length' => content_length,
101
+ 'Content-MD5' => content_md5,
102
+ 'Content-Type' => content_type,
103
+ 'X-QS-Storage-Class' => x_qs_storage_class
104
+ },
105
+ request_elements: {
106
+ },
107
+ request_body: body,
108
+
109
+ status_code: [
110
+ 200
111
+ ]
112
+ }
113
+
114
+ append_object_input_validate input
115
+ Request.new input
116
+ end
117
+
118
+ private
119
+
120
+ def append_object_input_validate(input)
121
+ input.deep_stringify_keys!
122
+
123
+ unless !input['request_params']['position'].nil? && !input['request_params']['position'].to_s.empty?
124
+ raise ParameterRequiredError.new('position', 'AppendObjectInput')
125
+ end
126
+
127
+ if input['request_headers']['X-QS-Storage-Class'] && !input['request_headers']['X-QS-Storage-Class'].to_s.empty?
128
+ x_qs_storage_class_valid_values = %w[STANDARD STANDARD_IA]
129
+ unless x_qs_storage_class_valid_values.include? input['request_headers']['X-QS-Storage-Class'].to_s
130
+ raise ParameterValueNotAllowedError.new(
131
+ 'X-QS-Storage-Class',
132
+ input['request_headers']['X-QS-Storage-Class'],
133
+ x_qs_storage_class_valid_values,
134
+ )
135
+ end
136
+ end
137
+ end
138
+
139
+ public
140
+
68
141
  # complete_multipart_upload: Complete multipart upload.
69
142
  # Documentation URL: https://docs.qingcloud.com/qingstor/api/object/complete_multipart_upload.html
70
143
  def complete_multipart_upload(object_key, upload_id: '', etag: '',
@@ -90,21 +163,22 @@ module QingStor
90
163
  request_method: 'POST',
91
164
  request_uri: '/<bucket-name>/<object-key>',
92
165
  request_params: {
93
- 'upload_id' => upload_id,
166
+ 'upload_id' => upload_id
94
167
  },
95
168
  request_headers: {
96
169
  'ETag' => etag,
97
170
  'X-QS-Encryption-Customer-Algorithm' => x_qs_encryption_customer_algorithm,
98
171
  'X-QS-Encryption-Customer-Key' => x_qs_encryption_customer_key,
99
- 'X-QS-Encryption-Customer-Key-MD5' => x_qs_encryption_customer_key_md5,
172
+ 'X-QS-Encryption-Customer-Key-MD5' => x_qs_encryption_customer_key_md5
100
173
  },
101
174
  request_elements: {
102
- 'object_parts' => object_parts,
175
+ 'object_parts' => object_parts
103
176
  },
104
177
  request_body: nil,
178
+
105
179
  status_code: [
106
- 201, # Object created
107
- ],
180
+ 201
181
+ ]
108
182
  }
109
183
 
110
184
  complete_multipart_upload_input_validate input
@@ -120,6 +194,10 @@ module QingStor
120
194
  raise ParameterRequiredError.new('upload_id', 'CompleteMultipartUploadInput')
121
195
  end
122
196
 
197
+ unless !input['request_elements']['object_parts'].nil? && !input['request_elements']['object_parts'].to_s.empty?
198
+ raise ParameterRequiredError.new('object_parts', 'CompleteMultipartUploadInput')
199
+ end
200
+
123
201
  input['request_elements']['object_parts'].each do |x|
124
202
  unless !x['part_number'].nil? && !x['part_number'].to_s.empty?
125
203
  raise ParameterRequiredError.new('part_number', 'object_part')
@@ -151,9 +229,10 @@ module QingStor
151
229
  request_elements: {
152
230
  },
153
231
  request_body: nil,
232
+
154
233
  status_code: [
155
- 204, # Object deleted
156
- ],
234
+ 204
235
+ ]
157
236
  }
158
237
 
159
238
  delete_object_input_validate input
@@ -225,7 +304,7 @@ module QingStor
225
304
  'response-content-encoding' => response_content_encoding,
226
305
  'response-content-language' => response_content_language,
227
306
  'response-content-type' => response_content_type,
228
- 'response-expires' => response_expires,
307
+ 'response-expires' => response_expires
229
308
  },
230
309
  request_headers: {
231
310
  'If-Match' => if_match,
@@ -235,17 +314,18 @@ module QingStor
235
314
  'Range' => range,
236
315
  'X-QS-Encryption-Customer-Algorithm' => x_qs_encryption_customer_algorithm,
237
316
  'X-QS-Encryption-Customer-Key' => x_qs_encryption_customer_key,
238
- 'X-QS-Encryption-Customer-Key-MD5' => x_qs_encryption_customer_key_md5,
317
+ 'X-QS-Encryption-Customer-Key-MD5' => x_qs_encryption_customer_key_md5
239
318
  },
240
319
  request_elements: {
241
320
  },
242
321
  request_body: nil,
322
+
243
323
  status_code: [
244
- 200, # OK
245
- 206, # Partial content
246
- 304, # Not modified
247
- 412, # Precondition failed
248
- ],
324
+ 200,
325
+ 206,
326
+ 304,
327
+ 412
328
+ ]
249
329
  }
250
330
 
251
331
  get_object_input_validate input
@@ -302,14 +382,15 @@ module QingStor
302
382
  'If-Unmodified-Since' => if_unmodified_since,
303
383
  'X-QS-Encryption-Customer-Algorithm' => x_qs_encryption_customer_algorithm,
304
384
  'X-QS-Encryption-Customer-Key' => x_qs_encryption_customer_key,
305
- 'X-QS-Encryption-Customer-Key-MD5' => x_qs_encryption_customer_key_md5,
385
+ 'X-QS-Encryption-Customer-Key-MD5' => x_qs_encryption_customer_key_md5
306
386
  },
307
387
  request_elements: {
308
388
  },
309
389
  request_body: nil,
390
+
310
391
  status_code: [
311
- 200, # OK
312
- ],
392
+ 200
393
+ ]
313
394
  }
314
395
 
315
396
  head_object_input_validate input
@@ -324,23 +405,100 @@ module QingStor
324
405
 
325
406
  public
326
407
 
408
+ # image_process: Image process with the action on the object
409
+ # Documentation URL: https://docs.qingcloud.com/qingstor/data_process/image_process/index.html
410
+ def image_process(object_key, action: '',
411
+ response_cache_control: '',
412
+ response_content_disposition: '',
413
+ response_content_encoding: '',
414
+ response_content_language: '',
415
+ response_content_type: '',
416
+ response_expires: '', if_modified_since: '')
417
+ request = image_process_request object_key, action: action,
418
+ response_cache_control: response_cache_control,
419
+ response_content_disposition: response_content_disposition,
420
+ response_content_encoding: response_content_encoding,
421
+ response_content_language: response_content_language,
422
+ response_content_type: response_content_type,
423
+ response_expires: response_expires, if_modified_since: if_modified_since
424
+ request.send
425
+ end
426
+
427
+ def image_process_request(object_key, action: '',
428
+ response_cache_control: '',
429
+ response_content_disposition: '',
430
+ response_content_encoding: '',
431
+ response_content_language: '',
432
+ response_content_type: '',
433
+ response_expires: '', if_modified_since: '')
434
+ properties[:'object-key'] = object_key
435
+ input = {
436
+ config: config,
437
+ properties: properties,
438
+ api_name: 'Image Process',
439
+ request_method: 'GET',
440
+ request_uri: '/<bucket-name>/<object-key>?image',
441
+ request_params: {
442
+ 'action' => action,
443
+ 'response-cache-control' => response_cache_control,
444
+ 'response-content-disposition' => response_content_disposition,
445
+ 'response-content-encoding' => response_content_encoding,
446
+ 'response-content-language' => response_content_language,
447
+ 'response-content-type' => response_content_type,
448
+ 'response-expires' => response_expires
449
+ },
450
+ request_headers: {
451
+ 'If-Modified-Since' => if_modified_since
452
+ },
453
+ request_elements: {
454
+ },
455
+ request_body: nil,
456
+
457
+ status_code: [
458
+ 200,
459
+ 304
460
+ ]
461
+ }
462
+
463
+ image_process_input_validate input
464
+ Request.new input
465
+ end
466
+
467
+ private
468
+
469
+ def image_process_input_validate(input)
470
+ input.deep_stringify_keys!
471
+
472
+ unless !input['request_params']['action'].nil? && !input['request_params']['action'].to_s.empty?
473
+ raise ParameterRequiredError.new('action', 'ImageProcessInput')
474
+ end
475
+ end
476
+
477
+ public
478
+
327
479
  # initiate_multipart_upload: Initial multipart upload on the object.
328
480
  # Documentation URL: https://docs.qingcloud.com/qingstor/api/object/initiate_multipart_upload.html
329
481
  def initiate_multipart_upload(object_key, content_type: '',
330
482
  x_qs_encryption_customer_algorithm: '',
331
483
  x_qs_encryption_customer_key: '',
332
- x_qs_encryption_customer_key_md5: '')
484
+ x_qs_encryption_customer_key_md5: '',
485
+ x_qs_meta_data: [],
486
+ x_qs_storage_class: '')
333
487
  request = initiate_multipart_upload_request object_key, content_type: content_type,
334
488
  x_qs_encryption_customer_algorithm: x_qs_encryption_customer_algorithm,
335
489
  x_qs_encryption_customer_key: x_qs_encryption_customer_key,
336
- x_qs_encryption_customer_key_md5: x_qs_encryption_customer_key_md5
490
+ x_qs_encryption_customer_key_md5: x_qs_encryption_customer_key_md5,
491
+ x_qs_meta_data: x_qs_meta_data,
492
+ x_qs_storage_class: x_qs_storage_class
337
493
  request.send
338
494
  end
339
495
 
340
496
  def initiate_multipart_upload_request(object_key, content_type: '',
341
497
  x_qs_encryption_customer_algorithm: '',
342
498
  x_qs_encryption_customer_key: '',
343
- x_qs_encryption_customer_key_md5: '')
499
+ x_qs_encryption_customer_key_md5: '',
500
+ x_qs_meta_data: [],
501
+ x_qs_storage_class: '')
344
502
  properties[:'object-key'] = object_key
345
503
  input = {
346
504
  config: config,
@@ -355,13 +513,16 @@ module QingStor
355
513
  'X-QS-Encryption-Customer-Algorithm' => x_qs_encryption_customer_algorithm,
356
514
  'X-QS-Encryption-Customer-Key' => x_qs_encryption_customer_key,
357
515
  'X-QS-Encryption-Customer-Key-MD5' => x_qs_encryption_customer_key_md5,
516
+ 'X-QS-MetaData' => x_qs_meta_data,
517
+ 'X-QS-Storage-Class' => x_qs_storage_class
358
518
  },
359
519
  request_elements: {
360
520
  },
361
521
  request_body: nil,
522
+
362
523
  status_code: [
363
- 200, # OK
364
- ],
524
+ 200
525
+ ]
365
526
  }
366
527
 
367
528
  initiate_multipart_upload_input_validate input
@@ -372,6 +533,17 @@ module QingStor
372
533
 
373
534
  def initiate_multipart_upload_input_validate(input)
374
535
  input.deep_stringify_keys!
536
+
537
+ if input['request_headers']['X-QS-Storage-Class'] && !input['request_headers']['X-QS-Storage-Class'].to_s.empty?
538
+ x_qs_storage_class_valid_values = %w[STANDARD STANDARD_IA]
539
+ unless x_qs_storage_class_valid_values.include? input['request_headers']['X-QS-Storage-Class'].to_s
540
+ raise ParameterValueNotAllowedError.new(
541
+ 'X-QS-Storage-Class',
542
+ input['request_headers']['X-QS-Storage-Class'],
543
+ x_qs_storage_class_valid_values,
544
+ )
545
+ end
546
+ end
375
547
  end
376
548
 
377
549
  public
@@ -400,16 +572,17 @@ module QingStor
400
572
  request_params: {
401
573
  'limit' => limit,
402
574
  'part_number_marker' => part_number_marker,
403
- 'upload_id' => upload_id,
575
+ 'upload_id' => upload_id
404
576
  },
405
577
  request_headers: {
406
578
  },
407
579
  request_elements: {
408
580
  },
409
581
  request_body: nil,
582
+
410
583
  status_code: [
411
- 200, # OK
412
- ],
584
+ 200
585
+ ]
413
586
  }
414
587
 
415
588
  list_multipart_input_validate input
@@ -454,14 +627,17 @@ module QingStor
454
627
  request_headers: {
455
628
  'Access-Control-Request-Headers' => access_control_request_headers,
456
629
  'Access-Control-Request-Method' => access_control_request_method,
457
- 'Origin' => origin,
630
+ 'Origin' => origin
458
631
  },
459
632
  request_elements: {
460
633
  },
461
634
  request_body: nil,
635
+
462
636
  status_code: [
463
- 200, # OK
464
- ],
637
+ 200,
638
+ 304,
639
+ 412
640
+ ]
465
641
  }
466
642
 
467
643
  options_object_input_validate input
@@ -486,7 +662,9 @@ module QingStor
486
662
 
487
663
  # put_object: Upload the object.
488
664
  # Documentation URL: https://docs.qingcloud.com/qingstor/api/object/put.html
489
- def put_object(object_key, content_length: nil,
665
+ def put_object(object_key, cache_control: '',
666
+ content_encoding: '',
667
+ content_length: nil,
490
668
  content_md5: '',
491
669
  content_type: '',
492
670
  expect: '',
@@ -503,9 +681,13 @@ module QingStor
503
681
  x_qs_encryption_customer_key_md5: '',
504
682
  x_qs_fetch_if_unmodified_since: '',
505
683
  x_qs_fetch_source: '',
684
+ x_qs_meta_data: [],
506
685
  x_qs_move_source: '',
686
+ x_qs_storage_class: '',
507
687
  body: nil)
508
- request = put_object_request object_key, content_length: content_length,
688
+ request = put_object_request object_key, cache_control: cache_control,
689
+ content_encoding: content_encoding,
690
+ content_length: content_length,
509
691
  content_md5: content_md5,
510
692
  content_type: content_type,
511
693
  expect: expect,
@@ -522,12 +704,16 @@ module QingStor
522
704
  x_qs_encryption_customer_key_md5: x_qs_encryption_customer_key_md5,
523
705
  x_qs_fetch_if_unmodified_since: x_qs_fetch_if_unmodified_since,
524
706
  x_qs_fetch_source: x_qs_fetch_source,
707
+ x_qs_meta_data: x_qs_meta_data,
525
708
  x_qs_move_source: x_qs_move_source,
709
+ x_qs_storage_class: x_qs_storage_class,
526
710
  body: body
527
711
  request.send
528
712
  end
529
713
 
530
- def put_object_request(object_key, content_length: nil,
714
+ def put_object_request(object_key, cache_control: '',
715
+ content_encoding: '',
716
+ content_length: nil,
531
717
  content_md5: '',
532
718
  content_type: '',
533
719
  expect: '',
@@ -544,7 +730,9 @@ module QingStor
544
730
  x_qs_encryption_customer_key_md5: '',
545
731
  x_qs_fetch_if_unmodified_since: '',
546
732
  x_qs_fetch_source: '',
733
+ x_qs_meta_data: [],
547
734
  x_qs_move_source: '',
735
+ x_qs_storage_class: '',
548
736
  body: nil)
549
737
  properties[:'object-key'] = object_key
550
738
  input = {
@@ -556,6 +744,8 @@ module QingStor
556
744
  request_params: {
557
745
  },
558
746
  request_headers: {
747
+ 'Cache-Control' => cache_control,
748
+ 'Content-Encoding' => content_encoding,
559
749
  'Content-Length' => content_length,
560
750
  'Content-MD5' => content_md5,
561
751
  'Content-Type' => content_type,
@@ -573,14 +763,17 @@ module QingStor
573
763
  'X-QS-Encryption-Customer-Key-MD5' => x_qs_encryption_customer_key_md5,
574
764
  'X-QS-Fetch-If-Unmodified-Since' => x_qs_fetch_if_unmodified_since,
575
765
  'X-QS-Fetch-Source' => x_qs_fetch_source,
766
+ 'X-QS-MetaData' => x_qs_meta_data,
576
767
  'X-QS-Move-Source' => x_qs_move_source,
768
+ 'X-QS-Storage-Class' => x_qs_storage_class
577
769
  },
578
770
  request_elements: {
579
771
  },
580
772
  request_body: body,
773
+
581
774
  status_code: [
582
- 201, # Object created
583
- ],
775
+ 201
776
+ ]
584
777
  }
585
778
 
586
779
  put_object_input_validate input
@@ -591,6 +784,17 @@ module QingStor
591
784
 
592
785
  def put_object_input_validate(input)
593
786
  input.deep_stringify_keys!
787
+
788
+ if input['request_headers']['X-QS-Storage-Class'] && !input['request_headers']['X-QS-Storage-Class'].to_s.empty?
789
+ x_qs_storage_class_valid_values = %w[STANDARD STANDARD_IA]
790
+ unless x_qs_storage_class_valid_values.include? input['request_headers']['X-QS-Storage-Class'].to_s
791
+ raise ParameterValueNotAllowedError.new(
792
+ 'X-QS-Storage-Class',
793
+ input['request_headers']['X-QS-Storage-Class'],
794
+ x_qs_storage_class_valid_values,
795
+ )
796
+ end
797
+ end
594
798
  end
595
799
 
596
800
  public
@@ -600,6 +804,15 @@ module QingStor
600
804
  def upload_multipart(object_key, part_number: nil,
601
805
  upload_id: '', content_length: nil,
602
806
  content_md5: '',
807
+ x_qs_copy_range: '',
808
+ x_qs_copy_source: '',
809
+ x_qs_copy_source_encryption_customer_algorithm: '',
810
+ x_qs_copy_source_encryption_customer_key: '',
811
+ x_qs_copy_source_encryption_customer_key_md5: '',
812
+ x_qs_copy_source_if_match: '',
813
+ x_qs_copy_source_if_modified_since: '',
814
+ x_qs_copy_source_if_none_match: '',
815
+ x_qs_copy_source_if_unmodified_since: '',
603
816
  x_qs_encryption_customer_algorithm: '',
604
817
  x_qs_encryption_customer_key: '',
605
818
  x_qs_encryption_customer_key_md5: '',
@@ -607,6 +820,15 @@ module QingStor
607
820
  request = upload_multipart_request object_key, part_number: part_number,
608
821
  upload_id: upload_id, content_length: content_length,
609
822
  content_md5: content_md5,
823
+ x_qs_copy_range: x_qs_copy_range,
824
+ x_qs_copy_source: x_qs_copy_source,
825
+ x_qs_copy_source_encryption_customer_algorithm: x_qs_copy_source_encryption_customer_algorithm,
826
+ x_qs_copy_source_encryption_customer_key: x_qs_copy_source_encryption_customer_key,
827
+ x_qs_copy_source_encryption_customer_key_md5: x_qs_copy_source_encryption_customer_key_md5,
828
+ x_qs_copy_source_if_match: x_qs_copy_source_if_match,
829
+ x_qs_copy_source_if_modified_since: x_qs_copy_source_if_modified_since,
830
+ x_qs_copy_source_if_none_match: x_qs_copy_source_if_none_match,
831
+ x_qs_copy_source_if_unmodified_since: x_qs_copy_source_if_unmodified_since,
610
832
  x_qs_encryption_customer_algorithm: x_qs_encryption_customer_algorithm,
611
833
  x_qs_encryption_customer_key: x_qs_encryption_customer_key,
612
834
  x_qs_encryption_customer_key_md5: x_qs_encryption_customer_key_md5,
@@ -617,6 +839,15 @@ module QingStor
617
839
  def upload_multipart_request(object_key, part_number: nil,
618
840
  upload_id: '', content_length: nil,
619
841
  content_md5: '',
842
+ x_qs_copy_range: '',
843
+ x_qs_copy_source: '',
844
+ x_qs_copy_source_encryption_customer_algorithm: '',
845
+ x_qs_copy_source_encryption_customer_key: '',
846
+ x_qs_copy_source_encryption_customer_key_md5: '',
847
+ x_qs_copy_source_if_match: '',
848
+ x_qs_copy_source_if_modified_since: '',
849
+ x_qs_copy_source_if_none_match: '',
850
+ x_qs_copy_source_if_unmodified_since: '',
620
851
  x_qs_encryption_customer_algorithm: '',
621
852
  x_qs_encryption_customer_key: '',
622
853
  x_qs_encryption_customer_key_md5: '',
@@ -630,21 +861,31 @@ module QingStor
630
861
  request_uri: '/<bucket-name>/<object-key>',
631
862
  request_params: {
632
863
  'part_number' => part_number,
633
- 'upload_id' => upload_id,
864
+ 'upload_id' => upload_id
634
865
  },
635
866
  request_headers: {
636
- 'Content-Length' => content_length,
637
- 'Content-MD5' => content_md5,
638
- 'X-QS-Encryption-Customer-Algorithm' => x_qs_encryption_customer_algorithm,
639
- 'X-QS-Encryption-Customer-Key' => x_qs_encryption_customer_key,
640
- 'X-QS-Encryption-Customer-Key-MD5' => x_qs_encryption_customer_key_md5,
867
+ 'Content-Length' => content_length,
868
+ 'Content-MD5' => content_md5,
869
+ 'X-QS-Copy-Range' => x_qs_copy_range,
870
+ 'X-QS-Copy-Source' => x_qs_copy_source,
871
+ 'X-QS-Copy-Source-Encryption-Customer-Algorithm' => x_qs_copy_source_encryption_customer_algorithm,
872
+ 'X-QS-Copy-Source-Encryption-Customer-Key' => x_qs_copy_source_encryption_customer_key,
873
+ 'X-QS-Copy-Source-Encryption-Customer-Key-MD5' => x_qs_copy_source_encryption_customer_key_md5,
874
+ 'X-QS-Copy-Source-If-Match' => x_qs_copy_source_if_match,
875
+ 'X-QS-Copy-Source-If-Modified-Since' => x_qs_copy_source_if_modified_since,
876
+ 'X-QS-Copy-Source-If-None-Match' => x_qs_copy_source_if_none_match,
877
+ 'X-QS-Copy-Source-If-Unmodified-Since' => x_qs_copy_source_if_unmodified_since,
878
+ 'X-QS-Encryption-Customer-Algorithm' => x_qs_encryption_customer_algorithm,
879
+ 'X-QS-Encryption-Customer-Key' => x_qs_encryption_customer_key,
880
+ 'X-QS-Encryption-Customer-Key-MD5' => x_qs_encryption_customer_key_md5
641
881
  },
642
882
  request_elements: {
643
883
  },
644
884
  request_body: body,
885
+
645
886
  status_code: [
646
- 201, # Object multipart created
647
- ],
887
+ 201
888
+ ]
648
889
  }
649
890
 
650
891
  upload_multipart_input_validate input