This is an example of how to use the Memset API with Ruby and the XMLRPC library.
Substitute API_KEY_HEX with a valid API key.
#!/usr/bin/env ruby
#
# Memset API example with Ruby.
#
# Requires XMLRPC library.
#
require 'xmlrpc/client'
require 'pp'
API_URL = "https://API_KEY_HEX:@api.memset.com/v1/xmlrpc"
server = XMLRPC::Client.new2(API_URL)
result = server.call("system.listMethods")
pp result
# methods must use named parameters
result = server.call("service.info", { :name => "myserver1" })
pp result
begin
result = server.call("service.info", { :name => "doesnotexist" })
rescue XMLRPC::FaultException => ex
print "Remote call failed (method doesnotexist): " + ex + "\n"
end
result = server.call("server.reboot", { :name => "myserver1" })
pp result