azure-storage 0.11.4.preview → 0.11.5.preview
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/azure/storage/blob/blob.rb +1 -1
- data/lib/azure/storage/blob/blob_service.rb +4 -4
- data/lib/azure/storage/client.rb +20 -14
- data/lib/azure/storage/client_options.rb +1 -1
- data/lib/azure/storage/core/auth/shared_access_signature_generator.rb +6 -7
- data/lib/azure/storage/queue/queue_service.rb +2 -2
- data/lib/azure/storage/service/storage_service.rb +20 -4
- data/lib/azure/storage/table/batch.rb +2 -2
- data/lib/azure/storage/table/query.rb +1 -1
- data/lib/azure/storage/table/table_service.rb +8 -8
- data/lib/azure/storage/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99c064d9e707d08b6efa5c7c83f96e6cb8a5ddc6
|
4
|
+
data.tar.gz: 5cc39f4003ae67bbb655fe8d30a5701d2404b736
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0359aaaeca2ae969a7ec5ffd68a281fb679fe952bf12fcbdda6e1a9086b2221a8e6c33853e8c0f8df170b6906fc748b21f86011a20c4ed4280baea3b07dd5393
|
7
|
+
data.tar.gz: a19f2f613d09b8da5305c0fc9d46395929be89d8640978af4123f1934147cae34fb6e5cbd230e20109e9eff7de041246c21699a28fcf944c4b289ba8b2c4f0a5
|
@@ -38,10 +38,10 @@ module Azure::Storage
|
|
38
38
|
include Azure::Storage::Blob
|
39
39
|
include Azure::Storage::Blob::Container
|
40
40
|
|
41
|
-
def initialize(options = {})
|
41
|
+
def initialize(options = {}, &block)
|
42
42
|
client_config = options[:client] || Azure::Storage
|
43
43
|
signer = options[:signer] || Azure::Storage::Core::Auth::SharedKey.new(client_config.storage_account_name, client_config.storage_access_key)
|
44
|
-
super(signer, client_config.storage_account_name, options)
|
44
|
+
super(signer, client_config.storage_account_name, options, &block)
|
45
45
|
@host = client.storage_blob_host
|
46
46
|
end
|
47
47
|
|
@@ -49,7 +49,7 @@ module Azure::Storage
|
|
49
49
|
# Force the request.body to the content encoding of specified in the header
|
50
50
|
if headers && !body.nil? && (body.is_a? String) && ((body.encoding.to_s <=> 'ASCII_8BIT') != 0)
|
51
51
|
if headers['x-ms-blob-content-type'].nil?
|
52
|
-
Service::StorageService.with_header headers, 'x-ms-blob-content-type', "text/plain; charset=#{body.encoding
|
52
|
+
Service::StorageService.with_header headers, 'x-ms-blob-content-type', "text/plain; charset=#{body.encoding}"
|
53
53
|
else
|
54
54
|
charset = parse_charset_from_content_type(headers['x-ms-blob-content-type'])
|
55
55
|
body.force_encoding(charset) if charset
|
@@ -177,7 +177,7 @@ module Azure::Storage
|
|
177
177
|
else
|
178
178
|
uri = container_uri(container, query)
|
179
179
|
end
|
180
|
-
|
180
|
+
|
181
181
|
duration = -1
|
182
182
|
duration = options[:duration] if options[:duration]
|
183
183
|
|
data/lib/azure/storage/client.rb
CHANGED
@@ -27,6 +27,7 @@ require 'azure/storage/core/http_client'
|
|
27
27
|
|
28
28
|
require 'azure/storage/client_options'
|
29
29
|
|
30
|
+
require 'azure/storage/service/storage_service'
|
30
31
|
require 'azure/storage/blob/blob_service'
|
31
32
|
require 'azure/storage/table/table_service'
|
32
33
|
require 'azure/storage/queue/queue_service'
|
@@ -59,6 +60,7 @@ module Azure::Storage
|
|
59
60
|
# * +:default_endpoints_protocol+ - String. http or https
|
60
61
|
# * +:use_path_style_uri+ - String. Whether use path style URI for specified endpoints
|
61
62
|
# * +:ca_file+ - String. File path of the CA file if having issue with SSL
|
63
|
+
# * +:user_agent_prefix+ - String. The user agent prefix that can identify the application calls the library
|
62
64
|
#
|
63
65
|
# The valid set of options inlcude:
|
64
66
|
# * Storage Emulator: +:use_development_storage+ required, +:development_storage_proxy_uri+ optionally
|
@@ -76,19 +78,24 @@ module Azure::Storage
|
|
76
78
|
# When empty options are given, it will try to read settings from Environment Variables. Refer to [Azure::Storage::ClientOptions.env_vars_mapping] for the mapping relationship
|
77
79
|
#
|
78
80
|
# @return [Azure::Storage::Client]
|
79
|
-
def initialize(options = {})
|
81
|
+
def initialize(options = {}, &block)
|
80
82
|
if options.is_a?(Hash)
|
81
83
|
options = setup_options if options.length == 0
|
82
84
|
options = parse_connection_string(options[:storage_connection_string]) if options[:storage_connection_string]
|
83
|
-
end
|
84
85
|
|
86
|
+
if options.has_key?(:user_agent_prefix)
|
87
|
+
Azure::Storage::Service::StorageService.user_agent_prefix = options[:user_agent_prefix]
|
88
|
+
options.delete :user_agent_prefix
|
89
|
+
end
|
90
|
+
end
|
91
|
+
Azure::Storage::Service::StorageService.register_request_callback &block if block_given?
|
85
92
|
reset!(options)
|
86
93
|
end
|
87
94
|
|
88
95
|
# Azure Blob service client configured from this Azure Storage client instance
|
89
96
|
# @return [Azure::Storage::Blob::BlobService]
|
90
|
-
def blob_client(options = {})
|
91
|
-
@blob_client ||= Azure::Storage::Blob::BlobService.new(default_client(options))
|
97
|
+
def blob_client(options = {}, &block)
|
98
|
+
@blob_client ||= Azure::Storage::Blob::BlobService.new(default_client(options), &block)
|
92
99
|
end
|
93
100
|
|
94
101
|
# Azure Queue service client configured from this Azure Storage client instance
|
@@ -104,7 +111,6 @@ module Azure::Storage
|
|
104
111
|
end
|
105
112
|
|
106
113
|
class << self
|
107
|
-
|
108
114
|
# Public: Creates an instance of [Azure::Storage::Client]
|
109
115
|
#
|
110
116
|
# ==== Attributes
|
@@ -127,6 +133,7 @@ module Azure::Storage
|
|
127
133
|
# * +:default_endpoints_protocol+ - String. http or https
|
128
134
|
# * +:use_path_style_uri+ - String. Whether use path style URI for specified endpoints
|
129
135
|
# * +:ca_file+ - String. File path of the CA file if having issue with SSL
|
136
|
+
# * +:user_agent_prefix+ - String. The user agent prefix that can identify the application calls the library
|
130
137
|
#
|
131
138
|
# The valid set of options inlcude:
|
132
139
|
# * Storage Emulator: +:use_development_storage+ required, +:development_storage_proxy_uri+ optionally
|
@@ -144,8 +151,8 @@ module Azure::Storage
|
|
144
151
|
# When empty options are given, it will try to read settings from Environment Variables. Refer to [Azure::Storage::ClientOptions.env_vars_mapping] for the mapping relationship
|
145
152
|
#
|
146
153
|
# @return [Azure::Storage::Client]
|
147
|
-
def create(options={})
|
148
|
-
Client.new(options)
|
154
|
+
def create(options={}, &block)
|
155
|
+
Client.new(options, &block)
|
149
156
|
end
|
150
157
|
|
151
158
|
# Public: Creates an instance of [Azure::Storage::Client] with Storage Emulator
|
@@ -155,17 +162,16 @@ module Azure::Storage
|
|
155
162
|
# * +proxy_uri+ - String. Used with +:use_development_storage+ if emulator is hosted other than localhost.
|
156
163
|
#
|
157
164
|
# @return [Azure::Storage::Client]
|
158
|
-
def create_development(proxy_uri=nil)
|
165
|
+
def create_development(proxy_uri=nil, &block)
|
159
166
|
proxy_uri ||= StorageServiceClientConstants::DEV_STORE_URI
|
160
|
-
create(:use_development_storage => true, :development_storage_proxy_uri => proxy_uri)
|
167
|
+
create(:use_development_storage => true, :development_storage_proxy_uri => proxy_uri, &block)
|
161
168
|
end
|
162
169
|
|
163
|
-
|
164
170
|
# Public: Creates an instance of [Azure::Storage::Client] from Environment Variables
|
165
171
|
#
|
166
172
|
# @return [Azure::Storage::Client]
|
167
|
-
def create_from_env
|
168
|
-
create
|
173
|
+
def create_from_env(&block)
|
174
|
+
create &block
|
169
175
|
end
|
170
176
|
|
171
177
|
# Public: Creates an instance of [Azure::Storage::Client] from Environment Variables
|
@@ -175,8 +181,8 @@ module Azure::Storage
|
|
175
181
|
# * +connection_string+ - String. Please refer to https://azure.microsoft.com/en-us/documentation/articles/storage-configure-connection-string/.
|
176
182
|
#
|
177
183
|
# @return [Azure::Storage::Client]
|
178
|
-
def create_from_connection_string(connection_string)
|
179
|
-
Client.new(connection_string)
|
184
|
+
def create_from_connection_string(connection_string, &block)
|
185
|
+
Client.new(connection_string, &block)
|
180
186
|
end
|
181
187
|
end
|
182
188
|
|
@@ -327,7 +327,7 @@ module Azure::Storage
|
|
327
327
|
|
328
328
|
def parse_connection_string(connection_string)
|
329
329
|
opts = {}
|
330
|
-
|
330
|
+
connection_string.split(';').each do |i|
|
331
331
|
e = i.index('=')
|
332
332
|
raise InvalidConnectionStringError,SR::INVALID_CONNECTION_STRING if e < 0 || e == i.length - 1
|
333
333
|
key,value = i[0..e-1],i[e+1..i.length-1]
|
@@ -153,7 +153,7 @@ module Azure::Storage::Core
|
|
153
153
|
valid_mappings.merge!(TABLE_KEY_MAPPINGS)
|
154
154
|
end
|
155
155
|
|
156
|
-
invalid_options = options.reject { |k,
|
156
|
+
invalid_options = options.reject { |k, _| valid_mappings.key?(k) }
|
157
157
|
raise Azure::Storage::InvalidOptionsError,"invalid options #{invalid_options} provided for SAS token generate" if invalid_options.length > 0
|
158
158
|
|
159
159
|
canonicalize_time(options)
|
@@ -162,7 +162,7 @@ module Azure::Storage::Core
|
|
162
162
|
.reject { |k, v| SERVICE_OPTIONAL_QUERY_PARAMS.include?(k) && v.to_s == '' }
|
163
163
|
.merge( sig: @signer.sign(signable_string_for_service(service_type, path, options)) )
|
164
164
|
|
165
|
-
|
165
|
+
URI.encode_www_form(query_hash)
|
166
166
|
end
|
167
167
|
|
168
168
|
# Construct the plaintext to the spec required for signatures
|
@@ -222,7 +222,7 @@ module Azure::Storage::Core
|
|
222
222
|
options = DEFAULTS.merge(options)
|
223
223
|
valid_mappings = ACCOUNT_KEY_MAPPINGS
|
224
224
|
|
225
|
-
invalid_options = options.reject { |k,
|
225
|
+
invalid_options = options.reject { |k, _| valid_mappings.key?(k) }
|
226
226
|
raise Azure::Storage::InvalidOptionsError,"invalid options #{invalid_options} provided for SAS token generate" if invalid_options.length > 0
|
227
227
|
|
228
228
|
canonicalize_time(options)
|
@@ -231,7 +231,7 @@ module Azure::Storage::Core
|
|
231
231
|
.reject { |k, v| ACCOUNT_OPTIONAL_QUERY_PARAMS.include?(k) && v.to_s == '' }
|
232
232
|
.merge( sig: @signer.sign(signable_string_for_account(options)) )
|
233
233
|
|
234
|
-
|
234
|
+
URI.encode_www_form(query_hash)
|
235
235
|
end
|
236
236
|
|
237
237
|
# Construct the plaintext to the spec required for signatures
|
@@ -239,7 +239,6 @@ module Azure::Storage::Core
|
|
239
239
|
def signable_string_for_account(options)
|
240
240
|
# Order is significant
|
241
241
|
# The newlines from empty strings here are required
|
242
|
-
signable_string =
|
243
242
|
[
|
244
243
|
@account_name,
|
245
244
|
options[:permissions],
|
@@ -311,7 +310,7 @@ module Azure::Storage::Core
|
|
311
310
|
# * +:startrk+ - String. Optional. The start row key of a specified row key range.
|
312
311
|
# * +:endrk+ - String. Optional. The end row key of a specified row key range.
|
313
312
|
def signed_uri(uri, use_account_sas, options)
|
314
|
-
|
313
|
+
CGI::parse(uri.query || '').inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
315
314
|
|
316
315
|
if options[:service] == nil and uri.host != nil
|
317
316
|
host_splits = uri.host.split('.')
|
@@ -324,7 +323,7 @@ module Azure::Storage::Core
|
|
324
323
|
generate_service_sas_token(uri.path, options)
|
325
324
|
end
|
326
325
|
|
327
|
-
|
326
|
+
URI.parse(uri.to_s + (uri.query.nil? ? '?' : '&') + sas_params)
|
328
327
|
end
|
329
328
|
end
|
330
329
|
end
|
@@ -30,10 +30,10 @@ module Azure::Storage
|
|
30
30
|
include Azure::Storage::Service
|
31
31
|
class QueueService < StorageService
|
32
32
|
|
33
|
-
def initialize(options = {})
|
33
|
+
def initialize(options = {}, &block)
|
34
34
|
client_config = options[:client] || Azure::Storage
|
35
35
|
signer = options[:signer] || Azure::Storage::Core::Auth::SharedKey.new(client_config.storage_account_name, client_config.storage_access_key)
|
36
|
-
super(signer, client_config.storage_account_name, options)
|
36
|
+
super(signer, client_config.storage_account_name, options, &block)
|
37
37
|
@host = @client.storage_queue_host
|
38
38
|
end
|
39
39
|
|
@@ -33,10 +33,11 @@ module Azure::Storage
|
|
33
33
|
# Create a new instance of the StorageService
|
34
34
|
#
|
35
35
|
# @param signer [Azure::Core::Auth::Signer] An implementation of Signer used for signing requests.
|
36
|
-
#
|
36
|
+
# (optional, Default=Azure::Storage::Auth::SharedKey.new)
|
37
37
|
# @param account_name [String] The account name (optional, Default=Azure::Storage.storage_account_name)
|
38
38
|
# @param options [Azure::Storage::Configurable] the client configuration context
|
39
|
-
def initialize(signer=nil, account_name=nil, options = {})
|
39
|
+
def initialize(signer=nil, account_name=nil, options = {}, &block)
|
40
|
+
StorageService.register_request_callback &block if block_given?
|
40
41
|
options[:client] = Azure::Storage if options[:client] == nil
|
41
42
|
client_config = options[:client]
|
42
43
|
signer = signer || Azure::Storage::Core::Auth::SharedKey.new(
|
@@ -118,6 +119,20 @@ module Azure::Storage
|
|
118
119
|
end
|
119
120
|
|
120
121
|
class << self
|
122
|
+
# @!attribute user_agent_prefix
|
123
|
+
# @return [Proc] Get or set the user agent prefix
|
124
|
+
attr_accessor :user_agent_prefix
|
125
|
+
|
126
|
+
# @!attribute request_callback
|
127
|
+
# @return [Proc] The callback before the request is signed and sent
|
128
|
+
attr_reader :request_callback
|
129
|
+
|
130
|
+
# Registers the callback when sending the request
|
131
|
+
# The headers in the request can be viewed or changed in the code block
|
132
|
+
def register_request_callback
|
133
|
+
@request_callback = Proc.new
|
134
|
+
end
|
135
|
+
|
121
136
|
# Adds metadata properties to header hash with required prefix
|
122
137
|
#
|
123
138
|
# metadata - A Hash of metadata name/value pairs
|
@@ -127,7 +142,7 @@ module Azure::Storage
|
|
127
142
|
metadata.each do |key, value|
|
128
143
|
headers["x-ms-meta-#{key}"] = value
|
129
144
|
end
|
130
|
-
|
145
|
+
end
|
131
146
|
end
|
132
147
|
|
133
148
|
# Adds a value to the Hash object
|
@@ -157,9 +172,10 @@ module Azure::Storage
|
|
157
172
|
def common_headers(options = {})
|
158
173
|
headers = {
|
159
174
|
'x-ms-version' => Azure::Storage::Default::STG_VERSION,
|
160
|
-
'User-Agent' => Azure::Storage::Default::USER_AGENT
|
175
|
+
'User-Agent' => user_agent_prefix ? "#{user_agent_prefix}; #{Azure::Storage::Default::USER_AGENT}" : Azure::Storage::Default::USER_AGENT
|
161
176
|
}
|
162
177
|
headers.merge!({'x-ms-client-request-id' => options[:request_id]}) if options[:request_id]
|
178
|
+
@request_callback.call(headers) if @request_callback
|
163
179
|
headers
|
164
180
|
end
|
165
181
|
end
|
@@ -184,12 +184,12 @@ module Azure::Storage
|
|
184
184
|
if op[:headers]
|
185
185
|
op[:headers].each { |k,v|
|
186
186
|
body.add_line "#{k}: #{v}"
|
187
|
-
|
187
|
+
}
|
188
188
|
end
|
189
189
|
|
190
190
|
if op[:body]
|
191
191
|
body.add_line "Content-Type: application/atom+xml;type=entry"
|
192
|
-
body.add_line "Content-Length: #{op[:body].bytesize
|
192
|
+
body.add_line "Content-Length: #{op[:body].bytesize}"
|
193
193
|
body.add_line ""
|
194
194
|
body.add_line op[:body]
|
195
195
|
else
|
@@ -109,7 +109,7 @@ module Azure::Storage
|
|
109
109
|
result = ""
|
110
110
|
clauses = []
|
111
111
|
filters.each { |f|
|
112
|
-
clauses.push "#{f[0]
|
112
|
+
clauses.push "#{f[0]} #{f[1]} #{Azure::Storage::Table::EdmType.serialize_query_value(f[2])}"
|
113
113
|
}
|
114
114
|
return nil if clauses.length == 0
|
115
115
|
|
@@ -31,10 +31,10 @@ module Azure::Storage
|
|
31
31
|
module Table
|
32
32
|
class TableService < Service::StorageService
|
33
33
|
|
34
|
-
def initialize(options = {})
|
34
|
+
def initialize(options = {}, &block)
|
35
35
|
client_config = options[:client] || Azure::Storage
|
36
36
|
signer = options[:signer] || Auth::SharedKey.new(client_config.storage_account_name, client_config.storage_access_key)
|
37
|
-
super(signer, client_config.storage_account_name, options)
|
37
|
+
super(signer, client_config.storage_account_name, options, &block)
|
38
38
|
@host = client.storage_table_host
|
39
39
|
end
|
40
40
|
|
@@ -569,12 +569,12 @@ module Azure::Storage
|
|
569
569
|
return table_name if table_name.kind_of? ::URI
|
570
570
|
|
571
571
|
path = if partition_key && row_key
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
572
|
+
"%s(PartitionKey='%s',RowKey='%s')" % [
|
573
|
+
table_name.encode("UTF-8"), encodeODataUriValue(partition_key.encode("UTF-8")), encodeODataUriValue(row_key.encode("UTF-8"))
|
574
|
+
]
|
575
|
+
else
|
576
|
+
"%s()" % table_name.encode("UTF-8")
|
577
|
+
end
|
578
578
|
|
579
579
|
uri = generate_uri(path)
|
580
580
|
qs = []
|
@@ -28,7 +28,7 @@ module Azure
|
|
28
28
|
# Fields represent the parts defined in http://semver.org/
|
29
29
|
MAJOR = 0 unless defined? MAJOR
|
30
30
|
MINOR = 11 unless defined? MINOR
|
31
|
-
UPDATE =
|
31
|
+
UPDATE = 5 unless defined? UPDATE
|
32
32
|
PRE = 'preview' unless defined? PRE
|
33
33
|
|
34
34
|
class << self
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: azure-storage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.5.preview
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Microsoft Corporation
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: azure-core
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 1.6.0
|
62
62
|
type: :runtime
|
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:
|
68
|
+
version: 1.6.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: dotenv
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|