Class: Conoha::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/conoha/config.rb

Defined Under Namespace

Classes: Account, Error

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#accountsObject (readonly)

Returns the value of attribute accounts.



5
6
7
# File 'lib/conoha/config.rb', line 5

def accounts
  @accounts
end

#authtokenObject

Returns the value of attribute authtoken.



5
6
7
# File 'lib/conoha/config.rb', line 5

def authtoken
  @authtoken
end

#passwordObject (readonly)

Returns the value of attribute password.



5
6
7
# File 'lib/conoha/config.rb', line 5

def password
  @password
end

#public_keyObject (readonly)

Returns the value of attribute public_key.



5
6
7
# File 'lib/conoha/config.rb', line 5

def public_key
  @public_key
end

#tenant_idObject (readonly)

Returns the value of attribute tenant_id.



5
6
7
# File 'lib/conoha/config.rb', line 5

def tenant_id
  @tenant_id
end

#usernameObject (readonly)

Returns the value of attribute username.



5
6
7
# File 'lib/conoha/config.rb', line 5

def username
  @username
end

Instance Method Details

#load_from_json!(json_str) ⇒ Object

Raises:



34
35
36
37
38
39
40
41
42
43
# File 'lib/conoha/config.rb', line 34

def load_from_json!(json_str)
  parsed = JSON.parse json_str
  raise Error.new unless parsed.is_a? Hash
  @username = parsed["username"]
  @password = parsed["password"]
  @tenant_id = parsed["tenant_id"]
  @public_key = parsed["public_key"]
  @authtoken = parsed["authtoken"]
  @accounts = parsed["accounts"]&.map { |e| Account.new e }
end

#load_from_yaml!(yaml_str) ⇒ Object

Raises:



29
30
31
32
# File 'lib/conoha/config.rb', line 29

def load_from_yaml!(yaml_str)
  loaded = YAML.load yaml_str
  raise Error.new unless loaded.is_a? Hash
end