November 23, 2017


list_agents.rb

list_agents.rb
# List agents.
#
# The script retrieves all the agents in a brand account.
# It displays the same result like in https://agent.softlayer.com/administration/user/list
#
# Important manual pages
# http://sldn.softlayer.com/reference/services/SoftLayer_Account/getUsers
# http://sldn.softlayer.com/reference/services/SoftLayer_User_Customer
#
# License: http://sldn.softlayer.com/article/License
# Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>

require 'softlayer_api'

# Your SoftLayer API username and key.
USERNAME = 'set me'
API_KEY = 'set me'

# Declaring the API client
client = SoftLayer::Client.new(username: USERNAME, api_key: API_KEY)
account_service = client['SoftLayer_Account']
object_mask = 'mask[id, firstName, lastName, username, email, userStatus[name]]'

begin
  result = account_service.setObjectMask(object_mask).getUsers
  print result
rescue StandardError => exception
  puts "Unable to list the agents.: #{exception}"
end

Feedback?

If this article contains any error, or leaves any of your questions unanswered, please help us out by opening up a github issue.
Open an issue