Module: Azure::Storage::ClientOptions

Included in:
Client
Defined in:
lib/azure/storage/core/client_options.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name) ⇒ Object (private)


147
148
149
150
# File 'lib/azure/storage/core/client_options.rb', line 147

def method_missing(method_name)
  return super unless options.key? method_name
  options[method_name]
end

Instance Attribute Details

#ca_fileObject

Returns the value of attribute ca_file


23
24
25
# File 'lib/azure/storage/core/client_options.rb', line 23

def ca_file
  @ca_file
end

Class Method Details

.connection_string_mappingHash

The mapping between Storage Connection String items and the options name


124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/azure/storage/core/client_options.rb', line 124

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_mappingHash

The mapping between Storage Environment Variables and the options name


106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/azure/storage/core/client_options.rb', line 106

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_optionsArray

The valid options for the storage client


85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/azure/storage/core/client_options.rb', line 85

def self.valid_options
  @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

#optionsHash

The options after validated and normalized


78
79
80
# File 'lib/azure/storage/core/client_options.rb', line 78

def options
  @options ||= {}
end

#reset!(options = {}) ⇒ Azure::Storage::Client

Public: Reset options for [Azure::Storage::Client]

Attributes

  • options - Hash. Optional parameters.

Options

Accepted key/value pairs in options parameter are:

  • :use_development_storage - TrueClass. Whether to use storage emulator.

  • :development_storage_proxy_uri - String. Used with :use_development_storage if emulator is hosted other than localhost.

  • :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 signiture 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

The valid set of options inlcude:

  • 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::ClientOptions.env_vars_mapping] for the mapping relationship


63
64
65
66
67
68
69
70
71
72
73
# File 'lib/azure/storage/core/client_options.rb', line 63

def reset!(options = {})
  if options.is_a? String
    options = parse_connection_string(options)
  end
  
  options = load_env if options.length == 0
  @ca_file = options.delete(:ca_file)
  @options = filter(options)
  self.send(:reset_config!, @options) if self.respond_to?(:reset_config!)
  self
end