November 23, 2017


create_notification_suscribers.rb
create_notification_suscribers.rb

#
# Create a notification subscription
#
# The script creates a notification for a determinate user in a determinate Virtual Guest
# for more reference see these reference pages
#
# Important manual pages
# http://sldn.softlayer.com/reference/services/SoftLayer_User_Customer_Notification_Virtual_Guest/createObject
# http://sldn.softlayer.com/reference/datatypes/SoftLayer_User_Customer_Notification_Virtual_Guests
#
# License: http://sldn.softlayer.com/article/License
# Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
require 'softlayer_api'
require 'pp'

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

# Build a SoftLayer_User_Customer_Notification_Virtual_Guest skeleton object
# which contains the virtual guest id and user id of the notification
new_notification = [
  {
    'guestId' => 7_698_972,
    'userId' => 205_832
  }
]

# Declare the API client
client = SoftLayer::Client.new(username: USERNAME, api_key: API_KEY)
user_customer_notificiation = client.service_named('SoftLayer_User_Customer_Notification_Virtual_Guest')

begin
  result = user_customer_notificiation.createObjects(new_notification)
  print result
rescue StandardError => e
  puts "Unable to create a new notification :-( -- #{e}"
end

Feedback?

We would love to hear it
Open an issue