azure-storage 0.13.0.preview → 0.14.0.preview
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 +4 -4
- data/lib/azure/storage.rb +14 -13
- data/lib/azure/storage/autoload.rb +31 -31
- data/lib/azure/storage/blob/append.rb +43 -41
- data/lib/azure/storage/blob/blob.rb +150 -147
- data/lib/azure/storage/blob/blob_service.rb +186 -184
- data/lib/azure/storage/blob/block.rb +56 -56
- data/lib/azure/storage/blob/container.rb +93 -92
- data/lib/azure/storage/blob/page.rb +187 -104
- data/lib/azure/storage/blob/serialization.rb +32 -18
- data/lib/azure/storage/client.rb +18 -17
- data/lib/azure/storage/client_options.rb +192 -193
- data/lib/azure/storage/client_options_error.rb +5 -5
- data/lib/azure/storage/configurable.rb +39 -39
- data/lib/azure/storage/core.rb +6 -4
- data/lib/azure/storage/core/auth/shared_access_signature.rb +5 -3
- data/lib/azure/storage/core/auth/shared_access_signature_generator.rb +34 -33
- data/lib/azure/storage/core/auth/shared_access_signature_signer.rb +5 -5
- data/lib/azure/storage/core/auth/shared_key.rb +17 -15
- data/lib/azure/storage/core/autoload.rb +15 -13
- data/lib/azure/storage/core/error.rb +3 -1
- data/lib/azure/storage/core/filter/exponential_retry_filter.rb +13 -11
- data/lib/azure/storage/core/filter/linear_retry_filter.rb +10 -8
- data/lib/azure/storage/core/filter/retry_filter.rb +30 -29
- data/lib/azure/storage/core/http_client.rb +18 -16
- data/lib/azure/storage/core/sr.rb +50 -48
- data/lib/azure/storage/core/utility.rb +19 -17
- data/lib/azure/storage/default.rb +371 -361
- data/lib/azure/storage/file/directory.rb +36 -31
- data/lib/azure/storage/file/file.rb +103 -100
- data/lib/azure/storage/file/file_service.rb +42 -40
- data/lib/azure/storage/file/serialization.rb +9 -6
- data/lib/azure/storage/file/share.rb +48 -46
- data/lib/azure/storage/queue/message.rb +3 -1
- data/lib/azure/storage/queue/queue.rb +3 -2
- data/lib/azure/storage/queue/queue_service.rb +152 -151
- data/lib/azure/storage/queue/serialization.rb +7 -5
- data/lib/azure/storage/service/access_policy.rb +3 -1
- data/lib/azure/storage/service/cors.rb +4 -2
- data/lib/azure/storage/service/cors_rule.rb +3 -1
- data/lib/azure/storage/service/enumeration_results.rb +3 -1
- data/lib/azure/storage/service/logging.rb +5 -3
- data/lib/azure/storage/service/metrics.rb +5 -3
- data/lib/azure/storage/service/retention_policy.rb +3 -1
- data/lib/azure/storage/service/serialization.rb +31 -30
- data/lib/azure/storage/service/signed_identifier.rb +5 -4
- data/lib/azure/storage/service/storage_service.rb +33 -32
- data/lib/azure/storage/service/storage_service_properties.rb +6 -4
- data/lib/azure/storage/table/auth/shared_key.rb +9 -8
- data/lib/azure/storage/table/batch.rb +55 -55
- data/lib/azure/storage/table/batch_response.rb +17 -17
- data/lib/azure/storage/table/edmtype.rb +9 -7
- data/lib/azure/storage/table/entity.rb +4 -3
- data/lib/azure/storage/table/guid.rb +3 -1
- data/lib/azure/storage/table/query.rb +17 -19
- data/lib/azure/storage/table/serialization.rb +14 -12
- data/lib/azure/storage/table/table_service.rb +79 -80
- data/lib/azure/storage/version.rb +7 -5
- metadata +2 -2
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#-------------------------------------------------------------------------
|
2
4
|
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
5
|
#
|
@@ -21,15 +23,15 @@
|
|
21
23
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
24
|
# THE SOFTWARE.
|
23
25
|
#--------------------------------------------------------------------------
|
24
|
-
require
|
26
|
+
require "azure/storage/service/serialization"
|
25
27
|
|
26
|
-
require
|
27
|
-
require
|
28
|
-
require
|
28
|
+
require "azure/storage/table/guid"
|
29
|
+
require "azure/storage/table/edmtype"
|
30
|
+
require "azure/storage/table/entity"
|
29
31
|
|
30
|
-
require
|
31
|
-
require
|
32
|
-
require
|
32
|
+
require "time"
|
33
|
+
require "date"
|
34
|
+
require "json"
|
33
35
|
|
34
36
|
module Azure
|
35
37
|
module Storage
|
@@ -60,11 +62,11 @@ module Azure
|
|
60
62
|
|
61
63
|
def self.table_entries_from_hash(h)
|
62
64
|
values = []
|
63
|
-
if h[
|
64
|
-
h[
|
65
|
+
if h["value"]
|
66
|
+
h["value"].each do |name|
|
65
67
|
values.push(name)
|
66
68
|
end
|
67
|
-
elsif h[
|
69
|
+
elsif h["TableName"]
|
68
70
|
values = h
|
69
71
|
end
|
70
72
|
values
|
@@ -76,12 +78,12 @@ module Azure
|
|
76
78
|
|
77
79
|
def self.entities_from_json(json)
|
78
80
|
entities_hash = hash_from_json(json)
|
79
|
-
entities_hash[
|
81
|
+
entities_hash["value"].nil? ? [entity_from_hash(entities_hash)] : entities_from_hash(entities_hash)
|
80
82
|
end
|
81
83
|
|
82
84
|
def self.entities_from_hash(h)
|
83
85
|
entities = []
|
84
|
-
h[
|
86
|
+
h["value"].each { |entity_hash|
|
85
87
|
entities.push(entity_from_hash(entity_hash))
|
86
88
|
}
|
87
89
|
entities
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#-------------------------------------------------------------------------
|
2
4
|
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
5
|
#
|
@@ -21,16 +23,15 @@
|
|
21
23
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
24
|
# THE SOFTWARE.
|
23
25
|
#--------------------------------------------------------------------------
|
24
|
-
require
|
26
|
+
require "azure/storage/service/storage_service"
|
25
27
|
|
26
|
-
require
|
27
|
-
require
|
28
|
-
require
|
28
|
+
require "azure/storage/table/auth/shared_key"
|
29
|
+
require "azure/storage/table/serialization"
|
30
|
+
require "azure/storage/table/entity"
|
29
31
|
|
30
32
|
module Azure::Storage
|
31
33
|
module Table
|
32
34
|
class TableService < Service::StorageService
|
33
|
-
|
34
35
|
def initialize(options = {}, &block)
|
35
36
|
client_config = options[:client] || Azure::Storage
|
36
37
|
signer = options[:signer] || client_config.signer || Auth::SharedKey.new(client_config.storage_account_name, client_config.storage_access_key)
|
@@ -43,19 +44,19 @@ module Azure::Storage
|
|
43
44
|
# ==== Attributes
|
44
45
|
#
|
45
46
|
# * +table_name+ - String. The table name
|
46
|
-
# * +options+ - Hash. Optional parameters.
|
47
|
+
# * +options+ - Hash. Optional parameters.
|
47
48
|
#
|
48
49
|
# ==== Options
|
49
50
|
#
|
50
51
|
# Accepted key/value pairs in options parameter are:
|
51
52
|
#
|
52
53
|
# * +:timeout+ - Integer. A timeout in seconds.
|
53
|
-
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
54
|
+
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
54
55
|
# in the analytics logs when storage analytics logging is enabled.
|
55
56
|
# * +:accept+ - String. Specifies the accepted content-type of the response payload. Possible values are:
|
56
57
|
# :no_meta
|
57
58
|
# :min_meta
|
58
|
-
# :full_meta
|
59
|
+
# :full_meta
|
59
60
|
# * +:prefer+ - String. Specifies whether the response should include the inserted entity in the payload. Possible values are:
|
60
61
|
# HeaderConstants::PREFER_CONTENT
|
61
62
|
# HeaderConstants::PREFER_NO_CONTENT
|
@@ -63,13 +64,12 @@ module Azure::Storage
|
|
63
64
|
# See http://msdn.microsoft.com/en-us/library/azure/dd135729
|
64
65
|
#
|
65
66
|
# @return [nil] on success
|
66
|
-
def create_table(table_name, options={})
|
67
|
-
|
67
|
+
def create_table(table_name, options = {})
|
68
68
|
headers = {
|
69
69
|
HeaderConstants::ACCEPT => Table::Serialization.get_accept_string(options[:accept]),
|
70
70
|
}
|
71
71
|
headers[HeaderConstants::PREFER] = options[:prefer] unless options[:prefer].nil?
|
72
|
-
body = Serialization.hash_to_json(
|
72
|
+
body = Serialization.hash_to_json("TableName" => table_name)
|
73
73
|
|
74
74
|
call(:post, collection_uri(new_query(options)), body, headers, options)
|
75
75
|
nil
|
@@ -80,20 +80,19 @@ module Azure::Storage
|
|
80
80
|
# ==== Attributes
|
81
81
|
#
|
82
82
|
# * +table_name+ - String. The table name
|
83
|
-
# * +options+ - Hash. Optional parameters.
|
83
|
+
# * +options+ - Hash. Optional parameters.
|
84
84
|
#
|
85
85
|
# ==== Options
|
86
86
|
#
|
87
87
|
# Accepted key/value pairs in options parameter are:
|
88
88
|
# * +:timeout+ - Integer. A timeout in seconds.
|
89
|
-
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
89
|
+
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
90
90
|
# in the analytics logs when storage analytics logging is enabled.
|
91
91
|
#
|
92
92
|
# See http://msdn.microsoft.com/en-us/library/azure/dd179387
|
93
93
|
#
|
94
94
|
# Returns nil on success
|
95
|
-
def delete_table(table_name, options={})
|
96
|
-
|
95
|
+
def delete_table(table_name, options = {})
|
97
96
|
call(:delete, table_uri(table_name, new_query(options)), nil, {}, options)
|
98
97
|
nil
|
99
98
|
end
|
@@ -103,17 +102,17 @@ module Azure::Storage
|
|
103
102
|
# ==== Attributes
|
104
103
|
#
|
105
104
|
# * +table_name+ - String. The table name
|
106
|
-
# * +options+ - Hash. Optional parameters.
|
105
|
+
# * +options+ - Hash. Optional parameters.
|
107
106
|
#
|
108
107
|
# ==== Options
|
109
108
|
#
|
110
109
|
# Accepted key/value pairs in options parameter are:
|
111
110
|
# * +:timeout+ - Integer. A timeout in seconds.
|
112
|
-
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
111
|
+
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
113
112
|
# in the analytics logs when storage analytics logging is enabled.
|
114
113
|
#
|
115
114
|
# Returns the last updated time for the table
|
116
|
-
def get_table(table_name, options={})
|
115
|
+
def get_table(table_name, options = {})
|
117
116
|
headers = {
|
118
117
|
HeaderConstants::ACCEPT => Table::Serialization.get_accept_string(:full_meta),
|
119
118
|
}
|
@@ -127,7 +126,7 @@ module Azure::Storage
|
|
127
126
|
#
|
128
127
|
# ==== Attributes
|
129
128
|
#
|
130
|
-
# * +options+ - Hash. Optional parameters.
|
129
|
+
# * +options+ - Hash. Optional parameters.
|
131
130
|
#
|
132
131
|
# ==== Options
|
133
132
|
#
|
@@ -135,7 +134,7 @@ module Azure::Storage
|
|
135
134
|
# * +:next_table_token+ - String. A token used to enumerate the next page of results, when the list of tables is
|
136
135
|
# larger than a single operation can return at once. (optional)
|
137
136
|
# * +:timeout+ - Integer. A timeout in seconds.
|
138
|
-
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
137
|
+
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
139
138
|
# in the analytics logs when storage analytics logging is enabled.
|
140
139
|
# * +:accept+ - String. Specifies the accepted content-type of the response payload. Possible values are:
|
141
140
|
# :no_meta
|
@@ -145,7 +144,7 @@ module Azure::Storage
|
|
145
144
|
# See http://msdn.microsoft.com/en-us/library/azure/dd179405
|
146
145
|
#
|
147
146
|
# Returns an array with an extra continuation_token property on success
|
148
|
-
def query_tables(options={})
|
147
|
+
def query_tables(options = {})
|
149
148
|
query = new_query(options)
|
150
149
|
query[TableConstants::NEXT_TABLE_NAME] = options[:next_table_token] if options[:next_table_token]
|
151
150
|
uri = collection_uri(query)
|
@@ -168,23 +167,23 @@ module Azure::Storage
|
|
168
167
|
# ==== Attributes
|
169
168
|
#
|
170
169
|
# * +table_name+ - String. The table name
|
171
|
-
# * +options+ - Hash. Optional parameters.
|
170
|
+
# * +options+ - Hash. Optional parameters.
|
172
171
|
#
|
173
172
|
# ==== Options
|
174
173
|
#
|
175
174
|
# Accepted key/value pairs in options parameter are:
|
176
175
|
# * +:timeout+ - Integer. A timeout in seconds.
|
177
|
-
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
176
|
+
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
178
177
|
# in the analytics logs when storage analytics logging is enabled.
|
179
178
|
#
|
180
179
|
# See http://msdn.microsoft.com/en-us/library/azure/jj159100
|
181
180
|
#
|
182
181
|
# Returns a list of Azure::Storage::Entity::SignedIdentifier instances
|
183
|
-
def get_table_acl(table_name, options={})
|
182
|
+
def get_table_acl(table_name, options = {})
|
184
183
|
query = new_query(options)
|
185
184
|
query[QueryStringConstants::COMP] = QueryStringConstants::ACL
|
186
185
|
|
187
|
-
response = call(:get, generate_uri(table_name, query), nil, {
|
186
|
+
response = call(:get, generate_uri(table_name, query), nil, { "x-ms-version" => "2012-02-12" }, options)
|
188
187
|
|
189
188
|
signed_identifiers = []
|
190
189
|
signed_identifiers = Table::Serialization.signed_identifiers_from_xml response.body unless response.body == nil || response.body.length < 1
|
@@ -198,20 +197,20 @@ module Azure::Storage
|
|
198
197
|
# ==== Attributes
|
199
198
|
#
|
200
199
|
# * +table_name+ - String. The table name
|
201
|
-
# * +options+ - Hash. Optional parameters.
|
200
|
+
# * +options+ - Hash. Optional parameters.
|
202
201
|
#
|
203
202
|
# ==== Options
|
204
203
|
#
|
205
204
|
# Accepted key/value pairs in options parameter are:
|
206
205
|
# * +:signed_identifiers+ - Array. A list of Azure::Storage::Entity::SignedIdentifier instances
|
207
206
|
# * +:timeout+ - Integer. A timeout in seconds.
|
208
|
-
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
207
|
+
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
209
208
|
# in the analytics logs when storage analytics logging is enabled.
|
210
|
-
#
|
209
|
+
#
|
211
210
|
# See http://msdn.microsoft.com/en-us/library/azure/jj159102
|
212
211
|
#
|
213
212
|
# Returns nil on success
|
214
|
-
def set_table_acl(table_name, options={})
|
213
|
+
def set_table_acl(table_name, options = {})
|
215
214
|
query = new_query(options)
|
216
215
|
query[QueryStringConstants::COMP] = QueryStringConstants::ACL
|
217
216
|
|
@@ -219,7 +218,7 @@ module Azure::Storage
|
|
219
218
|
body = nil
|
220
219
|
body = Table::Serialization.signed_identifiers_to_xml options[:signed_identifiers] if options[:signed_identifiers] && options[:signed_identifiers].length > 0
|
221
220
|
|
222
|
-
call(:put, uri, body, {
|
221
|
+
call(:put, uri, body, { "x-ms-version" => "2012-02-12" }, options)
|
223
222
|
nil
|
224
223
|
end
|
225
224
|
|
@@ -229,8 +228,8 @@ module Azure::Storage
|
|
229
228
|
# ==== Attributes
|
230
229
|
#
|
231
230
|
# * +table_name+ - String. The table name
|
232
|
-
# * +entity_values+ - Hash. A hash of the name/value pairs for the entity.
|
233
|
-
# * +options+ - Hash. Optional parameters.
|
231
|
+
# * +entity_values+ - Hash. A hash of the name/value pairs for the entity.
|
232
|
+
# * +options+ - Hash. Optional parameters.
|
234
233
|
#
|
235
234
|
# ==== Options
|
236
235
|
#
|
@@ -265,7 +264,7 @@ module Azure::Storage
|
|
265
264
|
# ==== Attributes
|
266
265
|
#
|
267
266
|
# * +table_name+ - String. The table name
|
268
|
-
# * +options+ - Hash. Optional parameters.
|
267
|
+
# * +options+ - Hash. Optional parameters.
|
269
268
|
#
|
270
269
|
# ==== Options
|
271
270
|
#
|
@@ -282,14 +281,14 @@ module Azure::Storage
|
|
282
281
|
# * +:accept+ - String. Specifies the accepted content-type of the response payload. Possible values are:
|
283
282
|
# :no_meta
|
284
283
|
# :min_meta
|
285
|
-
# :full_meta
|
284
|
+
# :full_meta
|
286
285
|
#
|
287
286
|
# See http://msdn.microsoft.com/en-us/library/azure/dd179421
|
288
287
|
#
|
289
288
|
# Returns an array with an extra continuation_token property on success
|
290
289
|
def query_entities(table_name, options = {})
|
291
290
|
query = new_query(options)
|
292
|
-
query[QueryStringConstants::SELECT] = options[:select].join
|
291
|
+
query[QueryStringConstants::SELECT] = options[:select].join "," if options[:select]
|
293
292
|
query[QueryStringConstants::FILTER] = options[:filter] if options[:filter]
|
294
293
|
query[QueryStringConstants::TOP] = options[:top].to_s if options[:top] unless options[:partition_key] && options[:row_key]
|
295
294
|
query[QueryStringConstants::NEXT_PARTITION_KEY] = options[:continuation_token][:next_partition_key] if options[:continuation_token] && options[:continuation_token][:next_partition_key]
|
@@ -343,7 +342,7 @@ module Azure::Storage
|
|
343
342
|
if_match = options[:if_match] if options[:if_match]
|
344
343
|
|
345
344
|
uri = entities_uri(table_name,
|
346
|
-
entity_values[:PartitionKey] || entity_values[
|
345
|
+
entity_values[:PartitionKey] || entity_values["PartitionKey"],
|
347
346
|
entity_values[:RowKey] || entity_values["RowKey"], new_query(options))
|
348
347
|
|
349
348
|
headers = {}
|
@@ -384,8 +383,8 @@ module Azure::Storage
|
|
384
383
|
if_match = options[:if_match] if options[:if_match]
|
385
384
|
|
386
385
|
uri = entities_uri(table_name,
|
387
|
-
entity_values[:PartitionKey] || entity_values[
|
388
|
-
entity_values[:RowKey] || entity_values[
|
386
|
+
entity_values[:PartitionKey] || entity_values["PartitionKey"],
|
387
|
+
entity_values[:RowKey] || entity_values["RowKey"], new_query(options))
|
389
388
|
|
390
389
|
headers = { "X-HTTP-Method" => "MERGE" }
|
391
390
|
headers["If-Match"] = if_match || "*" unless options[:create_if_not_exists]
|
@@ -483,21 +482,21 @@ module Azure::Storage
|
|
483
482
|
#
|
484
483
|
# Accepted key/value pairs in options parameter are:
|
485
484
|
# * +:timeout+ - Integer. A timeout in seconds.
|
486
|
-
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
485
|
+
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
487
486
|
# in the analytics logs when storage analytics logging is enabled.
|
488
487
|
#
|
489
488
|
# See http://msdn.microsoft.com/en-us/library/azure/dd894038
|
490
489
|
#
|
491
490
|
# Returns an array of results, one for each operation in the batch
|
492
|
-
def execute_batch(batch, options={})
|
491
|
+
def execute_batch(batch, options = {})
|
493
492
|
headers = {
|
494
493
|
HeaderConstants::CONTENT_TYPE => "multipart/mixed; boundary=#{batch.batch_id}",
|
495
494
|
HeaderConstants::ACCEPT => Table::Serialization.get_accept_string(options[:accept]),
|
496
|
-
|
495
|
+
"Accept-Charset" => "UTF-8"
|
497
496
|
}
|
498
497
|
|
499
498
|
body = batch.to_body
|
500
|
-
response = call(:post, generate_uri(
|
499
|
+
response = call(:post, generate_uri("/$batch", new_query(options)), body, headers, options, true)
|
501
500
|
batch.parse_response(response)
|
502
501
|
rescue => e
|
503
502
|
raise_with_response(e, response)
|
@@ -516,7 +515,7 @@ module Azure::Storage
|
|
516
515
|
#
|
517
516
|
# Accepted key/value pairs in options parameter are:
|
518
517
|
# * +:timeout+ - Integer. A timeout in seconds.
|
519
|
-
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
518
|
+
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
520
519
|
# in the analytics logs when storage analytics logging is enabled.
|
521
520
|
#
|
522
521
|
# Returns an Azure::Storage::Table::Entity instance on success
|
@@ -531,9 +530,9 @@ module Azure::Storage
|
|
531
530
|
#
|
532
531
|
# Returns a URI
|
533
532
|
protected
|
534
|
-
|
535
|
-
|
536
|
-
|
533
|
+
def collection_uri(query = {})
|
534
|
+
generate_uri("Tables", query)
|
535
|
+
end
|
537
536
|
|
538
537
|
# Public: Generate the URI for a specific table.
|
539
538
|
#
|
@@ -543,7 +542,7 @@ module Azure::Storage
|
|
543
542
|
#
|
544
543
|
# Returns a URI
|
545
544
|
public
|
546
|
-
def table_uri(name, query={})
|
545
|
+
def table_uri(name, query = {})
|
547
546
|
return name if name.kind_of? ::URI
|
548
547
|
generate_uri("Tables('#{name}')", query)
|
549
548
|
end
|
@@ -564,9 +563,9 @@ module Azure::Storage
|
|
564
563
|
return table_name if table_name.kind_of? ::URI
|
565
564
|
|
566
565
|
path = if partition_key && row_key
|
567
|
-
|
568
|
-
|
569
|
-
|
566
|
+
"%s(PartitionKey='%s',RowKey='%s')" % [
|
567
|
+
table_name.encode("UTF-8"), encodeODataUriValue(partition_key.encode("UTF-8")), encodeODataUriValue(row_key.encode("UTF-8"))
|
568
|
+
]
|
570
569
|
else
|
571
570
|
"%s()" % table_name.encode("UTF-8")
|
572
571
|
end
|
@@ -579,55 +578,55 @@ module Azure::Storage
|
|
579
578
|
val = val.encode("UTF-8")
|
580
579
|
|
581
580
|
if key[0] == "$"
|
582
|
-
qs.push "#{key}#{::URI.encode_www_form(""=>val)}"
|
581
|
+
qs.push "#{key}#{::URI.encode_www_form("" => val)}"
|
583
582
|
else
|
584
|
-
qs.push ::URI.encode_www_form(key=>val)
|
583
|
+
qs.push ::URI.encode_www_form(key => val)
|
585
584
|
end
|
586
585
|
end
|
587
586
|
end
|
588
|
-
uri.query = qs.join
|
587
|
+
uri.query = qs.join "&" if qs.length > 0
|
589
588
|
uri
|
590
589
|
end
|
591
590
|
|
592
591
|
protected
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
592
|
+
def encodeODataUriValues(values)
|
593
|
+
new_values = []
|
594
|
+
values.each do |value|
|
595
|
+
new_values.push encodeODataUriValue(value)
|
596
|
+
end
|
597
|
+
new_values
|
597
598
|
end
|
598
|
-
new_values
|
599
|
-
end
|
600
599
|
|
601
600
|
protected
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
601
|
+
def encodeODataUriValue(value)
|
602
|
+
# Replace each single quote (') with double single quotes ('') not double
|
603
|
+
# quotes (")
|
604
|
+
value = value.gsub("'", "''")
|
606
605
|
|
607
|
-
|
608
|
-
|
606
|
+
# Encode the special URL characters
|
607
|
+
value = URI.escape(value)
|
609
608
|
|
610
|
-
|
611
|
-
|
609
|
+
value
|
610
|
+
end
|
612
611
|
|
613
612
|
protected
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
613
|
+
def raise_with_response(e, response)
|
614
|
+
raise e if response.nil?
|
615
|
+
raise "Response header: #{response.headers.inspect}\nResponse body: #{response.body.inspect}\n#{e.inspect}\n#{e.backtrace.join("\n")}"
|
616
|
+
end
|
618
617
|
|
619
618
|
protected
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
619
|
+
def call(method, uri, body = nil, headers = {}, options = {}, is_batch = false)
|
620
|
+
# Add JSON Content-Type header if is_batch is false because default is Atom.
|
621
|
+
headers[HeaderConstants::CONTENT_TYPE] = HeaderConstants::JSON_CONTENT_TYPE_VALUE unless is_batch
|
622
|
+
headers[HeaderConstants::DATA_SERVICE_VERSION] = TableConstants::DEFAULT_DATA_SERVICE_VERSION
|
623
|
+
super(method, uri, body, headers, options)
|
624
|
+
end
|
626
625
|
|
627
626
|
protected
|
628
|
-
|
629
|
-
|
630
|
-
|
627
|
+
def new_query(options = {})
|
628
|
+
options[:timeout].nil? ? {} : { QueryStringConstants::TIMEOUT => options[:timeout].to_s }
|
629
|
+
end
|
631
630
|
end
|
632
631
|
end
|
633
632
|
end
|