qingstor-sdk 2.2.0 → 2.2.1

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: c017ab0377c9dbe06078e86770f14657f3a3c119
4
- data.tar.gz: a94c9695d19a24647392a92ee09ea5cd0da7e831
3
+ metadata.gz: c85e73c270e2630d4e2499bd7ef31f1b6e246d2d
4
+ data.tar.gz: 1b3a584bbee63df761921a43d4f8270ae42beab0
5
5
  SHA512:
6
- metadata.gz: beb1bf011b11f37dc244d3840ff7fba7ea0130ae3177d167da5e45368c8d5636e68d27a5da4fd1b653a5cf0e25b45ecfd99186135f0d2967f4da4d97544487ce
7
- data.tar.gz: 8a4627ef7a91cd0fee08aee91d9769e9fa87ccd34ef4fe0b23161137168f79b8cdfce92e3b2222060fbdda2d7ccb28ca1af4e433fde488fec029d4052c125bce
6
+ metadata.gz: 8246701fa0c00c9959dce2e967984fdb9427c0378272eb510766fab145b3a276e4b79d0e275190e297275f96939f82cdce8016e1f3f34a6280e917fc36461c64
7
+ data.tar.gz: ac8bc039c6f9be943efae10848bfdc03b225e2d5a7264510f900de43b940998ae7734fcb7d36676d1c65b8b932b4eb53aaf58fb59741197133e538756a0e2c9d
data/README.md CHANGED
@@ -31,7 +31,7 @@ Specify `qingstor-sdk` as dependency in your application's Gemfile:
31
31
  gem 'qingstor-sdk'
32
32
  ```
33
33
 
34
- Ensure `qingstor-sdk` is installed as dependency with `bundle-install`:
34
+ Ensure `qingstor-sdk` is installed as dependency with `bundle install`:
35
35
 
36
36
  ``` bash
37
37
  $ bundle install
@@ -169,13 +169,19 @@ log_level: 'warn'
169
169
  ## Change Log
170
170
  All notable changes to QingStor SDK for Ruby will be documented here.
171
171
 
172
- ## [v2.2.0] - 2017-02-28
172
+ ### [v2.2.1] - 2017-03-10
173
173
 
174
- ### Added
174
+ #### Added
175
+
176
+ - Allow user to append additional info to User-Agent
177
+
178
+ ### [v2.2.0] - 2017-02-28
179
+
180
+ #### Added
175
181
 
176
182
  - Add ListMultipartUploads API.
177
183
 
178
- ### Fixed
184
+ #### Fixed
179
185
 
180
186
  - Fix request builder & signer.
181
187
 
@@ -228,7 +234,8 @@ All notable changes to QingStor SDK for Ruby will be documented here.
228
234
  The Apache License (Version 2.0, January 2004).
229
235
 
230
236
  [compatible]: https://github.com/yunify/qingstor-sdk-ruby/tree/compatible
231
- [v2.2.0]: https://github.com/yunify/qingstor-sdk-ruby/compare/v2.1.2...v2.2.0
237
+ [v2.2.1]: https://github.com/yunify/qingstor-sdk-ruby/compare/v2.2.0...v2.2.1
238
+ [v2.2.0]: https://github.com/yunify/qingstor-sdk-ruby/compare/v2.1.1...v2.2.0
232
239
  [v2.1.1]: https://github.com/yunify/qingstor-sdk-ruby/compare/v2.1.0...v2.1.1
233
240
  [v2.1.0]: https://github.com/yunify/qingstor-sdk-ruby/compare/v2.0.1...v2.1.0
234
241
  [v2.0.1]: https://github.com/yunify/qingstor-sdk-ruby/compare/v2.0.0...v2.0.1
@@ -46,6 +46,23 @@ 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
+
49
66
  def load_default_config
50
67
  load_config_from_file Contract::DEFAULT_CONFIG_FILEPATH
51
68
  end
@@ -1,12 +1,15 @@
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
+
11
14
  # Valid log levels are "debug", "info", "warn", "error", and "fatal".
12
- log_level: 'warn'
15
+ log_level: warn
@@ -14,11 +14,21 @@
14
14
  # | limitations under the License.
15
15
  # +-------------------------------------------------------------------------
16
16
 
17
- module QingCloud
17
+ module QingStor
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
+
22
32
  class NetworkError < SDKError
23
33
  end
24
34
 
@@ -92,6 +92,9 @@ module QingStor
92
92
  end
93
93
  unless input[:request_headers][:'User-Agent']
94
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
95
98
  input[:request_headers][:'User-Agent'] = ua
96
99
  end
97
100
 
@@ -99,11 +102,9 @@ module QingStor
99
102
  input[:request_headers][:'Content-MD5'] = Base64.encode64(Digest::MD5.digest(input[:request_body])).strip
100
103
  end
101
104
 
102
- input[:request_headers].map { |k, v|
103
- unless v.to_s.ascii_only?
104
- input[:request_headers][k] = escape v.to_s
105
- end
106
- }
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
107
108
 
108
109
  input[:request_headers]
109
110
  end
@@ -16,6 +16,6 @@
16
16
 
17
17
  module QingStor
18
18
  module SDK
19
- VERSION = '2.2.0'.freeze
19
+ VERSION = '2.2.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.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yunify SDK Group
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-28 00:00:00.000000000 Z
11
+ date: 2017-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport