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
Retrieve 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.
-
#company_name ⇒ Object
:attr_reader: company_name The company name of the primary contact.
-
#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.
-
#evault_master_users ⇒ Object
Retrieve an account’s master EVault user.
-
#find_VLAN_with_number(vlan_number) ⇒ Object
Searches the account’s list of VLANs for the ones with the given vlan number.
-
#find_vlan_with_number(vlan_number) ⇒ Object
Searches the account’s list of VLANs for the ones with the given vlan number.
-
#first_name ⇒ Object
:attr_reader: first_name The given name name of the primary contact.
-
#firstName ⇒ Object
:attr_reader: The given name name of the primary contact.
-
#image_templates ⇒ Object
Retrieve an account’s image templates.
-
#last_name ⇒ Object
:attr_reader: last_name The surname of the primary contact.
-
#lastName ⇒ Object
:attr_reader: The surname of the primary contact.
-
#network_message_delivery_accounts ⇒ Object
Retrieve an account’s network message delivery accounts.
-
#network_storage_groups ⇒ Object
Retrieve an account’s network storage groups.
-
#office_phone ⇒ Object
:attr_reader: office_phone The office phone number listed for the primary contact.
-
#officePhone ⇒ Object
:attr_reader: The office phone number listed for the primary contact.
-
#open_tickets ⇒ Object
Retrieve an account’s open tickets.
-
#postal_code ⇒ Object
:attr_reader: postal_code The postal code (in the US, aka. zip code) of the primary contact’s address.
-
#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.
-
#users ⇒ Object
Retrieve an account’s portal users.
-
#virtual_disk_images ⇒ Object
Retrieve an account’s virtual disk images.
-
#virtual_servers ⇒ Object
Retrieve 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.
300 301 302 303 304 305 306 307 |
# File 'lib/softlayer/Account.rb', line 300 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() Account.new(softlayer_client, network_hash) end |
Instance Method Details
#address1 ⇒ Object
:attr_reader: The first address line for the primary contact’s address
53 |
# File 'lib/softlayer/Account.rb', line 53 sl_attr :address1 |
#address2 ⇒ Object
:attr_reader: The second address line (if any, may be nil) for the primary contact’s address
58 |
# File 'lib/softlayer/Account.rb', line 58 sl_attr :address2 |
#bare_metal_servers ⇒ Object
Retrieve 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)
110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/softlayer/Account.rb', line 110 sl_dynamic_attr :bare_metal_servers do || .should_update? do @last_bare_metal_update ||= Time.at(0) (Time.now - @last_bare_metal_update) > 5 * 60 # update every 5 minutes end .to_update do @last_bare_metal_update = 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
63 |
# File 'lib/softlayer/Account.rb', line 63 sl_attr :city |
#company_name ⇒ Object
:attr_reader: company_name The company name of the primary contact
14 |
# File 'lib/softlayer/Account.rb', line 14 sl_attr :company_name, 'companyName' |
#companyName ⇒ Object
:attr_reader: The company name of the primary contact
DEPRECATION WARNING: This attribute is deprecated in favor of company_name and will be removed in the next major release.
22 |
# File 'lib/softlayer/Account.rb', line 22 sl_attr :companyName |
#country ⇒ Object
:attr_reader: The country stored as part of the primary contact’s address
76 |
# File 'lib/softlayer/Account.rb', line 76 sl_attr :country |
#evault_master_users ⇒ Object
Retrieve an account’s master EVault user. This is only used when an account has an EVault service. :call-seq:
evault_master_users(force_update=false)
127 128 129 130 131 132 133 134 135 136 |
# File 'lib/softlayer/Account.rb', line 127 sl_dynamic_attr :evault_master_users do |evault_users| evault_users.should_update? do @evault_master_users == nil end evault_users.to_update do evault_user_passwords = self.service.object_mask(AccountPassword.default_object_mask).getEvaultMasterUsers evault_user_passwords.collect { |evault_user_password| AccountPassword.new(softlayer_client, evault_user_password) unless evault_user_password.empty? }.compact end end |
#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.
DEPRECATION WARNING: This method is deprecated in favor of find_vlan_with_number and will be removed in the next major release.
287 288 289 290 291 292 293 294 |
# File 'lib/softlayer/Account.rb', line 287 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 |
#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.
267 268 269 270 271 272 273 274 |
# File 'lib/softlayer/Account.rb', line 267 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 |
#first_name ⇒ Object
:attr_reader: first_name The given name name of the primary contact
27 |
# File 'lib/softlayer/Account.rb', line 27 sl_attr :first_name, 'firstName' |
#firstName ⇒ Object
:attr_reader: The given name name of the primary contact
DEPRECATION WARNING: This attribute is deprecated in favor of first_name and will be removed in the next major release.
35 |
# File 'lib/softlayer/Account.rb', line 35 sl_attr :firstName |
#image_templates ⇒ Object
Retrieve an account’s image templates. Unless you force these to update, they will be refreshed every five minutes :call-seq:
image_templates(force_update=false)
143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/softlayer/Account.rb', line 143 sl_dynamic_attr :image_templates do |image_templates| image_templates.should_update? do @last_image_template_update ||= Time.at(0) (Time.now - @last_image_template_update) > 5 * 60 # update every 5 minutes end image_templates.to_update do @last_image_template_update ||= Time.now ImageTemplate.find_private_templates(:client => self.softlayer_client) end end |
#last_name ⇒ Object
:attr_reader: last_name The surname of the primary contact
40 |
# File 'lib/softlayer/Account.rb', line 40 sl_attr :last_name, 'lastName' |
#lastName ⇒ Object
:attr_reader: The surname of the primary contact
DEPRECATION WARNING: This attribute is deprecated in favor of last_name and will be removed in the next major release.
48 |
# File 'lib/softlayer/Account.rb', line 48 sl_attr :lastName |
#network_message_delivery_accounts ⇒ Object
Retrieve an account’s network message delivery accounts. :call-seq:
(force_update=false)
159 160 161 162 163 164 165 166 167 168 |
# File 'lib/softlayer/Account.rb', line 159 sl_dynamic_attr :network_message_delivery_accounts do |net_msg_deliv_accts| net_msg_deliv_accts.should_update? do @network_message_delivery_accounts == nil end net_msg_deliv_accts.to_update do = self.service.object_mask(NetworkMessageDelivery.default_object_mask).getNetworkMessageDeliveryAccounts .collect { |net_msg_deliv_acct| NetworkMessageDelivery.new(softlayer_client, net_msg_deliv_acct) unless net_msg_deliv_acct.empty? }.compact end end |
#network_storage_groups ⇒ Object
Retrieve an account’s network storage groups. :call-seq:
network_storage_groups(force_update=false)
174 175 176 177 178 179 180 181 182 183 |
# File 'lib/softlayer/Account.rb', line 174 sl_dynamic_attr :network_storage_groups do |net_stor_groups| net_stor_groups.should_update? do @network_storage_groups == nil end net_stor_groups.to_update do network_storage_groups = self.service.object_mask(NetworkStorageGroup.default_object_mask).getNetworkStorageGroups network_storage_groups.collect { |net_stor_group| NetworkStorageGroup.new(softlayer_client, net_stor_group) unless net_stor_group.empty? }.compact end end |
#office_phone ⇒ Object
:attr_reader: office_phone The office phone number listed for the primary contact
94 |
# File 'lib/softlayer/Account.rb', line 94 sl_attr :office_phone, 'officePhone' |
#officePhone ⇒ Object
:attr_reader: The office phone number listed for the primary contact
DEPRECATION WARNING: This attribute is deprecated in favor of office_phone and will be removed in the next major release.
102 |
# File 'lib/softlayer/Account.rb', line 102 sl_attr :officePhone |
#open_tickets ⇒ Object
Retrieve an account’s open tickets. Unless you force these to update, they will be refreshed every five minutes :call-seq:
open_tickets(force_update=false)
190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/softlayer/Account.rb', line 190 sl_dynamic_attr :open_tickets do |open_tickets| open_tickets.should_update? do @last_open_tickets_update ||= Time.at(0) (Time.now - @last_open_tickets_update) > 5 * 60 # update every 5 minutes end open_tickets.to_update do @last_open_tickets_update ||= Time.now open_tickets_data = self.service.object_mask(SoftLayer::Ticket.default_object_mask).getOpenTickets open_tickets_data.collect { |ticket_data| SoftLayer::Ticket.new(self.softlayer_client, ticket_data) } end end |
#postal_code ⇒ Object
:attr_reader: postal_code The postal code (in the US, aka. zip code) of the primary contact’s address
81 |
# File 'lib/softlayer/Account.rb', line 81 sl_attr :postal_code, 'postalCode' |
#postalCode ⇒ Object
:attr_reader: The postal code (in the US, aka. zip code) of the primary contact’s address
DEPRECATION WARNING: This attribute is deprecated in favor of postal_code and will be removed in the next major release.
89 |
# File 'lib/softlayer/Account.rb', line 89 sl_attr :postalCode |
#servers ⇒ Object
Get a list of the servers for the account. The list returned includes both bare metal and virtual servers
312 313 314 |
# File 'lib/softlayer/Account.rb', line 312 def servers return self. + self.virtual_servers end |
#service ⇒ Object
254 255 256 |
# File 'lib/softlayer/Account.rb', line 254 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)
71 |
# File 'lib/softlayer/Account.rb', line 71 sl_attr :state |
#users ⇒ Object
Retrieve an account’s portal users. :call-seq:
users(force_update=false)
207 208 209 210 211 212 213 214 215 216 |
# File 'lib/softlayer/Account.rb', line 207 sl_dynamic_attr :users do |users| users.should_update? do @users == nil end users.to_update do account_users = self.service.object_mask(UserCustomer.default_object_mask).getUsers account_users.collect { |account_user| UserCustomer.new(softlayer_client, account_user) unless account_user.empty? }.compact end end |
#virtual_disk_images ⇒ Object
Retrieve an account’s virtual disk images. Unless you force these to update, they will be refreshed every five minutes :call-seq:
virtual_disk_images(force_update=false)
223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/softlayer/Account.rb', line 223 sl_dynamic_attr :virtual_disk_images do |virtual_disk_images| virtual_disk_images.should_update? do @last_virtual_disk_images_update ||= Time.at(0) (Time.now - @last_virtual_disk_images_update) > 5 * 60 # update every 5 minutes end virtual_disk_images.to_update do @last_virtual_disk_images_update ||= Time.now virtual_disk_images_data = self.service.object_mask(SoftLayer::VirtualDiskImage.default_object_mask).getVirtualDiskImages virtual_disk_images_data.collect { |virtual_disk_image| SoftLayer::VirtualDiskImage.new(softlayer_client, virtual_disk_image) } end end |
#virtual_servers ⇒ Object
Retrieve 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)
242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/softlayer/Account.rb', line 242 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 |