Class: SoftLayer::Account

Inherits:
ModelBase show all
Includes:
DynamicAttribute
Defined in:
lib/softlayer/Account.rb

Instance Attribute Summary

Attributes inherited from ModelBase

#softlayer_client

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DynamicAttribute

included

Methods inherited from ModelBase

#[], #has_sl_property?, #initialize, #refresh_details, sl_attr, #to_ary

Constructor Details

This class inherits a constructor from SoftLayer::ModelBase

Class Method Details

.account_for_client(client = nil) ⇒ Object

Using the login credentials in the client, retrieve the account associated with those credentials.



124
125
126
127
128
129
130
131
# File 'lib/softlayer/Account.rb', line 124

def self.(client = nil)
  softlayer_client = client || Client.default_client
  raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client

   = softlayer_client['Account']
  network_hash = .getObject()
  new(softlayer_client, network_hash)
end

Instance Method Details

#address1Object

:attr_reader: The first address line for the primary contact’s address



45
# File 'lib/softlayer/Account.rb', line 45

sl_attr :address1

#address2Object

:attr_reader: The second address line (if any, may be nil) for the primary contact’s address



50
# File 'lib/softlayer/Account.rb', line 50

sl_attr :address2

#bare_metal_serversObject

The Bare Metal Servers (physical hardware) associated with the account. Unless you force these to update, they will be refreshed every five minutes. :call-seq:

bare_metal_servers(force_update=false)


86
87
88
89
90
91
92
93
94
95
96
# File 'lib/softlayer/Account.rb', line 86

sl_dynamic_attr :bare_metal_servers do |bare_metal|
  bare_metal.should_update? do
    @last_bare_metal_update ||= Time.at(0)
    (Time.now - @last_bare_metal_update) > 5 * 60  # update every 5 minutes
  end

  bare_metal.to_update do
    @last_bare_metal_update = Time.now
    BareMetalServer.find_servers(:client => self.softlayer_client)
  end
end

#cityObject

:attr_reader: The city stored as part of the primary contact’s address



55
# File 'lib/softlayer/Account.rb', line 55

sl_attr :city

#companyNameObject

:attr_reader: The company name of the primary contact



30
# File 'lib/softlayer/Account.rb', line 30

sl_attr :companyName

#countryObject

:attr_reader: The country stored as part of the primary contact’s address



68
# File 'lib/softlayer/Account.rb', line 68

sl_attr :country

#firstNameObject

:attr_reader: The given name name of the primary contact



35
# File 'lib/softlayer/Account.rb', line 35

sl_attr :firstName

#lastNameObject

:attr_reader: The surname of the primary contact



40
# File 'lib/softlayer/Account.rb', line 40

sl_attr :lastName

#officePhoneObject

:attr_reader: The office phone nubmer listed for the primary contact



78
# File 'lib/softlayer/Account.rb', line 78

sl_attr :officePhone

#postalCodeObject

:attr_reader: The postal code (in the US, aka. zip code) of the primary contact’s address



73
# File 'lib/softlayer/Account.rb', line 73

sl_attr :postalCode

#serversObject

Get a list of the servers for the account. The list returned includes both bare metal and virtual servers



136
137
138
# File 'lib/softlayer/Account.rb', line 136

def servers
  return self.bare_metal_servers + self.virtual_servers
end

#serviceObject



116
117
118
# File 'lib/softlayer/Account.rb', line 116

def service
  softlayer_client["Account"].object_with_id(self.id)
end

#stateObject

:attr_reader: The two character abbreviation for the state, province, or other similar national division that is part of the address of the primary contact. For addresses outside of the US and Canada, where there may not be an equivalent to a state, this may be ‘NA’ (for not applicable)



63
# File 'lib/softlayer/Account.rb', line 63

sl_attr :state

#virtual_serversObject

The virtual servers (aka. CCIs or Virtual_Guests) associated with the account. Unless you force these to update, they will be refreshed every five minutes. :call-seq:

virtual_servers(force_update=false)


104
105
106
107
108
109
110
111
112
113
114
# File 'lib/softlayer/Account.rb', line 104

sl_dynamic_attr :virtual_servers do |virtual_servers|
  virtual_servers.should_update? do
    @last_virtual_server_update ||= Time.at(0)
    (Time.now - @last_virtual_server_update) > 5 * 60  # update every 5 minutes
  end

  virtual_servers.to_update do
    @last_virtual_server_update = Time.now
    VirtualServer.find_servers(:client => self.softlayer_client)
  end
end