azure-storage-common 1.1.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/azure/core.rb +47 -0
- data/lib/azure/core/auth/authorizer.rb +36 -0
- data/lib/azure/core/auth/shared_key.rb +125 -0
- data/lib/azure/core/auth/shared_key_lite.rb +48 -0
- data/lib/azure/core/auth/signer.rb +51 -0
- data/lib/azure/core/default.rb +23 -0
- data/lib/azure/core/error.rb +21 -0
- data/lib/azure/core/filtered_service.rb +45 -0
- data/lib/azure/core/http/debug_filter.rb +36 -0
- data/lib/azure/core/http/http_error.rb +135 -0
- data/lib/azure/core/http/http_filter.rb +53 -0
- data/lib/azure/core/http/http_request.rb +194 -0
- data/lib/azure/core/http/http_response.rb +102 -0
- data/lib/azure/core/http/retry_policy.rb +84 -0
- data/lib/azure/core/http/signer_filter.rb +33 -0
- data/lib/azure/core/service.rb +46 -0
- data/lib/azure/core/signed_service.rb +45 -0
- data/lib/azure/core/utility.rb +244 -0
- data/lib/azure/core/version.rb +33 -0
- data/lib/azure/http_response_helper.rb +38 -0
- data/lib/azure/storage/common.rb +26 -26
- data/lib/azure/storage/common/autoload.rb +62 -61
- data/lib/azure/storage/common/client.rb +162 -162
- data/lib/azure/storage/common/client_options.rb +363 -363
- data/lib/azure/storage/common/client_options_error.rb +41 -41
- data/lib/azure/storage/common/configurable.rb +212 -212
- data/lib/azure/storage/common/core.rb +35 -35
- data/lib/azure/storage/common/core/auth/anonymous_signer.rb +43 -43
- data/lib/azure/storage/common/core/auth/shared_access_signature.rb +30 -30
- data/lib/azure/storage/common/core/auth/shared_access_signature_generator.rb +399 -352
- data/lib/azure/storage/common/core/auth/shared_access_signature_signer.rb +57 -57
- data/lib/azure/storage/common/core/auth/shared_key.rb +60 -60
- data/lib/azure/storage/common/core/auth/token_signer.rb +43 -43
- data/lib/azure/storage/common/core/autoload.rb +53 -53
- data/lib/azure/storage/common/core/error.rb +43 -43
- data/lib/azure/storage/common/core/filter/exponential_retry_filter.rb +64 -64
- data/lib/azure/storage/common/core/filter/linear_retry_filter.rb +55 -55
- data/lib/azure/storage/common/core/filter/retry_filter.rb +300 -300
- data/lib/azure/storage/common/core/http_client.rb +79 -69
- data/lib/azure/storage/common/core/sr.rb +85 -85
- data/lib/azure/storage/common/core/token_credential.rb +64 -64
- data/lib/azure/storage/common/core/utility.rb +255 -255
- data/lib/azure/storage/common/default.rb +868 -868
- data/lib/azure/storage/common/service/access_policy.rb +37 -37
- data/lib/azure/storage/common/service/cors.rb +38 -38
- data/lib/azure/storage/common/service/cors_rule.rb +48 -48
- data/lib/azure/storage/common/service/enumeration_results.rb +32 -32
- data/lib/azure/storage/common/service/geo_replication.rb +40 -40
- data/lib/azure/storage/common/service/logging.rb +47 -47
- data/lib/azure/storage/common/service/metrics.rb +45 -45
- data/lib/azure/storage/common/service/retention_policy.rb +37 -37
- data/lib/azure/storage/common/service/serialization.rb +335 -335
- data/lib/azure/storage/common/service/signed_identifier.rb +40 -40
- data/lib/azure/storage/common/service/storage_service.rb +322 -322
- data/lib/azure/storage/common/service/storage_service_properties.rb +48 -48
- data/lib/azure/storage/common/service/storage_service_stats.rb +39 -39
- data/lib/azure/storage/common/service/user_delegation_key.rb +50 -0
- data/lib/azure/storage/common/version.rb +49 -49
- metadata +60 -18
@@ -0,0 +1,33 @@
|
|
1
|
+
#-------------------------------------------------------------------------
|
2
|
+
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
#--------------------------------------------------------------------------
|
15
|
+
|
16
|
+
module Azure
|
17
|
+
module Core
|
18
|
+
class Version
|
19
|
+
MAJOR = 0 unless defined? MAJOR
|
20
|
+
MINOR = 2 unless defined? MINOR
|
21
|
+
UPDATE = 0 unless defined? UPDATE
|
22
|
+
PRE = nil unless defined? PRE
|
23
|
+
|
24
|
+
class << self
|
25
|
+
|
26
|
+
# @return [String]
|
27
|
+
def to_s
|
28
|
+
[MAJOR, MINOR, UPDATE].join('.') + (PRE.nil? ? '' : "-#{PRE}")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#-------------------------------------------------------------------------
|
2
|
+
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
#--------------------------------------------------------------------------
|
15
|
+
|
16
|
+
module Azure
|
17
|
+
module HttpResponseHelper
|
18
|
+
|
19
|
+
# Sends request to HTTP server and returns a Faraday::Response
|
20
|
+
# @param method [Symbol] The HTTP method to use (:get, :post, :put, :del, etc...)
|
21
|
+
# @param url [URI] The URI of the HTTP endpoint to query
|
22
|
+
# @param conn [Net::HTTP] http agent for a given uri
|
23
|
+
# @param headers [String] The request headers
|
24
|
+
# @param body [String] The request body
|
25
|
+
#returns Faraday::Response
|
26
|
+
def set_up_response(method, url, conn, headers ,body)
|
27
|
+
conn.run_request(method, url, nil, nil) do |req|
|
28
|
+
req.body = body if body
|
29
|
+
req.headers = headers if headers
|
30
|
+
unless headers.nil?
|
31
|
+
keep_alive = headers['Keep-Alive'] || headers['keep-alive']
|
32
|
+
req.options[:timeout] = keep_alive.split('=').last.to_i unless keep_alive.nil?
|
33
|
+
end
|
34
|
+
req.options[:open_timeout] ||= 60
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/azure/storage/common.rb
CHANGED
@@ -1,26 +1,26 @@
|
|
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
|
-
require "azure/storage/common/autoload"
|
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
|
+
require "azure/storage/common/autoload"
|
@@ -1,61 +1,62 @@
|
|
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 "rubygems"
|
28
|
-
require "nokogiri"
|
29
|
-
require "base64"
|
30
|
-
require "openssl"
|
31
|
-
require "uri"
|
32
|
-
require "faraday"
|
33
|
-
require "faraday_middleware"
|
34
|
-
|
35
|
-
require "azure/storage/common/core/autoload"
|
36
|
-
require "azure/storage/common/default"
|
37
|
-
|
38
|
-
module Azure
|
39
|
-
module Storage
|
40
|
-
autoload :Common, "azure/storage/common/core"
|
41
|
-
module Common
|
42
|
-
autoload :Default, "azure/storage/common/default"
|
43
|
-
autoload :Configurable, "azure/storage/common/configurable"
|
44
|
-
autoload :Client, "azure/storage/common/client"
|
45
|
-
autoload :ClientOptions, "azure/storage/common/client_options"
|
46
|
-
|
47
|
-
module Auth
|
48
|
-
autoload :SharedAccessSignature, "azure/storage/common/core/auth/shared_access_signature"
|
49
|
-
end
|
50
|
-
|
51
|
-
module Service
|
52
|
-
autoload :Serialization, "azure/storage/common/service/serialization"
|
53
|
-
autoload :SignedIdentifier, "azure/storage/common/service/signed_identifier"
|
54
|
-
autoload :AccessPolicy, "azure/storage/common/service/access_policy"
|
55
|
-
autoload :StorageService, "azure/storage/common/service/storage_service"
|
56
|
-
autoload :CorsRule, "azure/storage/common/service/cors_rule"
|
57
|
-
autoload :EnumerationResults, "azure/storage/common/service/enumeration_results"
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
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 "rubygems"
|
28
|
+
require "nokogiri"
|
29
|
+
require "base64"
|
30
|
+
require "openssl"
|
31
|
+
require "uri"
|
32
|
+
require "faraday"
|
33
|
+
require "faraday_middleware"
|
34
|
+
|
35
|
+
require "azure/storage/common/core/autoload"
|
36
|
+
require "azure/storage/common/default"
|
37
|
+
|
38
|
+
module Azure
|
39
|
+
module Storage
|
40
|
+
autoload :Common, "azure/storage/common/core"
|
41
|
+
module Common
|
42
|
+
autoload :Default, "azure/storage/common/default"
|
43
|
+
autoload :Configurable, "azure/storage/common/configurable"
|
44
|
+
autoload :Client, "azure/storage/common/client"
|
45
|
+
autoload :ClientOptions, "azure/storage/common/client_options"
|
46
|
+
|
47
|
+
module Auth
|
48
|
+
autoload :SharedAccessSignature, "azure/storage/common/core/auth/shared_access_signature"
|
49
|
+
end
|
50
|
+
|
51
|
+
module Service
|
52
|
+
autoload :Serialization, "azure/storage/common/service/serialization"
|
53
|
+
autoload :SignedIdentifier, "azure/storage/common/service/signed_identifier"
|
54
|
+
autoload :AccessPolicy, "azure/storage/common/service/access_policy"
|
55
|
+
autoload :StorageService, "azure/storage/common/service/storage_service"
|
56
|
+
autoload :CorsRule, "azure/storage/common/service/cors_rule"
|
57
|
+
autoload :EnumerationResults, "azure/storage/common/service/enumeration_results"
|
58
|
+
autoload :UserDelegationKey, "azure/storage/common/service/user_delegation_key"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -1,162 +1,162 @@
|
|
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
|
28
|
-
class Client
|
29
|
-
include Azure::Storage::Common::Configurable
|
30
|
-
include Azure::Storage::Common::ClientOptions
|
31
|
-
include Azure::Storage::Common::Core::HttpClient
|
32
|
-
|
33
|
-
# Public: Creates an instance of [Azure::Storage::Common::Client]
|
34
|
-
#
|
35
|
-
# ==== Attributes
|
36
|
-
#
|
37
|
-
# * +options+ - Hash. Optional parameters.
|
38
|
-
#
|
39
|
-
# ==== Options
|
40
|
-
#
|
41
|
-
# Accepted key/value pairs in options parameter are:
|
42
|
-
#
|
43
|
-
# * +:use_development_storage+ - TrueClass|FalseClass. Whether to use storage emulator.
|
44
|
-
# * +:development_storage_proxy_uri+ - String. Used with +:use_development_storage+ if emulator is hosted other than localhost.
|
45
|
-
# * +:storage_connection_string+ - String. The storage connection string.
|
46
|
-
# * +:storage_account_name+ - String. The name of the storage account.
|
47
|
-
# * +:storage_access_key+ - Base64 String. The access key of the storage account.
|
48
|
-
# * +:storage_sas_token+ - String. The signed access signature for the storage account or one of its service.
|
49
|
-
# * +:storage_blob_host+ - String. Specified Blob serivce endpoint or hostname
|
50
|
-
# * +:storage_table_host+ - String. Specified Table serivce endpoint or hostname
|
51
|
-
# * +:storage_queue_host+ - String. Specified Queue serivce endpoint or hostname
|
52
|
-
# * +:storage_dns_suffix+ - String. The suffix of a regional Storage Serivce, to
|
53
|
-
# * +:default_endpoints_protocol+ - String. http or https
|
54
|
-
# * +:use_path_style_uri+ - String. Whether use path style URI for specified endpoints
|
55
|
-
# * +:ca_file+ - String. File path of the CA file if having issue with SSL
|
56
|
-
# * +:user_agent_prefix+ - String. The user agent prefix that can identify the application calls the library
|
57
|
-
#
|
58
|
-
# The valid set of options include:
|
59
|
-
# * Storage Emulator: +:use_development_storage+ required, +:development_storage_proxy_uri+ optionally
|
60
|
-
# * Storage account name and key: +:storage_account_name+ and +:storage_access_key+ required, set +:storage_dns_suffix+ necessarily
|
61
|
-
# * Storage account name and SAS token: +:storage_account_name+ and +:storage_sas_token+ required, set +:storage_dns_suffix+ necessarily
|
62
|
-
# * Specified hosts and SAS token: At least one of the service host and SAS token. It's up to user to ensure the SAS token is suitable for the serivce
|
63
|
-
# * Anonymous Blob: only +:storage_blob_host+, if it is to only access blobs within a container
|
64
|
-
#
|
65
|
-
# Additional notes:
|
66
|
-
# * Specified hosts can be set when use account name with access key or sas token
|
67
|
-
# * +:default_endpoints_protocol+ can be set if the scheme is not specified in hosts
|
68
|
-
# * Storage emulator always use path style URI
|
69
|
-
# * +:ca_file+ is independent.
|
70
|
-
#
|
71
|
-
# When empty options are given, it will try to read settings from Environment Variables. Refer to [Azure::Storage::Common::ClientOptions.env_vars_mapping] for the mapping relationship
|
72
|
-
#
|
73
|
-
# @return [Azure::Storage::Common::Client]
|
74
|
-
def initialize(options = {}, &block)
|
75
|
-
if options.is_a?(Hash) && options.has_key?(:user_agent_prefix)
|
76
|
-
Azure::Storage::Common::Service::StorageService.user_agent_prefix = options[:user_agent_prefix]
|
77
|
-
options.delete :user_agent_prefix
|
78
|
-
end
|
79
|
-
Azure::Storage::Common::Service::StorageService.register_request_callback(&block) if block_given?
|
80
|
-
reset!(options)
|
81
|
-
end
|
82
|
-
|
83
|
-
class << self
|
84
|
-
# Public: Creates an instance of [Azure::Storage::Common::Client]
|
85
|
-
#
|
86
|
-
# ==== Attributes
|
87
|
-
#
|
88
|
-
# * +options+ - Hash. Optional parameters.
|
89
|
-
#
|
90
|
-
# ==== Options
|
91
|
-
#
|
92
|
-
# Accepted key/value pairs in options parameter are:
|
93
|
-
#
|
94
|
-
# * +:use_development_storage+ - TrueClass|FalseClass. Whether to use storage emulator.
|
95
|
-
# * +:development_storage_proxy_uri+ - String. Used with +:use_development_storage+ if emulator is hosted other than localhost.
|
96
|
-
# * +:storage_account_name+ - String. The name of the storage account.
|
97
|
-
# * +:storage_access_key+ - Base64 String. The access key of the storage account.
|
98
|
-
# * +:storage_sas_token+ - String. The signed access signature for the storage account or one of its service.
|
99
|
-
# * +:storage_blob_host+ - String. Specified Blob service endpoint or hostname
|
100
|
-
# * +:storage_table_host+ - String. Specified Table service endpoint or hostname
|
101
|
-
# * +:storage_queue_host+ - String. Specified Queue service endpoint or hostname
|
102
|
-
# * +:storage_dns_suffix+ - String. The suffix of a regional Storage Service, to
|
103
|
-
# * +:default_endpoints_protocol+ - String. http or https
|
104
|
-
# * +:use_path_style_uri+ - String. Whether use path style URI for specified endpoints
|
105
|
-
# * +:ca_file+ - String. File path of the CA file if having issue with SSL
|
106
|
-
# * +:ssl_version+ - Symbol. The ssl version to be used, sample: :TLSv1_1, :TLSv1_2, for the details, see https://github.com/ruby/openssl/blob/master/lib/openssl/ssl.rb
|
107
|
-
# * +:ssl_min_version+ - Symbol. The min ssl version supported, only supported in Ruby 2.5+
|
108
|
-
# * +:ssl_max_version+ - Symbol. The max ssl version supported, only supported in Ruby 2.5+
|
109
|
-
# * +:user_agent_prefix+ - String. The user agent prefix that can identify the application calls the library
|
110
|
-
#
|
111
|
-
# The valid set of options include:
|
112
|
-
# * Storage Emulator: +:use_development_storage+ required, +:development_storage_proxy_uri+ optionally
|
113
|
-
# * Storage account name and key: +:storage_account_name+ and +:storage_access_key+ required, set +:storage_dns_suffix+ necessarily
|
114
|
-
# * Storage account name and SAS token: +:storage_account_name+ and +:storage_sas_token+ required, set +:storage_dns_suffix+ necessarily
|
115
|
-
# * Specified hosts and SAS token: At least one of the service host and SAS token. It's up to user to ensure the SAS token is suitable for the serivce
|
116
|
-
# * Anonymous Blob: only +:storage_blob_host+, if it is to only access blobs within a container
|
117
|
-
#
|
118
|
-
# Additional notes:
|
119
|
-
# * Specified hosts can be set when use account name with access key or sas token
|
120
|
-
# * +:default_endpoints_protocol+ can be set if the scheme is not specified in hosts
|
121
|
-
# * Storage emulator always use path style URI
|
122
|
-
# * +:ca_file+ is independent.
|
123
|
-
#
|
124
|
-
# When empty options are given, it will try to read settings from Environment Variables. Refer to [Azure::Storage::Common::ClientOptions.env_vars_mapping] for the mapping relationship
|
125
|
-
#
|
126
|
-
# @return [Azure::Storage::Common::Client]
|
127
|
-
def create(options = {}, &block)
|
128
|
-
client = Client.new(options, &block)
|
129
|
-
end
|
130
|
-
|
131
|
-
# Public: Creates an instance of [Azure::Storage::Common::Client] with Storage Emulator
|
132
|
-
#
|
133
|
-
# ==== Attributes
|
134
|
-
#
|
135
|
-
# * +proxy_uri+ - String. Used with +:use_development_storage+ if emulator is hosted other than localhost.
|
136
|
-
#
|
137
|
-
# @return [Azure::Storage::Common::Client]
|
138
|
-
def create_development(proxy_uri = nil, &block)
|
139
|
-
proxy_uri ||= StorageServiceClientConstants::DEV_STORE_URI
|
140
|
-
client = create(use_development_storage: true, development_storage_proxy_uri: proxy_uri, &block)
|
141
|
-
end
|
142
|
-
|
143
|
-
# Public: Creates an instance of [Azure::Storage::Common::Client] from Environment Variables
|
144
|
-
#
|
145
|
-
# @return [Azure::Storage::Client]
|
146
|
-
def create_from_env(&block)
|
147
|
-
client = create(&block)
|
148
|
-
end
|
149
|
-
|
150
|
-
# Public: Creates an instance of [Azure::Storage::Common::Client] from Environment Variables
|
151
|
-
#
|
152
|
-
# ==== Attributes
|
153
|
-
#
|
154
|
-
# * +connection_string+ - String. Please refer to https://azure.microsoft.com/en-us/documentation/articles/storage-configure-connection-string/.
|
155
|
-
#
|
156
|
-
# @return [Azure::Storage::Common::Client]
|
157
|
-
def create_from_connection_string(connection_string, &block)
|
158
|
-
client = Client.new(connection_string, &block)
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
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
|
28
|
+
class Client
|
29
|
+
include Azure::Storage::Common::Configurable
|
30
|
+
include Azure::Storage::Common::ClientOptions
|
31
|
+
include Azure::Storage::Common::Core::HttpClient
|
32
|
+
|
33
|
+
# Public: Creates an instance of [Azure::Storage::Common::Client]
|
34
|
+
#
|
35
|
+
# ==== Attributes
|
36
|
+
#
|
37
|
+
# * +options+ - Hash. Optional parameters.
|
38
|
+
#
|
39
|
+
# ==== Options
|
40
|
+
#
|
41
|
+
# Accepted key/value pairs in options parameter are:
|
42
|
+
#
|
43
|
+
# * +:use_development_storage+ - TrueClass|FalseClass. Whether to use storage emulator.
|
44
|
+
# * +:development_storage_proxy_uri+ - String. Used with +:use_development_storage+ if emulator is hosted other than localhost.
|
45
|
+
# * +:storage_connection_string+ - String. The storage connection string.
|
46
|
+
# * +:storage_account_name+ - String. The name of the storage account.
|
47
|
+
# * +:storage_access_key+ - Base64 String. The access key of the storage account.
|
48
|
+
# * +:storage_sas_token+ - String. The signed access signature for the storage account or one of its service.
|
49
|
+
# * +:storage_blob_host+ - String. Specified Blob serivce endpoint or hostname
|
50
|
+
# * +:storage_table_host+ - String. Specified Table serivce endpoint or hostname
|
51
|
+
# * +:storage_queue_host+ - String. Specified Queue serivce endpoint or hostname
|
52
|
+
# * +:storage_dns_suffix+ - String. The suffix of a regional Storage Serivce, to
|
53
|
+
# * +:default_endpoints_protocol+ - String. http or https
|
54
|
+
# * +:use_path_style_uri+ - String. Whether use path style URI for specified endpoints
|
55
|
+
# * +:ca_file+ - String. File path of the CA file if having issue with SSL
|
56
|
+
# * +:user_agent_prefix+ - String. The user agent prefix that can identify the application calls the library
|
57
|
+
#
|
58
|
+
# The valid set of options include:
|
59
|
+
# * Storage Emulator: +:use_development_storage+ required, +:development_storage_proxy_uri+ optionally
|
60
|
+
# * Storage account name and key: +:storage_account_name+ and +:storage_access_key+ required, set +:storage_dns_suffix+ necessarily
|
61
|
+
# * Storage account name and SAS token: +:storage_account_name+ and +:storage_sas_token+ required, set +:storage_dns_suffix+ necessarily
|
62
|
+
# * Specified hosts and SAS token: At least one of the service host and SAS token. It's up to user to ensure the SAS token is suitable for the serivce
|
63
|
+
# * Anonymous Blob: only +:storage_blob_host+, if it is to only access blobs within a container
|
64
|
+
#
|
65
|
+
# Additional notes:
|
66
|
+
# * Specified hosts can be set when use account name with access key or sas token
|
67
|
+
# * +:default_endpoints_protocol+ can be set if the scheme is not specified in hosts
|
68
|
+
# * Storage emulator always use path style URI
|
69
|
+
# * +:ca_file+ is independent.
|
70
|
+
#
|
71
|
+
# When empty options are given, it will try to read settings from Environment Variables. Refer to [Azure::Storage::Common::ClientOptions.env_vars_mapping] for the mapping relationship
|
72
|
+
#
|
73
|
+
# @return [Azure::Storage::Common::Client]
|
74
|
+
def initialize(options = {}, &block)
|
75
|
+
if options.is_a?(Hash) && options.has_key?(:user_agent_prefix)
|
76
|
+
Azure::Storage::Common::Service::StorageService.user_agent_prefix = options[:user_agent_prefix]
|
77
|
+
options.delete :user_agent_prefix
|
78
|
+
end
|
79
|
+
Azure::Storage::Common::Service::StorageService.register_request_callback(&block) if block_given?
|
80
|
+
reset!(options)
|
81
|
+
end
|
82
|
+
|
83
|
+
class << self
|
84
|
+
# Public: Creates an instance of [Azure::Storage::Common::Client]
|
85
|
+
#
|
86
|
+
# ==== Attributes
|
87
|
+
#
|
88
|
+
# * +options+ - Hash. Optional parameters.
|
89
|
+
#
|
90
|
+
# ==== Options
|
91
|
+
#
|
92
|
+
# Accepted key/value pairs in options parameter are:
|
93
|
+
#
|
94
|
+
# * +:use_development_storage+ - TrueClass|FalseClass. Whether to use storage emulator.
|
95
|
+
# * +:development_storage_proxy_uri+ - String. Used with +:use_development_storage+ if emulator is hosted other than localhost.
|
96
|
+
# * +:storage_account_name+ - String. The name of the storage account.
|
97
|
+
# * +:storage_access_key+ - Base64 String. The access key of the storage account.
|
98
|
+
# * +:storage_sas_token+ - String. The signed access signature for the storage account or one of its service.
|
99
|
+
# * +:storage_blob_host+ - String. Specified Blob service endpoint or hostname
|
100
|
+
# * +:storage_table_host+ - String. Specified Table service endpoint or hostname
|
101
|
+
# * +:storage_queue_host+ - String. Specified Queue service endpoint or hostname
|
102
|
+
# * +:storage_dns_suffix+ - String. The suffix of a regional Storage Service, to
|
103
|
+
# * +:default_endpoints_protocol+ - String. http or https
|
104
|
+
# * +:use_path_style_uri+ - String. Whether use path style URI for specified endpoints
|
105
|
+
# * +:ca_file+ - String. File path of the CA file if having issue with SSL
|
106
|
+
# * +:ssl_version+ - Symbol. The ssl version to be used, sample: :TLSv1_1, :TLSv1_2, for the details, see https://github.com/ruby/openssl/blob/master/lib/openssl/ssl.rb
|
107
|
+
# * +:ssl_min_version+ - Symbol. The min ssl version supported, only supported in Ruby 2.5+
|
108
|
+
# * +:ssl_max_version+ - Symbol. The max ssl version supported, only supported in Ruby 2.5+
|
109
|
+
# * +:user_agent_prefix+ - String. The user agent prefix that can identify the application calls the library
|
110
|
+
#
|
111
|
+
# The valid set of options include:
|
112
|
+
# * Storage Emulator: +:use_development_storage+ required, +:development_storage_proxy_uri+ optionally
|
113
|
+
# * Storage account name and key: +:storage_account_name+ and +:storage_access_key+ required, set +:storage_dns_suffix+ necessarily
|
114
|
+
# * Storage account name and SAS token: +:storage_account_name+ and +:storage_sas_token+ required, set +:storage_dns_suffix+ necessarily
|
115
|
+
# * Specified hosts and SAS token: At least one of the service host and SAS token. It's up to user to ensure the SAS token is suitable for the serivce
|
116
|
+
# * Anonymous Blob: only +:storage_blob_host+, if it is to only access blobs within a container
|
117
|
+
#
|
118
|
+
# Additional notes:
|
119
|
+
# * Specified hosts can be set when use account name with access key or sas token
|
120
|
+
# * +:default_endpoints_protocol+ can be set if the scheme is not specified in hosts
|
121
|
+
# * Storage emulator always use path style URI
|
122
|
+
# * +:ca_file+ is independent.
|
123
|
+
#
|
124
|
+
# When empty options are given, it will try to read settings from Environment Variables. Refer to [Azure::Storage::Common::ClientOptions.env_vars_mapping] for the mapping relationship
|
125
|
+
#
|
126
|
+
# @return [Azure::Storage::Common::Client]
|
127
|
+
def create(options = {}, &block)
|
128
|
+
client = Client.new(options, &block)
|
129
|
+
end
|
130
|
+
|
131
|
+
# Public: Creates an instance of [Azure::Storage::Common::Client] with Storage Emulator
|
132
|
+
#
|
133
|
+
# ==== Attributes
|
134
|
+
#
|
135
|
+
# * +proxy_uri+ - String. Used with +:use_development_storage+ if emulator is hosted other than localhost.
|
136
|
+
#
|
137
|
+
# @return [Azure::Storage::Common::Client]
|
138
|
+
def create_development(proxy_uri = nil, &block)
|
139
|
+
proxy_uri ||= StorageServiceClientConstants::DEV_STORE_URI
|
140
|
+
client = create(use_development_storage: true, development_storage_proxy_uri: proxy_uri, &block)
|
141
|
+
end
|
142
|
+
|
143
|
+
# Public: Creates an instance of [Azure::Storage::Common::Client] from Environment Variables
|
144
|
+
#
|
145
|
+
# @return [Azure::Storage::Client]
|
146
|
+
def create_from_env(&block)
|
147
|
+
client = create(&block)
|
148
|
+
end
|
149
|
+
|
150
|
+
# Public: Creates an instance of [Azure::Storage::Common::Client] from Environment Variables
|
151
|
+
#
|
152
|
+
# ==== Attributes
|
153
|
+
#
|
154
|
+
# * +connection_string+ - String. Please refer to https://azure.microsoft.com/en-us/documentation/articles/storage-configure-connection-string/.
|
155
|
+
#
|
156
|
+
# @return [Azure::Storage::Common::Client]
|
157
|
+
def create_from_connection_string(connection_string, &block)
|
158
|
+
client = Client.new(connection_string, &block)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|