November 23, 2017


list_tags.rb

list_tags.rb
# List the tags for a VSI
#
# The scripts list all the tags set in an arbitrary  VSI,
# it uses the SoftLayer_Virtual_Guest::getTagReferences method
# to get the tags. For more information please see below
#
# Important manual pages:
# http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest
# http://sldn.softlayer.com/reference/datatypes/SoftLayer_Virtual_Guest
# http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/getTagReferences
#
# License: http://sldn.softlayer.com/article/License
# Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
require 'softlayer_api'
require 'pp'

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

# The virtual guestId you wish to get the tags
virtual_guest_id = 784_498_4

client = SoftLayer::Client.new(username: USERNAME, api_key: API_KEY)
virtual_guest_service = client['SoftLayer_Virtual_Guest']

begin
  # Sending the request to get the tags
  result = virtual_guest_service.object_with_id(virtual_guest_id).getTagReferences
  print result
rescue StandardError => exception
  puts "Unable retrieve the tags. : #{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