The following scripts are provided by Samanage as examples and training purposes only and not designed to work in every use case without some modification to the script itself. These scripts are not supported by Samanage as part of your Samanage Master Subscription Agreement, however if you would like this script customized to support your use case, please contact us at API.Scripts@samanage.com for a personal quote.
SamanageAPI is a simple Ruby file that provides a simple platform for working with the Samanage API.
SamanageAPI is a ruby Class that allows you to easily generate API calls to Get/Post/Put items into Samanage by passing a path, email, user and optional data as arguments. To begin using this function, simply require SamanageAPI.rb in your ruby script.
Getting data from Samanage
Example: To 'get' users
users = SamanageAPI.get("users.xml", "firstname.lastname@example.org","password")
When successful users will contain hash with the following keys:
Creating user in Samanage
email = "email@example.com"
pass = "password"
xml = "John Doejohn.firstname.lastname@example.org"
call = SamanageAPI.post("users.xml", email, pass, xml)
Updating users in Samanage
xml = "value"
call = SamanageAPI.put("users/USER_ID.xml", email, pass, xml)
When correct information is entered call["success"] should be set to true and call["code"] will return 201 (Created)