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
|
#
|
@@ -25,22 +27,22 @@
|
|
25
27
|
module Azure
|
26
28
|
module Storage
|
27
29
|
module Core
|
28
|
-
autoload :HttpClient,
|
29
|
-
autoload :Utility,
|
30
|
-
autoload :Logger,
|
31
|
-
autoload :Error,
|
32
|
-
|
30
|
+
autoload :HttpClient, "azure/storage/core/http_client"
|
31
|
+
autoload :Utility, "azure/storage/core/utility"
|
32
|
+
autoload :Logger, "azure/storage/core/utility"
|
33
|
+
autoload :Error, "azure/storage/core/error"
|
34
|
+
|
33
35
|
module Auth
|
34
|
-
autoload :SharedKey,
|
35
|
-
autoload :SharedAccessSignature,
|
36
|
-
autoload :SharedAccessSignatureSigner,
|
36
|
+
autoload :SharedKey, "azure/storage/core/auth/shared_key.rb"
|
37
|
+
autoload :SharedAccessSignature, "azure/storage/core/auth/shared_access_signature_generator.rb"
|
38
|
+
autoload :SharedAccessSignatureSigner, "azure/storage/core/auth/shared_access_signature_signer.rb"
|
37
39
|
end
|
38
|
-
|
40
|
+
|
39
41
|
module Filter
|
40
|
-
autoload :RetryPolicyFilter,
|
41
|
-
autoload :LinearRetryPolicyFilter,
|
42
|
-
autoload :ExponentialRetryPolicyFilter,
|
42
|
+
autoload :RetryPolicyFilter, "azure/storage/core/filter/retry_filter"
|
43
|
+
autoload :LinearRetryPolicyFilter, "azure/storage/core/filter/linear_retry_filter"
|
44
|
+
autoload :ExponentialRetryPolicyFilter, "azure/storage/core/filter/exponential_retry_filter"
|
43
45
|
end
|
44
46
|
end
|
45
47
|
end
|
46
|
-
end
|
48
|
+
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,7 +23,7 @@
|
|
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/core"
|
25
27
|
|
26
28
|
module Azure::Storage::Core
|
27
29
|
# Superclass for errors generated from this library, so people can
|
@@ -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,27 +23,27 @@
|
|
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
|
25
|
-
require
|
26
|
+
require "azure/core"
|
27
|
+
require "azure/core/http/retry_policy"
|
26
28
|
|
27
29
|
module Azure::Storage::Core::Filter
|
28
30
|
class ExponentialRetryPolicyFilter < RetryPolicyFilter
|
29
|
-
def initialize(retry_count=nil, min_retry_interval=nil, max_retry_interval=nil)
|
31
|
+
def initialize(retry_count = nil, min_retry_interval = nil, max_retry_interval = nil)
|
30
32
|
@retry_count = retry_count || ExponentialRetryPolicyFilter::DEFAULT_RETRY_COUNT
|
31
33
|
@min_retry_interval = min_retry_interval || ExponentialRetryPolicyFilter::DEFAULT_MIN_RETRY_INTERVAL
|
32
34
|
@max_retry_interval = max_retry_interval || ExponentialRetryPolicyFilter::DEFAULT_MAX_RETRY_INTERVAL
|
33
|
-
|
35
|
+
|
34
36
|
super @retry_count, @min_retry_interval
|
35
37
|
end
|
36
|
-
|
38
|
+
|
37
39
|
attr_reader :min_retry_interval,
|
38
40
|
:max_retry_interval
|
39
|
-
|
41
|
+
|
40
42
|
DEFAULT_RETRY_COUNT = 3
|
41
43
|
DEFAULT_MIN_RETRY_INTERVAL = 10
|
42
44
|
DEFAULT_MAX_RETRY_INTERVAL = 90
|
43
|
-
|
44
|
-
# Overrides the base class implementation of call to determine
|
45
|
+
|
46
|
+
# Overrides the base class implementation of call to determine
|
45
47
|
# how the HTTP request should continue retrying
|
46
48
|
#
|
47
49
|
# retry_data - Hash. Stores stateful retry data
|
@@ -53,10 +55,10 @@ module Azure::Storage::Core::Filter
|
|
53
55
|
def apply_retry_policy(retry_data)
|
54
56
|
# Adjust retry count
|
55
57
|
retry_data[:count] = retry_data[:count] === nil ? 1 : retry_data[:count] + 1
|
56
|
-
|
58
|
+
|
57
59
|
# Adjust retry interval
|
58
|
-
increment_delta = (@max_retry_interval - @min_retry_interval).fdiv(2
|
60
|
+
increment_delta = (@max_retry_interval - @min_retry_interval).fdiv(2**(@retry_count - 1)) * (2**(retry_data[:count] - 1));
|
59
61
|
retry_data[:interval] = retry_data[:interval] === nil ? @min_retry_interval : [@min_retry_interval + increment_delta, @max_retry_interval].min;
|
60
62
|
end
|
61
63
|
end
|
62
|
-
end
|
64
|
+
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,22 +23,22 @@
|
|
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
|
25
|
-
require
|
26
|
+
require "azure/core"
|
27
|
+
require "azure/core/http/retry_policy"
|
26
28
|
|
27
29
|
module Azure::Storage::Core::Filter
|
28
30
|
class LinearRetryPolicyFilter < RetryPolicyFilter
|
29
|
-
def initialize(retry_count=nil, retry_interval=nil)
|
31
|
+
def initialize(retry_count = nil, retry_interval = nil)
|
30
32
|
@retry_count = retry_count || LinearRetryPolicyFilter::DEFAULT_RETRY_COUNT
|
31
33
|
@retry_interval = retry_interval || LinearRetryPolicyFilter::DEFAULT_RETRY_INTERVAL
|
32
|
-
|
34
|
+
|
33
35
|
super @retry_count, @retry_interval
|
34
36
|
end
|
35
|
-
|
37
|
+
|
36
38
|
DEFAULT_RETRY_COUNT = 3
|
37
39
|
DEFAULT_RETRY_INTERVAL = 30
|
38
|
-
|
39
|
-
# Overrides the base class implementation of call to determine
|
40
|
+
|
41
|
+
# Overrides the base class implementation of call to determine
|
40
42
|
# how the HTTP request should continue retrying
|
41
43
|
#
|
42
44
|
# retry_data - Hash. Stores stateful retry data
|
@@ -50,4 +52,4 @@ module Azure::Storage::Core::Filter
|
|
50
52
|
retry_data[:interval] = @retry_interval
|
51
53
|
end
|
52
54
|
end
|
53
|
-
end
|
55
|
+
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,22 +23,22 @@
|
|
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
|
25
|
-
require
|
26
|
+
require "azure/core"
|
27
|
+
require "azure/core/http/retry_policy"
|
26
28
|
|
27
29
|
module Azure::Storage::Core::Filter
|
28
30
|
class RetryPolicyFilter < Azure::Core::Http::RetryPolicy
|
29
|
-
def initialize(retry_count=nil, retry_interval=nil)
|
31
|
+
def initialize(retry_count = nil, retry_interval = nil)
|
30
32
|
@retry_count = retry_count
|
31
33
|
@retry_interval = retry_interval
|
32
|
-
|
34
|
+
|
33
35
|
super &:should_retry?
|
34
36
|
end
|
35
|
-
|
37
|
+
|
36
38
|
attr_reader :retry_count,
|
37
39
|
:retry_interval
|
38
|
-
|
39
|
-
# Overrides the base class implementation of call to determine
|
40
|
+
|
41
|
+
# Overrides the base class implementation of call to determine
|
40
42
|
# whether to retry the operation
|
41
43
|
#
|
42
44
|
# response - HttpResponse. The response from the active request
|
@@ -57,10 +59,10 @@ module Azure::Storage::Core::Filter
|
|
57
59
|
# Cannot retry immediately when it returns true, as it need check other errors
|
58
60
|
should_retry_on_local_error? retry_data
|
59
61
|
return false unless should_retry_on_error? response, retry_data
|
60
|
-
|
62
|
+
|
61
63
|
adjust_retry_parameter retry_data
|
62
64
|
end
|
63
|
-
|
65
|
+
|
64
66
|
# Apply the retry policy to determine how the HTTP request should continue retrying
|
65
67
|
#
|
66
68
|
# retry_data - Hash. Stores stateful retry data
|
@@ -73,7 +75,7 @@ module Azure::Storage::Core::Filter
|
|
73
75
|
# Alternatively, a subclass could override this method.
|
74
76
|
def apply_retry_policy(retry_data)
|
75
77
|
end
|
76
|
-
|
78
|
+
|
77
79
|
# Determines if the HTTP request should continue retrying
|
78
80
|
#
|
79
81
|
# retry_data - Hash. Stores stateful retry data
|
@@ -89,30 +91,30 @@ module Azure::Storage::Core::Filter
|
|
89
91
|
end
|
90
92
|
|
91
93
|
error_message = retry_data[:error].inspect
|
92
|
-
|
93
|
-
if error_message.include?(
|
94
|
+
|
95
|
+
if error_message.include?("SocketError: Hostname not known")
|
94
96
|
# Retry on local DNS resolving
|
95
|
-
# When uses resolv-replace.rb to replace the libc resolver
|
96
|
-
# Reference:
|
97
|
-
# https://makandracards.com/ninjaconcept/30815-fixing-socketerror-getaddrinfo-name-or-service-not-known-with-ruby-s-resolv-replace-rb
|
98
|
-
# http://www.subelsky.com/2014/05/fixing-socketerror-getaddrinfo-name-or.html
|
97
|
+
# When uses resolv-replace.rb to replace the libc resolver
|
98
|
+
# Reference:
|
99
|
+
# https://makandracards.com/ninjaconcept/30815-fixing-socketerror-getaddrinfo-name-or-service-not-known-with-ruby-s-resolv-replace-rb
|
100
|
+
# http://www.subelsky.com/2014/05/fixing-socketerror-getaddrinfo-name-or.html
|
99
101
|
retry_data[:retryable] = true;
|
100
|
-
elsif error_message.include?(
|
101
|
-
# When uses the default resolver
|
102
|
+
elsif error_message.include?("getaddrinfo: Name or service not known")
|
103
|
+
# When uses the default resolver
|
102
104
|
retry_data[:retryable] = true;
|
103
|
-
elsif error_message.downcase.include?(
|
105
|
+
elsif error_message.downcase.include?("timeout")
|
104
106
|
retry_data[:retryable] = true;
|
105
|
-
elsif error_message.include?(
|
107
|
+
elsif error_message.include?("Errno::ECONNRESET")
|
106
108
|
retry_data[:retryable] = true;
|
107
|
-
elsif error_message.include?(
|
109
|
+
elsif error_message.include?("Errno::EACCES")
|
108
110
|
retry_data[:retryable] = false;
|
109
|
-
elsif error_message.include?(
|
111
|
+
elsif error_message.include?("NOSUPPORT")
|
110
112
|
retry_data[:retryable] = false;
|
111
113
|
end
|
112
|
-
|
114
|
+
|
113
115
|
retry_data[:retryable]
|
114
116
|
end
|
115
|
-
|
117
|
+
|
116
118
|
# Determines if the HTTP request should continue retrying
|
117
119
|
#
|
118
120
|
# response - Azure::Core::Http::HttpResponse. The response from the active request
|
@@ -123,7 +125,7 @@ module Azure::Storage::Core::Filter
|
|
123
125
|
# incrementing counter, timestamp, etc). The retry_data object
|
124
126
|
# will be the same instance throughout the lifetime of the request.
|
125
127
|
def should_retry_on_error?(response, retry_data)
|
126
|
-
response = response || retry_data[:error].http_response if retry_data[:error] && retry_data[:error].respond_to?(
|
128
|
+
response = response || retry_data[:error].http_response if retry_data[:error] && retry_data[:error].respond_to?("http_response")
|
127
129
|
unless response
|
128
130
|
retry_data[:retryable] = false unless retry_data[:error]
|
129
131
|
return retry_data[:retryable]
|
@@ -143,7 +145,7 @@ module Azure::Storage::Core::Filter
|
|
143
145
|
retry_data[:status_code] = nil
|
144
146
|
end
|
145
147
|
end
|
146
|
-
|
148
|
+
|
147
149
|
if (retry_data[:status_code] < 400)
|
148
150
|
retry_data[:retryable] = false;
|
149
151
|
return false;
|
@@ -177,15 +179,14 @@ module Azure::Storage::Core::Filter
|
|
177
179
|
end
|
178
180
|
retry_data[:retryable]
|
179
181
|
end
|
180
|
-
|
182
|
+
|
181
183
|
# Adjust the retry parameter
|
182
184
|
#
|
183
185
|
# retry_data - Hash. Stores stateful retry data
|
184
186
|
def adjust_retry_parameter(retry_data)
|
185
|
-
# TODO: Adjust the retry parameter according to the location and last attempt time
|
187
|
+
# TODO: Adjust the retry parameter according to the location and last attempt time
|
186
188
|
sleep retry_data[:interval] if retry_data[:retryable]
|
187
189
|
retry_data[:retryable]
|
188
190
|
end
|
189
|
-
|
190
191
|
end
|
191
192
|
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
|
#
|
@@ -43,21 +45,21 @@ module Azure::Storage::Core
|
|
43
45
|
|
44
46
|
private
|
45
47
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
48
|
+
def build_http(uri)
|
49
|
+
ssl_options = {}
|
50
|
+
if uri.is_a?(URI) && uri.scheme.downcase == "https"
|
51
|
+
ssl_options[:ca_file] = self.ca_file if self.ca_file
|
52
|
+
ssl_options[:verify] = true
|
53
|
+
end
|
54
|
+
proxy_options = if ENV["HTTP_PROXY"]
|
55
|
+
URI::parse(ENV["HTTP_PROXY"])
|
56
|
+
elsif ENV["HTTPS_PROXY"]
|
57
|
+
URI::parse(ENV["HTTPS_PROXY"])
|
58
|
+
end || nil
|
59
|
+
Faraday.new(uri, ssl: ssl_options, proxy: proxy_options) do |conn|
|
60
|
+
conn.use FaradayMiddleware::FollowRedirects
|
61
|
+
conn.adapter Faraday.default_adapter
|
62
|
+
end
|
60
63
|
end
|
61
|
-
end
|
62
64
|
end
|
63
|
-
end
|
65
|
+
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
|
#
|
@@ -25,59 +27,59 @@
|
|
25
27
|
|
26
28
|
module Azure::Storage
|
27
29
|
module SR
|
28
|
-
ANONYMOUS_ACCESS_BLOBSERVICE_ONLY =
|
29
|
-
ARGUMENT_NULL_OR_EMPTY =
|
30
|
-
ARGUMENT_NULL_OR_UNDEFINED =
|
31
|
-
ARGUMENT_OUT_OF_RANGE_ERROR =
|
32
|
-
BATCH_ONE_PARTITION_KEY =
|
33
|
-
BATCH_ONE_RETRIEVE =
|
34
|
-
BATCH_TOO_LARGE =
|
35
|
-
BLOB_INVALID_SEQUENCE_NUMBER =
|
30
|
+
ANONYMOUS_ACCESS_BLOBSERVICE_ONLY = "Anonymous access is only valid for the BlobService."
|
31
|
+
ARGUMENT_NULL_OR_EMPTY = "The argument must not be null or an empty string. Argument name: %s."
|
32
|
+
ARGUMENT_NULL_OR_UNDEFINED = "The argument must not be null or undefined. Argument name: %s."
|
33
|
+
ARGUMENT_OUT_OF_RANGE_ERROR = "The argument is out of range. Argument name: %s, Value passed: %s."
|
34
|
+
BATCH_ONE_PARTITION_KEY = "All entities in the batch must have the same PartitionKey value."
|
35
|
+
BATCH_ONE_RETRIEVE = "If a retrieve operation is part of a batch, it must be the only operation in the batch."
|
36
|
+
BATCH_TOO_LARGE = "Batches must not contain more than 100 operations."
|
37
|
+
BLOB_INVALID_SEQUENCE_NUMBER = "The sequence number may not be specified for an increment operation."
|
36
38
|
BLOB_TYPE_MISMATCH = 'Blob type of the blob reference doesn\'t match blob type of the blob.'
|
37
|
-
CANNOT_CREATE_SAS_WITHOUT_ACCOUNT_KEY =
|
38
|
-
CONTENT_LENGTH_MISMATCH =
|
39
|
-
CONTENT_TYPE_MISSING =
|
40
|
-
EMPTY_BATCH =
|
41
|
-
EXCEEDED_SIZE_LIMITATION =
|
42
|
-
HASH_MISMATCH =
|
43
|
-
INCORRECT_ENTITY_KEYS =
|
44
|
-
INVALID_BLOB_LENGTH =
|
39
|
+
CANNOT_CREATE_SAS_WITHOUT_ACCOUNT_KEY = "Cannot create Shared Access Signature unless the Account Name and Key are used to create the ServiceClient."
|
40
|
+
CONTENT_LENGTH_MISMATCH = "An incorrect number of bytes was read from the connection. The connection may have been closed."
|
41
|
+
CONTENT_TYPE_MISSING = "Content-Type response header is missing or invalid."
|
42
|
+
EMPTY_BATCH = "Batch must not be empty."
|
43
|
+
EXCEEDED_SIZE_LIMITATION = "Upload exceeds the size limitation. Max size is %s but the current size is %s"
|
44
|
+
HASH_MISMATCH = "Hash mismatch (integrity check failed), Expected value is %s, retrieved %s."
|
45
|
+
INCORRECT_ENTITY_KEYS = "PartitionKey and RowKey must be specified as strings in the entity object."
|
46
|
+
INVALID_BLOB_LENGTH = "createBlockBlobFromText requires the size of text to be less than 64MB. Please use createBlockBlobFromLocalFile or createBlockBlobFromStream to upload large blobs."
|
45
47
|
INVALID_CONNECTION_STRING = 'Connection strings must be of the form "key1=value1;key2=value2".'
|
46
48
|
INVALID_CONNECTION_STRING_BAD_KEY = 'Connection string contains unrecognized key: "%s"'
|
47
49
|
INVALID_CONNECTION_STRING_DUPLICATE_KEY = 'Connection string contains duplicate key: "%s"'
|
48
|
-
INVALID_CONNECTION_STRING_EMPTY_KEY =
|
49
|
-
INVALID_CLIENT_OPTIONS =
|
50
|
-
INVALID_DELETE_SNAPSHOT_OPTION =
|
50
|
+
INVALID_CONNECTION_STRING_EMPTY_KEY = "Connection strings must not contain empty keys."
|
51
|
+
INVALID_CLIENT_OPTIONS = "Storage client options are invalid"
|
52
|
+
INVALID_DELETE_SNAPSHOT_OPTION = "The deleteSnapshots option cannot be included when deleting a specific snapshot using the snapshotId option."
|
51
53
|
INVALID_EDM_TYPE = 'The value \'%s\' does not match the type \'%s\'.'
|
52
|
-
INVALID_FILE_LENGTH =
|
53
|
-
INVALID_FILE_RANGE_FOR_UPDATE =
|
54
|
-
INVALID_HEADERS =
|
55
|
-
INVALID_MESSAGE_ID =
|
56
|
-
INVALID_PAGE_BLOB_LENGTH =
|
57
|
-
INVALID_PAGE_END_OFFSET =
|
58
|
-
INVALID_PAGE_RANGE_FOR_UPDATE =
|
59
|
-
INVALID_PAGE_START_OFFSET =
|
60
|
-
INVALID_POP_RECEIPT =
|
61
|
-
INVALID_PROPERTY_RESOLVER =
|
62
|
-
INVALID_RANGE_FOR_MD5 =
|
63
|
-
INVALID_SAS_VERSION =
|
64
|
-
INVALID_SAS_TOKEN =
|
65
|
-
INVALID_SIGNED_IDENTIFIERS =
|
66
|
-
INVALID_STREAM_LENGTH =
|
67
|
-
INVALID_STRING_ERROR =
|
68
|
-
INVALID_TABLE_OPERATION =
|
69
|
-
INVALID_TEXT_LENGTH =
|
70
|
-
MAXIMUM_EXECUTION_TIMEOUT_EXCEPTION =
|
71
|
-
MD5_NOT_PRESENT_ERROR =
|
72
|
-
METADATA_KEY_INVALID =
|
73
|
-
METADATA_VALUE_INVALID =
|
74
|
-
NO_CREDENTIALS_PROVIDED =
|
75
|
-
PRIMARY_ONLY_COMMAND =
|
76
|
-
QUERY_OPERATOR_REQUIRES_WHERE =
|
77
|
-
SECONDARY_ONLY_COMMAND =
|
78
|
-
STORAGE_HOST_LOCATION_REQUIRED =
|
54
|
+
INVALID_FILE_LENGTH = "createFileFromText requires the size of text to be less than 4MB. Please use createFileFromLocalFile or createFileFromStream to upload large files."
|
55
|
+
INVALID_FILE_RANGE_FOR_UPDATE = "Range size should be less than 4MB for a file range update operation."
|
56
|
+
INVALID_HEADERS = "Headers are not supported in the 2012-02-12 version."
|
57
|
+
INVALID_MESSAGE_ID = "Message ID cannot be null or undefined for deleteMessage and updateMessage operations."
|
58
|
+
INVALID_PAGE_BLOB_LENGTH = "Page blob length must be multiple of 512."
|
59
|
+
INVALID_PAGE_END_OFFSET = "Page end offset must be multiple of 512."
|
60
|
+
INVALID_PAGE_RANGE_FOR_UPDATE = "Page range size should be less than 4MB for a page update operation."
|
61
|
+
INVALID_PAGE_START_OFFSET = "Page start offset must be multiple of 512."
|
62
|
+
INVALID_POP_RECEIPT = "Pop Receipt cannot be null or undefined for deleteMessage and updateMessage operations."
|
63
|
+
INVALID_PROPERTY_RESOLVER = "The specified property resolver returned an invalid type. %s:{_:%s,$:%s }"
|
64
|
+
INVALID_RANGE_FOR_MD5 = "The requested range should be less than 4MB when contentMD5 is expected from the server"
|
65
|
+
INVALID_SAS_VERSION = "SAS Version ? is invalid. Valid versions include: ?."
|
66
|
+
INVALID_SAS_TOKEN = "The SAS token should not contain api-version."
|
67
|
+
INVALID_SIGNED_IDENTIFIERS = "Signed identifiers need to be an array."
|
68
|
+
INVALID_STREAM_LENGTH = "The length of the provided stream is invalid."
|
69
|
+
INVALID_STRING_ERROR = "Invalid string error."
|
70
|
+
INVALID_TABLE_OPERATION = "Operation not found: %s"
|
71
|
+
INVALID_TEXT_LENGTH = "The length of the provided text is invalid."
|
72
|
+
MAXIMUM_EXECUTION_TIMEOUT_EXCEPTION = "The client could not finish the operation within specified maximum execution timeout."
|
73
|
+
MD5_NOT_PRESENT_ERROR = "MD5 does not exist. If you do not want to force validation, please disable useTransactionalMD5."
|
74
|
+
METADATA_KEY_INVALID = "The key for one of the metadata key-value pairs is null, empty, or whitespace."
|
75
|
+
METADATA_VALUE_INVALID = "The value for one of the metadata key-value pairs is null, empty, or whitespace."
|
76
|
+
NO_CREDENTIALS_PROVIDED = "Credentials must be provided when creating a service client."
|
77
|
+
PRIMARY_ONLY_COMMAND = "This operation can only be executed against the primary storage location."
|
78
|
+
QUERY_OPERATOR_REQUIRES_WHERE = "%s operator needs to be used after where."
|
79
|
+
SECONDARY_ONLY_COMMAND = "This operation can only be executed against the secondary storage location."
|
80
|
+
STORAGE_HOST_LOCATION_REQUIRED = "The host for the storage service must be specified."
|
79
81
|
STORAGE_HOST_MISSING_LOCATION = 'The host for the target storage location is not specified. Please consider changing the request\'s location mode.'
|
80
|
-
TYPE_NOT_SUPPORTED =
|
81
|
-
MAX_BLOB_SIZE_CONDITION_NOT_MEET =
|
82
|
+
TYPE_NOT_SUPPORTED = "Type not supported when sending data to the service: "
|
83
|
+
MAX_BLOB_SIZE_CONDITION_NOT_MEET = "The max blob size condition specified was not met."
|
82
84
|
end
|
83
85
|
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
|
#
|
@@ -22,14 +24,14 @@
|
|
22
24
|
# THE SOFTWARE.
|
23
25
|
#--------------------------------------------------------------------------
|
24
26
|
|
25
|
-
require
|
26
|
-
require
|
27
|
+
require "ipaddr"
|
28
|
+
require "azure/storage/core/error"
|
27
29
|
|
28
30
|
if RUBY_VERSION.to_f < 2.0
|
29
31
|
begin
|
30
|
-
require
|
32
|
+
require "Win32/Console/ANSI" if RUBY_PLATFORM =~ /win32|mingw32/
|
31
33
|
rescue LoadError
|
32
|
-
puts
|
34
|
+
puts "WARNING: Output will look weird on Windows unless"\
|
33
35
|
' you install the "win32console" gem.'
|
34
36
|
end
|
35
37
|
end
|
@@ -53,11 +55,11 @@ module Azure::Storage
|
|
53
55
|
|
54
56
|
module Core
|
55
57
|
module Utility
|
56
|
-
def random_string(str =
|
57
|
-
str + (0...no_of_char).map { (
|
58
|
+
def random_string(str = "azure", no_of_char = 5)
|
59
|
+
str + (0...no_of_char).map { ("a".."z").to_a[rand(26)] }.join
|
58
60
|
end
|
59
61
|
|
60
|
-
def xml_content(xml, key, default =
|
62
|
+
def xml_content(xml, key, default = "")
|
61
63
|
content = default
|
62
64
|
node = xml.at_css(key)
|
63
65
|
content = node.text if node
|
@@ -67,8 +69,8 @@ module Azure::Storage
|
|
67
69
|
def locate_file(name)
|
68
70
|
if File.exist? name
|
69
71
|
name
|
70
|
-
elsif File.exist?(File.join(ENV[
|
71
|
-
File.join(ENV[
|
72
|
+
elsif File.exist?(File.join(ENV["HOME"], name))
|
73
|
+
File.join(ENV["HOME"], name)
|
72
74
|
else
|
73
75
|
Azure::Loggerx.error_with_exit "Unable to find #{name} file "
|
74
76
|
end
|
@@ -87,7 +89,7 @@ module Azure::Storage
|
|
87
89
|
end
|
88
90
|
|
89
91
|
def enable_winrm?(winrm_transport)
|
90
|
-
(!winrm_transport.nil? && (winrm_transport.select { |x| x.downcase ==
|
92
|
+
(!winrm_transport.nil? && (winrm_transport.select { |x| x.downcase == "http" || x.downcase == "https" }.size > 0))
|
91
93
|
end
|
92
94
|
|
93
95
|
def get_certificate(private_key_file)
|
@@ -95,10 +97,10 @@ module Azure::Storage
|
|
95
97
|
cert = OpenSSL::X509::Certificate.new
|
96
98
|
cert.version = 2
|
97
99
|
cert.serial = 0
|
98
|
-
name = OpenSSL::X509::Name.new([[
|
100
|
+
name = OpenSSL::X509::Name.new([["CN", "Azure Management Certificate"]])
|
99
101
|
cert.subject = cert.issuer = name
|
100
102
|
cert.not_before = Time.now
|
101
|
-
cert.not_after = cert.not_before + (60*60*24*365)
|
103
|
+
cert.not_after = cert.not_before + (60 * 60 * 24 * 365)
|
102
104
|
cert.public_key = rsa.public_key
|
103
105
|
cert.sign(rsa, OpenSSL::Digest::SHA1.new)
|
104
106
|
cert
|
@@ -110,8 +112,8 @@ module Azure::Storage
|
|
110
112
|
|
111
113
|
def parse_charset_from_content_type(content_type)
|
112
114
|
if (content_type && content_type.length > 0)
|
113
|
-
charset = content_type.split(
|
114
|
-
charset[
|
115
|
+
charset = content_type.split(";").delete_if { |attribute| !attribute.lstrip.start_with?("charset=") }.map { |x| x.lstrip }[0]
|
116
|
+
charset["charset=".length...charset.length] if charset
|
115
117
|
end
|
116
118
|
end
|
117
119
|
end
|
@@ -235,7 +237,7 @@ class IPAddr
|
|
235
237
|
end
|
236
238
|
|
237
239
|
def validate_address_space(ip)
|
238
|
-
if ip.split(
|
240
|
+
if ip.split("/").size != 2
|
239
241
|
raise "Cidr is invalid for IP #{ip}."
|
240
242
|
elsif valid?(ip)
|
241
243
|
raise "Address space '#{ip}' is invalid."
|
@@ -243,11 +245,11 @@ class IPAddr
|
|
243
245
|
end
|
244
246
|
|
245
247
|
def address_prefix(ip, cidr)
|
246
|
-
ip +
|
248
|
+
ip + "/" + cidr.to_s
|
247
249
|
end
|
248
250
|
|
249
251
|
def valid?(ip)
|
250
252
|
(IPAddr.new(ip) rescue nil).nil?
|
251
253
|
end
|
252
254
|
end
|
253
|
-
end
|
255
|
+
end
|