qingstor-sdk 1.9.3 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 077caf573d40509928daa24c05cfc408e48507d3
4
- data.tar.gz: fd249954ffe298be5d12febad583f88f2124d13b
3
+ metadata.gz: 33359165658b13aa899f8ffdbb30f2562f9c0db9
4
+ data.tar.gz: ccb554de7a1c9c00ee90963655cb6c877dbe74ff
5
5
  SHA512:
6
- metadata.gz: 96ca254d7e4090112d58ff1da2cf7917dad9148a188b0cf38aa3f7f961ec482c2ec9643e8456e8a13fb4cd910c6e91d3ca3e89e17eeaa4721f402fd48978beb9
7
- data.tar.gz: 58002a2563f7f51147386998c8fe4ec9a910068f3e5840ff6e41a37163a1737edcdba68ae598e3ee697b12fc09027f551de4627277893a6663af55386d951442
6
+ metadata.gz: 8752923dafeeffbb74d46f4cc0054d23e7a066640f5762a00ad9732d27eb99055672dd01b958d3f7fd043b9cb8cdd0eea1b11767978650d835fb26f7da38a484
7
+ data.tar.gz: 00ffd9672d3f59322029a0afd5fe958b25c704f00deba2f80570e7d5c2535ee957aefd0ab216744b7f59e47ec21ffc8c5ad1b61f6c3bbaaa757426550ed482c5
data/README.md CHANGED
@@ -1,15 +1,19 @@
1
1
  # QingStor::SDK
2
2
 
3
+ <span style="display: inline-block">
3
4
  [![Build Status](https://travis-ci.org/yunify/qingstor-sdk-ruby.svg?branch=master)](https://travis-ci.org/yunify/qingstor-sdk-ruby)
4
5
  [![Gem Version](https://badge.fury.io/rb/qingstor-sdk.svg)](http://badge.fury.io/rb/qingstor-sdk)
5
6
  [![API Reference](http://img.shields.io/badge/api-reference-green.svg)](https://docs.qingcloud.com/qingstor/)
6
7
  [![License](http://img.shields.io/badge/license-apache%20v2-blue.svg)](https://github.com/yunify/qingstor-sdk-ruby/blob/master/LICENSE)
8
+ </span>
7
9
 
8
10
  The official QingStor SDK for Ruby programming language.
9
11
 
10
12
  ## Installation
11
13
 
12
- The current code branch is intended to be compatible with Ruby v1.9.x. If you are using Ruby v2.1 or higher, please checkout the [master][master] branch.
14
+ This Gem uses Ruby's _keyword arguments_ feature, thus Ruby 2.1.5 or higher is
15
+ required. See [this article](https://robots.thoughtbot.com/ruby-2-keyword-arguments)
16
+ for more details about _keyword arguments_.
13
17
 
14
18
  ### Install from RubyGems
15
19
 
@@ -36,7 +40,7 @@ $ bundle install
36
40
  Get code from GitHub:
37
41
 
38
42
  ``` bash
39
- $ git clone git@github.com:yunify/qingstor-sdk-ruby.git
43
+ $ git clone git@https://github.com/yunify/qingstor-sdk-ruby.git
40
44
  ```
41
45
 
42
46
  Build and install with bundler:
@@ -62,8 +66,8 @@ otherwise.
62
66
  ___API Access Key Example:___
63
67
 
64
68
  ``` yaml
65
- access_key_id: 'ACCESS_KEY_ID_EXAMPLE'
66
- secret_access_key: 'SECRET_ACCESS_KEY_EXAMPLE'
69
+ access_key_id: 'WMAGPAJBJRKQEBRCEADPWMAGPAJBJRK'
70
+ secret_access_key: 'Qkk89OcoIaMVZ0iOfnfivjxL7W5o7oOumMvvUiuF'
67
71
  ```
68
72
 
69
73
  ### Code Example
@@ -160,40 +164,6 @@ connection_retries: 3
160
164
  log_level: 'warn'
161
165
  ```
162
166
 
163
- ## Change Log
164
- All notable changes to QingStor SDK for Ruby will be documented here.
165
-
166
- ### [v1.9.3] - 2017-03-15
167
-
168
- #### Added
169
-
170
- - Allow user to append additional info to User-Agent.
171
- - Add request parameters for GET Object.
172
- - Add IP address conditions for bucket policy.
173
-
174
- ### Fixed
175
-
176
- - Resource is not mandatory in bucket policy statement.
177
-
178
- ### [v1.9.2] - 2017-01-23
179
-
180
- #### Fixed
181
-
182
- - Fix request builder.
183
- - Fix dependencies.
184
-
185
- ### [v1.9.1] - 2017-01-16
186
-
187
- #### Fixed
188
-
189
- - Fix request signer.
190
-
191
- ### v1.9.0 - 2017-01-13
192
-
193
- #### Changed
194
-
195
- - Be compatible with Ruby v1.9.x.
196
-
197
167
  ## Reference Documentations
198
168
 
199
169
  - [QingStor Documentation](https://docs.qingcloud.com/qingstor/index.html)
@@ -202,17 +172,8 @@ All notable changes to QingStor SDK for Ruby will be documented here.
202
172
 
203
173
  ## Contributing
204
174
 
205
- 1. Fork it ( https://github.com/yunify/qingstor-sdk-ruby/fork )
206
- 2. Create your feature branch (`git checkout -b new-feature`)
207
- 3. Commit your changes (`git commit -asm 'Add some feature'`)
208
- 4. Push to the branch (`git push origin new-feature`)
209
- 5. Create a new Pull Request
175
+ This repository is automatically generated, please contribute to [`Snips`](https://github.com/yunify/snips) instead.
210
176
 
211
177
  ## LICENSE
212
178
 
213
179
  The Apache License (Version 2.0, January 2004).
214
-
215
- [master]: https://github.com/yunify/qingstor-sdk-ruby/tree/master
216
- [v1.9.3]: https://github.com/yunify/qingstor-sdk-ruby/compare/v1.9.2...v1.9.3
217
- [v1.9.2]: https://github.com/yunify/qingstor-sdk-ruby/compare/v1.9.1...v1.9.2
218
- [v1.9.1]: https://github.com/yunify/qingstor-sdk-ruby/compare/v1.9.0...v1.9.1
@@ -46,23 +46,6 @@ module QingStor
46
46
  self
47
47
  end
48
48
 
49
- def check
50
- [:access_key_id, :secret_access_key, :host, :port, :protocol].each do |x|
51
- if !self[x] || self[x].to_s.empty?
52
- raise ConfigurationError, "#{x.to_sym} not specified"
53
- end
54
- end
55
- if self[:additional_user_agent] && !self[:additional_user_agent].empty?
56
- self[:additional_user_agent].each_byte do |x|
57
- # Allow space(32) to ~(126) in ASCII Table, exclude "(34).
58
- if x < 32 || x > 126 || x == 32 || x == 34
59
- raise ConfigurationError, 'additional User-Agent contains characters that not allowed'
60
- end
61
- end
62
- end
63
- self
64
- end
65
-
66
49
  def load_default_config
67
50
  load_config_from_file Contract::DEFAULT_CONFIG_FILEPATH
68
51
  end
@@ -1,15 +1,12 @@
1
1
  # QingStor services configuration
2
2
 
3
- #access_key_id: ACCESS_KEY_ID
4
- #secret_access_key: SECRET_ACCESS_KEY
3
+ #access_key_id: 'ACCESS_KEY_ID'
4
+ #secret_access_key: 'SECRET_ACCESS_KEY'
5
5
 
6
- host: qingstor.com
6
+ host: 'qingstor.com'
7
7
  port: 443
8
- protocol: https
8
+ protocol: 'https'
9
9
  connection_retries: 3
10
10
 
11
- # Additional User-Agent
12
- additional_user_agent: ""
13
-
14
11
  # Valid log levels are "debug", "info", "warn", "error", and "fatal".
15
- log_level: warn
12
+ log_level: 'warn'
@@ -14,21 +14,11 @@
14
14
  # | limitations under the License.
15
15
  # +-------------------------------------------------------------------------
16
16
 
17
- module QingStor
17
+ module QingCloud
18
18
  module SDK
19
19
  class SDKError < StandardError
20
20
  end
21
21
 
22
- class ConfigurationError < SDKError
23
- def initialize(error_message)
24
- @error_message = error_message
25
- end
26
-
27
- def message
28
- "configuration is not valid, #{@error_message}"
29
- end
30
- end
31
-
32
22
  class NetworkError < SDKError
33
23
  end
34
24
 
@@ -14,10 +14,6 @@
14
14
  # | limitations under the License.
15
15
  # +-------------------------------------------------------------------------
16
16
 
17
- require 'cgi'
18
- require 'base64'
19
- require 'digest'
20
-
21
17
  require 'active_support/core_ext/hash/keys'
22
18
  require 'mimemagic'
23
19
 
@@ -30,7 +26,6 @@ module QingStor
30
26
  input[:request_uri] = request_uri input
31
27
  input[:request_body] = request_body input
32
28
  input[:request_headers] = request_headers input
33
- input[:request_params] = request_params input
34
29
 
35
30
  display = {}
36
31
  input.each { |k, v| display[k] = v unless k.to_s == 'request_body' }
@@ -51,7 +46,7 @@ module QingStor
51
46
  def self.request_uri(input)
52
47
  unless input[:properties].nil?
53
48
  input[:properties].each do |k, v|
54
- input[:request_uri].gsub! "<#{k}>", (escape v.to_s)
49
+ input[:request_uri].gsub! "<#{k}>", v.to_s
55
50
  end
56
51
  end
57
52
  input[:request_uri]
@@ -59,14 +54,7 @@ module QingStor
59
54
 
60
55
  def self.request_body(input)
61
56
  body = input[:request_body]
62
- body = body.is_a?(File) ? body.read : body
63
- return body if body
64
-
65
- if input[:request_elements] && !input[:request_elements].empty?
66
- json_body = JSON.generate input[:request_elements]
67
- Logger.info "QingStor request json: [#{input[:id]}] #{json_body}"
68
- json_body
69
- end
57
+ body.is_a?(File) ? body.read : body
70
58
  end
71
59
 
72
60
  def self.request_headers(input)
@@ -91,33 +79,12 @@ module QingStor
91
79
  input[:request_headers][:'Content-Type'] = 'application/octet-stream'
92
80
  end
93
81
  unless input[:request_headers][:'User-Agent']
94
- ua = "qingstor-sdk-ruby/#{QingStor::SDK::VERSION} (Ruby v#{RUBY_VERSION}; #{RUBY_PLATFORM})"
95
- if input[:config][:additional_user_agent] && !input[:config][:additional_user_agent].empty?
96
- ua = "#{ua} #{input[:config][:additional_user_agent]}"
97
- end
82
+ ua = "QingStorSDK/#{QingStor::SDK::VERSION} (Ruby v#{RUBY_VERSION}; #{RUBY_PLATFORM})"
98
83
  input[:request_headers][:'User-Agent'] = ua
99
84
  end
100
-
101
- if input[:api_name] == 'Delete Multiple Objects'
102
- input[:request_headers][:'Content-MD5'] = Base64.encode64(Digest::MD5.digest(input[:request_body])).strip
103
- end
104
-
105
- input[:request_headers].map do |k, v|
106
- input[:request_headers][k] = escape v.to_s unless v.to_s.ascii_only?
107
- end
108
-
109
85
  input[:request_headers]
110
86
  end
111
87
 
112
- def self.request_params(input)
113
- unless input[:request_params].nil?
114
- input[:request_params].map do |k, v|
115
- input[:request_params][k] = escape v.to_s
116
- end
117
- end
118
- input[:request_params]
119
- end
120
-
121
88
  def self.decorate_input(input)
122
89
  input.deep_symbolize_keys!
123
90
  input[:id] = (Random.new.rand * 1_000_000).to_int
@@ -131,14 +98,6 @@ module QingStor
131
98
  end
132
99
  object
133
100
  end
134
-
135
- def self.escape(origin)
136
- origin = CGI.escape origin
137
- origin.gsub! '%2F', '/'
138
- origin.gsub! '%3D', '='
139
- origin.gsub! '+', '%20'
140
- origin
141
- end
142
101
  end
143
102
  end
144
103
  end
@@ -14,7 +14,6 @@
14
14
  # | limitations under the License.
15
15
  # +-------------------------------------------------------------------------
16
16
 
17
- require 'uri'
18
17
  require 'time'
19
18
  require 'json'
20
19
  require 'net/http'
@@ -63,15 +62,12 @@ module QingStor
63
62
 
64
63
  def build
65
64
  params = input[:request_params].map { |k, v| "#{k}=#{v}" }
66
- query_string = params.join '&'
67
- if query_string && !query_string.empty?
68
- query_string = "#{input[:request_uri].include?('?') ? '&' : '?'}#{query_string}"
69
- end
70
- self.request_url = URI "#{input[:request_endpoint]}#{input[:request_uri]}#{query_string}"
65
+ query_string = !params.empty? ? "?#{params.join '&'}" : ''
66
+ self.request_url = "#{input[:request_endpoint]}#{Signer.escape input[:request_uri]}#{query_string}"
71
67
 
72
- request = new_http_request input[:request_method], request_url.to_s
73
- request.body = input[:request_body]
74
- input[:request_headers].each { |k, v| request[k.to_s] = v }
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 }
75
71
 
76
72
  self.http_request = request
77
73
  end
@@ -106,6 +102,18 @@ module QingStor
106
102
  end
107
103
  end
108
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
+
109
117
  def new_http_request(method, url)
110
118
  case method
111
119
  when 'GET'
@@ -87,22 +87,29 @@ module QingStor
87
87
  end
88
88
 
89
89
  def self.canonicalized_resource(input)
90
+ path = escape input[:request_uri]
91
+
90
92
  params = input[:request_params].keys.sort.map { |k|
91
93
  if sub_resource? k.to_s
92
94
  v = input[:request_params][k].to_s.strip
93
- !v.nil? && v != '' ? "#{k}=#{CGI.unescape v}" : k
95
+ !v.nil? && v != '' ? "#{k}=#{escape v}" : k
94
96
  end
95
97
  }.compact.join '&'
96
- params = input[:request_uri].include?('?') ? "&#{params}" : "?#{params}" if params != ''
97
- "#{input[:request_uri]}#{params}"
98
+ params = path.include?('?') ? "&#{params}" : "?#{params}" if params != ''
99
+ "#{path}#{params}"
100
+ end
101
+
102
+ def self.escape(original)
103
+ result = CGI.escape(original)
104
+ result.gsub! '%3F', '?'
105
+ result.gsub! '%2F', '/'
106
+ result.gsub! '+', '%20'
107
+ result.gsub! '%2B', '+'
108
+ result
98
109
  end
99
110
 
100
111
  def self.sub_resource?(key)
101
- %w(
102
- acl cors delete mirror part_number policy stats upload_id uploads
103
- response-expires response-cache-control response-content-type
104
- response-content-language response-content-encoding response-content-disposition
105
- ).include? key
112
+ %w(acl cors delete mirror part_number policy stats upload_id uploads).include? key
106
113
  end
107
114
  end
108
115
  end
@@ -28,18 +28,12 @@ module QingStor
28
28
 
29
29
  # delete_bucket: Delete a bucket.
30
30
  # Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/delete.html
31
- #
32
- # == Options
33
- #
34
- #
35
- def delete(options = {})
36
- options.deep_stringify_keys!
37
- request = delete_request options
31
+ def delete
32
+ request = delete_request
38
33
  request.send
39
34
  end
40
35
 
41
- def delete_request(options = {})
42
- options.deep_stringify_keys!
36
+ def delete_request
43
37
  input = {
44
38
  config: config,
45
39
  properties: properties,
@@ -52,7 +46,9 @@ module QingStor
52
46
  },
53
47
  request_elements: {
54
48
  },
49
+
55
50
  request_body: nil,
51
+
56
52
  status_code: [
57
53
  204, # Bucket deleted
58
54
  ],
@@ -72,18 +68,12 @@ module QingStor
72
68
 
73
69
  # delete_bucket_cors: Delete CORS information of the bucket.
74
70
  # Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/cors/delete_cors.html
75
- #
76
- # == Options
77
- #
78
- #
79
- def delete_cors(options = {})
80
- options.deep_stringify_keys!
81
- request = delete_cors_request options
71
+ def delete_cors
72
+ request = delete_cors_request
82
73
  request.send
83
74
  end
84
75
 
85
- def delete_cors_request(options = {})
86
- options.deep_stringify_keys!
76
+ def delete_cors_request
87
77
  input = {
88
78
  config: config,
89
79
  properties: properties,
@@ -96,7 +86,9 @@ module QingStor
96
86
  },
97
87
  request_elements: {
98
88
  },
89
+
99
90
  request_body: nil,
91
+
100
92
  status_code: [
101
93
  200, # OK
102
94
  ],
@@ -116,18 +108,12 @@ module QingStor
116
108
 
117
109
  # delete_bucket_external_mirror: Delete external mirror of the bucket.
118
110
  # Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/external_mirror/delete_external_mirror.html
119
- #
120
- # == Options
121
- #
122
- #
123
- def delete_external_mirror(options = {})
124
- options.deep_stringify_keys!
125
- request = delete_external_mirror_request options
111
+ def delete_external_mirror
112
+ request = delete_external_mirror_request
126
113
  request.send
127
114
  end
128
115
 
129
- def delete_external_mirror_request(options = {})
130
- options.deep_stringify_keys!
116
+ def delete_external_mirror_request
131
117
  input = {
132
118
  config: config,
133
119
  properties: properties,
@@ -140,7 +126,9 @@ module QingStor
140
126
  },
141
127
  request_elements: {
142
128
  },
129
+
143
130
  request_body: nil,
131
+
144
132
  status_code: [
145
133
  204, # No content
146
134
  ],
@@ -160,18 +148,12 @@ module QingStor
160
148
 
161
149
  # delete_bucket_policy: Delete policy information of the bucket.
162
150
  # Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/policy/delete_policy.html
163
- #
164
- # == Options
165
- #
166
- #
167
- def delete_policy(options = {})
168
- options.deep_stringify_keys!
169
- request = delete_policy_request options
151
+ def delete_policy
152
+ request = delete_policy_request
170
153
  request.send
171
154
  end
172
155
 
173
- def delete_policy_request(options = {})
174
- options.deep_stringify_keys!
156
+ def delete_policy_request
175
157
  input = {
176
158
  config: config,
177
159
  properties: properties,
@@ -184,7 +166,9 @@ module QingStor
184
166
  },
185
167
  request_elements: {
186
168
  },
169
+
187
170
  request_body: nil,
171
+
188
172
  status_code: [
189
173
  204, # No content
190
174
  ],
@@ -204,21 +188,15 @@ module QingStor
204
188
 
205
189
  # delete_multiple_objects: Delete multiple objects from the bucket.
206
190
  # Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/delete_multiple.html
207
- #
208
- # == Options
209
- #
210
- # * +:content_md5+ - Object MD5sum
211
- # * +:objects+ - A list of keys to delete
212
- # * +:quiet+ - Whether to return the list of deleted objects
213
- #
214
- def delete_multiple_objects(options = {})
215
- options.deep_stringify_keys!
216
- request = delete_multiple_objects_request options
191
+ def delete_multiple_objects(content_md5: '', objects: [],
192
+ quiet: nil)
193
+ request = delete_multiple_objects_request content_md5: content_md5, objects: objects,
194
+ quiet: quiet
217
195
  request.send
218
196
  end
219
197
 
220
- def delete_multiple_objects_request(options = {})
221
- options.deep_stringify_keys!
198
+ def delete_multiple_objects_request(content_md5: '', objects: [],
199
+ quiet: nil)
222
200
  input = {
223
201
  config: config,
224
202
  properties: properties,
@@ -228,12 +206,15 @@ module QingStor
228
206
  request_params: {
229
207
  },
230
208
  request_headers: {
209
+ 'Content-MD5' => content_md5,
231
210
  },
232
211
  request_elements: {
233
- 'objects' => options['objects'],
234
- 'quiet' => options['quiet'],
212
+ 'objects' => objects,
213
+ 'quiet' => quiet,
235
214
  },
215
+
236
216
  request_body: nil,
217
+
237
218
  status_code: [
238
219
  200, # OK
239
220
  ],
@@ -248,6 +229,10 @@ module QingStor
248
229
  def delete_multiple_objects_input_validate(input)
249
230
  input.deep_stringify_keys!
250
231
 
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
+
251
236
  unless !input['request_elements']['objects'].nil? && !input['request_elements']['objects'].to_s.empty?
252
237
  raise ParameterRequiredError.new('objects', 'DeleteMultipleObjectsInput')
253
238
  end
@@ -260,18 +245,12 @@ module QingStor
260
245
 
261
246
  # get_bucket_acl: Get ACL information of the bucket.
262
247
  # Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/get_acl.html
263
- #
264
- # == Options
265
- #
266
- #
267
- def get_acl(options = {})
268
- options.deep_stringify_keys!
269
- request = get_acl_request options
248
+ def get_acl
249
+ request = get_acl_request
270
250
  request.send
271
251
  end
272
252
 
273
- def get_acl_request(options = {})
274
- options.deep_stringify_keys!
253
+ def get_acl_request
275
254
  input = {
276
255
  config: config,
277
256
  properties: properties,
@@ -284,7 +263,9 @@ module QingStor
284
263
  },
285
264
  request_elements: {
286
265
  },
266
+
287
267
  request_body: nil,
268
+
288
269
  status_code: [
289
270
  200, # OK
290
271
  ],
@@ -304,18 +285,12 @@ module QingStor
304
285
 
305
286
  # get_bucket_cors: Get CORS information of the bucket.
306
287
  # Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/cors/get_cors.html
307
- #
308
- # == Options
309
- #
310
- #
311
- def get_cors(options = {})
312
- options.deep_stringify_keys!
313
- request = get_cors_request options
288
+ def get_cors
289
+ request = get_cors_request
314
290
  request.send
315
291
  end
316
292
 
317
- def get_cors_request(options = {})
318
- options.deep_stringify_keys!
293
+ def get_cors_request
319
294
  input = {
320
295
  config: config,
321
296
  properties: properties,
@@ -328,7 +303,9 @@ module QingStor
328
303
  },
329
304
  request_elements: {
330
305
  },
306
+
331
307
  request_body: nil,
308
+
332
309
  status_code: [
333
310
  200, # OK
334
311
  ],
@@ -348,18 +325,12 @@ module QingStor
348
325
 
349
326
  # get_bucket_external_mirror: Get external mirror of the bucket.
350
327
  # Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/external_mirror/get_external_mirror.html
351
- #
352
- # == Options
353
- #
354
- #
355
- def get_external_mirror(options = {})
356
- options.deep_stringify_keys!
357
- request = get_external_mirror_request options
328
+ def get_external_mirror
329
+ request = get_external_mirror_request
358
330
  request.send
359
331
  end
360
332
 
361
- def get_external_mirror_request(options = {})
362
- options.deep_stringify_keys!
333
+ def get_external_mirror_request
363
334
  input = {
364
335
  config: config,
365
336
  properties: properties,
@@ -372,7 +343,9 @@ module QingStor
372
343
  },
373
344
  request_elements: {
374
345
  },
346
+
375
347
  request_body: nil,
348
+
376
349
  status_code: [
377
350
  200, # OK
378
351
  ],
@@ -392,18 +365,12 @@ module QingStor
392
365
 
393
366
  # get_bucket_policy: Get policy information of the bucket.
394
367
  # Documentation URL: https://https://docs.qingcloud.com/qingstor/api/bucket/policy/get_policy.html
395
- #
396
- # == Options
397
- #
398
- #
399
- def get_policy(options = {})
400
- options.deep_stringify_keys!
401
- request = get_policy_request options
368
+ def get_policy
369
+ request = get_policy_request
402
370
  request.send
403
371
  end
404
372
 
405
- def get_policy_request(options = {})
406
- options.deep_stringify_keys!
373
+ def get_policy_request
407
374
  input = {
408
375
  config: config,
409
376
  properties: properties,
@@ -416,7 +383,9 @@ module QingStor
416
383
  },
417
384
  request_elements: {
418
385
  },
386
+
419
387
  request_body: nil,
388
+
420
389
  status_code: [
421
390
  200, # OK
422
391
  ],
@@ -436,18 +405,12 @@ module QingStor
436
405
 
437
406
  # get_bucket_statistics: Get statistics information of the bucket.
438
407
  # Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/get_stats.html
439
- #
440
- # == Options
441
- #
442
- #
443
- def get_statistics(options = {})
444
- options.deep_stringify_keys!
445
- request = get_statistics_request options
408
+ def get_statistics
409
+ request = get_statistics_request
446
410
  request.send
447
411
  end
448
412
 
449
- def get_statistics_request(options = {})
450
- options.deep_stringify_keys!
413
+ def get_statistics_request
451
414
  input = {
452
415
  config: config,
453
416
  properties: properties,
@@ -460,7 +423,9 @@ module QingStor
460
423
  },
461
424
  request_elements: {
462
425
  },
426
+
463
427
  request_body: nil,
428
+
464
429
  status_code: [
465
430
  200, # OK
466
431
  ],
@@ -480,18 +445,12 @@ module QingStor
480
445
 
481
446
  # head_bucket: Check whether the bucket exists and available.
482
447
  # Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/head.html
483
- #
484
- # == Options
485
- #
486
- #
487
- def head(options = {})
488
- options.deep_stringify_keys!
489
- request = head_request options
448
+ def head
449
+ request = head_request
490
450
  request.send
491
451
  end
492
452
 
493
- def head_request(options = {})
494
- options.deep_stringify_keys!
453
+ def head_request
495
454
  input = {
496
455
  config: config,
497
456
  properties: properties,
@@ -504,7 +463,9 @@ module QingStor
504
463
  },
505
464
  request_elements: {
506
465
  },
466
+
507
467
  request_body: nil,
468
+
508
469
  status_code: [
509
470
  200, # OK
510
471
  ],
@@ -522,76 +483,23 @@ module QingStor
522
483
 
523
484
  public
524
485
 
525
- # list_multipart_uploads: List multipart uploads in the bucket.
526
- # Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/list_multipart_uploads.html
527
- #
528
- # == Options
529
- #
530
- # * +:delimiter+ - Put all keys that share a common prefix into a list
531
- # * +:limit+ - Results count limit
532
- # * +:marker+ - Limit results to keys that start at this marker
533
- # * +:prefix+ - Limits results to keys that begin with the prefix
534
- #
535
- def list_multipart_uploads(options = {})
536
- options.deep_stringify_keys!
537
- request = list_multipart_uploads_request options
538
- request.send
539
- end
540
-
541
- def list_multipart_uploads_request(options = {})
542
- options.deep_stringify_keys!
543
- input = {
544
- config: config,
545
- properties: properties,
546
- api_name: 'List Multipart Uploads',
547
- request_method: 'GET',
548
- request_uri: '/<bucket-name>?uploads',
549
- request_params: {
550
- 'delimiter' => options['delimiter'],
551
- 'limit' => options['limit'],
552
- 'marker' => options['marker'],
553
- 'prefix' => options['prefix'],
554
- },
555
- request_headers: {
556
- },
557
- request_elements: {
558
- },
559
- request_body: nil,
560
- status_code: [
561
- 200, # OK
562
- ],
563
- }
564
-
565
- list_multipart_uploads_input_validate input
566
- Request.new input
567
- end
568
-
569
- private
570
-
571
- def list_multipart_uploads_input_validate(input)
572
- input.deep_stringify_keys!
573
- end
574
-
575
- public
576
-
577
486
  # list_objects: Retrieve the object list in a bucket.
578
487
  # Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/get.html
579
- #
580
- # == Options
581
- #
582
- # * +:delimiter+ - Put all keys that share a common prefix into a list
583
- # * +:limit+ - Results count limit
584
- # * +:marker+ - Limit results to keys that start at this marker
585
- # * +:prefix+ - Limits results to keys that begin with the prefix
586
- #
587
- def list_objects(options = {})
588
- options.deep_stringify_keys!
589
- request = list_objects_request options
488
+ def list_objects(delimiter: '',
489
+ limit: nil,
490
+ marker: '',
491
+ prefix: '')
492
+ request = list_objects_request delimiter: delimiter,
493
+ limit: limit,
494
+ marker: marker,
495
+ prefix: prefix
590
496
  request.send
591
497
  end
592
498
 
593
- def list_objects_request(options = {})
594
- options.deep_stringify_keys!
499
+ def list_objects_request(delimiter: '',
500
+ limit: nil,
501
+ marker: '',
502
+ prefix: '')
595
503
  input = {
596
504
  config: config,
597
505
  properties: properties,
@@ -599,16 +507,18 @@ module QingStor
599
507
  request_method: 'GET',
600
508
  request_uri: '/<bucket-name>',
601
509
  request_params: {
602
- 'delimiter' => options['delimiter'],
603
- 'limit' => options['limit'],
604
- 'marker' => options['marker'],
605
- 'prefix' => options['prefix'],
510
+ 'delimiter' => delimiter,
511
+ 'limit' => limit,
512
+ 'marker' => marker,
513
+ 'prefix' => prefix,
606
514
  },
607
515
  request_headers: {
608
516
  },
609
517
  request_elements: {
610
518
  },
519
+
611
520
  request_body: nil,
521
+
612
522
  status_code: [
613
523
  200, # OK
614
524
  ],
@@ -628,18 +538,12 @@ module QingStor
628
538
 
629
539
  # put_bucket: Create a new bucket.
630
540
  # Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/put.html
631
- #
632
- # == Options
633
- #
634
- #
635
- def put(options = {})
636
- options.deep_stringify_keys!
637
- request = put_request options
541
+ def put
542
+ request = put_request
638
543
  request.send
639
544
  end
640
545
 
641
- def put_request(options = {})
642
- options.deep_stringify_keys!
546
+ def put_request
643
547
  input = {
644
548
  config: config,
645
549
  properties: properties,
@@ -652,7 +556,9 @@ module QingStor
652
556
  },
653
557
  request_elements: {
654
558
  },
559
+
655
560
  request_body: nil,
561
+
656
562
  status_code: [
657
563
  201, # Bucket created
658
564
  ],
@@ -672,19 +578,12 @@ module QingStor
672
578
 
673
579
  # put_bucket_acl: Set ACL information of the bucket.
674
580
  # Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/put_acl.html
675
- #
676
- # == Options
677
- #
678
- # * +:acl+ - Bucket ACL rules
679
- #
680
- def put_acl(options = {})
681
- options.deep_stringify_keys!
682
- request = put_acl_request options
581
+ def put_acl(acl: [])
582
+ request = put_acl_request acl: acl
683
583
  request.send
684
584
  end
685
585
 
686
- def put_acl_request(options = {})
687
- options.deep_stringify_keys!
586
+ def put_acl_request(acl: [])
688
587
  input = {
689
588
  config: config,
690
589
  properties: properties,
@@ -696,9 +595,11 @@ module QingStor
696
595
  request_headers: {
697
596
  },
698
597
  request_elements: {
699
- 'acl' => options['acl'],
598
+ 'acl' => acl,
700
599
  },
600
+
701
601
  request_body: nil,
602
+
702
603
  status_code: [
703
604
  200, # OK
704
605
  ],
@@ -758,19 +659,12 @@ module QingStor
758
659
 
759
660
  # put_bucket_cors: Set CORS information of the bucket.
760
661
  # Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/cors/put_cors.html
761
- #
762
- # == Options
763
- #
764
- # * +:cors_rules+ - Bucket CORS rules
765
- #
766
- def put_cors(options = {})
767
- options.deep_stringify_keys!
768
- request = put_cors_request options
662
+ def put_cors(cors_rules: [])
663
+ request = put_cors_request cors_rules: cors_rules
769
664
  request.send
770
665
  end
771
666
 
772
- def put_cors_request(options = {})
773
- options.deep_stringify_keys!
667
+ def put_cors_request(cors_rules: [])
774
668
  input = {
775
669
  config: config,
776
670
  properties: properties,
@@ -782,9 +676,11 @@ module QingStor
782
676
  request_headers: {
783
677
  },
784
678
  request_elements: {
785
- 'cors_rules' => options['cors_rules'],
679
+ 'cors_rules' => cors_rules,
786
680
  },
681
+
787
682
  request_body: nil,
683
+
788
684
  status_code: [
789
685
  200, # OK
790
686
  ],
@@ -818,19 +714,12 @@ module QingStor
818
714
 
819
715
  # put_bucket_external_mirror: Set external mirror of the bucket.
820
716
  # Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/external_mirror/put_external_mirror.html
821
- #
822
- # == Options
823
- #
824
- # * +:source_site+ - Source site url
825
- #
826
- def put_external_mirror(options = {})
827
- options.deep_stringify_keys!
828
- request = put_external_mirror_request options
717
+ def put_external_mirror(source_site: '')
718
+ request = put_external_mirror_request source_site: source_site
829
719
  request.send
830
720
  end
831
721
 
832
- def put_external_mirror_request(options = {})
833
- options.deep_stringify_keys!
722
+ def put_external_mirror_request(source_site: '')
834
723
  input = {
835
724
  config: config,
836
725
  properties: properties,
@@ -842,9 +731,11 @@ module QingStor
842
731
  request_headers: {
843
732
  },
844
733
  request_elements: {
845
- 'source_site' => options['source_site'],
734
+ 'source_site' => source_site,
846
735
  },
736
+
847
737
  request_body: nil,
738
+
848
739
  status_code: [
849
740
  200, # OK
850
741
  ],
@@ -868,19 +759,12 @@ module QingStor
868
759
 
869
760
  # put_bucket_policy: Set policy information of the bucket.
870
761
  # Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/policy/put_policy.html
871
- #
872
- # == Options
873
- #
874
- # * +:statement+ - Bucket policy statement
875
- #
876
- def put_policy(options = {})
877
- options.deep_stringify_keys!
878
- request = put_policy_request options
762
+ def put_policy(statement: [])
763
+ request = put_policy_request statement: statement
879
764
  request.send
880
765
  end
881
766
 
882
- def put_policy_request(options = {})
883
- options.deep_stringify_keys!
767
+ def put_policy_request(statement: [])
884
768
  input = {
885
769
  config: config,
886
770
  properties: properties,
@@ -892,9 +776,11 @@ module QingStor
892
776
  request_headers: {
893
777
  },
894
778
  request_elements: {
895
- 'statement' => options['statement'],
779
+ 'statement' => statement,
896
780
  },
781
+
897
782
  request_body: nil,
783
+
898
784
  status_code: [
899
785
  200, # OK
900
786
  ],
@@ -920,18 +806,10 @@ module QingStor
920
806
 
921
807
  unless x['condition'].nil?
922
808
 
923
- unless x['condition']['ip_address'].nil?
924
-
925
- end
926
-
927
809
  unless x['condition']['is_null'].nil?
928
810
 
929
811
  end
930
812
 
931
- unless x['condition']['not_ip_address'].nil?
932
-
933
- end
934
-
935
813
  unless x['condition']['string_like'].nil?
936
814
 
937
815
  end
@@ -961,6 +839,10 @@ module QingStor
961
839
  raise ParameterRequiredError.new('id', 'statement')
962
840
  end
963
841
 
842
+ unless !x['resource'].nil? && !x['resource'].to_s.empty?
843
+ raise ParameterRequiredError.new('resource', 'statement')
844
+ end
845
+
964
846
  unless !x['user'].nil? && !x['user'].to_s.empty?
965
847
  raise ParameterRequiredError.new('user', 'statement')
966
848
  end