Module: Azure::Storage::Common::ClientOptions
- Included in:
- Client
- Defined in:
- lib/azure/storage/common/client_options.rb
Instance Attribute Summary collapse
-
#ca_file ⇒ Object
Returns the value of attribute ca_file.
-
#ssl_max_version ⇒ Object
Returns the value of attribute ssl_max_version.
-
#ssl_min_version ⇒ Object
Returns the value of attribute ssl_min_version.
-
#ssl_version ⇒ Object
Returns the value of attribute ssl_version.
Class Method Summary collapse
-
.connection_string_mapping ⇒ Hash
The mapping between Storage Connection String items and the options name.
-
.env_vars_mapping ⇒ Hash
The mapping between Storage Environment Variables and the options name.
-
.valid_options ⇒ Array
The valid options for the storage client.
Instance Method Summary collapse
-
#options ⇒ Hash
The options after validated and normalized.
-
#reset!(options = {}) ⇒ Azure::Storage::Common::Client
Public: Reset options for [Azure::Storage::Common::Client].
-
#same_options?(opts) ⇒ Boolean
Check if this client is configured with the same options.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object (private)
171 172 173 174 |
# File 'lib/azure/storage/common/client_options.rb', line 171 def method_missing(method_name, *args, &block) return super unless .key? method_name [method_name] end |
Instance Attribute Details
#ca_file ⇒ Object
Returns the value of attribute ca_file.
33 34 35 |
# File 'lib/azure/storage/common/client_options.rb', line 33 def ca_file @ca_file end |
#ssl_max_version ⇒ Object
Returns the value of attribute ssl_max_version.
33 34 35 |
# File 'lib/azure/storage/common/client_options.rb', line 33 def ssl_max_version @ssl_max_version end |
#ssl_min_version ⇒ Object
Returns the value of attribute ssl_min_version.
33 34 35 |
# File 'lib/azure/storage/common/client_options.rb', line 33 def ssl_min_version @ssl_min_version end |
#ssl_version ⇒ Object
Returns the value of attribute ssl_version.
33 34 35 |
# File 'lib/azure/storage/common/client_options.rb', line 33 def ssl_version @ssl_version end |
Class Method Details
.connection_string_mapping ⇒ Hash
The mapping between Storage Connection String items and the options name
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/azure/storage/common/client_options.rb', line 153 def self.connection_string_mapping @connection_string_mapping ||= { "UseDevelopmentStorage" => :use_development_storage, "DevelopmentStorageProxyUri" => :development_storage_proxy_uri, "DefaultEndpointsProtocol" => :default_endpoints_protocol, "AccountName" => :storage_account_name, "AccountKey" => :storage_access_key, "BlobEndpoint" => :storage_blob_host, "TableEndpoint" => :storage_table_host, "QueueEndpoint" => :storage_queue_host, "FileEndpoint" => :storage_file_host, "SharedAccessSignature" => :storage_sas_token, "EndpointSuffix" => :storage_dns_suffix } end |
.env_vars_mapping ⇒ Hash
The mapping between Storage Environment Variables and the options name
135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/azure/storage/common/client_options.rb', line 135 def self.env_vars_mapping @env_vars_mapping ||= { "EMULATED" => :use_development_storage, "AZURE_STORAGE_ACCOUNT" => :storage_account_name, "AZURE_STORAGE_ACCESS_KEY" => :storage_access_key, "AZURE_STORAGE_CONNECTION_STRING" => :storage_connection_string, "AZURE_STORAGE_BLOB_HOST" => :storage_blob_host, "AZURE_STORAGE_TABLE_HOST" => :storage_table_host, "AZURE_STORAGE_QUEUE_HOST" => :storage_queue_host, "AZURE_STORAGE_FILE_HOST" => :storage_file_host, "AZURE_STORAGE_SAS_TOKEN" => :storage_sas_token, "AZURE_STORAGE_DNS_SUFFIX" => :storage_dns_suffix } end |
.valid_options ⇒ Array
The valid options for the storage client
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/azure/storage/common/client_options.rb', line 114 def self. @valid_options ||= [ :use_development_storage, :development_storage_proxy_uri, :storage_account_name, :storage_access_key, :storage_connection_string, :storage_sas_token, :storage_blob_host, :storage_table_host, :storage_queue_host, :storage_file_host, :storage_dns_suffix, :default_endpoints_protocol, :use_path_style_uri ] end |
Instance Method Details
#options ⇒ Hash
The options after validated and normalized
107 108 109 |
# File 'lib/azure/storage/common/client_options.rb', line 107 def @options ||= {} end |
#reset!(options = {}) ⇒ Azure::Storage::Common::Client
Public: Reset options for [Azure::Storage::Common::Client]
Attributes
-
options
- Hash | String. Optional parameters or storage connection string.
Options
Accepted key/value pairs in options parameter are:
-
:use_development_storage
- TrueClass|FalseClass. Whether to use storage emulator. -
:development_storage_proxy_uri
- String. Used with:use_development_storage
if emulator is hosted other than localhost. -
:storage_connection_string
- String. The storage connection string. -
:storage_account_name
- String. The name of the storage account. -
:storage_access_key
- Base64 String. The access key of the storage account. -
:storage_sas_token
- String. The signed access signature for the storage account or one of its service. -
:storage_blob_host
- String. Specified Blob serivce endpoint or hostname -
:storage_table_host
- String. Specified Table serivce endpoint or hostname -
:storage_queue_host
- String. Specified Queue serivce endpoint or hostname -
:storage_dns_suffix
- String. The suffix of a regional Storage Serivce, to -
:default_endpoints_protocol
- String. http or https -
:use_path_style_uri
- String. Whether use path style URI for specified endpoints -
:ca_file
- String. File path of the CA file if having issue with SSL -
:ssl_version
- Symbol. The ssl version to be used, sample: :TLSv1_1, :TLSv1_2, for the details, see github.com/ruby/openssl/blob/master/lib/openssl/ssl.rb -
:ssl_min_version
- Symbol. The min ssl version supported, only supported in Ruby 2.5+ -
:ssl_max_version
- Symbol. The max ssl version supported, only supported in Ruby 2.5+
The valid set of options include:
-
Storage Emulator:
:use_development_storage
required,:development_storage_proxy_uri
optionally -
Storage account name and key:
:storage_account_name
and:storage_access_key
required, set:storage_dns_suffix
necessarily -
Storage account name and SAS token:
:storage_account_name
and:storage_sas_token
required, set:storage_dns_suffix
necessarily -
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
-
Anonymous Blob: only
:storage_blob_host
, if it is to only access blobs within a container
Additional notes:
-
Specified hosts can be set when use account name with access key or sas token
-
:default_endpoints_protocol
can be set if the scheme is not specified in hosts -
Storage emulator always use path style URI
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
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/azure/storage/common/client_options.rb', line 77 def reset!( = {}) if .is_a? String = parse_connection_string() elsif .is_a? Hash # When the options are provided via singleton setup: Azure::Storage.setup() = if .length == 0 = parse_connection_string([:storage_connection_string]) if [:storage_connection_string] end # Load from environment when no valid input = load_env if .length == 0 @ca_file = .delete(:ca_file) @ssl_version = .delete(:ssl_version) @ssl_min_version = .delete(:ssl_min_version) @ssl_max_version = .delete(:ssl_max_version) @options = filter() self.send(:reset_config!, @options) if self.respond_to?(:reset_config!) self end |
#same_options?(opts) ⇒ Boolean
Check if this client is configured with the same options
100 101 102 |
# File 'lib/azure/storage/common/client_options.rb', line 100 def (opts) opts.length == 0 || opts.hash == .hash end |