Skip to content

Commit 3248688

Browse files
committed
Cleanup syntax case across classes to better follow Ruby style guide.
This addresses issues raised in #99. We fix most of the case issues and mark the old ones as deprecated and for removal with v4. v4-cleanup-required
1 parent bdae747 commit 3248688

8 files changed

Lines changed: 183 additions & 6 deletions

File tree

lib/softlayer/Account.rb

Lines changed: 40 additions & 0 deletions
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
##

lib/softlayer/NetworkComponent.rb

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,31 @@
66

77
module SoftLayer
88
class NetworkComponent < SoftLayer::ModelBase
9+
##
10+
# :attr_reader: max_speed
11+
# A network component's maximum allowed speed,
12+
sl_attr :max_speed, 'maxSpeed'
13+
14+
##
15+
# :attr_reader:
16+
# A network component's maximum allowed speed,
17+
#
18+
# DEPRECATION WARNING: This attribute is deprecated in favor of max_speed
19+
# and will be removed in the next major release.
20+
sl_attr :maxSpeed
21+
22+
##
23+
# :attr_reader:
24+
# A network component's short name.
925
sl_attr :name
26+
27+
# :attr_reader:
28+
# A network component's port number.
1029
sl_attr :port
30+
31+
##
32+
# :attr_reader:
33+
# A network component's speed, measured in Mbit per second.
1134
sl_attr :speed
12-
sl_attr :maxSpeed
1335
end
1436
end

lib/softlayer/ProductItemCategory.rb

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,22 @@ module SoftLayer
1010
# the product order is the price_id, the rest of the information is provided
1111
# to make the object friendly to humans who may be searching for the
1212
# meaning of a given price_id.
13-
class ProductConfigurationOption < Struct.new(:capacity, :capacityRestrictionMaximum, :capacityRestrictionMinimum,
14-
:capacityRestrictionType, :description, :hourlyRecurringFee, :laborFee, :oneTimeFee, :price_id, :recurringFee,
15-
:requiredCoreCount, :setupFee, :units)
13+
#
14+
# DEPRECATION WARNING: The following configuration option keys have been deprecated and
15+
# will be removed with the next major version: capacityRestrictionMaximum, capacityRestrictionMinimum,
16+
# capacityRestrictionType, hourlyRecurringFee, laborFee, oneTimeFee, recurringFee, requiredCoreCount, setupFee
17+
class ProductConfigurationOption < Struct.new(:capacity, :capacityRestrictionMaximum, :capicity_restriction_maximum,
18+
:capacityRestrictionMinimum, :capacity_restriction_minimum, :capacityRestrictionType, :capacity_restriction_type,
19+
:description, :hourlyRecurringFee, :hourly_recurring_fee, :laborFee, :labor_fee, :oneTimeFee, :one_time_fee,
20+
:price_id, :recurringFee, :recurring_fee, :requiredCoreCount, :required_core_count, :setupFee, :setup_fee, :units)
1621
# Is it evil, or just incongruous to give methods to a struct?
1722

1823
def initialize(package_item_data, price_item_data)
1924
self.capacity = package_item_data['capacity']
2025
self.description = package_item_data['description']
2126
self.units = package_item_data['units']
2227

28+
#DEPRECATION WARNING: All these are deprecated and will be removed with the next major version, pleace use keys below
2329
self.capacityRestrictionMaximum = price_item_data['capacityRestrictionMaximum'] ? price_item_data['capacityRestrictionMaximum'] : nil
2430
self.capacityRestrictionMinimum = price_item_data['capacityRestrictionMinimum'] ? price_item_data['capacityRestrictionMinimum'] : nil
2531
self.capacityRestrictionType = price_item_data['capacityRestrictionType'] ? price_item_data['capacityRestrictionType'] : nil
@@ -30,6 +36,16 @@ def initialize(package_item_data, price_item_data)
3036
self.recurringFee = price_item_data['recurringFee'] ? price_item_data['recurringFee'].to_f : 0.0
3137
self.requiredCoreCount = price_item_data['requiredCoreCount'] ? price_item_data['requiredCoreCount'] : nil
3238
self.setupFee = price_item_data['setupFee'] ? price_item_data['setupFee'].to_f : 0.0
39+
40+
self.capacity_restriction_maximum = price_item_data['capacityRestrictionMaximum'] ? price_item_data['capacityRestrictionMaximum'] : nil
41+
self.capacity_restriction_minimum = price_item_data['capacityRestrictionMinimum'] ? price_item_data['capacityRestrictionMinimum'] : nil
42+
self.capacity_restriction_type = price_item_data['capacityRestrictionType'] ? price_item_data['capacityRestrictionType'] : nil
43+
self.hourly_recurring_fee = price_item_data['hourlyRecurringFee'] ? price_item_data['hourlyRecurringFee'].to_f : 0.0
44+
self.labor_fee = price_item_data['laborFee'] ? price_item_data['laborFee'].to_f : 0.0
45+
self.one_time_fee = price_item_data['oneTimeFee'] ? price_item_data['oneTimeFee'].to_f : 0.0
46+
self.recurring_fee = price_item_data['recurringFee'] ? price_item_data['recurringFee'].to_f : 0.0
47+
self.required_core_count = price_item_data['requiredCoreCount'] ? price_item_data['requiredCoreCount'] : nil
48+
self.setup_fee = price_item_data['setupFee'] ? price_item_data['setupFee'].to_f : 0.0
3349
end
3450

3551
# returns true if the configuration option has no fees associated with it.
@@ -51,10 +67,19 @@ def free?
5167
class ProductItemCategory < ModelBase
5268
include ::SoftLayer::DynamicAttribute
5369

70+
##
71+
# :attr_reader: category_code
72+
# The categoryCode is a primary identifier for a particular
73+
# category. It is a string like 'os' or 'ram'
74+
sl_attr :category_code, 'categoryCode'
75+
5476
##
5577
# :attr_reader:
5678
# The categoryCode is a primary identifier for a particular
5779
# category. It is a string like 'os' or 'ram'
80+
#
81+
# DEPRECATION WARNING: This attribute is deprecated in favor of category_code
82+
# and will be removed in the next major release.
5883
sl_attr :categoryCode
5984

6085
##

lib/softlayer/ProductPackage.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def required_categories
127127
##
128128
# Returns the product category with the given category code (or nil if one cannot be found)
129129
def category(category_code)
130-
categories.find { |category| category.categoryCode == category_code }
130+
categories.find { |category| category.category_code == category_code }
131131
end
132132

133133
##

lib/softlayer/Server.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,17 @@ class Server < SoftLayer::ModelBase
2828
# The domain name SoftLayer has stored for the server
2929
sl_attr :domain
3030

31+
##
32+
# :attr_reader: fully_qualified_domain_name
33+
# A convenience attribute that combines the hostname and domain name
34+
sl_attr :fully_qualified_domain_name, 'fullyQualifiedDomainName'
35+
3136
##
3237
# :attr_reader:
3338
# A convenience attribute that combines the hostname and domain name
39+
#
40+
# DEPRECATION WARNING: This attribute is deprecated in favor of fully_qualified_domain_name
41+
# and will be removed in the next major release.
3442
sl_attr :fullyQualifiedDomainName
3543

3644
##

lib/softlayer/Ticket.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,17 @@ class Ticket < SoftLayer::ModelBase
1717
# The ticket system maintains a fixed set of subjects for tickets that are used to ensure tickets make it to the right folks quickly
1818
sl_attr :subject
1919

20+
##
21+
# :attr_reader: last_edited
22+
# The date the ticket was last updated.
23+
sl_attr :last_edited, 'lastEditDate'
24+
2025
##
2126
# :attr_reader:
2227
# The date the ticket was last updated.
28+
#
29+
# DEPRECATION WARNING: This attribute is deprecated in favor of last_edited
30+
# and will be removed in the next major release.
2331
sl_attr :lastEditDate
2432

2533
##

lib/softlayer/VLANFirewall.rb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,19 @@ module SoftLayer
2020
class VLANFirewall < SoftLayer::ModelBase
2121
include ::SoftLayer::DynamicAttribute
2222

23+
##
24+
# :attr_reader: vlan_number
25+
#
26+
# The number of the VLAN protected by this firewall.
27+
sl_attr :vlan_number, 'vlanNumber'
28+
2329
##
2430
# :attr_reader: VLAN_number
2531
#
2632
# The number of the VLAN protected by this firewall.
2733
#
34+
# DEPRECATION WARNING: This attribute is deprecated in favor of vlan_number
35+
# and will be removed in the next major release.
2836
sl_attr :VLAN_number, 'vlanNumber'
2937

3038
##
@@ -54,13 +62,37 @@ class VLANFirewall < SoftLayer::ModelBase
5462
##
5563
# Returns the name of the primary router the firewall is attached to.
5664
# This is often a "customer router" in one of the datacenters.
65+
def primary_router
66+
return self['primaryRouter']['hostname']
67+
end
68+
69+
##
70+
# Returns the name of the primary router the firewall is attached to.
71+
# This is often a "customer router" in one of the datacenters.
72+
#
73+
# DEPRECATION WARNING: This method is deprecated in favor of primary_router
74+
# and will be removed in the next major release.
5775
def primaryRouter
5876
return self['primaryRouter']['hostname']
5977
end
6078

6179
##
6280
# The fully qualified domain name of the physical device the
6381
# firewall is implemented by.
82+
def fully_qualified_domain_name
83+
if self.has_sl_property?('networkVlanFirewall')
84+
return self['networkVlanFirewall']['fullyQualifiedDomainName']
85+
else
86+
return @softlayer_hash
87+
end
88+
end
89+
90+
##
91+
# The fully qualified domain name of the physical device the
92+
# firewall is implemented by.
93+
#
94+
# DEPRECATION WARNING: This method is deprecated in favor of fully_qualified_domain_name
95+
# and will be removed in the next major release.
6496
def fullyQualifiedDomainName
6597
if self.has_sl_property?('networkVlanFirewall')
6698
return self['networkVlanFirewall']['fullyQualifiedDomainName']

lib/softlayer/VirtualServer.rb

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,76 @@ class VirtualServer < Server
2121
# to the server.
2222
sl_attr :cores, 'maxCpu'
2323

24+
##
25+
# :attr_reader: provision_date
26+
# The date the Virtual Server was provisioned. This attribute can be
27+
# nil if the SoftLayer system has not yet finished provisioning the
28+
# server (consequently this attribute is used by the #wait_until_ready
29+
# method to determine when a server has been provisioned)
30+
sl_attr :provision_date, 'provisionDate'
31+
2432
##
2533
# :attr_reader:
2634
# The date the Virtual Server was provisioned. This attribute can be
2735
# nil if the SoftLayer system has not yet finished provisioning the
2836
# server (consequently this attribute is used by the #wait_until_ready
2937
# method to determine when a server has been provisioned)
38+
#
39+
# DEPRECATION WARNING: This attribute is deprecated in favor of provision_date
40+
# and will be removed in the next major release.
3041
sl_attr :provisionDate
3142

43+
##
44+
# :attr_reader: active_transaction
45+
# The active transaction (if any) for this virtual server. Transactions
46+
# are used to make configuration changes to the server and only one
47+
# transaction can be active at a time.
48+
sl_attr :active_transaction, 'activeTransaction'
49+
3250
##
3351
# :attr_reader:
3452
# The active transaction (if any) for this virtual server. Transactions
3553
# are used to make configuration changes to the server and only one
3654
# transaction can be active at a time.
55+
#
56+
# DEPRECATION WARNING: This attribute is deprecated in favor of active_transaction
57+
# and will be removed in the next major release.
3758
sl_attr :activeTransaction
3859

60+
##
61+
# :attr_reader: block_devices
62+
# Storage devices attached to the server. Storage may be local
63+
# to the host running the Virtual Server, or it may be located
64+
# on the SAN
65+
sl_attr :block_devices, 'blockDevices'
66+
3967
##
4068
# :attr_reader:
4169
# Storage devices attached to the server. Storage may be local
4270
# to the host running the Virtual Server, or it may be located
4371
# on the SAN
72+
#
73+
# DEPRECATION WARNING: This attribute is deprecated in favor of block_devices
74+
# and will be removed in the next major release.
4475
sl_attr :blockDevices
4576

77+
##
78+
# :attr_reader: last_operating_system_reload
79+
# The last operating system reload transaction that was
80+
# run for this server. #wait_until_ready compares the
81+
# ID of this transaction to the ID of the active transaction
82+
# to determine if an OS reload is in progress.
83+
sl_attr :last_operating_system_reload, 'lastOperatingSystemReload'
84+
4685
##
4786
# :attr_reader:
4887
# The last operating system reload transaction that was
4988
# run for this server. #wait_until_ready compares the
5089
# ID of this transaction to the ID of the active transaction
5190
# to determine if an OS reload is in progress.
91+
#
92+
# DEPRECATION WARNING: This attribute is deprecated in favor of last_operating_system_reload
93+
# and will be removed in the next major release.
5294
sl_attr :lastOperatingSystemReload
5395

5496
##
@@ -130,7 +172,7 @@ def wait_until_ready(max_trials, wait_for_transactions = false, seconds_between_
130172
has_os_reload = has_sl_property? :lastOperatingSystemReload
131173
has_active_transaction = has_sl_property? :activeTransaction
132174

133-
reloading_os = has_active_transaction && has_os_reload && (self.lastOperatingSystemReload['id'] == self.activeTransaction['id'])
175+
reloading_os = has_active_transaction && has_os_reload && (self.last_operating_system_reload['id'] == self.active_transaction['id'])
134176
provisioned = has_sl_property?(:provisionDate) && ! self['provisionDate'].empty?
135177

136178
# a server is ready when it is provisioned, not reloading the OS

0 commit comments

Comments
 (0)