qingstor-sdk 2.0.0 → 2.0.1

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
  SHA1:
3
- metadata.gz: 33359165658b13aa899f8ffdbb30f2562f9c0db9
4
- data.tar.gz: ccb554de7a1c9c00ee90963655cb6c877dbe74ff
3
+ metadata.gz: 121f4fa26d746085c9c07a1217863b907228aaac
4
+ data.tar.gz: b41e30469b51ea9d1ce6acd983d9371bfc41a348
5
5
  SHA512:
6
- metadata.gz: 8752923dafeeffbb74d46f4cc0054d23e7a066640f5762a00ad9732d27eb99055672dd01b958d3f7fd043b9cb8cdd0eea1b11767978650d835fb26f7da38a484
7
- data.tar.gz: 00ffd9672d3f59322029a0afd5fe958b25c704f00deba2f80570e7d5c2535ee957aefd0ab216744b7f59e47ec21ffc8c5ad1b61f6c3bbaaa757426550ed482c5
6
+ metadata.gz: 26183f925125c74f9cafdd94786229f4a87ff9689dfcdea1a63a58f26a4ad9a5be7d034b7284e56578a269d70b45c7bca096b2e4747289d2950ee63aec384b57
7
+ data.tar.gz: b5c50f4616a145c5637c16eec5aee9f28fe8f0c1a943a195fd41a049235efa26b6a48da0acd4eeeda949707c95e34484c92a1a13f41c3110ed2b211489a6db9b
data/README.md CHANGED
@@ -40,7 +40,7 @@ $ bundle install
40
40
  Get code from GitHub:
41
41
 
42
42
  ``` bash
43
- $ git clone git@https://github.com/yunify/qingstor-sdk-ruby.git
43
+ $ git clone git@github.com:yunify/qingstor-sdk-ruby.git
44
44
  ```
45
45
 
46
46
  Build and install with bundler:
@@ -66,8 +66,8 @@ otherwise.
66
66
  ___API Access Key Example:___
67
67
 
68
68
  ``` yaml
69
- access_key_id: 'WMAGPAJBJRKQEBRCEADPWMAGPAJBJRK'
70
- secret_access_key: 'Qkk89OcoIaMVZ0iOfnfivjxL7W5o7oOumMvvUiuF'
69
+ access_key_id: 'ACCESS_KEY_ID_EXAMPLE'
70
+ secret_access_key: 'SECRET_ACCESS_KEY_EXAMPLE'
71
71
  ```
72
72
 
73
73
  ### Code Example
@@ -164,6 +164,17 @@ connection_retries: 3
164
164
  log_level: 'warn'
165
165
  ```
166
166
 
167
+ ## Change Log
168
+ All notable changes to QingStor SDK for Ruby will be documented here.
169
+
170
+ ### [v2.0.1] - 2016-12-16
171
+ #### Changed
172
+ - Improve the implementation of deleting multiple objects.
173
+
174
+ ### v2.0.0 - 2016-12-14
175
+ #### Added
176
+ - QingStor SDK for the Ruby programming language.
177
+
167
178
  ## Reference Documentations
168
179
 
169
180
  - [QingStor Documentation](https://docs.qingcloud.com/qingstor/index.html)
@@ -172,8 +183,14 @@ log_level: 'warn'
172
183
 
173
184
  ## Contributing
174
185
 
175
- This repository is automatically generated, please contribute to [`Snips`](https://github.com/yunify/snips) instead.
186
+ 1. Fork it ( https://github.com/yunify/qingstor-sdk-ruby/fork )
187
+ 2. Create your feature branch (`git checkout -b new-feature`)
188
+ 3. Commit your changes (`git commit -asm 'Add some feature'`)
189
+ 4. Push to the branch (`git push origin new-feature`)
190
+ 5. Create a new Pull Request
176
191
 
177
192
  ## LICENSE
178
193
 
179
194
  The Apache License (Version 2.0, January 2004).
195
+
196
+ [v2.0.1]: https://github.com/yunify/qingstor-sdk-ruby/compare/v2.0.0...v2.0.1
@@ -14,6 +14,9 @@
14
14
  # | limitations under the License.
15
15
  # +-------------------------------------------------------------------------
16
16
 
17
+ require 'base64'
18
+ require 'digest'
19
+
17
20
  require 'active_support/core_ext/hash/keys'
18
21
  require 'mimemagic'
19
22
 
@@ -54,7 +57,14 @@ module QingStor
54
57
 
55
58
  def self.request_body(input)
56
59
  body = input[:request_body]
57
- body.is_a?(File) ? body.read : body
60
+ body = body.is_a?(File) ? body.read : body
61
+ return body if body
62
+
63
+ if input[:request_elements] && !input[:request_elements].empty?
64
+ json_body = JSON.generate input[:request_elements]
65
+ Logger.info "QingStor request json: [#{input[:id]}] #{json_body}"
66
+ json_body
67
+ end
58
68
  end
59
69
 
60
70
  def self.request_headers(input)
@@ -79,9 +89,14 @@ module QingStor
79
89
  input[:request_headers][:'Content-Type'] = 'application/octet-stream'
80
90
  end
81
91
  unless input[:request_headers][:'User-Agent']
82
- ua = "QingStorSDK/#{QingStor::SDK::VERSION} (Ruby v#{RUBY_VERSION}; #{RUBY_PLATFORM})"
92
+ ua = "qingstor-sdk-ruby/#{QingStor::SDK::VERSION} (Ruby v#{RUBY_VERSION}; #{RUBY_PLATFORM})"
83
93
  input[:request_headers][:'User-Agent'] = ua
84
94
  end
95
+
96
+ if input[:api_name] == 'Delete Multiple Objects'
97
+ input[:request_headers][:'Content-MD5'] = Base64.encode64(Digest::MD5.digest(input[:request_body])).strip
98
+ end
99
+
85
100
  input[:request_headers]
86
101
  end
87
102
 
@@ -66,8 +66,8 @@ module QingStor
66
66
  self.request_url = "#{input[:request_endpoint]}#{Signer.escape input[:request_uri]}#{query_string}"
67
67
 
68
68
  request = new_http_request input[:request_method], request_url
69
- request.body = build_request_body input[:request_body], input[:request_elements]
70
- input[:request_headers].each { |k, v| request.add_field k.to_s, v }
69
+ request.body = input[:request_body]
70
+ input[:request_headers].each { |k, v| request[k.to_s] = v }
71
71
 
72
72
  self.http_request = request
73
73
  end
@@ -102,18 +102,6 @@ module QingStor
102
102
  end
103
103
  end
104
104
 
105
- def build_request_body(request_body, request_elements)
106
- if request_body
107
- request_body
108
- elsif request_elements
109
- unless request_elements.empty?
110
- json_body = JSON.generate request_elements
111
- Logger.info "QingStor request json: [#{input[:id]}] #{json_body}"
112
- json_body
113
- end
114
- end
115
- end
116
-
117
105
  def new_http_request(method, url)
118
106
  case method
119
107
  when 'GET'
@@ -46,9 +46,7 @@ module QingStor
46
46
  },
47
47
  request_elements: {
48
48
  },
49
-
50
49
  request_body: nil,
51
-
52
50
  status_code: [
53
51
  204, # Bucket deleted
54
52
  ],
@@ -86,9 +84,7 @@ module QingStor
86
84
  },
87
85
  request_elements: {
88
86
  },
89
-
90
87
  request_body: nil,
91
-
92
88
  status_code: [
93
89
  200, # OK
94
90
  ],
@@ -126,9 +122,7 @@ module QingStor
126
122
  },
127
123
  request_elements: {
128
124
  },
129
-
130
125
  request_body: nil,
131
-
132
126
  status_code: [
133
127
  204, # No content
134
128
  ],
@@ -166,9 +160,7 @@ module QingStor
166
160
  },
167
161
  request_elements: {
168
162
  },
169
-
170
163
  request_body: nil,
171
-
172
164
  status_code: [
173
165
  204, # No content
174
166
  ],
@@ -188,14 +180,14 @@ module QingStor
188
180
 
189
181
  # delete_multiple_objects: Delete multiple objects from the bucket.
190
182
  # Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/delete_multiple.html
191
- def delete_multiple_objects(content_md5: '', objects: [],
183
+ def delete_multiple_objects(objects: [],
192
184
  quiet: nil)
193
- request = delete_multiple_objects_request content_md5: content_md5, objects: objects,
194
- quiet: quiet
185
+ request = delete_multiple_objects_request objects: objects,
186
+ quiet: quiet
195
187
  request.send
196
188
  end
197
189
 
198
- def delete_multiple_objects_request(content_md5: '', objects: [],
190
+ def delete_multiple_objects_request(objects: [],
199
191
  quiet: nil)
200
192
  input = {
201
193
  config: config,
@@ -206,15 +198,12 @@ module QingStor
206
198
  request_params: {
207
199
  },
208
200
  request_headers: {
209
- 'Content-MD5' => content_md5,
210
201
  },
211
202
  request_elements: {
212
203
  'objects' => objects,
213
204
  'quiet' => quiet,
214
205
  },
215
-
216
206
  request_body: nil,
217
-
218
207
  status_code: [
219
208
  200, # OK
220
209
  ],
@@ -229,10 +218,6 @@ module QingStor
229
218
  def delete_multiple_objects_input_validate(input)
230
219
  input.deep_stringify_keys!
231
220
 
232
- unless !input['request_headers']['Content-MD5'].nil? && !input['request_headers']['Content-MD5'].to_s.empty?
233
- raise ParameterRequiredError.new('Content-MD5', 'DeleteMultipleObjectsInput')
234
- end
235
-
236
221
  unless !input['request_elements']['objects'].nil? && !input['request_elements']['objects'].to_s.empty?
237
222
  raise ParameterRequiredError.new('objects', 'DeleteMultipleObjectsInput')
238
223
  end
@@ -263,9 +248,7 @@ module QingStor
263
248
  },
264
249
  request_elements: {
265
250
  },
266
-
267
251
  request_body: nil,
268
-
269
252
  status_code: [
270
253
  200, # OK
271
254
  ],
@@ -303,9 +286,7 @@ module QingStor
303
286
  },
304
287
  request_elements: {
305
288
  },
306
-
307
289
  request_body: nil,
308
-
309
290
  status_code: [
310
291
  200, # OK
311
292
  ],
@@ -343,9 +324,7 @@ module QingStor
343
324
  },
344
325
  request_elements: {
345
326
  },
346
-
347
327
  request_body: nil,
348
-
349
328
  status_code: [
350
329
  200, # OK
351
330
  ],
@@ -383,9 +362,7 @@ module QingStor
383
362
  },
384
363
  request_elements: {
385
364
  },
386
-
387
365
  request_body: nil,
388
-
389
366
  status_code: [
390
367
  200, # OK
391
368
  ],
@@ -423,9 +400,7 @@ module QingStor
423
400
  },
424
401
  request_elements: {
425
402
  },
426
-
427
403
  request_body: nil,
428
-
429
404
  status_code: [
430
405
  200, # OK
431
406
  ],
@@ -463,9 +438,7 @@ module QingStor
463
438
  },
464
439
  request_elements: {
465
440
  },
466
-
467
441
  request_body: nil,
468
-
469
442
  status_code: [
470
443
  200, # OK
471
444
  ],
@@ -516,9 +489,7 @@ module QingStor
516
489
  },
517
490
  request_elements: {
518
491
  },
519
-
520
492
  request_body: nil,
521
-
522
493
  status_code: [
523
494
  200, # OK
524
495
  ],
@@ -556,9 +527,7 @@ module QingStor
556
527
  },
557
528
  request_elements: {
558
529
  },
559
-
560
530
  request_body: nil,
561
-
562
531
  status_code: [
563
532
  201, # Bucket created
564
533
  ],
@@ -597,9 +566,7 @@ module QingStor
597
566
  request_elements: {
598
567
  'acl' => acl,
599
568
  },
600
-
601
569
  request_body: nil,
602
-
603
570
  status_code: [
604
571
  200, # OK
605
572
  ],
@@ -678,9 +645,7 @@ module QingStor
678
645
  request_elements: {
679
646
  'cors_rules' => cors_rules,
680
647
  },
681
-
682
648
  request_body: nil,
683
-
684
649
  status_code: [
685
650
  200, # OK
686
651
  ],
@@ -733,9 +698,7 @@ module QingStor
733
698
  request_elements: {
734
699
  'source_site' => source_site,
735
700
  },
736
-
737
701
  request_body: nil,
738
-
739
702
  status_code: [
740
703
  200, # OK
741
704
  ],
@@ -778,9 +741,7 @@ module QingStor
778
741
  request_elements: {
779
742
  'statement' => statement,
780
743
  },
781
-
782
744
  request_body: nil,
783
-
784
745
  status_code: [
785
746
  200, # OK
786
747
  ],
@@ -43,9 +43,7 @@ module QingStor
43
43
  },
44
44
  request_elements: {
45
45
  },
46
-
47
46
  request_body: nil,
48
-
49
47
  status_code: [
50
48
  204, # Object multipart deleted
51
49
  ],
@@ -103,9 +101,7 @@ module QingStor
103
101
  request_elements: {
104
102
  'object_parts' => object_parts,
105
103
  },
106
-
107
104
  request_body: nil,
108
-
109
105
  status_code: [
110
106
  201, # Object created
111
107
  ],
@@ -154,9 +150,7 @@ module QingStor
154
150
  },
155
151
  request_elements: {
156
152
  },
157
-
158
153
  request_body: nil,
159
-
160
154
  status_code: [
161
155
  204, # Object deleted
162
156
  ],
@@ -224,9 +218,7 @@ module QingStor
224
218
  },
225
219
  request_elements: {
226
220
  },
227
-
228
221
  request_body: nil,
229
-
230
222
  status_code: [
231
223
  200, # OK
232
224
  206, # Partial content
@@ -293,9 +285,7 @@ module QingStor
293
285
  },
294
286
  request_elements: {
295
287
  },
296
-
297
288
  request_body: nil,
298
-
299
289
  status_code: [
300
290
  200, # OK
301
291
  ],
@@ -347,9 +337,7 @@ module QingStor
347
337
  },
348
338
  request_elements: {
349
339
  },
350
-
351
340
  request_body: nil,
352
-
353
341
  status_code: [
354
342
  200, # OK
355
343
  ],
@@ -397,9 +385,7 @@ module QingStor
397
385
  },
398
386
  request_elements: {
399
387
  },
400
-
401
388
  request_body: nil,
402
-
403
389
  status_code: [
404
390
  200, # OK
405
391
  ],
@@ -451,9 +437,7 @@ module QingStor
451
437
  },
452
438
  request_elements: {
453
439
  },
454
-
455
440
  request_body: nil,
456
-
457
441
  status_code: [
458
442
  200, # OK
459
443
  ],
@@ -496,6 +480,7 @@ module QingStor
496
480
  x_qs_encryption_customer_algorithm: '',
497
481
  x_qs_encryption_customer_key: '',
498
482
  x_qs_encryption_customer_key_md5: '',
483
+ x_qs_fetch_if_unmodified_since: '',
499
484
  x_qs_fetch_source: '',
500
485
  x_qs_move_source: '',
501
486
  body: nil)
@@ -514,6 +499,7 @@ module QingStor
514
499
  x_qs_encryption_customer_algorithm: x_qs_encryption_customer_algorithm,
515
500
  x_qs_encryption_customer_key: x_qs_encryption_customer_key,
516
501
  x_qs_encryption_customer_key_md5: x_qs_encryption_customer_key_md5,
502
+ x_qs_fetch_if_unmodified_since: x_qs_fetch_if_unmodified_since,
517
503
  x_qs_fetch_source: x_qs_fetch_source,
518
504
  x_qs_move_source: x_qs_move_source,
519
505
  body: body
@@ -535,6 +521,7 @@ module QingStor
535
521
  x_qs_encryption_customer_algorithm: '',
536
522
  x_qs_encryption_customer_key: '',
537
523
  x_qs_encryption_customer_key_md5: '',
524
+ x_qs_fetch_if_unmodified_since: '',
538
525
  x_qs_fetch_source: '',
539
526
  x_qs_move_source: '',
540
527
  body: nil)
@@ -563,14 +550,13 @@ module QingStor
563
550
  'X-QS-Encryption-Customer-Algorithm' => x_qs_encryption_customer_algorithm,
564
551
  'X-QS-Encryption-Customer-Key' => x_qs_encryption_customer_key,
565
552
  'X-QS-Encryption-Customer-Key-MD5' => x_qs_encryption_customer_key_md5,
553
+ 'X-QS-Fetch-If-Unmodified-Since' => x_qs_fetch_if_unmodified_since,
566
554
  'X-QS-Fetch-Source' => x_qs_fetch_source,
567
555
  'X-QS-Move-Source' => x_qs_move_source,
568
556
  },
569
557
  request_elements: {
570
558
  },
571
-
572
559
  request_body: body,
573
-
574
560
  status_code: [
575
561
  201, # Object created
576
562
  ],
@@ -634,9 +620,7 @@ module QingStor
634
620
  },
635
621
  request_elements: {
636
622
  },
637
-
638
623
  request_body: body,
639
-
640
624
  status_code: [
641
625
  201, # Object multipart created
642
626
  ],
@@ -48,9 +48,7 @@ module QingStor
48
48
  },
49
49
  request_elements: {
50
50
  },
51
-
52
51
  request_body: nil,
53
-
54
52
  status_code: [
55
53
  200, # OK
56
54
  ],
@@ -16,6 +16,6 @@
16
16
 
17
17
  module QingStor
18
18
  module SDK
19
- VERSION = '2.0.0'.freeze
19
+ VERSION = '2.0.1'.freeze
20
20
  end
21
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qingstor-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
- - Jingwen Peng
7
+ - Yunify SDK Group
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-02 00:00:00.000000000 Z
11
+ date: 2016-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.13.2
61
+ version: 1.10.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.13.2
68
+ version: 1.10.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -108,9 +108,23 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: 0.12.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.45.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.45.0
111
125
  description: The official QingStor SDK for Ruby programming language.
112
126
  email:
113
- - pengsrc@yunify.com
127
+ - sdk_group@yunify.com
114
128
  executables: []
115
129
  extensions: []
116
130
  extra_rdoc_files: []