Class: LogStash::Util::CloudSettingAuth

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/util/cloud_setting_auth.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ CloudSettingAuth

Returns a new instance of CloudSettingAuth.



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/logstash/util/cloud_setting_auth.rb', line 7

def initialize(value)
  return if value.nil?

  unless value.is_a?(String)
    raise ArgumentError.new("Cloud Auth must be String. Received: #{value.class}")
  end
  @original = value
  @username, sep, password = @original.partition(":")
  if @username.empty? || sep.empty? || password.empty?
    raise ArgumentError.new("Cloud Auth username and password format should be \"<username>:<password>\".")
  end
  @password = LogStash::Util::Password.new(password)
end

Instance Attribute Details

#originalObject (readonly)

Returns the value of attribute original.



5
6
7
# File 'lib/logstash/util/cloud_setting_auth.rb', line 5

def original
  @original
end

#passwordObject (readonly)

Returns the value of attribute password.



5
6
7
# File 'lib/logstash/util/cloud_setting_auth.rb', line 5

def password
  @password
end

#usernameObject (readonly)

Returns the value of attribute username.



5
6
7
# File 'lib/logstash/util/cloud_setting_auth.rb', line 5

def username
  @username
end

Instance Method Details

#inspectObject



25
26
27
# File 'lib/logstash/util/cloud_setting_auth.rb', line 25

def inspect
  to_s
end

#to_sObject



21
22
23
# File 'lib/logstash/util/cloud_setting_auth.rb', line 21

def to_s
  "#{@username}:#{@password}"
end