Class: SoftLayer::Account
- Includes:
- DynamicAttribute
- Defined in:
- lib/softlayer/Account.rb
Instance Attribute Summary
Attributes inherited from ModelBase
Class Method Summary collapse
-
.account_for_client(client = nil) ⇒ Object
Using the login credentials in the client, retrieve the account associated with those credentials.
Instance Method Summary collapse
-
#address1 ⇒ Object
:attr_reader: The first address line for the primary contact’s address.
-
#address2 ⇒ Object
:attr_reader: The second address line (if any, may be nil) for the primary contact’s address.
-
#bare_metal_servers ⇒ Object
The Bare Metal Servers (physical hardware) associated with the account.
-
#city ⇒ Object
:attr_reader: The city stored as part of the primary contact’s address.
-
#companyName ⇒ Object
:attr_reader: The company name of the primary contact.
-
#country ⇒ Object
:attr_reader: The country stored as part of the primary contact’s address.
-
#find_VLAN_with_number(vlan_number) ⇒ Object
Searches the account’s list of VLANs for the ones with the given vlan number.
-
#firstName ⇒ Object
:attr_reader: The given name name of the primary contact.
-
#lastName ⇒ Object
:attr_reader: The surname of the primary contact.
-
#officePhone ⇒ Object
:attr_reader: The office phone nubmer listed for the primary contact.
-
#postalCode ⇒ Object
:attr_reader: The postal code (in the US, aka. zip code) of the primary contact’s address.
-
#servers ⇒ Object
Get a list of the servers for the account.
- #service ⇒ Object
-
#state ⇒ Object
: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.
-
#virtual_servers ⇒ Object
The virtual servers (aka. CCIs or Virtual_Guests) associated with the account.
Methods included from DynamicAttribute
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.
151 152 153 154 155 156 157 158 |
# File 'lib/softlayer/Account.rb', line 151 def self.account_for_client(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 account_service = softlayer_client[:Account] network_hash = account_service.getObject() new(softlayer_client, network_hash) end |
Instance Method Details
#address1 ⇒ Object
:attr_reader: The first address line for the primary contact’s address
29 |
# File 'lib/softlayer/Account.rb', line 29 sl_attr :address1 |
#address2 ⇒ Object
:attr_reader: The second address line (if any, may be nil) for the primary contact’s address
34 |
# File 'lib/softlayer/Account.rb', line 34 sl_attr :address2 |
#bare_metal_servers ⇒ Object
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:
(force_update=false)
70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/softlayer/Account.rb', line 70 sl_dynamic_attr :bare_metal_servers do || .should_update? do ||= Time.at(0) (Time.now - ) > 5 * 60 # update every 5 minutes end .to_update do = Time.now BareMetalServer.find_servers(:client => self.softlayer_client) end end |
#city ⇒ Object
:attr_reader: The city stored as part of the primary contact’s address
39 |
# File 'lib/softlayer/Account.rb', line 39 sl_attr :city |
#companyName ⇒ Object
:attr_reader: The company name of the primary contact
14 |
# File 'lib/softlayer/Account.rb', line 14 sl_attr :companyName |
#country ⇒ Object
:attr_reader: The country stored as part of the primary contact’s address
52 |
# File 'lib/softlayer/Account.rb', line 52 sl_attr :country |
#find_VLAN_with_number(vlan_number) ⇒ Object
Searches the account’s list of VLANs for the ones with the given vlan number. This may return multiple results because a VLAN can span different routers and you will get a separate segment for each router.
The IDs of the different segments can be helpful for ordering firewalls.
138 139 140 141 142 143 144 145 |
# File 'lib/softlayer/Account.rb', line 138 def find_VLAN_with_number(vlan_number) filter = SoftLayer::ObjectFilter.new() { |filter| filter.accept('networkVlans.vlanNumber').when_it is vlan_number } vlan_data = self.service.object_mask("mask[id,vlanNumber,primaryRouter,networkSpace]").object_filter(filter).getNetworkVlans return vlan_data end |
#firstName ⇒ Object
:attr_reader: The given name name of the primary contact
19 |
# File 'lib/softlayer/Account.rb', line 19 sl_attr :firstName |
#lastName ⇒ Object
:attr_reader: The surname of the primary contact
24 |
# File 'lib/softlayer/Account.rb', line 24 sl_attr :lastName |
#officePhone ⇒ Object
:attr_reader: The office phone nubmer listed for the primary contact
62 |
# File 'lib/softlayer/Account.rb', line 62 sl_attr :officePhone |
#postalCode ⇒ Object
:attr_reader: The postal code (in the US, aka. zip code) of the primary contact’s address
57 |
# File 'lib/softlayer/Account.rb', line 57 sl_attr :postalCode |
#servers ⇒ Object
Get a list of the servers for the account. The list returned includes both bare metal and virtual servers
163 164 165 |
# File 'lib/softlayer/Account.rb', line 163 def servers return self. + self.virtual_servers end |
#service ⇒ Object
125 126 127 |
# File 'lib/softlayer/Account.rb', line 125 def service softlayer_client[:Account].object_with_id(self.id) end |
#state ⇒ Object
: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)
47 |
# File 'lib/softlayer/Account.rb', line 47 sl_attr :state |
#virtual_servers ⇒ Object
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)
88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/softlayer/Account.rb', line 88 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 |