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.



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

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.



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

def original
  @original
end

#passwordObject (readonly)

Returns the value of attribute password.



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

def password
  @password
end

#usernameObject (readonly)

Returns the value of attribute username.



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

def username
  @username
end

Instance Method Details

#inspectObject



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

def inspect
  to_s
end

#to_sObject



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

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