November 23, 2017


# Get all items from Device list using an object mask
# Important manual pages:
# see
# license <>
# author SoftLayer Technologies, Inc. <>

require 'rubygems'
require 'softlayer_api'

# Your SoftLayer API username.
SL_API_USERNAME = 'set me'

# Your SoftLayer API key.
SL_API_KEY = 'set me'

# Softlayer API public endpoint

softlayer_client = SL_API_USERNAME,
                                         api_key: SL_API_KEY,
                                         endpoint_url: API_PUBLIC_ENDPOINT)

search_service = softlayer_client.service_named('SoftLayer_Search')

# Create an object mask to get more information than by default
mask = 'mask[resource(SoftLayer_Hardware)'\
    '[ id, fullyQualifiedDomainName,datacenter],'\
    '[ id, fullyQualifiedDomainName,datacenter],'\
    '[ id, name,datacenter.longName],'\
    '[ id, fullyQualifiedDomainName,datacenter.longName]]'

# The items with the following Device types should be displayed
# using the below filter:
# Bare Metal Server, Virtual Server, Firewall, Gateway Member, Netscaler,KVM/IP
filter_data = '_objectType:SoftLayer_Hardware,'\
    'SoftLayer_Network_Application_Delivery_Controller '

  # Display all items with specif properties included in the mask.
  result = search_service.object_mask(mask).advancedSearch(filter_data)
  puts 'Process finished successfully'
  p result
rescue StandardError => e
  raise e


We would love to hear it
Open an issue