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.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/lib/azure/storage.rb +14 -13
  3. data/lib/azure/storage/autoload.rb +31 -31
  4. data/lib/azure/storage/blob/append.rb +43 -41
  5. data/lib/azure/storage/blob/blob.rb +150 -147
  6. data/lib/azure/storage/blob/blob_service.rb +186 -184
  7. data/lib/azure/storage/blob/block.rb +56 -56
  8. data/lib/azure/storage/blob/container.rb +93 -92
  9. data/lib/azure/storage/blob/page.rb +187 -104
  10. data/lib/azure/storage/blob/serialization.rb +32 -18
  11. data/lib/azure/storage/client.rb +18 -17
  12. data/lib/azure/storage/client_options.rb +192 -193
  13. data/lib/azure/storage/client_options_error.rb +5 -5
  14. data/lib/azure/storage/configurable.rb +39 -39
  15. data/lib/azure/storage/core.rb +6 -4
  16. data/lib/azure/storage/core/auth/shared_access_signature.rb +5 -3
  17. data/lib/azure/storage/core/auth/shared_access_signature_generator.rb +34 -33
  18. data/lib/azure/storage/core/auth/shared_access_signature_signer.rb +5 -5
  19. data/lib/azure/storage/core/auth/shared_key.rb +17 -15
  20. data/lib/azure/storage/core/autoload.rb +15 -13
  21. data/lib/azure/storage/core/error.rb +3 -1
  22. data/lib/azure/storage/core/filter/exponential_retry_filter.rb +13 -11
  23. data/lib/azure/storage/core/filter/linear_retry_filter.rb +10 -8
  24. data/lib/azure/storage/core/filter/retry_filter.rb +30 -29
  25. data/lib/azure/storage/core/http_client.rb +18 -16
  26. data/lib/azure/storage/core/sr.rb +50 -48
  27. data/lib/azure/storage/core/utility.rb +19 -17
  28. data/lib/azure/storage/default.rb +371 -361
  29. data/lib/azure/storage/file/directory.rb +36 -31
  30. data/lib/azure/storage/file/file.rb +103 -100
  31. data/lib/azure/storage/file/file_service.rb +42 -40
  32. data/lib/azure/storage/file/serialization.rb +9 -6
  33. data/lib/azure/storage/file/share.rb +48 -46
  34. data/lib/azure/storage/queue/message.rb +3 -1
  35. data/lib/azure/storage/queue/queue.rb +3 -2
  36. data/lib/azure/storage/queue/queue_service.rb +152 -151
  37. data/lib/azure/storage/queue/serialization.rb +7 -5
  38. data/lib/azure/storage/service/access_policy.rb +3 -1
  39. data/lib/azure/storage/service/cors.rb +4 -2
  40. data/lib/azure/storage/service/cors_rule.rb +3 -1
  41. data/lib/azure/storage/service/enumeration_results.rb +3 -1
  42. data/lib/azure/storage/service/logging.rb +5 -3
  43. data/lib/azure/storage/service/metrics.rb +5 -3
  44. data/lib/azure/storage/service/retention_policy.rb +3 -1
  45. data/lib/azure/storage/service/serialization.rb +31 -30
  46. data/lib/azure/storage/service/signed_identifier.rb +5 -4
  47. data/lib/azure/storage/service/storage_service.rb +33 -32
  48. data/lib/azure/storage/service/storage_service_properties.rb +6 -4
  49. data/lib/azure/storage/table/auth/shared_key.rb +9 -8
  50. data/lib/azure/storage/table/batch.rb +55 -55
  51. data/lib/azure/storage/table/batch_response.rb +17 -17
  52. data/lib/azure/storage/table/edmtype.rb +9 -7
  53. data/lib/azure/storage/table/entity.rb +4 -3
  54. data/lib/azure/storage/table/guid.rb +3 -1
  55. data/lib/azure/storage/table/query.rb +17 -19
  56. data/lib/azure/storage/table/serialization.rb +14 -12
  57. data/lib/azure/storage/table/table_service.rb +79 -80
  58. data/lib/azure/storage/version.rb +7 -5
  59. 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
  #
@@ -36,4 +38,4 @@ module Azure::Storage
36
38
  attr_accessor :pop_receipt
37
39
  end
38
40
  end
39
- end
41
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #-------------------------------------------------------------------------
2
4
  # # Copyright (c) Microsoft and contributors. All rights reserved.
3
5
  #
@@ -24,7 +26,6 @@
24
26
  module Azure::Storage
25
27
  module Queue
26
28
  class Queue
27
-
28
29
  def initialize
29
30
  @metadata = {}
30
31
  yield self if block_given?
@@ -34,4 +35,4 @@ module Azure::Storage
34
35
  attr_accessor :metadata
35
36
  end
36
37
  end
37
- end
38
+ end
@@ -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,14 @@
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 'azure/storage/core/auth/shared_key'
25
- require 'azure/storage/service/storage_service'
26
- require 'azure/storage/queue/serialization'
26
+ require "azure/storage/core/auth/shared_key"
27
+ require "azure/storage/service/storage_service"
28
+ require "azure/storage/queue/serialization"
27
29
 
28
30
  module Azure::Storage
29
31
  module Queue
30
32
  include Azure::Storage::Service
31
33
  class QueueService < StorageService
32
-
33
34
  def initialize(options = {}, &block)
34
35
  client_config = options[:client] || Azure::Storage
35
36
  signer = options[:signer] || client_config.signer || Azure::Storage::Core::Auth::SharedKey.new(client_config.storage_account_name, client_config.storage_access_key)
@@ -46,39 +47,39 @@ module Azure::Storage
46
47
  # ==== Options
47
48
  #
48
49
  # Accepted key/value pairs in options parameter are:
49
- # * +:prefix+ - String. Filters the results to return only containers
50
+ # * +:prefix+ - String. Filters the results to return only containers
50
51
  # whose name begins with the specified prefix. (optional)
51
- # * +:marker+ - String. An identifier the specifies the portion of the
52
+ # * +:marker+ - String. An identifier the specifies the portion of the
52
53
  # list to be returned. This value comes from the property
53
- # Azure::Service::EnumerationResults.continuation_token when there
54
- # are more containers available than were returned. The
54
+ # Azure::Service::EnumerationResults.continuation_token when there
55
+ # are more containers available than were returned. The
55
56
  # marker value may then be used here to request the next set
56
57
  # of list items. (optional)
57
- # * +:max_results+ - Integer. Specifies the maximum number of containers to return.
58
- # If max_results is not specified, or is a value greater than
59
- # 5,000, the server will return up to 5,000 items. If it is set
60
- # to a value less than or equal to zero, the server will return
58
+ # * +:max_results+ - Integer. Specifies the maximum number of containers to return.
59
+ # If max_results is not specified, or is a value greater than
60
+ # 5,000, the server will return up to 5,000 items. If it is set
61
+ # to a value less than or equal to zero, the server will return
61
62
  # status code 400 (Bad Request). (optional)
62
63
  # * +:metadata+ - Boolean. Specifies whether or not to return the container metadata.
63
64
  # (optional, Default=false)
64
65
  # * +:timeout+ - Integer. A timeout in seconds.
65
- # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
66
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
66
67
  # in the analytics logs when storage analytics logging is enabled.
67
68
  #
68
69
  # NOTE: Metadata requested with the :metadata parameter must have been stored in
69
- # accordance with the naming restrictions imposed by the 2009-09-19 version of the queue
70
- # service. Beginning with that version, all metadata names must adhere to the naming
70
+ # accordance with the naming restrictions imposed by the 2009-09-19 version of the queue
71
+ # service. Beginning with that version, all metadata names must adhere to the naming
71
72
  # conventions for C# identifiers.
72
73
  #
73
- # See http://msdn.microsoft.com/en-us/library/azure/dd179466
74
+ # See http://msdn.microsoft.com/en-us/library/azure/dd179466
74
75
  #
75
- # Any metadata with invalid names which were previously stored, will be returned with the
76
+ # Any metadata with invalid names which were previously stored, will be returned with the
76
77
  # key "x-ms-invalid-name" in the metadata hash. This may contain multiple values and be an
77
78
  # Array (vs a String if it only contains a single value).
78
- #
79
+ #
79
80
  # Returns an Azure::Service::EnumerationResults
80
- def list_queues(options={})
81
- query = { }
81
+ def list_queues(options = {})
82
+ query = {}
82
83
  query["prefix"] = options[:prefix] if options[:prefix]
83
84
  query["marker"] = options[:marker] if options[:marker]
84
85
  query["maxresults"] = options[:max_results].to_s if options[:max_results]
@@ -92,14 +93,14 @@ module Azure::Storage
92
93
  end
93
94
 
94
95
  # Public: Clears all messages from the queue.
95
- #
96
- # If a queue contains a large number of messages, Clear Messages may time out
97
- # before all messages have been deleted. In this case the Queue service will
98
- # return status code 500 (Internal Server Error), with the additional error
99
- # code OperationTimedOut. If the operation times out, the client should
100
- # continue to retry Clear Messages until it succeeds, to ensure that all
96
+ #
97
+ # If a queue contains a large number of messages, Clear Messages may time out
98
+ # before all messages have been deleted. In this case the Queue service will
99
+ # return status code 500 (Internal Server Error), with the additional error
100
+ # code OperationTimedOut. If the operation times out, the client should
101
+ # continue to retry Clear Messages until it succeeds, to ensure that all
101
102
  # messages have been deleted.
102
- #
103
+ #
103
104
  # ==== Attributes
104
105
  #
105
106
  # * +queue_name+ - String. The name of the queue.
@@ -109,45 +110,45 @@ module Azure::Storage
109
110
  #
110
111
  # Accepted key/value pairs in options parameter are:
111
112
  # * +: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
113
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
113
114
  # in the analytics logs when storage analytics logging is enabled.
114
- #
115
+ #
115
116
  # See http://msdn.microsoft.com/en-us/library/azure/dd179454
116
- #
117
+ #
117
118
  # Returns nil on success
118
- def clear_messages(queue_name, options={})
119
- query = { }
119
+ def clear_messages(queue_name, options = {})
120
+ query = {}
120
121
  query["timeout"] = options[:timeout].to_s if options[:timeout]
121
122
  uri = messages_uri(queue_name, query)
122
123
  call(:delete, uri, nil, {}, options)
123
124
  nil
124
125
  end
125
-
126
+
126
127
  # Public: Creates a new queue under the storage account.
127
- #
128
+ #
128
129
  # ==== Attributes
129
130
  #
130
131
  # * +queue_name+ - String. The queue name.
131
- # * +options+ - Hash. Optional parameters.
132
+ # * +options+ - Hash. Optional parameters.
132
133
  #
133
134
  # ==== Options
134
135
  #
135
136
  # Accepted key/value pairs in options parameter are:
136
137
  # * +:metadata+ - Hash. A hash of user defined metadata.
137
138
  # * +: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
139
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
139
140
  # in the analytics logs when storage analytics logging is enabled.
140
141
  #
141
142
  # See http://msdn.microsoft.com/en-us/library/azure/dd179342
142
143
  #
143
144
  # Returns nil on success
144
- def create_queue(queue_name, options={})
145
- query = { }
145
+ def create_queue(queue_name, options = {})
146
+ query = {}
146
147
  query["timeout"] = options[:timeout].to_s if options[:timeout]
147
148
 
148
149
  uri = queue_uri(queue_name, query)
149
150
 
150
- headers = { }
151
+ headers = {}
151
152
  Service::StorageService.add_metadata_to_headers(options[:metadata] || {}, headers) if options[:metadata]
152
153
 
153
154
  call(:put, uri, nil, headers, options)
@@ -155,24 +156,24 @@ module Azure::Storage
155
156
  end
156
157
 
157
158
  # Public: Deletes a queue.
158
- #
159
+ #
159
160
  # ==== Attributes
160
161
  #
161
162
  # * +queue_name+ - String. The queue name.
162
- # * +options+ - Hash. Optional parameters.
163
+ # * +options+ - Hash. Optional parameters.
163
164
  #
164
165
  # ==== Options
165
166
  #
166
167
  # Accepted key/value pairs in options parameter are:
167
168
  # * +:timeout+ - Integer. A timeout in seconds.
168
- # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
169
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
169
170
  # in the analytics logs when storage analytics logging is enabled.
170
171
  #
171
172
  # See http://msdn.microsoft.com/en-us/library/azure/dd179436
172
173
  #
173
174
  # Returns nil on success
174
- def delete_queue(queue_name, options={})
175
- query = { }
175
+ def delete_queue(queue_name, options = {})
176
+ query = {}
176
177
  query["timeout"] = options[:timeout].to_s if options[:timeout]
177
178
 
178
179
  uri = queue_uri(queue_name, query)
@@ -182,17 +183,17 @@ module Azure::Storage
182
183
  end
183
184
 
184
185
  # Public: Returns queue properties, including user-defined metadata.
185
- #
186
+ #
186
187
  # ==== Attributes
187
188
  #
188
189
  # * +queue_name+ - String. The queue name.
189
- # * +options+ - Hash. Optional parameters.
190
+ # * +options+ - Hash. Optional parameters.
190
191
  #
191
192
  # ==== Options
192
193
  #
193
194
  # Accepted key/value pairs in options parameter are:
194
195
  # * +:timeout+ - Integer. A timeout in seconds.
195
- # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
196
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
196
197
  # in the analytics logs when storage analytics logging is enabled.
197
198
  #
198
199
  # See http://msdn.microsoft.com/en-us/library/azure/dd179384
@@ -202,7 +203,7 @@ module Azure::Storage
202
203
  # lower than the actual number of messages in the queue, but could be higher.
203
204
  # * metadata - Hash. The queue metadata (Default: {})
204
205
  #
205
- def get_queue_metadata(queue_name, options={})
206
+ def get_queue_metadata(queue_name, options = {})
206
207
  query = { "comp" => "metadata" }
207
208
  query["timeout"] = options[:timeout].to_s if options[:timeout]
208
209
 
@@ -216,32 +217,32 @@ module Azure::Storage
216
217
  return approximate_messages_count.to_i, metadata
217
218
  end
218
219
 
219
- # Public: Sets user-defined metadata on the queue. To delete queue metadata, call
220
+ # Public: Sets user-defined metadata on the queue. To delete queue metadata, call
220
221
  # this API with an empty hash in the metadata parameter.
221
- #
222
+ #
222
223
  # ==== Attributes
223
224
  #
224
225
  # * +queue_name+ - String. The queue name.
225
226
  # * +metadata+ - Hash. A hash of user defined metadata
226
- # * +options+ - Hash. Optional parameters.
227
+ # * +options+ - Hash. Optional parameters.
227
228
  #
228
229
  # ==== Options
229
230
  #
230
231
  # Accepted key/value pairs in options parameter are:
231
232
  # * +:timeout+ - Integer. A timeout in seconds.
232
- # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
233
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
233
234
  # in the analytics logs when storage analytics logging is enabled.
234
235
  #
235
236
  # See http://msdn.microsoft.com/en-us/library/azure/dd179348
236
237
  #
237
238
  # Returns nil on success
238
- def set_queue_metadata(queue_name, metadata, options={})
239
+ def set_queue_metadata(queue_name, metadata, options = {})
239
240
  query = { "comp" => "metadata" }
240
241
  query["timeout"] = options[:timeout].to_s if options[:timeout]
241
242
 
242
243
  uri = queue_uri(queue_name, query)
243
244
 
244
- headers ={}
245
+ headers = {}
245
246
  Service::StorageService.add_metadata_to_headers(metadata || {}, headers)
246
247
 
247
248
  call(:put, uri, nil, headers, options)
@@ -253,26 +254,26 @@ module Azure::Storage
253
254
  # ==== Attributes
254
255
  #
255
256
  # * +queue_name+ - String. The queue name.
256
- # * +options+ - Hash. Optional parameters.
257
+ # * +options+ - Hash. Optional parameters.
257
258
  #
258
259
  # ==== Options
259
260
  #
260
261
  # Accepted key/value pairs in options parameter are:
261
262
  # * +:timeout+ - Integer. A timeout in seconds.
262
- # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
263
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
263
264
  # in the analytics logs when storage analytics logging is enabled.
264
265
  #
265
266
  # See http://msdn.microsoft.com/en-us/library/azure/jj159101
266
267
  #
267
268
  # Returns a list of Azure::Storage::Entity::SignedIdentifier instances
268
- def get_queue_acl(queue_name, options={})
269
+ def get_queue_acl(queue_name, options = {})
269
270
  query = { "comp" => "acl" }
270
271
  query["timeout"] = options[:timeout].to_s if options[:timeout]
271
272
 
272
273
  response = call(:get, queue_uri(queue_name, query), nil, {}, options)
273
274
 
274
275
  signed_identifiers = []
275
- signed_identifiers = Serialization.signed_identifiers_from_xml(response.body) unless response.body == nil or response.body.length < 1
276
+ signed_identifiers = Serialization.signed_identifiers_from_xml(response.body) unless response.body == (nil) || response.body.length < (1)
276
277
  signed_identifiers
277
278
  end
278
279
 
@@ -281,24 +282,24 @@ module Azure::Storage
281
282
  # ==== Attributes
282
283
  #
283
284
  # * +queue_name+ - String. The queue name.
284
- # * +options+ - Hash. Optional parameters.
285
+ # * +options+ - Hash. Optional parameters.
285
286
  #
286
287
  # ==== Options
287
288
  #
288
289
  # Accepted key/value pairs in options parameter are:
289
- # * +:signed_identifiers+ - Array. A list of Azure::Storage::Entity::SignedIdentifier instances
290
+ # * +:signed_identifiers+ - Array. A list of Azure::Storage::Entity::SignedIdentifier instances
290
291
  # * +:timeout+ - Integer. A timeout in seconds.
291
- # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
292
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
292
293
  # in the analytics logs when storage analytics logging is enabled.
293
- #
294
+ #
294
295
  # See http://msdn.microsoft.com/en-us/library/azure/jj159099
295
296
  #
296
297
  # Returns nil on success
297
- def set_queue_acl(queue_name, options={})
298
+ def set_queue_acl(queue_name, options = {})
298
299
  query = { "comp" => "acl" }
299
300
  query["timeout"] = options[:timeout].to_s if options[:timeout]
300
301
 
301
- uri =queue_uri(queue_name, query)
302
+ uri = queue_uri(queue_name, query)
302
303
  body = nil
303
304
  body = Serialization.signed_identifiers_to_xml(options[:signed_identifiers]) if options[:signed_identifiers] && options[:signed_identifiers].length > 0
304
305
 
@@ -307,33 +308,33 @@ module Azure::Storage
307
308
  end
308
309
 
309
310
  # Public: Adds a message to the queue and optionally sets a visibility timeout for the message.
310
- #
311
+ #
311
312
  # ==== Attributes
312
313
  #
313
314
  # * +queue_name+ - String. The queue name.
314
315
  # * +message_text+ - String. The message contents. Note that the message content must be in a format that may be encoded with UTF-8.
315
- # * +options+ - Hash. Optional parameters.
316
+ # * +options+ - Hash. Optional parameters.
316
317
  #
317
318
  # ==== Options
318
319
  #
319
320
  # Accepted key/value pairs in options parameter are:
320
- # * +:visibility_timeout+ - Integer. Specifies the new visibility timeout value, in seconds, relative to server
321
- # time. The new value must be larger than or equal to 0, and cannot be larger than 7
322
- # days. The visibility timeout of a message cannot be set to a value later than the
323
- # expiry time. :visibility_timeout should be set to a value smaller than the
321
+ # * +:visibility_timeout+ - Integer. Specifies the new visibility timeout value, in seconds, relative to server
322
+ # time. The new value must be larger than or equal to 0, and cannot be larger than 7
323
+ # days. The visibility timeout of a message cannot be set to a value later than the
324
+ # expiry time. :visibility_timeout should be set to a value smaller than the
324
325
  # time-to-live value. If not specified, the default value is 0.
325
- # * +:message_ttl+ - Integer. Specifies the time-to-live interval for the message, in seconds. The maximum
326
+ # * +:message_ttl+ - Integer. Specifies the time-to-live interval for the message, in seconds. The maximum
326
327
  # time-to-live allowed is 7 days. If not specified, the default time-to-live is 7 days.
327
328
  # * +:encode+ - Boolean. If set to true, the message will be base64 encoded.
328
329
  # * +:timeout+ - Integer. A timeout in seconds.
329
- # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
330
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
330
331
  # in the analytics logs when storage analytics logging is enabled.
331
332
  #
332
333
  # See http://msdn.microsoft.com/en-us/library/azure/dd179346
333
334
  #
334
- # Returns nil on success
335
- def create_message(queue_name, message_text, options={})
336
- query = { }
335
+ # Returns a list of Azure::Storage::Queue::Message object containing only the echo of request on success
336
+ def create_message(queue_name, message_text, options = {})
337
+ query = {}
337
338
 
338
339
  unless options.empty?
339
340
  query["visibilitytimeout"] = options[:visibility_timeout] if options[:visibility_timeout]
@@ -344,69 +345,69 @@ module Azure::Storage
344
345
  uri = messages_uri(queue_name, query)
345
346
  body = Serialization.message_to_xml(message_text, options[:encode])
346
347
 
347
- call(:post, uri, body, {}, options)
348
- nil
348
+ response = call(:post, uri, body, {}, options)
349
+ Serialization.queue_messages_from_xml(response.body, options[:decode])
349
350
  end
350
351
 
351
352
  # Public: Deletes a specified message from the queue.
352
- #
353
+ #
353
354
  # ==== Attributes
354
355
  #
355
356
  # * +queue_name+ - String. The queue name.
356
357
  # * +message_id+ - String. The id of the message.
357
- # * +pop_receipt+ - String. The valid pop receipt value returned from an earlier call to the Get Messages or
358
+ # * +pop_receipt+ - String. The valid pop receipt value returned from an earlier call to the Get Messages or
358
359
  # Update Message operation.
359
- # * +options+ - Hash. Optional parameters.
360
+ # * +options+ - Hash. Optional parameters.
360
361
  #
361
362
  # ==== Options
362
363
  #
363
364
  # Accepted key/value pairs in options parameter are:
364
365
  # * +:timeout+ - Integer. A timeout in seconds.
365
- # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
366
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
366
367
  # in the analytics logs when storage analytics logging is enabled.
367
- #
368
+ #
368
369
  # See http://msdn.microsoft.com/en-us/library/azure/dd179347
369
370
  #
370
371
  # Returns nil on success
371
372
  #
372
373
  # Remarks:
373
374
  #
374
- # When a message is successfully deleted, it is immediately marked for deletion and is no longer accessible to
375
+ # When a message is successfully deleted, it is immediately marked for deletion and is no longer accessible to
375
376
  # clients. The message is later removed from the queue during garbage collection.
376
- #
377
- # After a client retrieves a message with the Get Messages operation, the client is expected to process and
378
- # delete the message. To delete the message, you must have two items of data returned in the response body of
377
+ #
378
+ # After a client retrieves a message with the Get Messages operation, the client is expected to process and
379
+ # delete the message. To delete the message, you must have two items of data returned in the response body of
379
380
  # the Get Messages operation:
380
- #
381
+ #
381
382
  # * The message ID, an opaque GUID value that identifies the message in the queue.
382
- #
383
+ #
383
384
  # * A valid pop receipt, an opaque value that indicates that the message has been retrieved.
384
- #
385
- # The message ID is returned from the previous Get Messages operation. The pop receipt is returned from the most
386
- # recent Get Messages or Update Message operation. In order for the Delete Message operation to succeed, the pop
387
- # receipt specified on the request must match the pop receipt returned from the Get Messages or Update Message
385
+ #
386
+ # The message ID is returned from the previous Get Messages operation. The pop receipt is returned from the most
387
+ # recent Get Messages or Update Message operation. In order for the Delete Message operation to succeed, the pop
388
+ # receipt specified on the request must match the pop receipt returned from the Get Messages or Update Message
388
389
  # operation.
389
- #
390
+ #
390
391
  # Pop receipts remain valid until one of the following events occurs:
391
392
  #
392
393
  # * The message has expired.
393
394
  #
394
- # * The message has been deleted using the last pop receipt received either from Get Messages or Update Message.
395
- #
396
- # * The invisibility time has elapsed and the message has been dequeued by a Get Messages request. When the
397
- # invisibility time elapses, the message becomes visible again. If it is retrieved by another Get Messages
395
+ # * The message has been deleted using the last pop receipt received either from Get Messages or Update Message.
396
+ #
397
+ # * The invisibility time has elapsed and the message has been dequeued by a Get Messages request. When the
398
+ # invisibility time elapses, the message becomes visible again. If it is retrieved by another Get Messages
398
399
  # request, the returned pop receipt can be used to delete or update the message.
399
- #
400
- # * The message has been updated with a new visibility timeout. When the message is updated, a new pop receipt
400
+ #
401
+ # * The message has been updated with a new visibility timeout. When the message is updated, a new pop receipt
401
402
  # will be returned.
402
- #
403
- # If the message has already been deleted when Delete Message is called, the Queue service returns status code
403
+ #
404
+ # If the message has already been deleted when Delete Message is called, the Queue service returns status code
404
405
  # 404 (Not Found).
405
- #
406
- # If a message with a matching pop receipt is not found, the service returns status code 400 (Bad Request), with
406
+ #
407
+ # If a message with a matching pop receipt is not found, the service returns status code 400 (Bad Request), with
407
408
  # additional error information indicating that the cause of the failure was a mismatched pop receipt.
408
409
  #
409
- def delete_message(queue_name, message_id, pop_receipt, options={})
410
+ def delete_message(queue_name, message_id, pop_receipt, options = {})
410
411
  query = { "popreceipt" => pop_receipt }
411
412
  query["timeout"] = options[:timeout].to_s if options[:timeout]
412
413
 
@@ -421,7 +422,7 @@ module Azure::Storage
421
422
  # ==== Attributes
422
423
  #
423
424
  # * +queue_name+ - String. The queue name.
424
- # * +options+ - Hash. Optional parameters.
425
+ # * +options+ - Hash. Optional parameters.
425
426
  #
426
427
  # ==== Options
427
428
  #
@@ -429,17 +430,17 @@ module Azure::Storage
429
430
  # * +:number_of_messages+ - Integer. How many messages to return. (optional, Default: 1)
430
431
  # * +:decode+ - Boolean. Boolean value indicating if the message should be base64 decoded.
431
432
  # * +:timeout+ - Integer. A timeout in seconds.
432
- # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
433
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
433
434
  # in the analytics logs when storage analytics logging is enabled.
434
435
  #
435
436
  # See http://msdn.microsoft.com/en-us/library/azure/dd179472
436
437
  #
437
438
  # Returns a list of Azure::Storage::Entity::Queue::Message instances
438
- def peek_messages(queue_name, options={})
439
- number_of_messages=1
439
+ def peek_messages(queue_name, options = {})
440
+ number_of_messages = 1
440
441
  number_of_messages = options[:number_of_messages] if options[:number_of_messages]
441
442
 
442
- query = { "peekonly" => "true", "numofmessages"=> number_of_messages.to_s }
443
+ query = { "peekonly" => "true", "numofmessages" => number_of_messages.to_s }
443
444
  query["timeout"] = options[:timeout].to_s if options[:timeout]
444
445
 
445
446
  uri = messages_uri(queue_name, query)
@@ -455,25 +456,25 @@ module Azure::Storage
455
456
  #
456
457
  # * +queue_name+ - String. The queue name.
457
458
  # * +visibility_timeout+ - Integer. The new visibility timeout value, in seconds, relative to server time.
458
- # * +options+ - Hash. Optional parameters.
459
+ # * +options+ - Hash. Optional parameters.
459
460
  #
460
461
  # ==== Options
461
462
  #
462
463
  # Accepted key/value pairs in options parameter are:
463
464
  # * +:number_of_messages+ - Integer. How many messages to return. (optional, Default: 1)
464
465
  # * +:timeout+ - Integer. A timeout in seconds.
465
- # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
466
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
466
467
  # in the analytics logs when storage analytics logging is enabled.
467
468
  # * +:decode+ - Boolean. Boolean value indicating if the message should be base64 decoded.
468
469
  #
469
470
  # See http://msdn.microsoft.com/en-us/library/azure/dd179474
470
471
  #
471
472
  # Returns a list of Azure::Storage::Entity::Queue::Message instances
472
- def list_messages(queue_name, visibility_timeout, options={})
473
- number_of_messages=1
473
+ def list_messages(queue_name, visibility_timeout, options = {})
474
+ number_of_messages = 1
474
475
  number_of_messages = options[:number_of_messages] if options[:number_of_messages]
475
476
 
476
- query = { "visibilitytimeout" => visibility_timeout.to_s, "numofmessages"=> number_of_messages.to_s }
477
+ query = { "visibilitytimeout" => visibility_timeout.to_s, "numofmessages" => number_of_messages.to_s }
477
478
  query["timeout"] = options[:timeout].to_s if options[:timeout]
478
479
 
479
480
  uri = messages_uri(queue_name, query)
@@ -484,24 +485,24 @@ module Azure::Storage
484
485
  end
485
486
 
486
487
  # Public: Adds a message to the queue and optionally sets a visibility timeout for the message.
487
- #
488
+ #
488
489
  # ==== Attributes
489
490
  #
490
491
  # * +queue_name+ - String. The queue name.
491
492
  # * +message_id+ - String. The id of the message.
492
- # * +pop_receipt+ - String. The valid pop receipt value returned from an earlier call to the Get Messages or
493
+ # * +pop_receipt+ - String. The valid pop receipt value returned from an earlier call to the Get Messages or
493
494
  # update Message operation.
494
- # * +message_text+ - String. The message contents. Note that the message content must be in a format that may
495
+ # * +message_text+ - String. The message contents. Note that the message content must be in a format that may
495
496
  # be encoded with UTF-8.
496
497
  # * +visibility_timeout+ - Integer. The new visibility timeout value, in seconds, relative to server time.
497
- # * +options+ - Hash. Optional parameters.
498
+ # * +options+ - Hash. Optional parameters.
498
499
  #
499
500
  # ==== Options
500
501
  #
501
502
  # Accepted key/value pairs in options parameter are:
502
503
  # * +:encode+ - Boolean. If set to true, the message will be base64 encoded.
503
504
  # * +:timeout+ - Integer. A timeout in seconds.
504
- # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
505
+ # * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
505
506
  # in the analytics logs when storage analytics logging is enabled.
506
507
  #
507
508
  # See http://msdn.microsoft.com/en-us/library/azure/hh452234
@@ -512,31 +513,31 @@ module Azure::Storage
512
513
  #
513
514
  # Remarks:
514
515
  #
515
- # An Update Message operation will fail if the specified message does not exist in the queue, or if the
516
+ # An Update Message operation will fail if the specified message does not exist in the queue, or if the
516
517
  # specified pop receipt does not match the message.
517
- #
518
- # A pop receipt is returned by the Get Messages operation or the Update Message operation. Pop receipts
518
+ #
519
+ # A pop receipt is returned by the Get Messages operation or the Update Message operation. Pop receipts
519
520
  # remain valid until one of the following events occurs:
520
- #
521
+ #
521
522
  # * The message has expired.
522
- #
523
- # * The message has been deleted using the last pop receipt received either from Get Messages or
524
- # Update Message.
525
- #
526
- # * The invisibility time has elapsed and the message has been dequeued by a Get Messages request. When
527
- # the invisibility time elapses, the message becomes visible again. If it is retrieved by another
523
+ #
524
+ # * The message has been deleted using the last pop receipt received either from Get Messages or
525
+ # Update Message.
526
+ #
527
+ # * The invisibility time has elapsed and the message has been dequeued by a Get Messages request. When
528
+ # the invisibility time elapses, the message becomes visible again. If it is retrieved by another
528
529
  # Get Messages request, the returned pop receipt can be used to delete or update the message.
529
- #
530
- # * The message has been updated with a new visibility timeout. When the message is updated, a new pop
530
+ #
531
+ # * The message has been updated with a new visibility timeout. When the message is updated, a new pop
531
532
  # receipt will be returned.
532
- #
533
- # The Update Message operation can be used to continually extend the invisibility of a queue message. This
534
- # functionality can be useful if you want a worker role to "lease" a queue message. For example, if a worker
535
- # role calls Get Messages and recognizes that it needs more time to process a message, it can continually
536
- # extend the message's invisibility until it is processed. If the worker role were to fail during processing,
533
+ #
534
+ # The Update Message operation can be used to continually extend the invisibility of a queue message. This
535
+ # functionality can be useful if you want a worker role to "lease" a queue message. For example, if a worker
536
+ # role calls Get Messages and recognizes that it needs more time to process a message, it can continually
537
+ # extend the message's invisibility until it is processed. If the worker role were to fail during processing,
537
538
  # eventually the message would become visible again and another worker role could process it.
538
539
  #
539
- def update_message(queue_name, message_id, pop_receipt, message_text, visibility_timeout, options={})
540
+ def update_message(queue_name, message_id, pop_receipt, message_text, visibility_timeout, options = {})
540
541
  query = { "visibilitytimeout" => visibility_timeout.to_s, "popreceipt" => pop_receipt }
541
542
  query["timeout"] = options[:timeout].to_s if options[:timeout]
542
543
 
@@ -557,10 +558,10 @@ module Azure::Storage
557
558
  #
558
559
  # Returns a URI.
559
560
  protected
560
- def collection_uri(query={})
561
- query.update({:comp => 'list', :include => 'metadata'})
562
- generate_uri("", query)
563
- end
561
+ def collection_uri(query = {})
562
+ query.update(comp: "list", include: "metadata")
563
+ generate_uri("", query)
564
+ end
564
565
 
565
566
  # Protected: Generate the URI for a given queue.
566
567
  #
@@ -571,10 +572,10 @@ module Azure::Storage
571
572
  #
572
573
  # Returns a URI.
573
574
  protected
574
- def queue_uri(queue_name, query={})
575
- return queue_name if queue_name.kind_of? ::URI
576
- generate_uri(queue_name, query)
577
- end
575
+ def queue_uri(queue_name, query = {})
576
+ return queue_name if queue_name.kind_of? ::URI
577
+ generate_uri(queue_name, query)
578
+ end
578
579
 
579
580
  # Protected: Generate the messages URI for the given queue.
580
581
  #
@@ -585,9 +586,9 @@ module Azure::Storage
585
586
  #
586
587
  # Returns a URI.
587
588
  protected
588
- def messages_uri(queue_name, query={})
589
- generate_uri("#{queue_name}/messages", query)
590
- end
589
+ def messages_uri(queue_name, query = {})
590
+ generate_uri("#{queue_name}/messages", query)
591
+ end
591
592
 
592
593
  # Protected: Generate the URI for a given message
593
594
  #
@@ -599,9 +600,9 @@ module Azure::Storage
599
600
  #
600
601
  # Returns a URI.
601
602
  protected
602
- def message_uri(queue_name, message_id, query={})
603
- generate_uri("#{queue_name}/messages/#{message_id}", query)
604
- end
603
+ def message_uri(queue_name, message_id, query = {})
604
+ generate_uri("#{queue_name}/messages/#{message_id}", query)
605
+ end
605
606
  end
606
607
  end
607
608
  end