Ruby

Ruby has standard class for XML-RPC called XMLRPC::Client – you can find the documentation at http://www.ruby-doc.org/stdlib/libdoc/xmlrpc/rdoc/classes/XMLRPC/Client.html.

1. Load class XMLRPC::Client.

require "xmlrpc/client"

2. Define structs AuthInfo, ServerAddress and CreationParameters.

AuthInfo = Struct.new( "AuthInfo", :login, :password )
ServerAddress = Struct.new( "ServerAddress", :ips, :macs )
CreationParameters = Struct.new( "CreationParameters", :hwid )

3. Define server connection.

server = XMLRPC::Client.new2( 'https://ka.plesk.com:7050/', nil, 900 )

4. Perform call to server and store response in result variable. Start with a begin. The code starting from here should be put into an begin/end block to catch possible exceptions. The method requires the following parameters:

  • String: method name
  • Struct: authInfo
  • String: kaclient
  • String: keytype
  • Array: features (pay attention that even if you only have a single feature or even none, you need to send an array)
  • Struct: CreationParameters for main Key
  • Array: additional Keys
  • Struct: CreationParameters for additional Keys
begin
puts 'Performing Call'
result = server.call( "partner10.createKey",
AuthInfo.new( "API_USER", "API_PASSWORD" ),
ServerAddress.new( [ "192.168.62.80" ], [] ),
'ka-client',
'VIRTUOZZO_2X3X',
['2CPU_40VPS'],
CreationParameters.new('2111.4355.5697.53D9.C5B3.766A.843A.1984' ),
[ 'VIRTUOZZO_TOOLS' ],
CreationParameters.new( '2111.4355.5697.53D9.C5B3.766A.843A.1984' ))

5. Print out result from response.

puts "Contents:"
result.each { | key, value | puts "#{key}: #{value}" }

6. Catch exceptions and finish begin/end block with end.

rescue XMLRPC::FaultException => e
puts "Error:"
puts e.faultCode
puts e.faultString
end
 

Leave your feedback on this topic here

If you have questions or need support, please visit the Plesk forum or contact your hosting provider.
The comments below are for feedback on the documentation only. No timely answers or help will be provided.