azure-storage-common 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/common/lib/azure/storage/common.rb +26 -0
- data/common/lib/azure/storage/common/autoload.rb +61 -0
- data/common/lib/azure/storage/common/client.rb +159 -0
- data/common/lib/azure/storage/common/client_options.rb +356 -0
- data/common/lib/azure/storage/common/client_options_error.rb +41 -0
- data/common/lib/azure/storage/common/configurable.rb +212 -0
- data/common/lib/azure/storage/common/core.rb +35 -0
- data/common/lib/azure/storage/common/core/auth/anonymous_signer.rb +43 -0
- data/common/lib/azure/storage/common/core/auth/shared_access_signature.rb +30 -0
- data/common/lib/azure/storage/common/core/auth/shared_access_signature_generator.rb +352 -0
- data/common/lib/azure/storage/common/core/auth/shared_access_signature_signer.rb +57 -0
- data/common/lib/azure/storage/common/core/auth/shared_key.rb +60 -0
- data/common/lib/azure/storage/common/core/autoload.rb +50 -0
- data/common/lib/azure/storage/common/core/error.rb +43 -0
- data/common/lib/azure/storage/common/core/filter/exponential_retry_filter.rb +64 -0
- data/common/lib/azure/storage/common/core/filter/linear_retry_filter.rb +55 -0
- data/common/lib/azure/storage/common/core/filter/retry_filter.rb +302 -0
- data/common/lib/azure/storage/common/core/http_client.rb +65 -0
- data/common/lib/azure/storage/common/core/sr.rb +85 -0
- data/common/lib/azure/storage/common/core/utility.rb +255 -0
- data/common/lib/azure/storage/common/default.rb +868 -0
- data/common/lib/azure/storage/common/service/access_policy.rb +37 -0
- data/common/lib/azure/storage/common/service/cors.rb +38 -0
- data/common/lib/azure/storage/common/service/cors_rule.rb +48 -0
- data/common/lib/azure/storage/common/service/enumeration_results.rb +32 -0
- data/common/lib/azure/storage/common/service/geo_replication.rb +40 -0
- data/common/lib/azure/storage/common/service/logging.rb +47 -0
- data/common/lib/azure/storage/common/service/metrics.rb +45 -0
- data/common/lib/azure/storage/common/service/retention_policy.rb +37 -0
- data/common/lib/azure/storage/common/service/serialization.rb +335 -0
- data/common/lib/azure/storage/common/service/signed_identifier.rb +40 -0
- data/common/lib/azure/storage/common/service/storage_service.rb +322 -0
- data/common/lib/azure/storage/common/service/storage_service_properties.rb +48 -0
- data/common/lib/azure/storage/common/service/storage_service_stats.rb +39 -0
- data/common/lib/azure/storage/common/version.rb +49 -0
- metadata +216 -0
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#-------------------------------------------------------------------------
|
4
|
+
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
5
|
+
#
|
6
|
+
# The MIT License(MIT)
|
7
|
+
|
8
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
9
|
+
# of this software and associated documentation files(the "Software"), to deal
|
10
|
+
# in the Software without restriction, including without limitation the rights
|
11
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
12
|
+
# copies of the Software, and to permit persons to whom the Software is
|
13
|
+
# furnished to do so, subject to the following conditions :
|
14
|
+
|
15
|
+
# The above copyright notice and this permission notice shall be included in
|
16
|
+
# all copies or substantial portions of the Software.
|
17
|
+
|
18
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
21
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
24
|
+
# THE SOFTWARE.
|
25
|
+
#--------------------------------------------------------------------------
|
26
|
+
|
27
|
+
module Azure::Storage::Common::Core
|
28
|
+
module HttpClient
|
29
|
+
# Returns the http agent based on uri
|
30
|
+
# @param uri [URI|String] the base uri (scheme, host, port) of the http endpoint
|
31
|
+
# @return [Net::HTTP] http agent for a given uri
|
32
|
+
def agents(uri)
|
33
|
+
key = uri.to_s
|
34
|
+
@agents ||= {}
|
35
|
+
unless @agents.key?(key)
|
36
|
+
@agents[key] = build_http(uri)
|
37
|
+
end
|
38
|
+
@agents[key]
|
39
|
+
end
|
40
|
+
|
41
|
+
# Empties all the http agents
|
42
|
+
def reset_agents!
|
43
|
+
@agents = nil
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
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
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#-------------------------------------------------------------------------
|
4
|
+
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
5
|
+
#
|
6
|
+
# The MIT License(MIT)
|
7
|
+
|
8
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
9
|
+
# of this software and associated documentation files(the "Software"), to deal
|
10
|
+
# in the Software without restriction, including without limitation the rights
|
11
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
12
|
+
# copies of the Software, and to permit persons to whom the Software is
|
13
|
+
# furnished to do so, subject to the following conditions :
|
14
|
+
|
15
|
+
# The above copyright notice and this permission notice shall be included in
|
16
|
+
# all copies or substantial portions of the Software.
|
17
|
+
|
18
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
21
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
24
|
+
# THE SOFTWARE.
|
25
|
+
#--------------------------------------------------------------------------
|
26
|
+
|
27
|
+
|
28
|
+
module Azure::Storage::Common::Core
|
29
|
+
module SR
|
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."
|
38
|
+
BLOB_TYPE_MISMATCH = 'Blob type of the blob reference doesn\'t match blob type of the blob.'
|
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."
|
47
|
+
INVALID_CONNECTION_STRING = 'Connection strings must be of the form "key1=value1;key2=value2".'
|
48
|
+
INVALID_CONNECTION_STRING_BAD_KEY = 'Connection string contains unrecognized key: "%s"'
|
49
|
+
INVALID_CONNECTION_STRING_DUPLICATE_KEY = 'Connection string contains duplicate key: "%s"'
|
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."
|
53
|
+
INVALID_EDM_TYPE = 'The value \'%s\' does not match the type \'%s\'.'
|
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."
|
81
|
+
STORAGE_HOST_MISSING_LOCATION = 'The host for the target storage location is not specified. Please consider changing the request\'s location mode.'
|
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."
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,255 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#-------------------------------------------------------------------------
|
4
|
+
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
5
|
+
#
|
6
|
+
# The MIT License(MIT)
|
7
|
+
|
8
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
9
|
+
# of this software and associated documentation files(the "Software"), to deal
|
10
|
+
# in the Software without restriction, including without limitation the rights
|
11
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
12
|
+
# copies of the Software, and to permit persons to whom the Software is
|
13
|
+
# furnished to do so, subject to the following conditions :
|
14
|
+
|
15
|
+
# The above copyright notice and this permission notice shall be included in
|
16
|
+
# all copies or substantial portions of the Software.
|
17
|
+
|
18
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
21
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
24
|
+
# THE SOFTWARE.
|
25
|
+
#--------------------------------------------------------------------------
|
26
|
+
|
27
|
+
require "ipaddr"
|
28
|
+
require "azure/storage/common/core/error"
|
29
|
+
|
30
|
+
if RUBY_VERSION.to_f < 2.0
|
31
|
+
begin
|
32
|
+
require "Win32/Console/ANSI" if RUBY_PLATFORM =~ /win32|mingw32/
|
33
|
+
rescue LoadError
|
34
|
+
puts "WARNING: Output will look weird on Windows unless"\
|
35
|
+
' you install the "win32console" gem.'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
module Azure::Storage::Common
|
40
|
+
module Error
|
41
|
+
# Azure Error
|
42
|
+
class Error < Azure::Core::Error
|
43
|
+
attr_reader :description
|
44
|
+
attr_reader :status_code
|
45
|
+
attr_reader :type
|
46
|
+
|
47
|
+
def initialize(type, status, description)
|
48
|
+
@type = type
|
49
|
+
@status_code = status
|
50
|
+
@description = description
|
51
|
+
super("#{type} (#{status_code}): #{description}")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
module Core
|
57
|
+
module Utility
|
58
|
+
def random_string(str = "azure", no_of_char = 5)
|
59
|
+
str + (0...no_of_char).map { ("a".."z").to_a[rand(26)] }.join
|
60
|
+
end
|
61
|
+
|
62
|
+
def xml_content(xml, key, default = "")
|
63
|
+
content = default
|
64
|
+
node = xml.at_css(key)
|
65
|
+
content = node.text if node
|
66
|
+
content
|
67
|
+
end
|
68
|
+
|
69
|
+
def locate_file(name)
|
70
|
+
if File.exist? name
|
71
|
+
name
|
72
|
+
elsif File.exist?(File.join(ENV["HOME"], name))
|
73
|
+
File.join(ENV["HOME"], name)
|
74
|
+
else
|
75
|
+
Azure::Loggerx.error_with_exit "Unable to find #{name} file "
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def export_der(cert, key, pass = nil, name = nil)
|
80
|
+
pkcs12 = OpenSSL::PKCS12.create(pass, name, key, cert)
|
81
|
+
Base64.encode64(pkcs12.to_der)
|
82
|
+
rescue Exception => e
|
83
|
+
puts e.message
|
84
|
+
abort
|
85
|
+
end
|
86
|
+
|
87
|
+
def export_fingerprint(certificate)
|
88
|
+
Digest::SHA1.hexdigest(certificate.to_der)
|
89
|
+
end
|
90
|
+
|
91
|
+
def enable_winrm?(winrm_transport)
|
92
|
+
(!winrm_transport.nil? && (winrm_transport.select { |x| x.downcase == "http" || x.downcase == "https" }.size > 0))
|
93
|
+
end
|
94
|
+
|
95
|
+
def get_certificate(private_key_file)
|
96
|
+
rsa = OpenSSL::PKey.read File.read(private_key_file)
|
97
|
+
cert = OpenSSL::X509::Certificate.new
|
98
|
+
cert.version = 2
|
99
|
+
cert.serial = 0
|
100
|
+
name = OpenSSL::X509::Name.new([["CN", "Azure Management Certificate"]])
|
101
|
+
cert.subject = cert.issuer = name
|
102
|
+
cert.not_before = Time.now
|
103
|
+
cert.not_after = cert.not_before + (60 * 60 * 24 * 365)
|
104
|
+
cert.public_key = rsa.public_key
|
105
|
+
cert.sign(rsa, OpenSSL::Digest::SHA1.new)
|
106
|
+
cert
|
107
|
+
end
|
108
|
+
|
109
|
+
def initialize_external_logger(logger)
|
110
|
+
Loggerx.initialize_external_logger(logger)
|
111
|
+
end
|
112
|
+
|
113
|
+
def parse_charset_from_content_type(content_type)
|
114
|
+
if (content_type && content_type.length > 0)
|
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
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
# Logger
|
122
|
+
module Logger
|
123
|
+
class << self
|
124
|
+
attr_accessor :logger
|
125
|
+
|
126
|
+
def info(msg)
|
127
|
+
if logger.nil?
|
128
|
+
puts msg.bold.white
|
129
|
+
else
|
130
|
+
logger.info(msg)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def error_with_exit(msg)
|
135
|
+
if logger.nil?
|
136
|
+
puts msg.bold.red
|
137
|
+
else
|
138
|
+
logger.error(msg)
|
139
|
+
end
|
140
|
+
|
141
|
+
raise msg.bold.red
|
142
|
+
end
|
143
|
+
|
144
|
+
def warn(msg)
|
145
|
+
if logger.nil?
|
146
|
+
puts msg.yellow
|
147
|
+
else
|
148
|
+
logger.warn(msg)
|
149
|
+
end
|
150
|
+
|
151
|
+
msg
|
152
|
+
end
|
153
|
+
|
154
|
+
def error(msg)
|
155
|
+
if logger.nil?
|
156
|
+
puts msg.bold.red
|
157
|
+
else
|
158
|
+
logger.error(msg)
|
159
|
+
end
|
160
|
+
|
161
|
+
msg
|
162
|
+
end
|
163
|
+
|
164
|
+
def exception_message(msg)
|
165
|
+
if logger.nil?
|
166
|
+
puts msg.bold.red
|
167
|
+
else
|
168
|
+
logger.warn(msg)
|
169
|
+
end
|
170
|
+
|
171
|
+
raise msg.bold.red
|
172
|
+
end
|
173
|
+
|
174
|
+
def success(msg)
|
175
|
+
msg_with_new_line = msg + "\n"
|
176
|
+
if logger.nil?
|
177
|
+
print msg_with_new_line.green
|
178
|
+
else
|
179
|
+
logger.info(msg)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def initialize_external_logger(logger)
|
184
|
+
@logger = logger
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
class String
|
192
|
+
{ reset: 0,
|
193
|
+
bold: 1,
|
194
|
+
dark: 2,
|
195
|
+
underline: 4,
|
196
|
+
blink: 5,
|
197
|
+
orange: 6,
|
198
|
+
negative: 7,
|
199
|
+
black: 30,
|
200
|
+
red: 31,
|
201
|
+
green: 32,
|
202
|
+
yellow: 33,
|
203
|
+
blue: 34,
|
204
|
+
magenta: 35,
|
205
|
+
cyan: 36,
|
206
|
+
white: 37,
|
207
|
+
}.each do |key, value|
|
208
|
+
define_method key do
|
209
|
+
"\e[#{value}m" + self + "\e[0m"
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
# Code validate private/public IP acceptable ranges.
|
215
|
+
class IPAddr
|
216
|
+
def private?
|
217
|
+
return false unless self.ipv4?
|
218
|
+
PRIVATE_RANGES.each do |ipr|
|
219
|
+
return true if ipr.include?(self)
|
220
|
+
end
|
221
|
+
false
|
222
|
+
end
|
223
|
+
|
224
|
+
def public?
|
225
|
+
!private?
|
226
|
+
end
|
227
|
+
|
228
|
+
class << self
|
229
|
+
def validate_ip_and_prefix(ip, cidr)
|
230
|
+
if cidr.to_s.empty?
|
231
|
+
raise "Cidr is missing for IP '#{ip}'."
|
232
|
+
elsif valid?(ip)
|
233
|
+
raise "Ip address '#{ip}' is invalid."
|
234
|
+
elsif !IPAddr.new(ip).private?
|
235
|
+
raise "Ip Address #{ip} must be private."
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
def validate_address_space(ip)
|
240
|
+
if ip.split("/").size != 2
|
241
|
+
raise "Cidr is invalid for IP #{ip}."
|
242
|
+
elsif valid?(ip)
|
243
|
+
raise "Address space '#{ip}' is invalid."
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
def address_prefix(ip, cidr)
|
248
|
+
ip + "/" + cidr.to_s
|
249
|
+
end
|
250
|
+
|
251
|
+
def valid?(ip)
|
252
|
+
(IPAddr.new(ip) rescue nil).nil?
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end
|
@@ -0,0 +1,868 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#-------------------------------------------------------------------------
|
4
|
+
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
5
|
+
#
|
6
|
+
# The MIT License(MIT)
|
7
|
+
|
8
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
9
|
+
# of this software and associated documentation files(the "Software"), to deal
|
10
|
+
# in the Software without restriction, including without limitation the rights
|
11
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
12
|
+
# copies of the Software, and to permit persons to whom the Software is
|
13
|
+
# furnished to do so, subject to the following conditions :
|
14
|
+
|
15
|
+
# The above copyright notice and this permission notice shall be included in
|
16
|
+
# all copies or substantial portions of the Software.
|
17
|
+
|
18
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
21
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
24
|
+
# THE SOFTWARE.
|
25
|
+
#--------------------------------------------------------------------------
|
26
|
+
|
27
|
+
require "rbconfig"
|
28
|
+
require "azure/storage/common/version"
|
29
|
+
|
30
|
+
module Azure::Storage::Common
|
31
|
+
module Default
|
32
|
+
# Default REST service (STG) version number. This is used only for SAS generator.
|
33
|
+
STG_VERSION = "2016-05-31"
|
34
|
+
|
35
|
+
# The number of default concurrent requests for parallel operation.
|
36
|
+
DEFAULT_PARALLEL_OPERATION_THREAD_COUNT = 1
|
37
|
+
|
38
|
+
# Constant representing a kilobyte (Non-SI version).
|
39
|
+
KB = 1024
|
40
|
+
# Constant representing a megabyte (Non-SI version).
|
41
|
+
MB = 1024 * 1024
|
42
|
+
# Constant representing a gigabyte (Non-SI version).
|
43
|
+
GB = 1024 * 1024 * 1024
|
44
|
+
|
45
|
+
# Specifies HTTP.
|
46
|
+
HTTP = "http"
|
47
|
+
# Specifies HTTPS.
|
48
|
+
HTTPS = "https"
|
49
|
+
# Default HTTP port.
|
50
|
+
DEFAULT_HTTP_PORT = 80
|
51
|
+
# Default HTTPS port.
|
52
|
+
DEFAULT_HTTPS_PORT = 443
|
53
|
+
|
54
|
+
# Marker for atom metadata.
|
55
|
+
XML_METADATA_MARKER = "$"
|
56
|
+
# Marker for atom value.
|
57
|
+
XML_VALUE_MARKER = "_"
|
58
|
+
|
59
|
+
def os
|
60
|
+
host_os = RbConfig::CONFIG["host_os"]
|
61
|
+
case host_os
|
62
|
+
when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
|
63
|
+
"Windows #{host_os}"
|
64
|
+
when /darwin|mac os/
|
65
|
+
"MacOS #{host_os}"
|
66
|
+
when /linux/
|
67
|
+
"Linux #{host_os}"
|
68
|
+
when /solaris|bsd/
|
69
|
+
"Unix #{host_os}"
|
70
|
+
else
|
71
|
+
"Unknown #{host_os}"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
module_function :os
|
76
|
+
|
77
|
+
class << self
|
78
|
+
def options
|
79
|
+
Hash[Azure::Storage::Common::Configurable.keys.map { |key| [key, send(key)] }]
|
80
|
+
end
|
81
|
+
|
82
|
+
# Default storage access key
|
83
|
+
# @return [String]
|
84
|
+
def storage_access_key
|
85
|
+
ENV["AZURE_STORAGE_ACCESS_KEY"]
|
86
|
+
end
|
87
|
+
|
88
|
+
# Default storage account name
|
89
|
+
# @return [String]
|
90
|
+
def storage_account_name
|
91
|
+
ENV["AZURE_STORAGE_ACCOUNT"]
|
92
|
+
end
|
93
|
+
|
94
|
+
# Default storage connection string
|
95
|
+
# @return [String]
|
96
|
+
def storage_connection_string
|
97
|
+
ENV["AZURE_STORAGE_CONNECTION_STRING"]
|
98
|
+
end
|
99
|
+
|
100
|
+
# Default storage shared access signature token
|
101
|
+
# @return [String]
|
102
|
+
def storage_sas_token
|
103
|
+
ENV["AZURE_STORAGE_SAS_TOKEN"]
|
104
|
+
end
|
105
|
+
|
106
|
+
# Default storage table host
|
107
|
+
# @return [String]
|
108
|
+
def storage_table_host
|
109
|
+
ENV["AZURE_STORAGE_TABLE_HOST"]
|
110
|
+
end
|
111
|
+
|
112
|
+
# Default storage blob host
|
113
|
+
# @return [String]
|
114
|
+
def storage_blob_host
|
115
|
+
ENV["AZURE_STORAGE_BLOB_HOST"]
|
116
|
+
end
|
117
|
+
|
118
|
+
# Default storage queue host
|
119
|
+
# @return [String]
|
120
|
+
def storage_queue_host
|
121
|
+
ENV["AZURE_STORAGE_QUEUE_HOST"]
|
122
|
+
end
|
123
|
+
|
124
|
+
# Default storage file host
|
125
|
+
# @return [String]
|
126
|
+
def storage_file_host
|
127
|
+
ENV["AZURE_STORAGE_FILE_HOST"]
|
128
|
+
end
|
129
|
+
|
130
|
+
# A placeholder to map with the Azure::Storage::Common::Configurable.keys
|
131
|
+
# @return nil
|
132
|
+
def signer
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
# Service Types
|
138
|
+
module ServiceType
|
139
|
+
BLOB = "blob"
|
140
|
+
QUEUE = "queue"
|
141
|
+
TABLE = "table"
|
142
|
+
FILE = "file"
|
143
|
+
end
|
144
|
+
|
145
|
+
# Specifies the location mode used to decide which location the request should be sent to.
|
146
|
+
module LocationMode
|
147
|
+
PRIMARY_ONLY = 0
|
148
|
+
PRIMARY_THEN_SECONDARY = 1
|
149
|
+
SECONDARY_ONLY = 2
|
150
|
+
SECONDARY_THEN_PRIMARY = 3
|
151
|
+
end
|
152
|
+
|
153
|
+
# Specifies the location used to indicate which location the operation (REST API) can be performed against.
|
154
|
+
# This is determined by the API and cannot be specified by the users.
|
155
|
+
module RequestLocationMode
|
156
|
+
PRIMARY_ONLY = 0
|
157
|
+
SECONDARY_ONLY = 1
|
158
|
+
PRIMARY_OR_SECONDARY = 2
|
159
|
+
end
|
160
|
+
|
161
|
+
# Represents a storage service location.
|
162
|
+
module StorageLocation
|
163
|
+
PRIMARY = 0
|
164
|
+
SECONDARY = 1
|
165
|
+
end
|
166
|
+
|
167
|
+
# Defines constants for use with shared access policies.
|
168
|
+
module AclConstants
|
169
|
+
# XML element for an access policy.
|
170
|
+
ACCESS_POLICY = "AccessPolicy"
|
171
|
+
|
172
|
+
# XML element for the end time of an access policy.
|
173
|
+
EXPIRY = "Expiry"
|
174
|
+
|
175
|
+
# XML attribute for IDs.
|
176
|
+
ID = "Id"
|
177
|
+
|
178
|
+
# XML element for the permission of an access policy.
|
179
|
+
PERMISSION = "Permission"
|
180
|
+
|
181
|
+
# XML element for a signed identifier.
|
182
|
+
SIGNED_IDENTIFIER_ELEMENT = "SignedIdentifier"
|
183
|
+
|
184
|
+
# XML element for signed identifiers.
|
185
|
+
SIGNED_IDENTIFIERS_ELEMENT = "SignedIdentifiers"
|
186
|
+
|
187
|
+
# XML element for the start time of an access policy.
|
188
|
+
START = "Start"
|
189
|
+
end
|
190
|
+
|
191
|
+
# Defines constants for use with service properties.
|
192
|
+
module ServicePropertiesConstants
|
193
|
+
# XML element for storage service properties.
|
194
|
+
STORAGE_SERVICE_PROPERTIES_ELEMENT = "StorageServiceProperties"
|
195
|
+
|
196
|
+
# Default analytics version to send for logging, hour metrics and minute metrics.
|
197
|
+
DEFAULT_ANALYTICS_VERSION = "1.0"
|
198
|
+
|
199
|
+
# XML element for logging.
|
200
|
+
LOGGING_ELEMENT = "Logging"
|
201
|
+
|
202
|
+
# XML element for version.
|
203
|
+
VERSION_ELEMENT = "Version"
|
204
|
+
|
205
|
+
# XML element for delete.
|
206
|
+
DELETE_ELEMENT = "Delete"
|
207
|
+
|
208
|
+
# XML element for read.
|
209
|
+
READ_ELEMENT = "Read"
|
210
|
+
|
211
|
+
# XML element for write.
|
212
|
+
WRITE_ELEMENT = "Write"
|
213
|
+
|
214
|
+
# XML element for retention policy.
|
215
|
+
RETENTION_POLICY_ELEMENT = "RetentionPolicy"
|
216
|
+
|
217
|
+
# XML element for enabled.
|
218
|
+
ENABLED_ELEMENT = "Enabled"
|
219
|
+
|
220
|
+
# XML element for days.
|
221
|
+
DAYS_ELEMENT = "Days"
|
222
|
+
|
223
|
+
# XML element for HourMetrics.
|
224
|
+
HOUR_METRICS_ELEMENT = "HourMetrics"
|
225
|
+
|
226
|
+
# XML element for MinuteMetrics.
|
227
|
+
MINUTE_METRICS_ELEMENT = "MinuteMetrics"
|
228
|
+
|
229
|
+
# XML element for Cors.
|
230
|
+
CORS_ELEMENT = "Cors"
|
231
|
+
|
232
|
+
# XML element for CorsRule.
|
233
|
+
CORS_RULE_ELEMENT = "CorsRule"
|
234
|
+
|
235
|
+
# XML element for AllowedOrigins.
|
236
|
+
ALLOWED_ORIGINS_ELEMENT = "AllowedOrigins"
|
237
|
+
|
238
|
+
# XML element for AllowedMethods.
|
239
|
+
ALLOWED_METHODS_ELEMENT = "AllowedMethods"
|
240
|
+
|
241
|
+
# XML element for MaxAgeInSeconds.
|
242
|
+
MAX_AGE_IN_SECONDS_ELEMENT = "MaxAgeInSeconds"
|
243
|
+
|
244
|
+
# XML element for ExposedHeaders.
|
245
|
+
EXPOSED_HEADERS_ELEMENT = "ExposedHeaders"
|
246
|
+
|
247
|
+
# XML element for AllowedHeaders.
|
248
|
+
ALLOWED_HEADERS_ELEMENT = "AllowedHeaders"
|
249
|
+
|
250
|
+
# XML element for IncludeAPIs.
|
251
|
+
INCLUDE_APIS_ELEMENT = "IncludeAPIs"
|
252
|
+
|
253
|
+
# XML element for DefaultServiceVersion.
|
254
|
+
DEFAULT_SERVICE_VERSION_ELEMENT = "DefaultServiceVersion"
|
255
|
+
end
|
256
|
+
|
257
|
+
# Defines constants for use with HTTP headers.
|
258
|
+
module HeaderConstants
|
259
|
+
# The accept ranges header.
|
260
|
+
ACCEPT_RANGES = "accept_ranges"
|
261
|
+
|
262
|
+
# The content transfer encoding header.
|
263
|
+
CONTENT_TRANSFER_ENCODING = "content-transfer-encoding"
|
264
|
+
|
265
|
+
# The transfer encoding header.
|
266
|
+
TRANSFER_ENCODING = "transfer-encoding"
|
267
|
+
|
268
|
+
# The server header.
|
269
|
+
SERVER = "server"
|
270
|
+
|
271
|
+
# The location header.
|
272
|
+
LOCATION = "location"
|
273
|
+
|
274
|
+
# The Last-Modified header
|
275
|
+
LAST_MODIFIED = "Last-Modified"
|
276
|
+
|
277
|
+
# The data service version.
|
278
|
+
DATA_SERVICE_VERSION = "DataServiceVersion"
|
279
|
+
|
280
|
+
# The maximum data service version.
|
281
|
+
MAX_DATA_SERVICE_VERSION = "maxdataserviceversion"
|
282
|
+
|
283
|
+
# The master Windows Azure Storage header prefix.
|
284
|
+
PREFIX_FOR_STORAGE = "x-ms-"
|
285
|
+
|
286
|
+
# The client request Id header.
|
287
|
+
CLIENT_REQUEST_ID = "x-ms-client-request-id"
|
288
|
+
|
289
|
+
# The header that specifies the approximate message count of a queue.
|
290
|
+
APPROXIMATE_MESSAGES_COUNT = "x-ms-approximate-messages-count"
|
291
|
+
|
292
|
+
# The Authorization header.
|
293
|
+
AUTHORIZATION = "authorization"
|
294
|
+
|
295
|
+
# The header that specifies public access to blobs.
|
296
|
+
BLOB_PUBLIC_ACCESS = "x-ms-blob-public-access"
|
297
|
+
|
298
|
+
# The header for the blob type.
|
299
|
+
BLOB_TYPE = "x-ms-blob-type"
|
300
|
+
|
301
|
+
# The header for the type.
|
302
|
+
TYPE = "x-ms-type"
|
303
|
+
|
304
|
+
# Specifies the block blob type.
|
305
|
+
BLOCK_BLOB = "blockblob"
|
306
|
+
|
307
|
+
# The CacheControl header.
|
308
|
+
CACHE_CONTROL = "cache-control"
|
309
|
+
|
310
|
+
# The header that specifies blob caching control.
|
311
|
+
BLOB_CACHE_CONTROL = "x-ms-blob-cache-control"
|
312
|
+
|
313
|
+
# The header that specifies caching control.
|
314
|
+
FILE_CACHE_CONTROL = "x-ms-cache-control"
|
315
|
+
|
316
|
+
# The copy status.
|
317
|
+
COPY_STATUS = "x-ms-copy-status"
|
318
|
+
|
319
|
+
# The copy completion time
|
320
|
+
COPY_COMPLETION_TIME = "x-ms-copy-completion-time"
|
321
|
+
|
322
|
+
# The copy status message
|
323
|
+
COPY_STATUS_DESCRIPTION = "x-ms-copy-status-description"
|
324
|
+
|
325
|
+
# The copy identifier.
|
326
|
+
COPY_ID = "x-ms-copy-id"
|
327
|
+
|
328
|
+
# Progress of any copy operation
|
329
|
+
COPY_PROGRESS = "x-ms-copy-progress"
|
330
|
+
|
331
|
+
# The copy action.
|
332
|
+
COPY_ACTION = "x-ms-copy-action"
|
333
|
+
|
334
|
+
# The ContentID header.
|
335
|
+
CONTENT_ID = "content-id"
|
336
|
+
|
337
|
+
# The ContentEncoding header.
|
338
|
+
CONTENT_ENCODING = "content-encoding"
|
339
|
+
|
340
|
+
# The header that specifies blob content encoding.
|
341
|
+
BLOB_CONTENT_ENCODING = "x-ms-blob-content-encoding"
|
342
|
+
|
343
|
+
# The header that specifies content encoding.
|
344
|
+
FILE_CONTENT_ENCODING = "x-ms-content-encoding"
|
345
|
+
|
346
|
+
# The ContentLangauge header.
|
347
|
+
CONTENT_LANGUAGE = "content-language"
|
348
|
+
|
349
|
+
# The header that specifies blob content language.
|
350
|
+
BLOB_CONTENT_LANGUAGE = "x-ms-blob-content-language"
|
351
|
+
|
352
|
+
# The header that specifies content language.
|
353
|
+
FILE_CONTENT_LANGUAGE = "x-ms-content-language"
|
354
|
+
|
355
|
+
# The ContentLength header.
|
356
|
+
CONTENT_LENGTH = "content-length"
|
357
|
+
|
358
|
+
# The header that specifies blob content length.
|
359
|
+
BLOB_CONTENT_LENGTH = "x-ms-blob-content-length"
|
360
|
+
|
361
|
+
# The header that specifies content length.
|
362
|
+
FILE_CONTENT_LENGTH = "x-ms-content-length"
|
363
|
+
|
364
|
+
# The ContentDisposition header.
|
365
|
+
CONTENT_DISPOSITION = "content-disposition"
|
366
|
+
|
367
|
+
# The header that specifies blob content disposition.
|
368
|
+
BLOB_CONTENT_DISPOSITION = "x-ms-blob-content-disposition"
|
369
|
+
|
370
|
+
# The header that specifies content disposition.
|
371
|
+
FILE_CONTENT_DISPOSITION = "x-ms-content-disposition"
|
372
|
+
|
373
|
+
# The ContentMD5 header.
|
374
|
+
CONTENT_MD5 = "content-md5"
|
375
|
+
|
376
|
+
# The header that specifies blob content MD5.
|
377
|
+
BLOB_CONTENT_MD5 = "x-ms-blob-content-md5"
|
378
|
+
|
379
|
+
# The header that specifies content MD5.
|
380
|
+
FILE_CONTENT_MD5 = "x-ms-content-md5"
|
381
|
+
|
382
|
+
# The ContentRange header.
|
383
|
+
CONTENT_RANGE = "cache-range"
|
384
|
+
|
385
|
+
# The ContentType header.
|
386
|
+
CONTENT_TYPE = "Content-Type"
|
387
|
+
|
388
|
+
# The header that specifies blob content type.
|
389
|
+
BLOB_CONTENT_TYPE = "x-ms-blob-content-type"
|
390
|
+
|
391
|
+
# The header that specifies content type.
|
392
|
+
FILE_CONTENT_TYPE = "x-ms-content-type"
|
393
|
+
|
394
|
+
# The header for copy source.
|
395
|
+
COPY_SOURCE = "x-ms-copy-source"
|
396
|
+
|
397
|
+
# The header that specifies the date.
|
398
|
+
DATE = "date"
|
399
|
+
|
400
|
+
# The header that specifies the date.
|
401
|
+
MS_DATE = "x-ms-date"
|
402
|
+
|
403
|
+
# The header to delete snapshots.
|
404
|
+
DELETE_SNAPSHOT = "x-ms-delete-snapshots"
|
405
|
+
|
406
|
+
# The ETag header.
|
407
|
+
ETAG = "etag"
|
408
|
+
|
409
|
+
# The IfMatch header.
|
410
|
+
IF_MATCH = "if-match"
|
411
|
+
|
412
|
+
# The IfModifiedSince header.
|
413
|
+
IF_MODIFIED_SINCE = "if-modified-since"
|
414
|
+
|
415
|
+
# The IfNoneMatch header.
|
416
|
+
IF_NONE_MATCH = "if-none-match"
|
417
|
+
|
418
|
+
# The IfUnmodifiedSince header.
|
419
|
+
IF_UNMODIFIED_SINCE = "if-unmodified-since"
|
420
|
+
|
421
|
+
# Specifies snapshots are to be included.
|
422
|
+
INCLUDE_SNAPSHOTS_VALUE = "include"
|
423
|
+
|
424
|
+
# Specifies that the content-type is JSON.
|
425
|
+
JSON_CONTENT_TYPE_VALUE = "application/json"
|
426
|
+
|
427
|
+
# The header that specifies lease ID.
|
428
|
+
LEASE_ID = "x-ms-lease-id"
|
429
|
+
|
430
|
+
# The header that specifies the lease break period.
|
431
|
+
LEASE_BREAK_PERIOD = "x-ms-lease-break-period"
|
432
|
+
|
433
|
+
# The header that specifies the proposed lease identifier.
|
434
|
+
PROPOSED_LEASE_ID = "x-ms-proposed-lease-id"
|
435
|
+
|
436
|
+
# The header that specifies the lease duration.
|
437
|
+
LEASE_DURATION = "x-ms-lease-duration"
|
438
|
+
|
439
|
+
# The header that specifies the source lease ID.
|
440
|
+
SOURCE_LEASE_ID = "x-ms-source-lease-id"
|
441
|
+
|
442
|
+
# The header that specifies lease time.
|
443
|
+
LEASE_TIME = "x-ms-lease-time"
|
444
|
+
|
445
|
+
# The header that specifies lease status.
|
446
|
+
LEASE_STATUS = "x-ms-lease-status"
|
447
|
+
|
448
|
+
# The header that specifies lease state.
|
449
|
+
LEASE_STATE = "x-ms-lease-state"
|
450
|
+
|
451
|
+
# Specifies the page blob type.
|
452
|
+
PAGE_BLOB = "PageBlob"
|
453
|
+
|
454
|
+
# The header that specifies page write mode.
|
455
|
+
PAGE_WRITE = "x-ms-page-write"
|
456
|
+
|
457
|
+
# The header that specifies file range write mode.
|
458
|
+
FILE_WRITE = "x-ms-write"
|
459
|
+
|
460
|
+
# The header that specifies whether the response should include the inserted entity.
|
461
|
+
PREFER = "Prefer"
|
462
|
+
|
463
|
+
# The header value which specifies that the response should include the inserted entity.
|
464
|
+
PREFER_CONTENT = "return-content"
|
465
|
+
|
466
|
+
# The header value which specifies that the response should not include the inserted entity.
|
467
|
+
PREFER_NO_CONTENT = "return-no-content"
|
468
|
+
|
469
|
+
# The header prefix for metadata.
|
470
|
+
PREFIX_FOR_STORAGE_METADATA = "x-ms-meta-"
|
471
|
+
|
472
|
+
# The header prefix for properties.
|
473
|
+
PREFIX_FOR_STORAGE_PROPERTIES = "x-ms-prop-"
|
474
|
+
|
475
|
+
# The Range header.
|
476
|
+
RANGE = "Range"
|
477
|
+
|
478
|
+
# The header that specifies if the request will populate the ContentMD5 header for range gets.
|
479
|
+
RANGE_GET_CONTENT_MD5 = "x-ms-range-get-content-md5"
|
480
|
+
|
481
|
+
# The format string for specifying ranges.
|
482
|
+
RANGE_HEADER_FORMAT = "bytes:%d-%d"
|
483
|
+
|
484
|
+
# The header that indicates the request ID.
|
485
|
+
REQUEST_ID = "x-ms-request-id"
|
486
|
+
|
487
|
+
# The header for specifying the sequence number.
|
488
|
+
SEQUENCE_NUMBER = "x-ms-blob-sequence-number"
|
489
|
+
|
490
|
+
# The header for specifying the If-Sequence-Number-EQ condition.
|
491
|
+
SEQUENCE_NUMBER_EQUAL = "x-ms-if-sequence-number-eq"
|
492
|
+
|
493
|
+
# The header for specifying the If-Sequence-Number-LT condition.
|
494
|
+
SEQUENCE_NUMBER_LESS_THAN = "x-ms-if-sequence-number-lt"
|
495
|
+
|
496
|
+
# The header for specifying the If-Sequence-Number-LE condition.
|
497
|
+
SEQUENCE_NUMBER_LESS_THAN_OR_EQUAL = "x-ms-if-sequence-number-le"
|
498
|
+
|
499
|
+
# The header that specifies sequence number action.
|
500
|
+
SEQUENCE_NUMBER_ACTION = "x-ms-sequence-number-action"
|
501
|
+
|
502
|
+
# The header for the blob content length.
|
503
|
+
SIZE = "x-ms-blob-content-length"
|
504
|
+
|
505
|
+
# The header for snapshots.
|
506
|
+
SNAPSHOT = "x-ms-snapshot"
|
507
|
+
|
508
|
+
# Specifies only snapshots are to be included.
|
509
|
+
SNAPSHOTS_ONLY_VALUE = "only"
|
510
|
+
|
511
|
+
# The header for the If-Match condition.
|
512
|
+
SOURCE_IF_MATCH = "x-ms-source-if-match"
|
513
|
+
|
514
|
+
# The header for the If-Modified-Since condition.
|
515
|
+
SOURCE_IF_MODIFIED_SINCE = "x-ms-source-if-modified-since"
|
516
|
+
|
517
|
+
# The header for the If-None-Match condition.
|
518
|
+
SOURCE_IF_NONE_MATCH = "x-ms-source-if-none-match"
|
519
|
+
|
520
|
+
# The header for the If-Unmodified-Since condition.
|
521
|
+
SOURCE_IF_UNMODIFIED_SINCE = "x-ms-source-if-unmodified-since"
|
522
|
+
|
523
|
+
# The header for data ranges.
|
524
|
+
STORAGE_RANGE = "x-ms-range"
|
525
|
+
|
526
|
+
# The header for storage version.
|
527
|
+
STORAGE_VERSION = "x-ms-version"
|
528
|
+
|
529
|
+
# The UserAgent header.
|
530
|
+
USER_AGENT = "user-agent"
|
531
|
+
|
532
|
+
# The pop receipt header.
|
533
|
+
POP_RECEIPT = "x-ms-popreceipt"
|
534
|
+
|
535
|
+
# The time next visibile header.
|
536
|
+
TIME_NEXT_VISIBLE = "x-ms-time-next-visible"
|
537
|
+
|
538
|
+
# The approximate message counter header.
|
539
|
+
APPROXIMATE_MESSAGE_COUNT = "x-ms-approximate-message-count"
|
540
|
+
|
541
|
+
# The lease action header.
|
542
|
+
LEASE_ACTION = "x-ms-lease-action"
|
543
|
+
|
544
|
+
# The accept header.
|
545
|
+
ACCEPT = "Accept"
|
546
|
+
|
547
|
+
# The accept charset header.
|
548
|
+
ACCEPT_CHARSET = "Accept-Charset"
|
549
|
+
|
550
|
+
# The host header.
|
551
|
+
HOST = "host"
|
552
|
+
|
553
|
+
# The correlation identifier header.
|
554
|
+
CORRELATION_ID = "x-ms-correlation-id"
|
555
|
+
|
556
|
+
# The group identifier header.
|
557
|
+
GROUP_ID = "x-ms-group-id"
|
558
|
+
|
559
|
+
# The share quota header.
|
560
|
+
SHARE_QUOTA = "x-ms-share-quota"
|
561
|
+
|
562
|
+
# The max blob size header.
|
563
|
+
BLOB_CONDITION_MAX_SIZE = "x-ms-blob-condition-maxsize"
|
564
|
+
|
565
|
+
# The append blob position header.
|
566
|
+
BLOB_CONDITION_APPEND_POSITION = "x-ms-blob-condition-appendpos"
|
567
|
+
|
568
|
+
# The append blob append offset header.
|
569
|
+
BLOB_APPEND_OFFSET = "x-ms-blob-append-offset"
|
570
|
+
|
571
|
+
# The append blob committed block header.
|
572
|
+
BLOB_COMMITTED_BLOCK_COUNT = "x-ms-blob-committed-block-count"
|
573
|
+
|
574
|
+
# The returned response payload should be with no metadata.
|
575
|
+
ODATA_NO_META = "application/json;odata=nometadata"
|
576
|
+
|
577
|
+
# The returned response payload should be with minimal metadata.
|
578
|
+
ODATA_MIN_META = "application/json;odata=minimalmetadata"
|
579
|
+
|
580
|
+
# The returned response payload should be with full metadata.
|
581
|
+
ODATA_FULL_META = "application/json;odata=fullmetadata"
|
582
|
+
|
583
|
+
# The header for if request has been encrypted at server side.
|
584
|
+
REQUEST_SERVER_ENCRYPTED = "x-ms-request-server-encrypted"
|
585
|
+
|
586
|
+
# The header for if blob data and application metadata has been encrypted at server side.
|
587
|
+
SERVER_ENCRYPTED = "x-ms-server-encrypted"
|
588
|
+
end
|
589
|
+
|
590
|
+
module QueryStringConstants
|
591
|
+
# Query component for SAS API version.
|
592
|
+
API_VERSION = "api-version"
|
593
|
+
|
594
|
+
# The Comp value.
|
595
|
+
COMP = "comp"
|
596
|
+
|
597
|
+
# The Res Type.
|
598
|
+
RESTYPE = "restype"
|
599
|
+
|
600
|
+
# The copy Id.
|
601
|
+
COPY_ID = "copyid"
|
602
|
+
|
603
|
+
# The Snapshot value.
|
604
|
+
SNAPSHOT = "snapshot"
|
605
|
+
|
606
|
+
# The timeout value.
|
607
|
+
TIMEOUT = "timeout"
|
608
|
+
|
609
|
+
# The signed start time query string argument for shared access signature.
|
610
|
+
SIGNED_START = "st"
|
611
|
+
|
612
|
+
# The signed expiry time query string argument for shared access signature.
|
613
|
+
SIGNED_EXPIRY = "se"
|
614
|
+
|
615
|
+
# The signed resource query string argument for shared access signature.
|
616
|
+
SIGNED_RESOURCE = "sr"
|
617
|
+
|
618
|
+
# The signed permissions query string argument for shared access signature.
|
619
|
+
SIGNED_PERMISSIONS = "sp"
|
620
|
+
|
621
|
+
# The signed identifier query string argument for shared access signature.
|
622
|
+
SIGNED_IDENTIFIER = "si"
|
623
|
+
|
624
|
+
# The signature query string argument for shared access signature.
|
625
|
+
SIGNATURE = "sig"
|
626
|
+
|
627
|
+
# The signed version argument for shared access signature.
|
628
|
+
SIGNED_VERSION = "sv"
|
629
|
+
|
630
|
+
# The cache control argument for shared access signature.
|
631
|
+
CACHE_CONTROL = "rscc"
|
632
|
+
|
633
|
+
# The content type argument for shared access signature.
|
634
|
+
CONTENT_TYPE = "rsct"
|
635
|
+
|
636
|
+
# The content encoding argument for shared access signature.
|
637
|
+
CONTENT_ENCODING = "rsce"
|
638
|
+
|
639
|
+
# The content language argument for shared access signature.
|
640
|
+
CONTENT_LANGUAGE = "rscl"
|
641
|
+
|
642
|
+
# The content disposition argument for shared access signature.
|
643
|
+
CONTENT_DISPOSITION = "rscd"
|
644
|
+
|
645
|
+
# The block identifier query string argument for blob service.
|
646
|
+
BLOCK_ID = "blockid"
|
647
|
+
|
648
|
+
# The block list type query string argument for blob service.
|
649
|
+
BLOCK_LIST_TYPE = "blocklisttype"
|
650
|
+
|
651
|
+
# The prefix query string argument for listing operations.
|
652
|
+
PREFIX = "prefix"
|
653
|
+
|
654
|
+
# The marker query string argument for listing operations.
|
655
|
+
MARKER = "marker"
|
656
|
+
|
657
|
+
# The maxresults query string argument for listing operations.
|
658
|
+
MAX_RESULTS = "maxresults"
|
659
|
+
|
660
|
+
# The delimiter query string argument for listing operations.
|
661
|
+
DELIMITER = "delimiter"
|
662
|
+
|
663
|
+
# The include query string argument for listing operations.
|
664
|
+
INCLUDE = "include"
|
665
|
+
|
666
|
+
# The peekonly query string argument for queue service.
|
667
|
+
PEEK_ONLY = "peekonly"
|
668
|
+
|
669
|
+
# The numofmessages query string argument for queue service.
|
670
|
+
NUM_OF_MESSAGES = "numofmessages"
|
671
|
+
|
672
|
+
# The popreceipt query string argument for queue service.
|
673
|
+
POP_RECEIPT = "popreceipt"
|
674
|
+
|
675
|
+
# The visibilitytimeout query string argument for queue service.
|
676
|
+
VISIBILITY_TIMEOUT = "visibilitytimeout"
|
677
|
+
|
678
|
+
# The messagettl query string argument for queue service.
|
679
|
+
MESSAGE_TTL = "messagettl"
|
680
|
+
|
681
|
+
# The select query string argument.
|
682
|
+
SELECT = "$select"
|
683
|
+
|
684
|
+
# The filter query string argument.
|
685
|
+
FILTER = "$filter"
|
686
|
+
|
687
|
+
# The top query string argument.
|
688
|
+
TOP = "$top"
|
689
|
+
|
690
|
+
# The skip query string argument.
|
691
|
+
SKIP = "$skip"
|
692
|
+
|
693
|
+
# The next partition key query string argument for table service.
|
694
|
+
NEXT_PARTITION_KEY = "NextPartitionKey"
|
695
|
+
|
696
|
+
# The next row key query string argument for table service.
|
697
|
+
NEXT_ROW_KEY = "NextRowKey"
|
698
|
+
|
699
|
+
# The lock identifier for service bus messages.
|
700
|
+
LOCK_ID = "lockid"
|
701
|
+
|
702
|
+
# The table name for table SAS URI's.
|
703
|
+
TABLENAME = "tn"
|
704
|
+
|
705
|
+
# The starting Partition Key for tableSAS URI's.
|
706
|
+
STARTPK = "spk"
|
707
|
+
|
708
|
+
# The starting Partition Key for tableSAS URI's.
|
709
|
+
STARTRK = "srk"
|
710
|
+
|
711
|
+
# The ending Partition Key for tableSAS URI's.
|
712
|
+
ENDPK = "epk"
|
713
|
+
|
714
|
+
# The ending Partition Key for tableSAS URI's.
|
715
|
+
ENDRK = "erk"
|
716
|
+
|
717
|
+
# ACL
|
718
|
+
ACL = "acl"
|
719
|
+
|
720
|
+
# Incremental Copy
|
721
|
+
INCREMENTAL_COPY = "incrementalcopy"
|
722
|
+
end
|
723
|
+
|
724
|
+
module StorageServiceClientConstants
|
725
|
+
# The default protocol.
|
726
|
+
DEFAULT_PROTOCOL = "https"
|
727
|
+
|
728
|
+
# Default credentials.
|
729
|
+
DEVSTORE_STORAGE_ACCOUNT = "devstoreaccount1"
|
730
|
+
DEVSTORE_STORAGE_ACCESS_KEY = "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="
|
731
|
+
|
732
|
+
# The development store URI.
|
733
|
+
DEV_STORE_URI = "http://127.0.0.1"
|
734
|
+
|
735
|
+
# Development ServiceClient URLs.
|
736
|
+
DEVSTORE_BLOB_HOST_PORT = "10000"
|
737
|
+
DEVSTORE_QUEUE_HOST_PORT = "10001"
|
738
|
+
DEVSTORE_TABLE_HOST_PORT = "10002"
|
739
|
+
DEVSTORE_FILE_HOST_PORT = "10003"
|
740
|
+
|
741
|
+
DEFAULT_ENDPOINT_SUFFIX = "core.windows.net"
|
742
|
+
end
|
743
|
+
|
744
|
+
module HttpConstants
|
745
|
+
# Http Verbs
|
746
|
+
module HttpVerbs
|
747
|
+
PUT = "PUT"
|
748
|
+
GET = "GET"
|
749
|
+
DELETE = "DELETE"
|
750
|
+
POST = "POST"
|
751
|
+
MERGE = "MERGE"
|
752
|
+
HEAD = "HEAD"
|
753
|
+
end
|
754
|
+
|
755
|
+
# Response codes.
|
756
|
+
module HttpResponseCodes
|
757
|
+
Ok = 200
|
758
|
+
Created = 201
|
759
|
+
Accepted = 202
|
760
|
+
NoContent = 204
|
761
|
+
PartialContent = 206
|
762
|
+
BadRequest = 400
|
763
|
+
Unauthorized = 401
|
764
|
+
Forbidden = 403
|
765
|
+
NotFound = 404
|
766
|
+
Conflict = 409
|
767
|
+
LengthRequired = 411
|
768
|
+
PreconditionFailed = 412
|
769
|
+
end
|
770
|
+
end
|
771
|
+
|
772
|
+
# Constants for storage error strings
|
773
|
+
# More details are at = http://msdn.microsoft.com/en-us/library/azure/dd179357.aspx
|
774
|
+
module StorageErrorCodeStrings
|
775
|
+
# Not Modified (304) = The condition specified in the conditional header(s) was not met for a read operation.
|
776
|
+
# Precondition Failed (412) = The condition specified in the conditional header(s) was not met for a write operation.
|
777
|
+
CONDITION_NOT_MET = "ConditionNotMet"
|
778
|
+
# Bad Request (400) = A required HTTP header was not specified.
|
779
|
+
MISSING_REQUIRED_HEADER = "MissingRequiredHeader"
|
780
|
+
# Bad Request (400) = A required XML node was not specified in the request body.
|
781
|
+
MISSING_REQUIRED_XML_NODE = "MissingRequiredXmlNode"
|
782
|
+
# Bad Request (400) = One of the HTTP headers specified in the request is not supported.
|
783
|
+
UNSUPPORTED_HEADER = "UnsupportedHeader"
|
784
|
+
# Bad Request (400) = One of the XML nodes specified in the request body is not supported.
|
785
|
+
UNSUPPORTED_XML_NODE = "UnsupportedXmlNode"
|
786
|
+
# Bad Request (400) = The value provided for one of the HTTP headers was not in the correct format.
|
787
|
+
INVALID_HEADER_VALUE = "InvalidHeaderValue"
|
788
|
+
# Bad Request (400) = The value provided for one of the XML nodes in the request body was not in the correct format.
|
789
|
+
INVALID_XML_NODE_VALUE = "InvalidXmlNodeValue"
|
790
|
+
# Bad Request (400) = A required query parameter was not specified for this request.
|
791
|
+
MISSING_REQUIRED_QUERY_PARAMETER = "MissingRequiredQueryParameter"
|
792
|
+
# Bad Request (400) = One of the query parameters specified in the request URI is not supported.
|
793
|
+
UNSUPPORTED_QUERY_PARAMETER = "UnsupportedQueryParameter"
|
794
|
+
# Bad Request (400) = An invalid value was specified for one of the query parameters in the request URI.
|
795
|
+
INVALID_QUERY_PARAMETER_VALUE = "InvalidQueryParameterValue"
|
796
|
+
# Bad Request (400) = A query parameter specified in the request URI is outside the permissible range.
|
797
|
+
OUT_OF_RANGE_QUERY_PARAMETER_VALUE = "OutOfRangeQueryParameterValue"
|
798
|
+
# Bad Request (400) = The url in the request could not be parsed.
|
799
|
+
REQUEST_URL_FAILED_TO_PARSE = "RequestUrlFailedToParse"
|
800
|
+
# Bad Request (400) = The requested URI does not represent any resource on the server.
|
801
|
+
INVALID_URI = "InvalidUri"
|
802
|
+
# Bad Request (400) = The HTTP verb specified was not recognized by the server.
|
803
|
+
INVALID_HTTP_VERB = "InvalidHttpVerb"
|
804
|
+
# Bad Request (400) = The key for one of the metadata key-value pairs is empty.
|
805
|
+
EMPTY_METADATA_KEY = "EmptyMetadataKey"
|
806
|
+
# Bad Request (400) = The specified XML is not syntactically valid.
|
807
|
+
INVALID_XML_DOCUMENT = "InvalidXmlDocument"
|
808
|
+
# Bad Request (400) = The MD5 value specified in the request did not match the MD5 value calculated by the server.
|
809
|
+
MD5_MISMATCH = "Md5Mismatch"
|
810
|
+
# Bad Request (400) = The MD5 value specified in the request is invalid. The MD5 value must be 128 bits and Base64-encoded.
|
811
|
+
INVALID_MD5 = "InvalidMd5"
|
812
|
+
# Bad Request (400) = One of the request inputs is out of range.
|
813
|
+
OUT_OF_RANGE_INPUT = "OutOfRangeInput"
|
814
|
+
# Bad Request (400) = The authentication information was not provided in the correct format. Verify the value of Authorization header.
|
815
|
+
INVALID_AUTHENTICATION_INFO = "InvalidAuthenticationInfo"
|
816
|
+
# Bad Request (400) = One of the request inputs is not valid.
|
817
|
+
INVALID_INPUT = "InvalidInput"
|
818
|
+
# Bad Request (400) = The specified metadata is invalid. It includes characters that are not permitted.
|
819
|
+
INVALID_METADATA = "InvalidMetadata"
|
820
|
+
# Bad Request (400) = The specifed resource name contains invalid characters.
|
821
|
+
INVALID_RESOURCE_NAME = "InvalidResourceName"
|
822
|
+
# Bad Request (400) = The size of the specified metadata exceeds the maximum size permitted.
|
823
|
+
METADATA_TOO_LARGE = "MetadataTooLarge"
|
824
|
+
# Bad Request (400) = Condition headers are not supported.
|
825
|
+
CONDITION_HEADER_NOT_SUPPORTED = "ConditionHeadersNotSupported"
|
826
|
+
# Bad Request (400) = Multiple condition headers are not supported.
|
827
|
+
MULTIPLE_CONDITION_HEADER_NOT_SUPPORTED = "MultipleConditionHeadersNotSupported"
|
828
|
+
# Forbidden (403) = Server failed to authenticate the request. Make sure the value of the Authorization header is formed correctly including the signature.
|
829
|
+
AUTHENTICATION_FAILED = "AuthenticationFailed"
|
830
|
+
# Forbidden (403) = Read-access geo-redundant replication is not enabled for the account.
|
831
|
+
# Forbidden (403) = Write operations to the secondary location are not allowed.
|
832
|
+
# Forbidden (403) = The account being accessed does not have sufficient permissions to execute this operation.
|
833
|
+
INSUFFICIENT_ACCOUNT_PERMISSIONS = "InsufficientAccountPermissions"
|
834
|
+
# Not Found (404) = The specified resource does not exist.
|
835
|
+
RESOURCE_NOT_FOUND = "ResourceNotFound"
|
836
|
+
# Forbidden (403) = The specified account is disabled.
|
837
|
+
ACCOUNT_IS_DISABLED = "AccountIsDisabled"
|
838
|
+
# Method Not Allowed (405) = The resource doesn't support the specified HTTP verb.
|
839
|
+
UNSUPPORTED_HTTP_VERB = "UnsupportedHttpVerb"
|
840
|
+
# Conflict (409) = The specified account already exists.
|
841
|
+
ACCOUNT_ALREADY_EXISTS = "AccountAlreadyExists"
|
842
|
+
# Conflict (409) = The specified account is in the process of being created.
|
843
|
+
ACCOUNT_BEING_CREATED = "AccountBeingCreated"
|
844
|
+
# Conflict (409) = The specified resource already exists.
|
845
|
+
RESOURCE_ALREADY_EXISTS = "ResourceAlreadyExists"
|
846
|
+
# Conflict (409) = The specified resource type does not match the type of the existing resource.
|
847
|
+
RESOURCE_TYPE_MISMATCH = "ResourceTypeMismatch"
|
848
|
+
# Length Required (411) = The Content-Length header was not specified.
|
849
|
+
MISSING_CONTENT_LENGTH_HEADER = "MissingContentLengthHeader"
|
850
|
+
# Request Entity Too Large (413) = The size of the request body exceeds the maximum size permitted.
|
851
|
+
REQUEST_BODY_TOO_LARGE = "RequestBodyTooLarge"
|
852
|
+
# Requested Range Not Satisfiable (416) = The range specified is invalid for the current size of the resource.
|
853
|
+
INVALID_RANGE = "InvalidRange"
|
854
|
+
# Internal Server Error (500) = The server encountered an internal error. Please retry the request.
|
855
|
+
INTERNAL_ERROR = "InternalError"
|
856
|
+
# Internal Server Error (500) = The operation could not be completed within the permitted time.
|
857
|
+
OPERATION_TIMED_OUT = "OperationTimedOut"
|
858
|
+
# Service Unavailable (503) = The server is currently unable to receive requests. Please retry your request.
|
859
|
+
SERVER_BUSY = "ServerBusy"
|
860
|
+
|
861
|
+
# Legacy error code strings
|
862
|
+
UPDATE_CONDITION_NOT_SATISFIED = "UpdateConditionNotSatisfied"
|
863
|
+
CONTAINER_NOT_FOUND = "ContainerNotFound"
|
864
|
+
CONTAINER_ALREADY_EXISTS = "ContainerAlreadyExists"
|
865
|
+
CONTAINER_DISABLED = "ContainerDisabled"
|
866
|
+
CONTAINER_BEING_DELETED = "ContainerBeingDeleted"
|
867
|
+
end
|
868
|
+
end
|