Module: Azure::Storage::Common::Configurable

Included in:
Client
Defined in:
lib/azure/storage/common/configurable.rb

Overview

The Azure::Storage::Common::Configurable module provides basic configuration for Azure storage activities.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#signerObject (readonly)

Returns the value of attribute signer.



69
70
71
# File 'lib/azure/storage/common/configurable.rb', line 69

def signer
  @signer
end

#storage_access_keyObject

Returns the value of attribute storage_access_key.



55
56
57
# File 'lib/azure/storage/common/configurable.rb', line 55

def storage_access_key
  @storage_access_key
end

#storage_account_nameString

Returns Azure Storage account name.

Returns:

  • (String)

    Azure Storage account name.



55
56
57
58
# File 'lib/azure/storage/common/configurable.rb', line 55

attr_accessor :storage_access_key,
:storage_account_name,
:storage_connection_string,
:storage_sas_token

#storage_blob_host(isSecondary = false) ⇒ String

Storage blob host

Returns:



55
56
57
58
# File 'lib/azure/storage/common/configurable.rb', line 55

attr_accessor :storage_access_key,
:storage_account_name,
:storage_connection_string,
:storage_sas_token

#storage_blob_host_secondary=(value) ⇒ Object (writeonly)

Sets the attribute storage_blob_host_secondary

Parameters:

  • value

    the value to set the attribute storage_blob_host_secondary to.



60
61
62
# File 'lib/azure/storage/common/configurable.rb', line 60

def storage_blob_host_secondary=(value)
  @storage_blob_host_secondary = value
end

#storage_connection_stringString

Returns Azure Storage connection string.

Returns:

  • (String)

    Azure Storage connection string.



55
56
57
58
# File 'lib/azure/storage/common/configurable.rb', line 55

attr_accessor :storage_access_key,
:storage_account_name,
:storage_connection_string,
:storage_sas_token

#storage_file_host(isSecondary = false) ⇒ String

Storage file host

Returns:



153
154
155
156
157
158
159
# File 'lib/azure/storage/common/configurable.rb', line 153

def storage_file_host(isSecondary = false)
  if isSecondary
    @storage_file_host_secondary || default_host(:file, true)
  else
    @storage_file_host || default_host(:file, false)
  end
end

#storage_file_host_secondary=(value) ⇒ Object (writeonly)

Sets the attribute storage_file_host_secondary

Parameters:

  • value

    the value to set the attribute storage_file_host_secondary to.



60
61
62
# File 'lib/azure/storage/common/configurable.rb', line 60

def storage_file_host_secondary=(value)
  @storage_file_host_secondary = value
end

#storage_queue_host(isSecondary = false) ⇒ String

Storage queue host

Returns:



55
56
57
58
# File 'lib/azure/storage/common/configurable.rb', line 55

attr_accessor :storage_access_key,
:storage_account_name,
:storage_connection_string,
:storage_sas_token

#storage_queue_host_secondary=(value) ⇒ Object (writeonly)

Sets the attribute storage_queue_host_secondary

Parameters:

  • value

    the value to set the attribute storage_queue_host_secondary to.



60
61
62
# File 'lib/azure/storage/common/configurable.rb', line 60

def storage_queue_host_secondary=(value)
  @storage_queue_host_secondary = value
end

#storage_sas_tokenObject

Returns the value of attribute storage_sas_token.



55
56
57
# File 'lib/azure/storage/common/configurable.rb', line 55

def storage_sas_token
  @storage_sas_token
end

#storage_table_host(isSecondary = false) ⇒ String

Storage table host

Returns:



55
56
57
58
# File 'lib/azure/storage/common/configurable.rb', line 55

attr_accessor :storage_access_key,
:storage_account_name,
:storage_connection_string,
:storage_sas_token

#storage_table_host_secondary=(value) ⇒ Object (writeonly)

Sets the attribute storage_table_host_secondary

Parameters:

  • value

    the value to set the attribute storage_table_host_secondary to.



60
61
62
# File 'lib/azure/storage/common/configurable.rb', line 60

def storage_table_host_secondary=(value)
  @storage_table_host_secondary = value
end

Class Method Details

.keysArray

List of configurable keys for Client

Returns:

  • (Array)

    of option keys



74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/azure/storage/common/configurable.rb', line 74

def keys
  @keys ||= [
    :storage_access_key,
    :storage_account_name,
    :storage_connection_string,
    :storage_sas_token,
    :storage_table_host,
    :storage_blob_host,
    :storage_queue_host,
    :storage_file_host,
    :signer
  ]
end

Instance Method Details

#configObject



94
95
96
# File 'lib/azure/storage/common/configurable.rb', line 94

def config
  self
end

#configure {|_self| ... } ⇒ Object

Set configuration options using a block

Yields:

  • (_self)

Yield Parameters:



90
91
92
# File 'lib/azure/storage/common/configurable.rb', line 90

def configure
  yield self
end

#reset_config!(options = {}) ⇒ Object Also known as: setup

Reset configuration options to default values



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/azure/storage/common/configurable.rb', line 99

def reset_config!(options = {})
  Azure::Storage::Common::Configurable.keys.each do |key|
    value =
      if self == Azure::Storage::Common
        Azure::Storage::Common::Default.options[key]
      else
        self.send(key)
      end
    instance_variable_set(:"@#{key}", options.fetch(key, value))

    # Set the secondary endpoint if the primary one is given
    if key.to_s.include? "host"
      instance_variable_set(:"@#{key}_secondary", secondary_endpoint(options.fetch(key, value)))
    end
  end
  self.send(:reset_agents!) if self.respond_to?(:reset_agents!)
  setup_signer_for_service(options[:api_version])
  self
end