azure 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/azure.gemspec +1 -1
- data/lib/azure.rb +1 -0
- data/lib/azure/blob/blob.rb +1 -1
- data/lib/azure/blob/blob_service.rb +14 -9
- data/lib/azure/blob/block.rb +2 -2
- data/lib/azure/blob/serialization.rb +6 -6
- data/lib/azure/configurable.rb +8 -0
- data/lib/azure/core/filtered_service.rb +1 -1
- data/lib/azure/core/http/debug_filter.rb +2 -2
- data/lib/azure/core/http/http_error.rb +1 -1
- data/lib/azure/core/http/http_filter.rb +15 -15
- data/lib/azure/core/http/http_request.rb +6 -6
- data/lib/azure/core/http/http_response.rb +1 -1
- data/lib/azure/core/http/retry_policy.rb +12 -12
- data/lib/azure/core/http/signer_filter.rb +1 -1
- data/lib/azure/core/service.rb +1 -1
- data/lib/azure/queue/queue_service.rb +91 -91
- data/lib/azure/queue/serialization.rb +1 -1
- data/lib/azure/service/cors.rb +1 -1
- data/lib/azure/service/logging.rb +1 -1
- data/lib/azure/service/metrics.rb +1 -1
- data/lib/azure/service/serialization.rb +10 -10
- data/lib/azure/service/signed_identifier.rb +1 -1
- data/lib/azure/service/storage_service.rb +2 -2
- data/lib/azure/service_bus/auth/wrap_service.rb +2 -2
- data/lib/azure/service_bus/brokered_message.rb +6 -6
- data/lib/azure/service_bus/interval.rb +2 -2
- data/lib/azure/service_bus/queue.rb +11 -11
- data/lib/azure/service_bus/relay.rb +4 -4
- data/lib/azure/service_bus/resource.rb +1 -1
- data/lib/azure/service_bus/rule.rb +1 -1
- data/lib/azure/service_bus/serialization.rb +2 -2
- data/lib/azure/service_bus/service_bus_service.rb +92 -92
- data/lib/azure/service_bus/sql_filter.rb +1 -1
- data/lib/azure/service_bus/sql_rule_action.rb +3 -3
- data/lib/azure/service_bus/subscription.rb +1 -1
- data/lib/azure/service_bus/topic.rb +11 -11
- data/lib/azure/storage_management/storage_management_service.rb +2 -2
- data/lib/azure/table/batch.rb +28 -28
- data/lib/azure/table/batch_response.rb +5 -5
- data/lib/azure/table/edmtype.rb +1 -1
- data/lib/azure/table/entity.rb +2 -2
- data/lib/azure/table/query.rb +6 -6
- data/lib/azure/table/serialization.rb +4 -4
- data/lib/azure/table/table_service.rb +30 -30
- data/lib/azure/version.rb +1 -1
- data/lib/azure/virtual_machine_management/virtual_machine_management_service.rb +5 -4
- data/lib/azure/virtual_network_management/serialization.rb +2 -2
- data/test/fixtures/list_os_images.xml +1 -1
- data/test/fixtures/list_virtual_networks.xml +0 -1
- data/test/fixtures/management_certificate.pem +55 -0
- data/test/fixtures/management_certificate.publishsettings +12 -0
- data/test/fixtures/updated_storage_accounts.xml +8 -8
- data/test/integration/blob/blob_metadata_test.rb +5 -5
- data/test/integration/blob/blob_pages_test.rb +5 -5
- data/test/integration/blob/blob_properties_test.rb +3 -3
- data/test/integration/blob/block_blob_test.rb +64 -15
- data/test/integration/blob/container/container_acl_test.rb +2 -2
- data/test/integration/blob/container/container_metadata_test.rb +2 -2
- data/test/integration/blob/container/create_container_test.rb +3 -3
- data/test/integration/blob/container/delete_container_test.rb +1 -1
- data/test/integration/blob/container/get_container_properties_test.rb +2 -2
- data/test/integration/blob/container/list_containers_test.rb +3 -3
- data/test/integration/blob/copy_blob_test.rb +4 -4
- data/test/integration/blob/create_blob_snapshot_test.rb +2 -2
- data/test/integration/blob/create_page_blob_test.rb +2 -2
- data/test/integration/blob/delete_blob_test.rb +4 -4
- data/test/integration/blob/get_blob_test.rb +7 -7
- data/test/integration/blob/informative_errors_test.rb +2 -2
- data/test/integration/blob/lease/acquire_lease_test.rb +1 -1
- data/test/integration/blob/lease/break_lease_test.rb +2 -2
- data/test/integration/blob/lease/release_lease_test.rb +2 -2
- data/test/integration/blob/lease/renew_lease_test.rb +2 -2
- data/test/integration/blob/list_blobs_test.rb +1 -1
- data/test/integration/database/delete_sql_server_firewall_test.rb +0 -1
- data/test/integration/database/delete_sql_server_test.rb +0 -1
- data/test/integration/location/Location_List_test.rb +0 -1
- data/test/integration/location/RoleSize_List_test.rb +0 -1
- data/test/integration/queue/clear_messages_test.rb +3 -3
- data/test/integration/queue/create_message_test.rb +5 -5
- data/test/integration/queue/create_queue_test.rb +1 -1
- data/test/integration/queue/delete_message_test.rb +4 -4
- data/test/integration/queue/delete_queue_test.rb +1 -1
- data/test/integration/queue/informative_errors_test.rb +2 -2
- data/test/integration/queue/list_messages_encoded_test.rb +2 -2
- data/test/integration/queue/list_messages_test.rb +3 -3
- data/test/integration/queue/list_queues_test.rb +1 -1
- data/test/integration/queue/peek_messages_test.rb +3 -3
- data/test/integration/queue/queue_metadata_test.rb +4 -4
- data/test/integration/queue/update_message_test.rb +4 -4
- data/test/integration/service_bus/informative_errors_test.rb +1 -1
- data/test/integration/service_bus/queues_test.rb +6 -6
- data/test/integration/service_bus/relay_test.rb +3 -3
- data/test/integration/service_bus/rules_test.rb +2 -2
- data/test/integration/service_bus/subscriptions_test.rb +4 -4
- data/test/integration/service_bus/topics_test.rb +2 -2
- data/test/integration/table/delete_entity_batch_test.rb +3 -3
- data/test/integration/table/delete_entity_test.rb +3 -3
- data/test/integration/table/delete_table_test.rb +1 -1
- data/test/integration/table/get_table_test.rb +4 -4
- data/test/integration/table/informative_errors_test.rb +2 -2
- data/test/integration/table/insert_entity_batch_test.rb +3 -3
- data/test/integration/table/insert_entity_test.rb +3 -3
- data/test/integration/table/insert_or_merge_entity_batch_test.rb +7 -7
- data/test/integration/table/insert_or_merge_entity_test.rb +8 -8
- data/test/integration/table/insert_or_replace_entity_batch_test.rb +7 -7
- data/test/integration/table/insert_or_replace_entity_test.rb +7 -7
- data/test/integration/table/merge_entity_batch_test.rb +1 -1
- data/test/integration/table/merge_entity_test.rb +1 -1
- data/test/integration/table/query_entities_test.rb +21 -21
- data/test/integration/table/query_tables_test.rb +2 -2
- data/test/integration/table/query_test.rb +21 -21
- data/test/integration/table/table_acl_test.rb +4 -4
- data/test/integration/table/update_entity_batch_test.rb +6 -6
- data/test/integration/table/update_entity_test.rb +8 -8
- data/test/unit/config/azure_test.rb +19 -0
- data/test/unit/core/auth/shared_key_lite_test.rb +3 -3
- data/test/unit/core/auth/shared_key_test.rb +2 -2
- data/test/unit/service/serialization_test.rb +44 -44
- metadata +4 -6
- data/.gitignore +0 -30
- data/.travis.yml +0 -13
- data/ChangeLog.txt +0 -56
- data/README.md +0 -702
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bda06759b70c920d48fe1272ce87ca645aaebd5
|
4
|
+
data.tar.gz: fafc97c79406bd2ff47b696e90fc025c8e0b9945
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af50fd89146d0af1b830bcb88a54cfa44e6f95349cbd39447ea9438604108425f379cff689b7609075221aca35bdb0a6df1d3f0418aa630080fdecd2d4202f92
|
7
|
+
data.tar.gz: 96a63eb8ee3b996079d62bcf7c030e8563ade20200a144705a9a1266a3710d2d40daf9316c67e215892c06f05dcd30322c7b52fc77807ddc55acde8fea463b17
|
data/azure.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.summary = 'Official ruby client library to consume Microsoft Azure services.'
|
26
26
|
s.homepage = 'http://github.com/azure/azure-sdk-for-ruby'
|
27
27
|
s.license = 'Apache License, Version 2.0'
|
28
|
-
s.files = `git ls-files`.split("\n")
|
28
|
+
s.files = `git ls-files`.split("\n").reject { |f| f.start_with?("lib/azure/arm") }
|
29
29
|
s.bindir = 'bin'
|
30
30
|
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
31
31
|
|
data/lib/azure.rb
CHANGED
@@ -106,6 +106,7 @@ module Azure
|
|
106
106
|
|
107
107
|
module VirtualMachineImageManagement
|
108
108
|
autoload :VirtualMachineImageManagementService, 'azure/virtual_machine_image_management/virtual_machine_image_management_service'
|
109
|
+
autoload :VirtualMachineDiskManagementService, 'azure/virtual_machine_image_management/virtual_machine_image_management_service'
|
109
110
|
autoload :Serialization, 'azure/virtual_machine_image_management/serialization'
|
110
111
|
autoload :VirtualMachineImage, 'azure/virtual_machine_image_management/virtual_machine_image'
|
111
112
|
autoload :VirtualMachineDisk, 'azure/virtual_machine_image_management/virtual_machine_disk'
|
data/lib/azure/blob/blob.rb
CHANGED
@@ -245,7 +245,7 @@ module Azure
|
|
245
245
|
# Accepted key/value pairs in options parameter are:
|
246
246
|
# * +:signed_identifiers+ - Array. A list of Azure::Entity::SignedIdentifier instances (optional)
|
247
247
|
# * +:timeout+ - Integer. A timeout in seconds.
|
248
|
-
#
|
248
|
+
#
|
249
249
|
# See http://msdn.microsoft.com/en-us/library/azure/dd179391.aspx
|
250
250
|
#
|
251
251
|
# Returns a tuple of (container, signed_identifiers)
|
@@ -472,7 +472,7 @@ module Azure
|
|
472
472
|
# * +:if_match+ - An ETag value. Specify an ETag value for this conditional header to write the page only if the blob's ETag value matches the value specified. If the values do not match, the Blob service returns status code 412 (Precondition Failed).
|
473
473
|
# * +:if_none_match+ - An ETag value. Specify an ETag value for this conditional header to write the page only if the blob's ETag value does not match the value specified. If the values are identical, the Blob service returns status code 412 (Precondition Failed).
|
474
474
|
# * +:timeout+ - Integer. A timeout in seconds.
|
475
|
-
#
|
475
|
+
#
|
476
476
|
# See http://msdn.microsoft.com/en-us/library/azure/ee691975.aspx
|
477
477
|
#
|
478
478
|
# Returns Blob
|
@@ -687,7 +687,7 @@ module Azure
|
|
687
687
|
# * +:metadata+ - Hash. Custom metadata values to store with the blob.
|
688
688
|
# * +:timeout+ - Integer. A timeout in seconds.
|
689
689
|
#
|
690
|
-
# See http://msdn.microsoft.com/en-us/library/azure/dd179467.aspx
|
690
|
+
# See http://msdn.microsoft.com/en-us/library/azure/dd179467.aspx
|
691
691
|
#
|
692
692
|
# Returns nil on success
|
693
693
|
def commit_blob_blocks(container, blob, block_list, options={})
|
@@ -719,8 +719,8 @@ module Azure
|
|
719
719
|
# There are two block lists maintained for a blob:
|
720
720
|
# 1) Committed Block List: The list of blocks that have been successfully
|
721
721
|
# committed to a given blob with commitBlobBlocks.
|
722
|
-
# 2) Uncommitted Block List: The list of blocks that have been uploaded for a
|
723
|
-
# blob using Put Block (REST API), but that have not yet been committed.
|
722
|
+
# 2) Uncommitted Block List: The list of blocks that have been uploaded for a
|
723
|
+
# blob using Put Block (REST API), but that have not yet been committed.
|
724
724
|
# These blocks are stored in Microsoft Azure in association with a blob, but do
|
725
725
|
# not yet form part of the blob.
|
726
726
|
#
|
@@ -1367,14 +1367,19 @@ module Azure
|
|
1367
1367
|
end
|
1368
1368
|
|
1369
1369
|
def call(method, uri, body=nil, headers=nil)
|
1370
|
-
#
|
1371
|
-
# (content encoding probably shouldn't be used this way)
|
1370
|
+
# Synchronize body and header encoding; header['Content-Encoding'] takes precedence.
|
1372
1371
|
if headers && !body.nil?
|
1373
1372
|
if headers['Content-Encoding'].nil?
|
1374
|
-
headers['Content-Encoding'] = body.encoding.to_s
|
1373
|
+
headers['Content-Encoding'] = body.encoding.to_s if body.respond_to? :encoding # String
|
1374
|
+
headers['Content-Encoding'] = body.external_encoding.to_s if body.respond_to? :external_encoding # IO
|
1375
1375
|
else
|
1376
|
-
body.force_encoding(headers['Content-Encoding'])
|
1376
|
+
body.force_encoding(headers['Content-Encoding']) if body.respond_to? :force_encoding # String
|
1377
|
+
body.set_encoding(headers['Content-Encoding']) if body.respond_to? :set_encoding # IO
|
1377
1378
|
end
|
1379
|
+
|
1380
|
+
# Azure Storage Service expects content-encoding to be lowercase.
|
1381
|
+
# Authentication will fail otherwise.
|
1382
|
+
headers['Content-Encoding'].downcase!
|
1378
1383
|
end
|
1379
1384
|
|
1380
1385
|
response = super
|
data/lib/azure/blob/block.rb
CHANGED
@@ -14,10 +14,10 @@
|
|
14
14
|
#--------------------------------------------------------------------------
|
15
15
|
module Azure
|
16
16
|
module Blob
|
17
|
-
# Represents a Block as part of a BlockList
|
17
|
+
# Represents a Block as part of a BlockList
|
18
18
|
# The type should be one of :uncommitted, :committed or :latest
|
19
19
|
class Block
|
20
|
-
|
20
|
+
|
21
21
|
def initialize
|
22
22
|
@type = :latest
|
23
23
|
yield self if block_given?
|
@@ -31,7 +31,7 @@ module Azure
|
|
31
31
|
expect_node("EnumerationResults", xml)
|
32
32
|
|
33
33
|
results = enumeration_results_from_xml(xml, Azure::Service::EnumerationResults.new)
|
34
|
-
|
34
|
+
|
35
35
|
return results unless (xml > "Containers").any? && ((xml > "Containers") > "Container").any?
|
36
36
|
|
37
37
|
if xml.Containers.Container.count == 0
|
@@ -82,7 +82,7 @@ module Azure
|
|
82
82
|
def self.container_properties_from_headers(headers)
|
83
83
|
props = {}
|
84
84
|
|
85
|
-
props[:last_modified] = headers["Last-Modified"]
|
85
|
+
props[:last_modified] = headers["Last-Modified"]
|
86
86
|
props[:etag] = headers["Etag"]
|
87
87
|
props[:lease_status] = headers["x-ms-lease-status"]
|
88
88
|
props[:lease_state] = headers["x-ms-lease-state"]
|
@@ -96,7 +96,7 @@ module Azure
|
|
96
96
|
end
|
97
97
|
|
98
98
|
def self.blob_enumeration_results_from_xml(xml)
|
99
|
-
|
99
|
+
|
100
100
|
xml = slopify(xml)
|
101
101
|
expect_node("EnumerationResults", xml)
|
102
102
|
|
@@ -116,7 +116,7 @@ module Azure
|
|
116
116
|
|
117
117
|
results
|
118
118
|
end
|
119
|
-
|
119
|
+
|
120
120
|
def self.blob_from_xml(xml)
|
121
121
|
xml = slopify(xml)
|
122
122
|
expect_node("Blob", xml)
|
@@ -178,7 +178,7 @@ module Azure
|
|
178
178
|
|
179
179
|
props[:content_length] = headers["x-ms-blob-content-length"] || headers["Content-Length"]
|
180
180
|
props[:content_length] = props[:content_length].to_i if props[:content_length]
|
181
|
-
|
181
|
+
|
182
182
|
props[:content_type] = headers["x-ms-blob-content-type"] || headers["Content-Type"]
|
183
183
|
props[:content_encoding] = headers["x-ms-blob-content-encoding"] || headers["Content-Encoding"]
|
184
184
|
props[:content_language] = headers["x-ms-blob-content-language"] || headers["Content-Language"]
|
@@ -261,7 +261,7 @@ module Azure
|
|
261
261
|
end
|
262
262
|
block_list[type].push block
|
263
263
|
end
|
264
|
-
|
264
|
+
|
265
265
|
def self.page_list_from_xml(xml)
|
266
266
|
xml = slopify(xml)
|
267
267
|
expect_node("PageList", xml)
|
data/lib/azure/configurable.rb
CHANGED
@@ -269,11 +269,19 @@ module Azure
|
|
269
269
|
def read_cert_from_file(cert_file_path)
|
270
270
|
if File.extname(cert_file_path).downcase == '.pem'
|
271
271
|
File.read(cert_file_path)
|
272
|
+
elsif File.extname(cert_file_path).downcase == '.publishsettings'
|
273
|
+
management_cert = parse_publishsettings(cert_file_path)['ManagementCertificate']
|
274
|
+
Base64.decode64(management_cert)
|
272
275
|
else
|
273
276
|
File.binread(cert_file_path)
|
274
277
|
end
|
275
278
|
end
|
276
279
|
|
280
|
+
def parse_publishsettings(pub_file_path)
|
281
|
+
pub_xml = Nokogiri::XML.parse(File.read(pub_file_path))
|
282
|
+
pub_xml.css('PublishData PublishProfile Subscription')[0]
|
283
|
+
end
|
284
|
+
|
277
285
|
def normalize_endpoint
|
278
286
|
if block_given?
|
279
287
|
File.join(yield, '')
|
@@ -20,7 +20,7 @@ module Azure
|
|
20
20
|
class FilteredService < Service
|
21
21
|
|
22
22
|
# Create a new instance of the FilteredService
|
23
|
-
#
|
23
|
+
#
|
24
24
|
# @param host [String] The hostname. (optional, Default empty)
|
25
25
|
# @param options [Hash] options including {:client} (optional, Default {})
|
26
26
|
def initialize(host='', options={})
|
@@ -16,14 +16,14 @@ require "azure/core/http/http_filter"
|
|
16
16
|
|
17
17
|
module Azure
|
18
18
|
module Core
|
19
|
-
module Http
|
19
|
+
module Http
|
20
20
|
# A HttpFilter implementation that displays information about the request and response for debugging
|
21
21
|
class DebugFilter < HttpFilter
|
22
22
|
def call(req, _next)
|
23
23
|
puts "--REQUEST-BEGIN---------------------------"
|
24
24
|
puts "method:", req.method, "uri:", req.uri, "headers:", req.headers, "body:", req.body
|
25
25
|
puts "--REQUEST-END---------------------------"
|
26
|
-
|
26
|
+
|
27
27
|
r = _next.call
|
28
28
|
puts "--RESPONSE-BEGIN---------------------------"
|
29
29
|
puts "status_code:", r.status_code, "headers:", r.headers, "body:", r.body
|
@@ -15,32 +15,32 @@
|
|
15
15
|
module Azure
|
16
16
|
module Core
|
17
17
|
module Http
|
18
|
-
# A filter which can modify the HTTP pipeline both before and
|
19
|
-
# after requests/responses. Multiple filters can be nested in a
|
18
|
+
# A filter which can modify the HTTP pipeline both before and
|
19
|
+
# after requests/responses. Multiple filters can be nested in a
|
20
20
|
# "Russian Doll" model to create a compound HTTP pipeline
|
21
21
|
class HttpFilter
|
22
|
-
|
23
|
-
# Initialize a HttpFilter
|
22
|
+
|
23
|
+
# Initialize a HttpFilter
|
24
|
+
#
|
25
|
+
# &block - An inline block which implements the filter.
|
26
|
+
#
|
27
|
+
# The inline block should take parameters |request, _next| where
|
28
|
+
# request is a HttpRequest and _next is an object that implements
|
29
|
+
# a method .call which returns an HttpResponse. The block passed
|
30
|
+
# to the constructor should also return HttpResponse, either as
|
31
|
+
# the result of calling _next.call or by customized logic.
|
24
32
|
#
|
25
|
-
# &block - An inline block which implements the filter.
|
26
|
-
#
|
27
|
-
# The inline block should take parameters |request, _next| where
|
28
|
-
# request is a HttpRequest and _next is an object that implements
|
29
|
-
# a method .call which returns an HttpResponse. The block passed
|
30
|
-
# to the constructor should also return HttpResponse, either as
|
31
|
-
# the result of calling _next.call or by customized logic.
|
32
|
-
#
|
33
33
|
def initialize(&block)
|
34
34
|
@block = block
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
# Executes the filter
|
38
38
|
#
|
39
39
|
# request - HttpRequest. The request
|
40
40
|
# _next - An object that implements .call (no params)
|
41
41
|
#
|
42
|
-
# NOTE: _next is a either a subsequent HttpFilter wrapped in a
|
43
|
-
# closure, or the HttpRequest object's call method. Either way,
|
42
|
+
# NOTE: _next is a either a subsequent HttpFilter wrapped in a
|
43
|
+
# closure, or the HttpRequest object's call method. Either way,
|
44
44
|
# it must have it's .call method executed within each filter to
|
45
45
|
# complete the pipeline. _next.call should return an HttpResponse
|
46
46
|
# and so should this Filter.
|
@@ -23,8 +23,8 @@ require 'azure/core/http/http_response'
|
|
23
23
|
module Azure
|
24
24
|
module Core
|
25
25
|
module Http
|
26
|
-
# Represents a HTTP request can perform synchronous queries to a
|
27
|
-
# HTTP server, returning a HttpResponse
|
26
|
+
# Represents a HTTP request can perform synchronous queries to a
|
27
|
+
# HTTP server, returning a HttpResponse
|
28
28
|
class HttpRequest
|
29
29
|
|
30
30
|
alias_method :_method, :method
|
@@ -70,15 +70,15 @@ module Azure
|
|
70
70
|
|
71
71
|
# Public: Applies a HttpFilter to the HTTP Pipeline
|
72
72
|
#
|
73
|
-
# filter - Any object that responds to .call(req, _next) and
|
74
|
-
# returns a HttpResponse eg. HttpFilter, Proc,
|
73
|
+
# filter - Any object that responds to .call(req, _next) and
|
74
|
+
# returns a HttpResponse eg. HttpFilter, Proc,
|
75
75
|
# lambda, etc. (optional)
|
76
76
|
#
|
77
77
|
# &block - An inline block may be used instead of a filter
|
78
78
|
#
|
79
79
|
# example:
|
80
80
|
#
|
81
|
-
# request.with_filter do |req, _next|
|
81
|
+
# request.with_filter do |req, _next|
|
82
82
|
# _next.call
|
83
83
|
# end
|
84
84
|
#
|
@@ -86,7 +86,7 @@ module Azure
|
|
86
86
|
#
|
87
87
|
# The code block provided must call _next or the filter pipeline
|
88
88
|
# will not complete and the HTTP request will never execute
|
89
|
-
#
|
89
|
+
#
|
90
90
|
def with_filter(filter=nil, &block)
|
91
91
|
filter = filter || block
|
92
92
|
if filter
|
@@ -17,21 +17,21 @@ require "azure/core/http/http_filter"
|
|
17
17
|
module Azure
|
18
18
|
module Core
|
19
19
|
module Http
|
20
|
-
|
21
|
-
# A HttpFilter implementation that handles retrying based on a
|
20
|
+
|
21
|
+
# A HttpFilter implementation that handles retrying based on a
|
22
22
|
# specific policy when HTTP layer errors occur
|
23
23
|
class RetryPolicy < HttpFilter
|
24
|
-
|
24
|
+
|
25
25
|
def initialize(&block)
|
26
26
|
@block = block
|
27
27
|
end
|
28
28
|
|
29
29
|
attr_accessor :retry_data
|
30
30
|
|
31
|
-
# Overrides the base class implementation of call to implement
|
32
|
-
# a retry loop that uses should_retry? to determine when to
|
31
|
+
# Overrides the base class implementation of call to implement
|
32
|
+
# a retry loop that uses should_retry? to determine when to
|
33
33
|
# break the loop
|
34
|
-
#
|
34
|
+
#
|
35
35
|
# req - HttpRequest. The HTTP request
|
36
36
|
# _next - HttpFilter. The next filter in the pipeline
|
37
37
|
def call(req, _next)
|
@@ -50,18 +50,18 @@ module Azure
|
|
50
50
|
end
|
51
51
|
|
52
52
|
# Determines if the HTTP request should continue retrying
|
53
|
-
#
|
53
|
+
#
|
54
54
|
# response - HttpResponse. The response from the active request
|
55
55
|
# retry_data - Hash. Stores stateful retry data
|
56
56
|
#
|
57
|
-
# The retry_data is a Hash which can be used to store
|
58
|
-
# stateful data about the request execution context (such as an
|
59
|
-
# incrementing counter, timestamp, etc). The retry_data object
|
57
|
+
# The retry_data is a Hash which can be used to store
|
58
|
+
# stateful data about the request execution context (such as an
|
59
|
+
# incrementing counter, timestamp, etc). The retry_data object
|
60
60
|
# will be the same instance throughout the lifetime of the request.
|
61
61
|
#
|
62
|
-
# If an inline block was passed to the constructor, that block
|
62
|
+
# If an inline block was passed to the constructor, that block
|
63
63
|
# will be used here and should return true to retry the job, or
|
64
|
-
# false to stop exit. If an inline block was not passed to the
|
64
|
+
# false to stop exit. If an inline block was not passed to the
|
65
65
|
# constructor the method returns false.
|
66
66
|
#
|
67
67
|
# Alternatively, a subclass could override this method.
|
@@ -16,7 +16,7 @@ require 'azure/core/http/http_filter'
|
|
16
16
|
|
17
17
|
module Azure
|
18
18
|
module Core
|
19
|
-
module Http
|
19
|
+
module Http
|
20
20
|
# A HttpFilter implementation that creates a authorization signature which is added to the request headers
|
21
21
|
class SignerFilter < HttpFilter
|
22
22
|
def initialize(signer)
|
data/lib/azure/core/service.rb
CHANGED
@@ -20,7 +20,7 @@ module Azure
|
|
20
20
|
class Service
|
21
21
|
|
22
22
|
# Create a new instance of the Service
|
23
|
-
#
|
23
|
+
#
|
24
24
|
# @param host [String] The hostname. (optional, Default empty)
|
25
25
|
# @param options [Hash] options including {:client} (optional, Default {})
|
26
26
|
def initialize(host='', options = {})
|
@@ -33,34 +33,34 @@ module Azure
|
|
33
33
|
# ==== Options
|
34
34
|
#
|
35
35
|
# Accepted key/value pairs in options parameter are:
|
36
|
-
# * +:prefix+ - String. Filters the results to return only containers
|
36
|
+
# * +:prefix+ - String. Filters the results to return only containers
|
37
37
|
# whose name begins with the specified prefix. (optional)
|
38
|
-
# * +:marker+ - String. An identifier the specifies the portion of the
|
38
|
+
# * +:marker+ - String. An identifier the specifies the portion of the
|
39
39
|
# list to be returned. This value comes from the property
|
40
|
-
# Azure::Service::EnumerationResults.continuation_token when there
|
41
|
-
# are more containers available than were returned. The
|
40
|
+
# Azure::Service::EnumerationResults.continuation_token when there
|
41
|
+
# are more containers available than were returned. The
|
42
42
|
# marker value may then be used here to request the next set
|
43
43
|
# of list items. (optional)
|
44
|
-
# * +:max_results+ - Integer. Specifies the maximum number of containers to return.
|
45
|
-
# If max_results is not specified, or is a value greater than
|
46
|
-
# 5,000, the server will return up to 5,000 items. If it is set
|
47
|
-
# to a value less than or equal to zero, the server will return
|
44
|
+
# * +:max_results+ - Integer. Specifies the maximum number of containers to return.
|
45
|
+
# If max_results is not specified, or is a value greater than
|
46
|
+
# 5,000, the server will return up to 5,000 items. If it is set
|
47
|
+
# to a value less than or equal to zero, the server will return
|
48
48
|
# status code 400 (Bad Request). (optional)
|
49
49
|
# * +:metadata+ - Boolean. Specifies whether or not to return the container metadata.
|
50
50
|
# (optional, Default=false)
|
51
51
|
# * +:timeout+ - Integer. A timeout in seconds.
|
52
52
|
#
|
53
53
|
# NOTE: Metadata requested with the :metadata parameter must have been stored in
|
54
|
-
# accordance with the naming restrictions imposed by the 2009-09-19 version of the queue
|
55
|
-
# service. Beginning with that version, all metadata names must adhere to the naming
|
54
|
+
# accordance with the naming restrictions imposed by the 2009-09-19 version of the queue
|
55
|
+
# service. Beginning with that version, all metadata names must adhere to the naming
|
56
56
|
# conventions for C# identifiers.
|
57
57
|
#
|
58
|
-
# See http://msdn.microsoft.com/en-us/library/azure/dd179466
|
58
|
+
# See http://msdn.microsoft.com/en-us/library/azure/dd179466
|
59
59
|
#
|
60
|
-
# Any metadata with invalid names which were previously stored, will be returned with the
|
60
|
+
# Any metadata with invalid names which were previously stored, will be returned with the
|
61
61
|
# key "x-ms-invalid-name" in the metadata hash. This may contain multiple values and be an
|
62
62
|
# Array (vs a String if it only contains a single value).
|
63
|
-
#
|
63
|
+
#
|
64
64
|
# Returns an Azure::Service::EnumerationResults
|
65
65
|
def list_queues(options={})
|
66
66
|
query = { }
|
@@ -77,14 +77,14 @@ module Azure
|
|
77
77
|
end
|
78
78
|
|
79
79
|
# Public: Clears all messages from the queue.
|
80
|
-
#
|
81
|
-
# If a queue contains a large number of messages, Clear Messages may time out
|
82
|
-
# before all messages have been deleted. In this case the Queue service will
|
83
|
-
# return status code 500 (Internal Server Error), with the additional error
|
84
|
-
# code OperationTimedOut. If the operation times out, the client should
|
85
|
-
# continue to retry Clear Messages until it succeeds, to ensure that all
|
80
|
+
#
|
81
|
+
# If a queue contains a large number of messages, Clear Messages may time out
|
82
|
+
# before all messages have been deleted. In this case the Queue service will
|
83
|
+
# return status code 500 (Internal Server Error), with the additional error
|
84
|
+
# code OperationTimedOut. If the operation times out, the client should
|
85
|
+
# continue to retry Clear Messages until it succeeds, to ensure that all
|
86
86
|
# messages have been deleted.
|
87
|
-
#
|
87
|
+
#
|
88
88
|
# ==== Attributes
|
89
89
|
#
|
90
90
|
# * +queue_name+ - String. The name of the queue.
|
@@ -94,9 +94,9 @@ module Azure
|
|
94
94
|
#
|
95
95
|
# Accepted key/value pairs in options parameter are:
|
96
96
|
# * +:timeout+ - Integer. A timeout in seconds.
|
97
|
-
#
|
97
|
+
#
|
98
98
|
# See http://msdn.microsoft.com/en-us/library/azure/dd179454
|
99
|
-
#
|
99
|
+
#
|
100
100
|
# Returns nil on success
|
101
101
|
def clear_messages(queue_name, options={})
|
102
102
|
query = { }
|
@@ -105,13 +105,13 @@ module Azure
|
|
105
105
|
call(:delete, uri)
|
106
106
|
nil
|
107
107
|
end
|
108
|
-
|
108
|
+
|
109
109
|
# Public: Creates a new queue under the storage account.
|
110
|
-
#
|
110
|
+
#
|
111
111
|
# ==== Attributes
|
112
112
|
#
|
113
113
|
# * +queue_name+ - String. The queue name.
|
114
|
-
# * +options+ - Hash. Optional parameters.
|
114
|
+
# * +options+ - Hash. Optional parameters.
|
115
115
|
#
|
116
116
|
# ==== Options
|
117
117
|
#
|
@@ -136,11 +136,11 @@ module Azure
|
|
136
136
|
end
|
137
137
|
|
138
138
|
# Public: Deletes a queue.
|
139
|
-
#
|
139
|
+
#
|
140
140
|
# ==== Attributes
|
141
141
|
#
|
142
142
|
# * +queue_name+ - String. The queue name.
|
143
|
-
# * +options+ - Hash. Optional parameters.
|
143
|
+
# * +options+ - Hash. Optional parameters.
|
144
144
|
#
|
145
145
|
# ==== Options
|
146
146
|
#
|
@@ -161,11 +161,11 @@ module Azure
|
|
161
161
|
end
|
162
162
|
|
163
163
|
# Public: Returns queue properties, including user-defined metadata.
|
164
|
-
#
|
164
|
+
#
|
165
165
|
# ==== Attributes
|
166
166
|
#
|
167
167
|
# * +queue_name+ - String. The queue name.
|
168
|
-
# * +options+ - Hash. Optional parameters.
|
168
|
+
# * +options+ - Hash. Optional parameters.
|
169
169
|
#
|
170
170
|
# ==== Options
|
171
171
|
#
|
@@ -193,14 +193,14 @@ module Azure
|
|
193
193
|
return approximate_messages_count.to_i, metadata
|
194
194
|
end
|
195
195
|
|
196
|
-
# Public: Sets user-defined metadata on the queue. To delete queue metadata, call
|
196
|
+
# Public: Sets user-defined metadata on the queue. To delete queue metadata, call
|
197
197
|
# this API with an empty hash in the metadata parameter.
|
198
|
-
#
|
198
|
+
#
|
199
199
|
# ==== Attributes
|
200
200
|
#
|
201
201
|
# * +queue_name+ - String. The queue name.
|
202
202
|
# * +metadata+ - Hash. A hash of user defined metadata
|
203
|
-
# * +options+ - Hash. Optional parameters.
|
203
|
+
# * +options+ - Hash. Optional parameters.
|
204
204
|
#
|
205
205
|
# ==== Options
|
206
206
|
#
|
@@ -228,7 +228,7 @@ module Azure
|
|
228
228
|
# ==== Attributes
|
229
229
|
#
|
230
230
|
# * +queue_name+ - String. The queue name.
|
231
|
-
# * +options+ - Hash. Optional parameters.
|
231
|
+
# * +options+ - Hash. Optional parameters.
|
232
232
|
#
|
233
233
|
# ==== Options
|
234
234
|
#
|
@@ -254,14 +254,14 @@ module Azure
|
|
254
254
|
# ==== Attributes
|
255
255
|
#
|
256
256
|
# * +queue_name+ - String. The queue name.
|
257
|
-
# * +options+ - Hash. Optional parameters.
|
257
|
+
# * +options+ - Hash. Optional parameters.
|
258
258
|
#
|
259
259
|
# ==== Options
|
260
260
|
#
|
261
261
|
# Accepted key/value pairs in options parameter are:
|
262
|
-
# * +:signed_identifiers+ - Array. A list of Azure::Entity::SignedIdentifier instances
|
262
|
+
# * +:signed_identifiers+ - Array. A list of Azure::Entity::SignedIdentifier instances
|
263
263
|
# * +:timeout+ - Integer. A timeout in seconds.
|
264
|
-
#
|
264
|
+
#
|
265
265
|
# See http://msdn.microsoft.com/en-us/library/azure/jj159099
|
266
266
|
#
|
267
267
|
# Returns nil on success
|
@@ -278,22 +278,22 @@ module Azure
|
|
278
278
|
end
|
279
279
|
|
280
280
|
# Public: Adds a message to the queue and optionally sets a visibility timeout for the message.
|
281
|
-
#
|
281
|
+
#
|
282
282
|
# ==== Attributes
|
283
283
|
#
|
284
284
|
# * +queue_name+ - String. The queue name.
|
285
285
|
# * +message_text+ - String. The message contents. Note that the message content must be in a format that may be encoded with UTF-8.
|
286
|
-
# * +options+ - Hash. Optional parameters.
|
286
|
+
# * +options+ - Hash. Optional parameters.
|
287
287
|
#
|
288
288
|
# ==== Options
|
289
289
|
#
|
290
290
|
# Accepted key/value pairs in options parameter are:
|
291
|
-
# * +:visibility_timeout+ - Integer. Specifies the new visibility timeout value, in seconds, relative to server
|
292
|
-
# time. The new value must be larger than or equal to 0, and cannot be larger than 7
|
293
|
-
# days. The visibility timeout of a message cannot be set to a value later than the
|
294
|
-
# expiry time. :visibility_timeout should be set to a value smaller than the
|
291
|
+
# * +:visibility_timeout+ - Integer. Specifies the new visibility timeout value, in seconds, relative to server
|
292
|
+
# time. The new value must be larger than or equal to 0, and cannot be larger than 7
|
293
|
+
# days. The visibility timeout of a message cannot be set to a value later than the
|
294
|
+
# expiry time. :visibility_timeout should be set to a value smaller than the
|
295
295
|
# time-to-live value. If not specified, the default value is 0.
|
296
|
-
# * +:message_ttl+ - Integer. Specifies the time-to-live interval for the message, in seconds. The maximum
|
296
|
+
# * +:message_ttl+ - Integer. Specifies the time-to-live interval for the message, in seconds. The maximum
|
297
297
|
# time-to-live allowed is 7 days. If not specified, the default time-to-live is 7 days.
|
298
298
|
# * +:encode+ - Boolean. If set to true, the message will be base64 encoded.
|
299
299
|
# * +:timeout+ - Integer. A timeout in seconds.
|
@@ -318,59 +318,59 @@ module Azure
|
|
318
318
|
end
|
319
319
|
|
320
320
|
# Public: Deletes a specified message from the queue.
|
321
|
-
#
|
321
|
+
#
|
322
322
|
# ==== Attributes
|
323
323
|
#
|
324
324
|
# * +queue_name+ - String. The queue name.
|
325
325
|
# * +message_id+ - String. The id of the message.
|
326
|
-
# * +pop_receipt+ - String. The valid pop receipt value returned from an earlier call to the Get Messages or
|
326
|
+
# * +pop_receipt+ - String. The valid pop receipt value returned from an earlier call to the Get Messages or
|
327
327
|
# Update Message operation.
|
328
|
-
# * +options+ - Hash. Optional parameters.
|
328
|
+
# * +options+ - Hash. Optional parameters.
|
329
329
|
#
|
330
330
|
# ==== Options
|
331
331
|
#
|
332
332
|
# Accepted key/value pairs in options parameter are:
|
333
333
|
# * +:timeout+ - Integer. A timeout in seconds.
|
334
|
-
#
|
334
|
+
#
|
335
335
|
# See http://msdn.microsoft.com/en-us/library/azure/dd179347
|
336
336
|
#
|
337
337
|
# Returns nil on success
|
338
338
|
#
|
339
339
|
# Remarks:
|
340
340
|
#
|
341
|
-
# When a message is successfully deleted, it is immediately marked for deletion and is no longer accessible to
|
341
|
+
# When a message is successfully deleted, it is immediately marked for deletion and is no longer accessible to
|
342
342
|
# clients. The message is later removed from the queue during garbage collection.
|
343
|
-
#
|
344
|
-
# After a client retrieves a message with the Get Messages operation, the client is expected to process and
|
345
|
-
# delete the message. To delete the message, you must have two items of data returned in the response body of
|
343
|
+
#
|
344
|
+
# After a client retrieves a message with the Get Messages operation, the client is expected to process and
|
345
|
+
# delete the message. To delete the message, you must have two items of data returned in the response body of
|
346
346
|
# the Get Messages operation:
|
347
|
-
#
|
347
|
+
#
|
348
348
|
# * The message ID, an opaque GUID value that identifies the message in the queue.
|
349
|
-
#
|
349
|
+
#
|
350
350
|
# * A valid pop receipt, an opaque value that indicates that the message has been retrieved.
|
351
|
-
#
|
352
|
-
# The message ID is returned from the previous Get Messages operation. The pop receipt is returned from the most
|
353
|
-
# recent Get Messages or Update Message operation. In order for the Delete Message operation to succeed, the pop
|
354
|
-
# receipt specified on the request must match the pop receipt returned from the Get Messages or Update Message
|
351
|
+
#
|
352
|
+
# The message ID is returned from the previous Get Messages operation. The pop receipt is returned from the most
|
353
|
+
# recent Get Messages or Update Message operation. In order for the Delete Message operation to succeed, the pop
|
354
|
+
# receipt specified on the request must match the pop receipt returned from the Get Messages or Update Message
|
355
355
|
# operation.
|
356
|
-
#
|
356
|
+
#
|
357
357
|
# Pop receipts remain valid until one of the following events occurs:
|
358
358
|
#
|
359
359
|
# * The message has expired.
|
360
360
|
#
|
361
|
-
# * The message has been deleted using the last pop receipt received either from Get Messages or Update Message.
|
362
|
-
#
|
363
|
-
# * The invisibility time has elapsed and the message has been dequeued by a Get Messages request. When the
|
364
|
-
# invisibility time elapses, the message becomes visible again. If it is retrieved by another Get Messages
|
361
|
+
# * The message has been deleted using the last pop receipt received either from Get Messages or Update Message.
|
362
|
+
#
|
363
|
+
# * The invisibility time has elapsed and the message has been dequeued by a Get Messages request. When the
|
364
|
+
# invisibility time elapses, the message becomes visible again. If it is retrieved by another Get Messages
|
365
365
|
# request, the returned pop receipt can be used to delete or update the message.
|
366
|
-
#
|
367
|
-
# * The message has been updated with a new visibility timeout. When the message is updated, a new pop receipt
|
366
|
+
#
|
367
|
+
# * The message has been updated with a new visibility timeout. When the message is updated, a new pop receipt
|
368
368
|
# will be returned.
|
369
|
-
#
|
370
|
-
# If the message has already been deleted when Delete Message is called, the Queue service returns status code
|
369
|
+
#
|
370
|
+
# If the message has already been deleted when Delete Message is called, the Queue service returns status code
|
371
371
|
# 404 (Not Found).
|
372
|
-
#
|
373
|
-
# If a message with a matching pop receipt is not found, the service returns status code 400 (Bad Request), with
|
372
|
+
#
|
373
|
+
# If a message with a matching pop receipt is not found, the service returns status code 400 (Bad Request), with
|
374
374
|
# additional error information indicating that the cause of the failure was a mismatched pop receipt.
|
375
375
|
#
|
376
376
|
def delete_message(queue_name, message_id, pop_receipt, options={})
|
@@ -388,7 +388,7 @@ module Azure
|
|
388
388
|
# ==== Attributes
|
389
389
|
#
|
390
390
|
# * +queue_name+ - String. The queue name.
|
391
|
-
# * +options+ - Hash. Optional parameters.
|
391
|
+
# * +options+ - Hash. Optional parameters.
|
392
392
|
#
|
393
393
|
# ==== Options
|
394
394
|
#
|
@@ -420,7 +420,7 @@ module Azure
|
|
420
420
|
#
|
421
421
|
# * +queue_name+ - String. The queue name.
|
422
422
|
# * +visibility_timeout+ - Integer. The new visibility timeout value, in seconds, relative to server time.
|
423
|
-
# * +options+ - Hash. Optional parameters.
|
423
|
+
# * +options+ - Hash. Optional parameters.
|
424
424
|
#
|
425
425
|
# ==== Options
|
426
426
|
#
|
@@ -447,17 +447,17 @@ module Azure
|
|
447
447
|
end
|
448
448
|
|
449
449
|
# Public: Adds a message to the queue and optionally sets a visibility timeout for the message.
|
450
|
-
#
|
450
|
+
#
|
451
451
|
# ==== Attributes
|
452
452
|
#
|
453
453
|
# * +queue_name+ - String. The queue name.
|
454
454
|
# * +message_id+ - String. The id of the message.
|
455
|
-
# * +pop_receipt+ - String. The valid pop receipt value returned from an earlier call to the Get Messages or
|
455
|
+
# * +pop_receipt+ - String. The valid pop receipt value returned from an earlier call to the Get Messages or
|
456
456
|
# update Message operation.
|
457
|
-
# * +message_text+ - String. The message contents. Note that the message content must be in a format that may
|
457
|
+
# * +message_text+ - String. The message contents. Note that the message content must be in a format that may
|
458
458
|
# be encoded with UTF-8.
|
459
459
|
# * +visibility_timeout+ - Integer. The new visibility timeout value, in seconds, relative to server time.
|
460
|
-
# * +options+ - Hash. Optional parameters.
|
460
|
+
# * +options+ - Hash. Optional parameters.
|
461
461
|
#
|
462
462
|
# ==== Options
|
463
463
|
#
|
@@ -473,28 +473,28 @@ module Azure
|
|
473
473
|
#
|
474
474
|
# Remarks:
|
475
475
|
#
|
476
|
-
# An Update Message operation will fail if the specified message does not exist in the queue, or if the
|
476
|
+
# An Update Message operation will fail if the specified message does not exist in the queue, or if the
|
477
477
|
# specified pop receipt does not match the message.
|
478
|
-
#
|
479
|
-
# A pop receipt is returned by the Get Messages operation or the Update Message operation. Pop receipts
|
478
|
+
#
|
479
|
+
# A pop receipt is returned by the Get Messages operation or the Update Message operation. Pop receipts
|
480
480
|
# remain valid until one of the following events occurs:
|
481
|
-
#
|
481
|
+
#
|
482
482
|
# * The message has expired.
|
483
|
-
#
|
484
|
-
# * The message has been deleted using the last pop receipt received either from Get Messages or
|
485
|
-
# Update Message.
|
486
|
-
#
|
487
|
-
# * The invisibility time has elapsed and the message has been dequeued by a Get Messages request. When
|
488
|
-
# the invisibility time elapses, the message becomes visible again. If it is retrieved by another
|
483
|
+
#
|
484
|
+
# * The message has been deleted using the last pop receipt received either from Get Messages or
|
485
|
+
# Update Message.
|
486
|
+
#
|
487
|
+
# * The invisibility time has elapsed and the message has been dequeued by a Get Messages request. When
|
488
|
+
# the invisibility time elapses, the message becomes visible again. If it is retrieved by another
|
489
489
|
# Get Messages request, the returned pop receipt can be used to delete or update the message.
|
490
|
-
#
|
491
|
-
# * The message has been updated with a new visibility timeout. When the message is updated, a new pop
|
490
|
+
#
|
491
|
+
# * The message has been updated with a new visibility timeout. When the message is updated, a new pop
|
492
492
|
# receipt will be returned.
|
493
|
-
#
|
494
|
-
# The Update Message operation can be used to continually extend the invisibility of a queue message. This
|
495
|
-
# functionality can be useful if you want a worker role to "lease" a queue message. For example, if a worker
|
496
|
-
# role calls Get Messages and recognizes that it needs more time to process a message, it can continually
|
497
|
-
# extend the message's invisibility until it is processed. If the worker role were to fail during processing,
|
493
|
+
#
|
494
|
+
# The Update Message operation can be used to continually extend the invisibility of a queue message. This
|
495
|
+
# functionality can be useful if you want a worker role to "lease" a queue message. For example, if a worker
|
496
|
+
# role calls Get Messages and recognizes that it needs more time to process a message, it can continually
|
497
|
+
# extend the message's invisibility until it is processed. If the worker role were to fail during processing,
|
498
498
|
# eventually the message would become visible again and another worker role could process it.
|
499
499
|
#
|
500
500
|
def update_message(queue_name, message_id, pop_receipt, message_text, visibility_timeout, options={})
|