Skip to content

Commit 2aee085

Browse files
committed
Merge pull request #100 from ju2wheels/feature/case_cleanup
Cleanup syntax case across classes to better follow Ruby style guide.
2 parents bdae747 + 1b19697 commit 2aee085

24 files changed

Lines changed: 482 additions & 118 deletions

lib/softlayer/Account.rb

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,43 @@ module SoftLayer
88
class Account < SoftLayer::ModelBase
99
include ::SoftLayer::DynamicAttribute
1010

11+
##
12+
# :attr_reader: company_name
13+
# The company name of the primary contact
14+
sl_attr :company_name, 'companyName'
15+
1116
##
1217
# :attr_reader:
1318
# The company name of the primary contact
19+
#
20+
# DEPRECATION WARNING: This attribute is deprecated in favor of company_name
21+
# and will be removed in the next major release.
1422
sl_attr :companyName
1523

24+
##
25+
# :attr_reader: first_name
26+
# The given name name of the primary contact
27+
sl_attr :first_name, 'firstName'
28+
1629
##
1730
# :attr_reader:
1831
# The given name name of the primary contact
32+
#
33+
# DEPRECATION WARNING: This attribute is deprecated in favor of first_name
34+
# and will be removed in the next major release.
1935
sl_attr :firstName
2036

37+
##
38+
# :attr_reader: last_name
39+
# The surname of the primary contact
40+
sl_attr :last_name, 'lastName'
41+
2142
##
2243
# :attr_reader:
2344
# The surname of the primary contact
45+
#
46+
# DEPRECATION WARNING: This attribute is deprecated in favor of last_name
47+
# and will be removed in the next major release.
2448
sl_attr :lastName
2549

2650
##
@@ -51,14 +75,30 @@ class Account < SoftLayer::ModelBase
5175
# The country stored as part of the primary contact's address
5276
sl_attr :country
5377

78+
##
79+
# :attr_reader: postal_code
80+
# The postal code (in the US, aka. zip code) of the primary contact's address
81+
sl_attr :postal_code, 'postalCode'
82+
5483
##
5584
# :attr_reader:
5685
# The postal code (in the US, aka. zip code) of the primary contact's address
86+
#
87+
# DEPRECATION WARNING: This attribute is deprecated in favor of postal_code
88+
# and will be removed in the next major release.
5789
sl_attr :postalCode
5890

91+
##
92+
# :attr_reader: office_phone
93+
# The office phone number listed for the primary contact
94+
sl_attr :office_phone, 'officePhone'
95+
5996
##
6097
# :attr_reader:
6198
# The office phone number listed for the primary contact
99+
#
100+
# DEPRECATION WARNING: This attribute is deprecated in favor of office_phone
101+
# and will be removed in the next major release.
62102
sl_attr :officePhone
63103

64104
##
@@ -224,6 +264,26 @@ def service
224264
# The IDs of the different segments can be helpful for ordering
225265
# firewalls.
226266
#
267+
def find_vlan_with_number(vlan_number)
268+
filter = SoftLayer::ObjectFilter.new() { |filter|
269+
filter.accept('networkVlans.vlanNumber').when_it is vlan_number
270+
}
271+
272+
vlan_data = self.service.object_mask("mask[id,vlanNumber,primaryRouter,networkSpace]").object_filter(filter).getNetworkVlans
273+
return vlan_data
274+
end
275+
276+
##
277+
# Searches the account's list of VLANs for the ones with the given
278+
# vlan number. This may return multiple results because a VLAN can
279+
# span different routers and you will get a separate segment for
280+
# each router.
281+
#
282+
# The IDs of the different segments can be helpful for ordering
283+
# firewalls.
284+
#
285+
# DEPRECATION WARNING: This method is deprecated in favor of find_vlan_with_number
286+
# and will be removed in the next major release.
227287
def find_VLAN_with_number(vlan_number)
228288
filter = SoftLayer::ObjectFilter.new() { |filter|
229289
filter.accept('networkVlans.vlanNumber').when_it is vlan_number
@@ -243,7 +303,7 @@ def self.account_for_client(client = nil)
243303

244304
account_service = softlayer_client[:Account]
245305
network_hash = account_service.getObject()
246-
new(softlayer_client, network_hash)
306+
Account.new(softlayer_client, network_hash)
247307
end
248308

249309
##

lib/softlayer/AccountPassword.rb

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,19 @@ def password=(password)
7979
# * <b>+:datacenter+</b> (string/array) - Include network storage account passwords from servers matching this datacenter
8080
# * <b>+:domain+</b> (string/array) - Include network storage account passwords from servers matching this domain
8181
# * <b>+:hostname+</b> (string/array) - Include network storage account passwords from servers matching this hostname
82-
# * <b>+:network_storage_server_type+</b> (string) - Include network storage account passwords attached to this server type
83-
# * <b>+:network_storage_type+</b> (string) - Include network storage account passwords from devices of this storage type
82+
# * <b>+:network_storage_server_type+</b> (symbol) - Include network storage account passwords attached to this server type
83+
# * <b>+:network_storage_type+</b> (symbol) - Include network storage account passwords from devices of this storage type
8484
# * <b>+:tags+</b> (string/array) - Include network storage account passwords from servers matching these tags
8585
# * <b>+:username+</b> (string/array) - Include network storage account passwords with this username only
8686
#
87+
# Additionally you may provide options related to the request itself:
88+
# * <b>*:account_password_object_filter*</b> (ObjectFilter) - Include network storage account passwords for account passwords that match the
89+
# criteria of this object filter
90+
# * <b>*:account_password_object_mask*</b> (string) - The object mask of properties you wish to receive for the items returned.
91+
# If not provided, the result will use the default object mask
92+
# * <b>*:network_storage_object_filter*</b> (ObjectFilter) - Include network storage account passwords from network storage that matches the
93+
# criteria of this object filter
94+
#
8795
def self.find_network_storage_account_passwords(options_hash = {})
8896
softlayer_client = options_hash[:client] || Client.default_client
8997
raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client
@@ -197,11 +205,19 @@ def self.find_network_storage_account_passwords(options_hash = {})
197205
# * <b>+:datacenter+</b> (string/array) - Include network storage webcc passwords from servers matching this datacenter
198206
# * <b>+:domain+</b> (string/array) - Include network storage webcc passwords from servers matching this domain
199207
# * <b>+:hostname+</b> (string/array) - Include network storage webcc passwords from servers matching this hostname
200-
# * <b>+:network_storage_server_type+</b> (string) - Include network storage webcc passwords attached to this server type
201-
# * <b>+:network_storage_type+</b> (string) - Include network storage webcc passwords from devices of this storage type
208+
# * <b>+:network_storage_server_type+</b> (symbol) - Include network storage webcc passwords attached to this server type
209+
# * <b>+:network_storage_type+</b> (symbol) - Include network storage webcc passwords from devices of this storage type
202210
# * <b>+:tags+</b> (string/array) - Include network storage webcc passwords from servers matching these tags
203211
# * <b>+:username+</b> (string/array) - Include network storage webcc passwords with this username only
204212
#
213+
# Additionally you may provide options related to the request itself:
214+
# * <b>*:network_storage_object_filter*</b> (ObjectFilter) - Include network storage account passwords from network storage that matches the
215+
# criteria of this object filter
216+
# * <b>*:webcc_password_object_filter*</b> (ObjectFilter) - Include network storage account passwords for webcc passwords that match the
217+
# criteria of this object filter
218+
# * <b>*:webcc_password_object_mask*</b> (string) - The object mask of properties you wish to receive for the items returned.
219+
# If not provided, the result will use the default object mask
220+
#
205221
def self.find_network_storage_webcc_passwords(options_hash = {})
206222
softlayer_client = options_hash[:client] || Client.default_client
207223
raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client

lib/softlayer/BareMetalServer.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ def firewall_port_speed
155155
#
156156
# If no client is given, then the routine will try to use Client.default_client
157157
# If no client can be found the routine will raise an error.
158+
#
159+
# Additionally you may provide options related to the request itself:
160+
# * <b>*:object_mask*</b> (string) - The object mask of properties you wish to receive for the items returned.
161+
# If not provided, the result will use the default object mask
158162
def self.server_with_id(server_id, options = {})
159163
softlayer_client = options[:client] || Client.default_client
160164
raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client
@@ -194,9 +198,11 @@ def self.server_with_id(server_id, options = {})
194198
# * <b>+:private_ip+</b> (string/array) - same as :public_ip, but for private IP addresses
195199
#
196200
# Additionally you may provide options related to the request itself:
197-
#
198-
# * <b>+:object_mask+</b> (string, hash, or array) - The object mask of properties you wish to receive for the items returned If not provided, the result will use the default object mask
199-
# * <b>+:result_limit+</b> (hash with :limit, and :offset keys) - Limit the scope of results returned.
201+
# * <b>*:object_filter*</b> (ObjectFilter) - Include hardware servers for servers that matche the
202+
# criteria of this object filter
203+
# * <b>+:object_mask+</b> (string, hash, or array) - The object mask of properties you wish to receive for the items returned.
204+
# If not provided, the result will use the default object mask
205+
# * <b>+:result_limit+</b> (hash with :limit, and :offset keys) - Limit the scope of results returned.
200206
#
201207
def self.find_servers(options_hash = {})
202208
softlayer_client = options_hash[:client] || Client.default_client
@@ -231,16 +237,10 @@ def self.find_servers(options_hash = {})
231237
account_service = softlayer_client[:Account]
232238
account_service = account_service.object_filter(object_filter) unless object_filter.empty?
233239
account_service = account_service.object_mask(default_object_mask.to_sl_object_mask)
240+
account_service = account_service.object_mask(options_hash[:object_mask]) if options_hash[:object_mask]
234241

235-
if(options_hash.has_key? :object_mask)
236-
account_service = account_service.object_mask(options_hash[:object_mask])
237-
end
238-
239-
if options_hash.has_key?(:result_limit)
240-
offset = options[:result_limit][:offset]
241-
limit = options[:result_limit][:limit]
242-
243-
account_service = account_service.result_limit(offset, limit)
242+
if options_hash[:result_limit] && options_hash[:result_limit][:offset] && options_hash[:result_limit][:limit]
243+
account_service = account_service.result_limit(options_hash[:result_limit][:offset], options_hash[:result_limit][:limit])
244244
end
245245

246246
bare_metal_data = account_service.getHardware()

lib/softlayer/BareMetalServerOrder.rb

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ class BareMetalServerOrder
7878
# Object responding to to_s and providing a valid URI, The URI of a post provisioning script to run on
7979
# this server once it is created.
8080
# Corresponds to +postInstallScriptUri+ in the +createObject+ documentation
81+
attr_accessor :provision_script_uri
82+
83+
# Object responding to to_s and providing a valid URI, The URI of a post provisioning script to run on
84+
# this server once it is created.
85+
# Corresponds to +postInstallScriptUri+ in the +createObject+ documentation
86+
#
87+
# DEPRECATION WARNING: This attribute is deprecated in favor of provision_script_uri
88+
# and will be removed in the next major release.
8189
attr_accessor :provision_script_URI
8290

8391
# Boolean, If true then the server will only have a private network interface (and no public network interface)
@@ -149,13 +157,14 @@ def hardware_instance_template
149157

150158
template['privateNetworkOnlyFlag'] = true if @private_network_only
151159

152-
template['datacenter'] = {"name" => @datacenter.name} if @datacenter
153-
template['userData'] = [{'value' => @user_metadata}] if @user_metadata
154-
template['networkComponents'] = [{'maxSpeed'=> @max_port_speed}] if @max_port_speed
155-
template['postInstallScriptUri'] = @provision_script_URI.to_s if @provision_script_URI
156-
template['sshKeys'] = @ssh_key_ids.collect { |ssh_key| {'id'=> ssh_key.to_i } } if @ssh_key_ids
157-
template['primaryNetworkComponent'] = { "networkVlan" => { "id" => @public_vlan_id.to_i } } if @public_vlan_id
160+
template['datacenter'] = {"name" => @datacenter.name} if @datacenter
161+
template['userData'] = [{'value' => @user_metadata}] if @user_metadata
162+
template['networkComponents'] = [{'maxSpeed'=> @max_port_speed}] if @max_port_speed
163+
template['postInstallScriptUri'] = @provision_script_URI.to_s if @provision_script_URI
164+
template['postInstallScriptUri'] = @provision_script_uri.to_s if @provision_script_uri
165+
template['primaryNetworkComponent'] = { "networkVlan" => { "id" => @public_vlan_id.to_i } } if @public_vlan_id
158166
template['primaryBackendNetworkComponent'] = { "networkVlan" => {"id" => @private_vlan_id.to_i } } if @private_vlan_id
167+
template['sshKeys'] = @ssh_key_ids.collect { |ssh_key| {'id'=> ssh_key.to_i } } if @ssh_key_ids
159168

160169
if @disks && !@disks.empty?
161170
template['hardDrives'] = @disks.collect do |disk|

lib/softlayer/BareMetalServerOrder_Package.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ class BareMetalServerOrder_Package < Server
7575

7676
# The URI of a script to execute on the server after it has been provisioned. This may be
7777
# any object which accepts the to_s message. The resulting string will be passed to SoftLayer API.
78+
attr_accessor :provision_script_uri
79+
80+
# The URI of a script to execute on the server after it has been provisioned. This may be
81+
# any object which accepts the to_s message. The resulting string will be passed to SoftLayer API.
82+
#
83+
# DEPRECATION WARNING: This attribute is deprecated in favor of provision_script_uri
84+
# and will be removed in the next major release.
7885
attr_accessor :provision_script_URI
7986

8087
# An array of the ids of SSH keys to install on the server upon provisioning
@@ -151,6 +158,7 @@ def hardware_order
151158
product_order['imageTemplateGlobalIdentifier'] = @image_template.global_id if @image_template
152159
product_order['location'] = @datacenter.id if @datacenter
153160
product_order['provisionScripts'] = [@provision_script_URI.to_s] if @provision_script_URI
161+
product_order['provisionScripts'] = [@provision_script_uri.to_s] if @provision_script_uri
154162
product_order['sshKeys'] = [{ 'sshKeyIds' => @ssh_key_ids }] if @ssh_key_ids
155163
product_order['primaryNetworkComponent'] = { "networkVlan" => { "id" => @public_vlan_id.to_i } } if @public_vlan_id
156164
product_order['primaryBackendNetworkComponent'] = { "networkVlan" => {"id" => @private_vlan_id.to_i } } if @private_vlan_id

0 commit comments

Comments
 (0)