This is a module and class factory for SoftLayer’s customer portal API (sldn.softlayer.com ). See the rdoc documentation and the sample directory for usage details.

The factory creates classes as they are declared. As a group:

SLAPICLASSES = [ ‘SoftLayer::Account’ ] SLAPISERVICES = [ ‘SoftLayer_Billing_Item’, ‘SoftLayer_Network_Storage’ ] SoftLayer::declareClasses(:ruby => SLAPICLASSES, :soap => SLAPISERVICES)

Or one at a time:

SoftLayer::ClassFactory(:class => ‘SoftLayer::Account’)

Objects are then created and used like normal Ruby objects:

account = SoftLayer::Account.new(:user => AUTH_USER, :key => AUTH_KEY, :initParam => ACCT_ID) puts account.getBalance

The object’s associated Type is available like a hash:

puts account

Object Masks:

account.objectMask = { ‘allBillingItems’ => nil } pp account

API user and key is cached after first use (but can be overridden on a per object basis):

SLAPISERVICES = [ ‘SoftLayer_Account’, ‘SoftLayer_Billing_Item’, ‘SoftLayer_Network_Storage’ ] SoftLayer::declareClasses(:soap => SLAPISERVICES)

account = SoftLayer::Account.new(:user => AUTH_USER, :key => AUTH_KEY, :initParam => ACCT_ID) account.objectMask={ ‘allBillingItems’ => nil, ‘nasNetworkStorage’ => nil } account.each do |bi| billingItem = SoftLayer::Billing::Item.new(:initParam => bi) pp billingItem.getLocation end

account.each do |n| nas = SoftLayer::Network::Storage(:user => OTHER_AUTH_USER, :key => OTHER_AUTH_KEY, :initParam => n) pp nas.capacityGb end

Result Limits:

account.getAllBillingItems(:limit => [X,Y]) do |bia| ( blah ) end

Such that bia is an array containing X or fewer elements; blah executes on each batch until there’s no more.

Without a block, should return the 5 elements offset from Y:

bia = account.getAllBillingItems(:limit => [5,Y]) bia.size <= 5