qingstor-sdk 1.9.2 → 1.9.3

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: 263b91ca92ae77072e2332a22e1bdb7cbff66f1c
4
- data.tar.gz: 71ce0e672123b085c239af8cc3234f5c8bc96eea
3
+ metadata.gz: 077caf573d40509928daa24c05cfc408e48507d3
4
+ data.tar.gz: fd249954ffe298be5d12febad583f88f2124d13b
5
5
  SHA512:
6
- metadata.gz: ff856c3fd10328cc09f4080c526bcea7fd8707145f6bae10bf21b092352198637f7bcada0caf5c00ef80c821b70d8595dc5d96ec8241e74346e01bd77ad15f3a
7
- data.tar.gz: e07eb400e5a6afafcf084611d79f94469c0381ffa79f0eafc1f9091106936744cb382e76e812614c1d6c2ec8526866ce7d2c74a82df649d25cc4f8c0aa0ec5a1
6
+ metadata.gz: 96ca254d7e4090112d58ff1da2cf7917dad9148a188b0cf38aa3f7f961ec482c2ec9643e8456e8a13fb4cd910c6e91d3ca3e89e17eeaa4721f402fd48978beb9
7
+ data.tar.gz: 58002a2563f7f51147386998c8fe4ec9a910068f3e5840ff6e41a37163a1737edcdba68ae598e3ee697b12fc09027f551de4627277893a6663af55386d951442
data/README.md CHANGED
@@ -1,11 +1,9 @@
1
1
  # QingStor::SDK
2
2
 
3
- <span style="display: inline-block">
4
3
  [![Build Status](https://travis-ci.org/yunify/qingstor-sdk-ruby.svg?branch=master)](https://travis-ci.org/yunify/qingstor-sdk-ruby)
5
4
  [![Gem Version](https://badge.fury.io/rb/qingstor-sdk.svg)](http://badge.fury.io/rb/qingstor-sdk)
6
5
  [![API Reference](http://img.shields.io/badge/api-reference-green.svg)](https://docs.qingcloud.com/qingstor/)
7
6
  [![License](http://img.shields.io/badge/license-apache%20v2-blue.svg)](https://github.com/yunify/qingstor-sdk-ruby/blob/master/LICENSE)
8
- </span>
9
7
 
10
8
  The official QingStor SDK for Ruby programming language.
11
9
 
@@ -165,6 +163,18 @@ log_level: 'warn'
165
163
  ## Change Log
166
164
  All notable changes to QingStor SDK for Ruby will be documented here.
167
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
+
168
178
  ### [v1.9.2] - 2017-01-23
169
179
 
170
180
  #### Fixed
@@ -203,5 +213,6 @@ All notable changes to QingStor SDK for Ruby will be documented here.
203
213
  The Apache License (Version 2.0, January 2004).
204
214
 
205
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
206
217
  [v1.9.2]: https://github.com/yunify/qingstor-sdk-ruby/compare/v1.9.1...v1.9.2
207
218
  [v1.9.1]: https://github.com/yunify/qingstor-sdk-ruby/compare/v1.9.0...v1.9.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
 
@@ -51,7 +51,7 @@ module QingStor
51
51
  def self.request_uri(input)
52
52
  unless input[:properties].nil?
53
53
  input[:properties].each do |k, v|
54
- input[:request_uri].gsub! "<#{k}>", v.to_s
54
+ input[:request_uri].gsub! "<#{k}>", (escape v.to_s)
55
55
  end
56
56
  end
57
57
  input[:request_uri]
@@ -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,14 +102,17 @@ module QingStor
99
102
  input[:request_headers][:'Content-MD5'] = Base64.encode64(Digest::MD5.digest(input[:request_body])).strip
100
103
  end
101
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
+
102
109
  input[:request_headers]
103
110
  end
104
111
 
105
112
  def self.request_params(input)
106
113
  unless input[:request_params].nil?
107
114
  input[:request_params].map do |k, v|
108
- input[:request_params][k] = CGI.escape v.to_s
109
- input[:request_params][k].gsub! '+', '%20'
115
+ input[:request_params][k] = escape v.to_s
110
116
  end
111
117
  end
112
118
  input[:request_params]
@@ -125,6 +131,14 @@ module QingStor
125
131
  end
126
132
  object
127
133
  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
128
142
  end
129
143
  end
130
144
  end
@@ -63,10 +63,13 @@ module QingStor
63
63
 
64
64
  def build
65
65
  params = input[:request_params].map { |k, v| "#{k}=#{v}" }
66
- query_string = !params.empty? ? "?#{params.join '&'}" : ''
66
+ query_string = params.join '&'
67
+ if query_string && !query_string.empty?
68
+ query_string = "#{input[:request_uri].include?('?') ? '&' : '?'}#{query_string}"
69
+ end
67
70
  self.request_url = URI "#{input[:request_endpoint]}#{input[:request_uri]}#{query_string}"
68
71
 
69
- request = new_http_request input[:request_method], request_url.path
72
+ request = new_http_request input[:request_method], request_url.to_s
70
73
  request.body = input[:request_body]
71
74
  input[:request_headers].each { |k, v| request[k.to_s] = v }
72
75
 
@@ -87,19 +87,14 @@ module QingStor
87
87
  end
88
88
 
89
89
  def self.canonicalized_resource(input)
90
- path = CGI.escape input[:request_uri]
91
- path.gsub! '%3F', '?'
92
- path.gsub! '%2F', '/'
93
- path.gsub! '+', '%20'
94
-
95
90
  params = input[:request_params].keys.sort.map { |k|
96
91
  if sub_resource? k.to_s
97
92
  v = input[:request_params][k].to_s.strip
98
93
  !v.nil? && v != '' ? "#{k}=#{CGI.unescape v}" : k
99
94
  end
100
95
  }.compact.join '&'
101
- params = path.include?('?') ? "&#{params}" : "?#{params}" if params != ''
102
- "#{path}#{params}"
96
+ params = input[:request_uri].include?('?') ? "&#{params}" : "?#{params}" if params != ''
97
+ "#{input[:request_uri]}#{params}"
103
98
  end
104
99
 
105
100
  def self.sub_resource?(key)
@@ -522,6 +522,58 @@ module QingStor
522
522
 
523
523
  public
524
524
 
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
+
525
577
  # list_objects: Retrieve the object list in a bucket.
526
578
  # Documentation URL: https://docs.qingcloud.com/qingstor/api/bucket/get.html
527
579
  #
@@ -909,10 +961,6 @@ module QingStor
909
961
  raise ParameterRequiredError.new('id', 'statement')
910
962
  end
911
963
 
912
- unless !x['resource'].nil? && !x['resource'].to_s.empty?
913
- raise ParameterRequiredError.new('resource', 'statement')
914
- end
915
-
916
964
  unless !x['user'].nil? && !x['user'].to_s.empty?
917
965
  raise ParameterRequiredError.new('user', 'statement')
918
966
  end
@@ -16,6 +16,6 @@
16
16
 
17
17
  module QingStor
18
18
  module SDK
19
- VERSION = '1.9.2'.freeze
19
+ VERSION = '1.9.3'.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: 1.9.2
4
+ version: 1.9.3
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-01-23 00:00:00.000000000 Z
11
+ date: 2017-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport