Class: XClarityClient::Configuration
- Inherits:
-
Object
- Object
- XClarityClient::Configuration
- Defined in:
- lib/xclarity_client/configuration.rb
Constant Summary collapse
- HEADER_MESSAGE =
'XClarityClient::Configuration initialize'.freeze
Instance Attribute Summary collapse
-
#auth_type ⇒ Object
Returns the value of attribute auth_type.
-
#host ⇒ Object
Returns the value of attribute host.
-
#password ⇒ Object
Returns the value of attribute password.
-
#port ⇒ Object
Returns the value of attribute port.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#user_agent_label ⇒ Object
Returns the value of attribute user_agent_label.
-
#username ⇒ Object
Returns the value of attribute username.
-
#verify_ssl ⇒ Object
Returns the value of attribute verify_ssl.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args) ⇒ Configuration
constructor
A new instance of Configuration.
- #validate_auth_type ⇒ Object
- #validate_port ⇒ Object
- #validate_required_params ⇒ Object
- #validate_timeout ⇒ Object
Constructor Details
#initialize(args) ⇒ Configuration
Returns a new instance of Configuration.
9 10 11 12 13 14 15 16 17 |
# File 'lib/xclarity_client/configuration.rb', line 9 def initialize(args) args.each { |key, value| send("#{key}=", value) } validate_required_params validate_auth_type validate_port validate_timeout $lxca_log.info(HEADER_MESSAGE, 'Configuration built successfully') end |
Instance Attribute Details
#auth_type ⇒ Object
Returns the value of attribute auth_type.
4 5 6 |
# File 'lib/xclarity_client/configuration.rb', line 4 def auth_type @auth_type end |
#host ⇒ Object
Returns the value of attribute host.
4 5 6 |
# File 'lib/xclarity_client/configuration.rb', line 4 def host @host end |
#password ⇒ Object
Returns the value of attribute password.
4 5 6 |
# File 'lib/xclarity_client/configuration.rb', line 4 def password @password end |
#port ⇒ Object
Returns the value of attribute port.
4 5 6 |
# File 'lib/xclarity_client/configuration.rb', line 4 def port @port end |
#timeout ⇒ Object
Returns the value of attribute timeout.
4 5 6 |
# File 'lib/xclarity_client/configuration.rb', line 4 def timeout @timeout end |
#user_agent_label ⇒ Object
Returns the value of attribute user_agent_label.
4 5 6 |
# File 'lib/xclarity_client/configuration.rb', line 4 def user_agent_label @user_agent_label end |
#username ⇒ Object
Returns the value of attribute username.
4 5 6 |
# File 'lib/xclarity_client/configuration.rb', line 4 def username @username end |
#verify_ssl ⇒ Object
Returns the value of attribute verify_ssl.
4 5 6 |
# File 'lib/xclarity_client/configuration.rb', line 4 def verify_ssl @verify_ssl end |
Class Method Details
.default ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/xclarity_client/configuration.rb', line 42 def self.default data = { :username => ENV['LXCA_USERNAME'], :password => ENV['LXCA_PASSWORD'], :host => ENV['LXCA_HOST'], :port => ENV['LXCA_PORT'], :verify_ssl => ENV['LXCA_VERIFY_SSL'] != 'NONE' } new(data) end |
Instance Method Details
#validate_auth_type ⇒ Object
36 37 38 39 40 |
# File 'lib/xclarity_client/configuration.rb', line 36 def validate_auth_type msg = 'The auth_type must be a String' raise_exception(msg) unless auth_type.kind_of?(String) self.auth_type = 'basic_auth' if auth_type.strip.empty? end |
#validate_port ⇒ Object
19 20 21 22 |
# File 'lib/xclarity_client/configuration.rb', line 19 def validate_port msg = 'The port number and host must be valid' raise_exception(msg) unless valid_port?(port) || !host.empty? end |
#validate_required_params ⇒ Object
29 30 31 32 33 34 |
# File 'lib/xclarity_client/configuration.rb', line 29 def validate_required_params required_params = [username, password, host, port, verify_ssl] msg = 'The follow params: username, password, host, port and ' \ 'verify_ssl must all be specified' raise_exception(msg) if required_params.any?(&:nil?) end |
#validate_timeout ⇒ Object
24 25 26 27 |
# File 'lib/xclarity_client/configuration.rb', line 24 def validate_timeout msg = 'the timeout must be in seconds and an Integer' raise_exception(msg) unless timeout.kind_of?(Integer) || timeout.nil? end |