Class: Softlayer::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Config

Returns a new instance of Config.



13
14
15
16
17
18
19
# File 'lib/softlayer/config.rb', line 13

def initialize(params = {})
  @username = params[:username] if params[:username]
  @api_key = params[:api_key] if params[:api_key]
  @open_timeout = 5
  @read_timeout = 5
  @mock = false
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



4
5
6
# File 'lib/softlayer/config.rb', line 4

def api_key
  @api_key
end

#impersonate_tokenObject

Returns the value of attribute impersonate_token.



9
10
11
# File 'lib/softlayer/config.rb', line 9

def impersonate_token
  @impersonate_token
end

#impersonate_userObject

Returns the value of attribute impersonate_user.



8
9
10
# File 'lib/softlayer/config.rb', line 8

def impersonate_user
  @impersonate_user
end

#mockObject

Returns the value of attribute mock.



11
12
13
# File 'lib/softlayer/config.rb', line 11

def mock
  @mock
end

#open_timeoutObject

Returns the value of attribute open_timeout.



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

def open_timeout
  @open_timeout
end

#read_timeoutObject

Returns the value of attribute read_timeout.



6
7
8
# File 'lib/softlayer/config.rb', line 6

def read_timeout
  @read_timeout
end

#usernameObject

Returns the value of attribute username.



3
4
5
# File 'lib/softlayer/config.rb', line 3

def username
  @username
end

Instance Method Details

#check!Object

Check the configuration.

Will raise a Softlayer::Errors::MissingConfigOption if any of the API login ID or the API key are missing.



24
25
26
27
# File 'lib/softlayer/config.rb', line 24

def check!
  fail Softlayer::Errors::MissingConfigOption.new('username') unless username && username.strip.length > 0
  fail Softlayer::Errors::MissingConfigOption.new('api_key') unless api_key && api_key.strip.length > 0
end

#mock?Boolean

Returns:



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

def mock?
  self.mock
end