azure-storage 0.10.0.preview
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/azure/storage.rb +58 -0
- data/lib/azure/storage/autoload.rb +71 -0
- data/lib/azure/storage/blob/append.rb +154 -0
- data/lib/azure/storage/blob/blob.rb +821 -0
- data/lib/azure/storage/blob/blob_service.rb +510 -0
- data/lib/azure/storage/blob/block.rb +264 -0
- data/lib/azure/storage/blob/container.rb +552 -0
- data/lib/azure/storage/blob/page.rb +380 -0
- data/lib/azure/storage/blob/serialization.rb +297 -0
- data/lib/azure/storage/client.rb +185 -0
- data/lib/azure/storage/configurable.rb +137 -0
- data/lib/azure/storage/core.rb +33 -0
- data/lib/azure/storage/core/auth/shared_access_signature.rb +27 -0
- data/lib/azure/storage/core/auth/shared_access_signature_generator.rb +194 -0
- data/lib/azure/storage/core/auth/shared_access_signature_signer.rb +49 -0
- data/lib/azure/storage/core/auth/shared_key.rb +125 -0
- data/lib/azure/storage/core/auth/shared_key_lite.rb +55 -0
- data/lib/azure/storage/core/auth/signer.rb +60 -0
- data/lib/azure/storage/core/autoload.rb +35 -0
- data/lib/azure/storage/core/client_options.rb +334 -0
- data/lib/azure/storage/core/client_options_error.rb +39 -0
- data/lib/azure/storage/core/constants.rb +1077 -0
- data/lib/azure/storage/core/error.rb +47 -0
- data/lib/azure/storage/core/filtered_service.rb +54 -0
- data/lib/azure/storage/core/http/debug_filter.rb +45 -0
- data/lib/azure/storage/core/http/http_error.rb +95 -0
- data/lib/azure/storage/core/http/http_filter.rb +62 -0
- data/lib/azure/storage/core/http/http_request.rb +182 -0
- data/lib/azure/storage/core/http/http_response.rb +105 -0
- data/lib/azure/storage/core/http/retry_policy.rb +83 -0
- data/lib/azure/storage/core/http/signer_filter.rb +42 -0
- data/lib/azure/storage/core/http_client.rb +63 -0
- data/lib/azure/storage/core/service.rb +55 -0
- data/lib/azure/storage/core/signed_service.rb +54 -0
- data/lib/azure/storage/core/sr.rb +83 -0
- data/lib/azure/storage/core/utility.rb +254 -0
- data/lib/azure/storage/queue/message.rb +39 -0
- data/lib/azure/storage/queue/queue.rb +37 -0
- data/lib/azure/storage/queue/queue_service.rb +580 -0
- data/lib/azure/storage/queue/serialization.rb +113 -0
- data/lib/azure/storage/service/access_policy.rb +35 -0
- data/lib/azure/storage/service/cors.rb +36 -0
- data/lib/azure/storage/service/cors_rule.rb +46 -0
- data/lib/azure/storage/service/enumeration_results.rb +30 -0
- data/lib/azure/storage/service/logging.rb +45 -0
- data/lib/azure/storage/service/metrics.rb +43 -0
- data/lib/azure/storage/service/retention_policy.rb +35 -0
- data/lib/azure/storage/service/serialization.rb +308 -0
- data/lib/azure/storage/service/signed_identifier.rb +39 -0
- data/lib/azure/storage/service/storage_service.rb +131 -0
- data/lib/azure/storage/service/storage_service_properties.rb +46 -0
- data/lib/azure/storage/table/auth/shared_key.rb +68 -0
- data/lib/azure/storage/table/auth/shared_key_lite.rb +53 -0
- data/lib/azure/storage/table/batch.rb +339 -0
- data/lib/azure/storage/table/batch_response.rb +127 -0
- data/lib/azure/storage/table/edmtype.rb +136 -0
- data/lib/azure/storage/table/entity.rb +40 -0
- data/lib/azure/storage/table/guid.rb +33 -0
- data/lib/azure/storage/table/query.rb +121 -0
- data/lib/azure/storage/table/serialization.rb +117 -0
- data/lib/azure/storage/table/table_service.rb +571 -0
- data/lib/azure/storage/version.rb +46 -0
- metadata +329 -0
@@ -0,0 +1,105 @@
|
|
1
|
+
#-------------------------------------------------------------------------
|
2
|
+
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
|
+
#
|
4
|
+
# The MIT License(MIT)
|
5
|
+
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files(the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions :
|
12
|
+
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
# THE SOFTWARE.
|
23
|
+
#--------------------------------------------------------------------------
|
24
|
+
require 'azure/storage/core/http/http_error'
|
25
|
+
|
26
|
+
module Azure
|
27
|
+
module Core
|
28
|
+
module Http
|
29
|
+
# A small proxy to clean up the API of Net::HTTPResponse.
|
30
|
+
class HttpResponse
|
31
|
+
|
32
|
+
# Public: Initialize a new response.
|
33
|
+
#
|
34
|
+
# http_response - A Net::HTTPResponse.
|
35
|
+
def initialize(http_response, uri='')
|
36
|
+
@http_response = http_response
|
37
|
+
@uri = uri
|
38
|
+
end
|
39
|
+
|
40
|
+
attr_accessor :uri
|
41
|
+
|
42
|
+
# Public: Get the response body.
|
43
|
+
#
|
44
|
+
# Returns a String.
|
45
|
+
def body
|
46
|
+
@http_response.body
|
47
|
+
end
|
48
|
+
|
49
|
+
# Public: Get the response status code.
|
50
|
+
#
|
51
|
+
# Returns a Fixnum.
|
52
|
+
def status_code
|
53
|
+
@http_response.status
|
54
|
+
end
|
55
|
+
|
56
|
+
# Public: Check if this response was successful. A request is considered
|
57
|
+
# successful if the response is in the 200 - 399 range.
|
58
|
+
#
|
59
|
+
# Returns nil|false.
|
60
|
+
def success?
|
61
|
+
@http_response.success?
|
62
|
+
end
|
63
|
+
|
64
|
+
# Public: Get all the response headers as a Hash.
|
65
|
+
#
|
66
|
+
# Returns a Hash.
|
67
|
+
def headers
|
68
|
+
@http_response.headers
|
69
|
+
end
|
70
|
+
|
71
|
+
# Public: Get an error that wraps this HTTP response, as long as this
|
72
|
+
# response was unsuccessful. This method will return nil if the
|
73
|
+
# response was successful.
|
74
|
+
#
|
75
|
+
# Returns an Azure::Core::Http::HTTPError.
|
76
|
+
def exception
|
77
|
+
HTTPError.new(self) unless success?
|
78
|
+
end
|
79
|
+
|
80
|
+
alias_method :error, :exception
|
81
|
+
|
82
|
+
# TODO: This needs to be deleted and HttpError needs to be refactored to not rely on HttpResponse.
|
83
|
+
# The dependency on knowing the internal structure of HttpResponse breaks good design principles.
|
84
|
+
# The only reason this class exists is because the HttpError parses the HttpResponse to produce an error msg.
|
85
|
+
class MockResponse
|
86
|
+
def initialize(code, body, headers)
|
87
|
+
@status = code
|
88
|
+
@body = body
|
89
|
+
@headers = headers
|
90
|
+
@headers.each { |k,v|
|
91
|
+
@headers[k] = [v] unless v.respond_to? first
|
92
|
+
}
|
93
|
+
end
|
94
|
+
attr_accessor :status
|
95
|
+
attr_accessor :body
|
96
|
+
attr_accessor :headers
|
97
|
+
|
98
|
+
def to_hash
|
99
|
+
@headers
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
#-------------------------------------------------------------------------
|
2
|
+
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
|
+
#
|
4
|
+
# The MIT License(MIT)
|
5
|
+
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files(the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions :
|
12
|
+
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
# THE SOFTWARE.
|
23
|
+
#--------------------------------------------------------------------------
|
24
|
+
require "azure/storage/core/http/http_filter"
|
25
|
+
|
26
|
+
module Azure
|
27
|
+
module Core
|
28
|
+
module Http
|
29
|
+
|
30
|
+
# A HttpFilter implementation that handles retrying based on a
|
31
|
+
# specific policy when HTTP layer errors occur
|
32
|
+
class RetryPolicy < HttpFilter
|
33
|
+
|
34
|
+
def initialize(&block)
|
35
|
+
@block = block
|
36
|
+
end
|
37
|
+
|
38
|
+
attr_accessor :retry_data
|
39
|
+
|
40
|
+
# Overrides the base class implementation of call to implement
|
41
|
+
# a retry loop that uses should_retry? to determine when to
|
42
|
+
# break the loop
|
43
|
+
#
|
44
|
+
# req - HttpRequest. The HTTP request
|
45
|
+
# _next - HttpFilter. The next filter in the pipeline
|
46
|
+
def call(req, _next)
|
47
|
+
retry_data = {}
|
48
|
+
response = nil
|
49
|
+
begin
|
50
|
+
response = _next.call
|
51
|
+
rescue
|
52
|
+
retry_data[:error] = $!
|
53
|
+
end while should_retry?(response, retry_data)
|
54
|
+
if retry_data.has_key?(:error)
|
55
|
+
raise retry_data[:error]
|
56
|
+
else
|
57
|
+
response
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# Determines if the HTTP request should continue retrying
|
62
|
+
#
|
63
|
+
# response - HttpResponse. The response from the active request
|
64
|
+
# retry_data - Hash. Stores stateful retry data
|
65
|
+
#
|
66
|
+
# The retry_data is a Hash which can be used to store
|
67
|
+
# stateful data about the request execution context (such as an
|
68
|
+
# incrementing counter, timestamp, etc). The retry_data object
|
69
|
+
# will be the same instance throughout the lifetime of the request.
|
70
|
+
#
|
71
|
+
# If an inline block was passed to the constructor, that block
|
72
|
+
# will be used here and should return true to retry the job, or
|
73
|
+
# false to stop exit. If an inline block was not passed to the
|
74
|
+
# constructor the method returns false.
|
75
|
+
#
|
76
|
+
# Alternatively, a subclass could override this method.
|
77
|
+
def should_retry?(response, retry_data)
|
78
|
+
@block ? @block.call(response, retry_data) : false
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#-------------------------------------------------------------------------
|
2
|
+
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
|
+
#
|
4
|
+
# The MIT License(MIT)
|
5
|
+
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files(the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions :
|
12
|
+
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
# THE SOFTWARE.
|
23
|
+
#--------------------------------------------------------------------------
|
24
|
+
require 'azure/storage/core/http/http_filter'
|
25
|
+
|
26
|
+
module Azure
|
27
|
+
module Core
|
28
|
+
module Http
|
29
|
+
# A HttpFilter implementation that creates a authorization signature which is added to the request headers
|
30
|
+
class SignerFilter < HttpFilter
|
31
|
+
def initialize(signer)
|
32
|
+
@signer = signer
|
33
|
+
end
|
34
|
+
|
35
|
+
def call(req, _next)
|
36
|
+
@signer.sign_request(req)
|
37
|
+
_next.call
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
#-------------------------------------------------------------------------
|
2
|
+
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
|
+
#
|
4
|
+
# The MIT License(MIT)
|
5
|
+
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files(the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions :
|
12
|
+
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
# THE SOFTWARE.
|
23
|
+
#--------------------------------------------------------------------------
|
24
|
+
|
25
|
+
module Azure::Core
|
26
|
+
module HttpClient
|
27
|
+
# Returns the http agent based on uri
|
28
|
+
# @param uri [URI|String] the base uri (scheme, host, port) of the http endpoint
|
29
|
+
# @return [Net::HTTP] http agent for a given uri
|
30
|
+
def agents(uri)
|
31
|
+
key = uri.to_s
|
32
|
+
@agents ||= {}
|
33
|
+
unless @agents.key?(key)
|
34
|
+
@agents[key] = build_http(uri)
|
35
|
+
end
|
36
|
+
@agents[key]
|
37
|
+
end
|
38
|
+
|
39
|
+
# Empties all the http agents
|
40
|
+
def reset_agents!
|
41
|
+
@agents = nil
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
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
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#-------------------------------------------------------------------------
|
2
|
+
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
|
+
#
|
4
|
+
# The MIT License(MIT)
|
5
|
+
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files(the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions :
|
12
|
+
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
# THE SOFTWARE.
|
23
|
+
#--------------------------------------------------------------------------
|
24
|
+
require 'azure/storage/core/http/http_request'
|
25
|
+
|
26
|
+
module Azure
|
27
|
+
module Core
|
28
|
+
# A base class for Service implementations
|
29
|
+
class Service
|
30
|
+
|
31
|
+
# Create a new instance of the Service
|
32
|
+
#
|
33
|
+
# @param host [String] The hostname. (optional, Default empty)
|
34
|
+
# @param options [Hash] options including {:client} (optional, Default {})
|
35
|
+
def initialize(host='', options = {})
|
36
|
+
@host = host
|
37
|
+
@client = options[:client] || Azure::Storage
|
38
|
+
end
|
39
|
+
|
40
|
+
attr_accessor :host, :client
|
41
|
+
|
42
|
+
def call(method, uri, body=nil, headers={})
|
43
|
+
request = Core::Http::HttpRequest.new(method, uri, body: body, headers: headers, client: @client)
|
44
|
+
yield request if block_given?
|
45
|
+
request.call
|
46
|
+
end
|
47
|
+
|
48
|
+
def generate_uri(path='', query={})
|
49
|
+
uri = URI.parse(File.join(host, path))
|
50
|
+
uri.query = URI.encode_www_form(query) unless query == nil or query.empty?
|
51
|
+
uri
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
#-------------------------------------------------------------------------
|
2
|
+
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
|
+
#
|
4
|
+
# The MIT License(MIT)
|
5
|
+
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files(the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions :
|
12
|
+
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
# THE SOFTWARE.
|
23
|
+
#--------------------------------------------------------------------------
|
24
|
+
require 'azure/storage/core/filtered_service'
|
25
|
+
require 'azure/storage/core/http/signer_filter'
|
26
|
+
require 'azure/storage/core/auth/shared_key'
|
27
|
+
|
28
|
+
module Azure
|
29
|
+
module Core
|
30
|
+
# A base class for Service implementations
|
31
|
+
class SignedService < FilteredService
|
32
|
+
|
33
|
+
# Create a new instance of the SignedService
|
34
|
+
#
|
35
|
+
# @param signer [Azure::Core::Auth::Signer]. An implementation of Signer used for signing requests. (optional, Default=Azure::Storage::Auth::SharedKey.new)
|
36
|
+
# @param account_name [String] The account name (optional, Default=Azure::Storage.config.storage_account_name)
|
37
|
+
# @param options [Hash] options
|
38
|
+
def initialize(signer=nil, account_name=nil, options={})
|
39
|
+
super('', options)
|
40
|
+
signer ||= Azure::Storage::Auth::SharedKey.new(client.storage_account_name, client.storage_access_key)
|
41
|
+
@account_name = account_name || client.storage_account_name
|
42
|
+
@signer = signer
|
43
|
+
filters.unshift Core::Http::SignerFilter.new(signer) if signer
|
44
|
+
end
|
45
|
+
|
46
|
+
attr_accessor :account_name
|
47
|
+
attr_accessor :signer
|
48
|
+
|
49
|
+
def call(method, uri, body=nil, headers=nil)
|
50
|
+
super(method, uri, body, headers)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
#-------------------------------------------------------------------------
|
2
|
+
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
|
+
#
|
4
|
+
# The MIT License(MIT)
|
5
|
+
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files(the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions :
|
12
|
+
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
# THE SOFTWARE.
|
23
|
+
#--------------------------------------------------------------------------
|
24
|
+
|
25
|
+
|
26
|
+
module Azure::Storage
|
27
|
+
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.'
|
36
|
+
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.'
|
45
|
+
INVALID_CONNECTION_STRING = 'Connection strings must be of the form "key1=value1;key2=value2".'
|
46
|
+
INVALID_CONNECTION_STRING_BAD_KEY = 'Connection string contains unrecognized key: "%s"'
|
47
|
+
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.'
|
51
|
+
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.'
|
79
|
+
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
|
+
end
|
83
|
+
end
|