azure-storage 0.13.0.preview → 0.14.0.preview

Sign up to get free protection for your applications and to get access to all the features.
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
  #
@@ -25,22 +27,22 @@
25
27
  module Azure
26
28
  module Storage
27
29
  module Core
28
- autoload :HttpClient, 'azure/storage/core/http_client'
29
- autoload :Utility, 'azure/storage/core/utility'
30
- autoload :Logger, 'azure/storage/core/utility'
31
- autoload :Error, 'azure/storage/core/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, 'azure/storage/core/auth/shared_key.rb'
35
- autoload :SharedAccessSignature, 'azure/storage/core/auth/shared_access_signature_generator.rb'
36
- autoload :SharedAccessSignatureSigner, 'azure/storage/core/auth/shared_access_signature_signer.rb'
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, 'azure/storage/core/filter/retry_filter'
41
- autoload :LinearRetryPolicyFilter, 'azure/storage/core/filter/linear_retry_filter'
42
- autoload :ExponentialRetryPolicyFilter, 'azure/storage/core/filter/exponential_retry_filter'
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 'azure/core'
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 'azure/core'
25
- require 'azure/core/http/retry_policy'
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 ** (@retry_count - 1)) * (2 ** (retry_data[:count] - 1));
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 'azure/core'
25
- require 'azure/core/http/retry_policy'
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 'azure/core'
25
- require 'azure/core/http/retry_policy'
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?('SocketError: Hostname not known')
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?('getaddrinfo: Name or service not known')
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?('timeout')
105
+ elsif error_message.downcase.include?("timeout")
104
106
  retry_data[:retryable] = true;
105
- elsif error_message.include?('Errno::ECONNRESET')
107
+ elsif error_message.include?("Errno::ECONNRESET")
106
108
  retry_data[:retryable] = true;
107
- elsif error_message.include?('Errno::EACCES')
109
+ elsif error_message.include?("Errno::EACCES")
108
110
  retry_data[:retryable] = false;
109
- elsif error_message.include?('NOSUPPORT')
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?('http_response')
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
- def build_http(uri)
47
- ssl_options = {}
48
- if uri.is_a?(URI) && uri.scheme.downcase == 'https'
49
- ssl_options[:ca_file] = self.ca_file if self.ca_file
50
- ssl_options[:verify] = true
51
- end
52
- proxy_options = if ENV['HTTP_PROXY']
53
- URI::parse(ENV['HTTP_PROXY'])
54
- elsif ENV['HTTPS_PROXY']
55
- URI::parse(ENV['HTTPS_PROXY'])
56
- end || nil
57
- Faraday.new(uri, ssl: ssl_options, proxy: proxy_options) do |conn|
58
- conn.use FaradayMiddleware::FollowRedirects
59
- conn.adapter Faraday.default_adapter
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 = 'Anonymous access is only valid for the BlobService.'
29
- ARGUMENT_NULL_OR_EMPTY = 'The argument must not be null or an empty string. Argument name: %s.'
30
- ARGUMENT_NULL_OR_UNDEFINED = 'The argument must not be null or undefined. Argument name: %s.'
31
- ARGUMENT_OUT_OF_RANGE_ERROR = 'The argument is out of range. Argument name: %s, Value passed: %s.'
32
- BATCH_ONE_PARTITION_KEY = 'All entities in the batch must have the same PartitionKey value.'
33
- BATCH_ONE_RETRIEVE = 'If a retrieve operation is part of a batch, it must be the only operation in the batch.'
34
- BATCH_TOO_LARGE = 'Batches must not contain more than 100 operations.'
35
- BLOB_INVALID_SEQUENCE_NUMBER = 'The sequence number may not be specified for an increment operation.'
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 = 'Cannot create Shared Access Signature unless the Account Name and Key are used to create the ServiceClient.'
38
- CONTENT_LENGTH_MISMATCH = 'An incorrect number of bytes was read from the connection. The connection may have been closed.'
39
- CONTENT_TYPE_MISSING = 'Content-Type response header is missing or invalid.'
40
- EMPTY_BATCH = 'Batch must not be empty.'
41
- EXCEEDED_SIZE_LIMITATION = 'Upload exceeds the size limitation. Max size is %s but the current size is %s'
42
- HASH_MISMATCH = 'Hash mismatch (integrity check failed), Expected value is %s, retrieved %s.'
43
- INCORRECT_ENTITY_KEYS = 'PartitionKey and RowKey must be specified as strings in the entity object.'
44
- INVALID_BLOB_LENGTH = 'createBlockBlobFromText requires the size of text to be less than 64MB. Please use createBlockBlobFromLocalFile or createBlockBlobFromStream to upload large blobs.'
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 = 'Connection strings must not contain empty keys.'
49
- INVALID_CLIENT_OPTIONS = 'Storage client options are invalid'
50
- INVALID_DELETE_SNAPSHOT_OPTION = 'The deleteSnapshots option cannot be included when deleting a specific snapshot using the snapshotId 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 = 'createFileFromText requires the size of text to be less than 4MB. Please use createFileFromLocalFile or createFileFromStream to upload large files.'
53
- INVALID_FILE_RANGE_FOR_UPDATE = 'Range size should be less than 4MB for a file range update operation.'
54
- INVALID_HEADERS = 'Headers are not supported in the 2012-02-12 version.'
55
- INVALID_MESSAGE_ID = 'Message ID cannot be null or undefined for deleteMessage and updateMessage operations.'
56
- INVALID_PAGE_BLOB_LENGTH = 'Page blob length must be multiple of 512.'
57
- INVALID_PAGE_END_OFFSET = 'Page end offset must be multiple of 512.'
58
- INVALID_PAGE_RANGE_FOR_UPDATE = 'Page range size should be less than 4MB for a page update operation.'
59
- INVALID_PAGE_START_OFFSET = 'Page start offset must be multiple of 512.'
60
- INVALID_POP_RECEIPT = 'Pop Receipt cannot be null or undefined for deleteMessage and updateMessage operations.'
61
- INVALID_PROPERTY_RESOLVER = 'The specified property resolver returned an invalid type. %s:{_:%s,$:%s }'
62
- INVALID_RANGE_FOR_MD5 = 'The requested range should be less than 4MB when contentMD5 is expected from the server'
63
- INVALID_SAS_VERSION = 'SAS Version ? is invalid. Valid versions include: ?.'
64
- INVALID_SAS_TOKEN = 'The SAS token should not contain api-version.'
65
- INVALID_SIGNED_IDENTIFIERS = 'Signed identifiers need to be an array.'
66
- INVALID_STREAM_LENGTH = 'The length of the provided stream is invalid.'
67
- INVALID_STRING_ERROR = 'Invalid string error.'
68
- INVALID_TABLE_OPERATION = 'Operation not found: %s'
69
- INVALID_TEXT_LENGTH = 'The length of the provided text is invalid.'
70
- MAXIMUM_EXECUTION_TIMEOUT_EXCEPTION = 'The client could not finish the operation within specified maximum execution timeout.'
71
- MD5_NOT_PRESENT_ERROR = 'MD5 does not exist. If you do not want to force validation, please disable useTransactionalMD5.'
72
- METADATA_KEY_INVALID = 'The key for one of the metadata key-value pairs is null, empty, or whitespace.'
73
- METADATA_VALUE_INVALID = 'The value for one of the metadata key-value pairs is null, empty, or whitespace.'
74
- NO_CREDENTIALS_PROVIDED = 'Credentials must be provided when creating a service client.'
75
- PRIMARY_ONLY_COMMAND = 'This operation can only be executed against the primary storage location.'
76
- QUERY_OPERATOR_REQUIRES_WHERE = '%s operator needs to be used after where.'
77
- SECONDARY_ONLY_COMMAND = 'This operation can only be executed against the secondary storage location.'
78
- STORAGE_HOST_LOCATION_REQUIRED = 'The host for the storage service must be specified.'
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 = 'Type not supported when sending data to the service: '
81
- MAX_BLOB_SIZE_CONDITION_NOT_MEET = 'The max blob size condition specified was not met.'
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 'ipaddr'
26
- require 'azure/storage/core/error'
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 'Win32/Console/ANSI' if RUBY_PLATFORM =~ /win32|mingw32/
32
+ require "Win32/Console/ANSI" if RUBY_PLATFORM =~ /win32|mingw32/
31
33
  rescue LoadError
32
- puts 'WARNING: Output will look weird on Windows unless'\
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 = 'azure', no_of_char = 5)
57
- str + (0...no_of_char).map { ('a'..'z').to_a[rand(26)] }.join
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['HOME'], name))
71
- File.join(ENV['HOME'], name)
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 == 'http' || x.downcase == 'https' }.size > 0))
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([['CN', 'Azure Management Certificate']])
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(';').delete_if { |attribute| !attribute.lstrip.start_with?('charset=') }.map { |x| x.lstrip }[0]
114
- charset['charset='.length...charset.length] if 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('/').size != 2
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 + '/' + cidr.to_s
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