Previous Topic

Next Topic

Locate topic in Contents

Importing Subscriptions Using XML API

Subscriptions import consists in placing a corresponding order an creating a new subscription after this order is completed. An order can be free or not, and this can be defined using the is_free parameter in the place_order function called in the subscription import script. The script is located in the /usr/sbin directory on the Management Node.

Example of subscription import script:

#!/usr/bin/perl

use strict;

# Below is the sample script for order generation based on Parallels Business Automation - Standard XML API.

# Feel free to modify it according to inline comments and XML API documentation.

my $order = place_order({

hp_sid => 1, # hosting plan series key

account_id => 2, # subscription owner

period => 2592000, # subscription period

app_list => [], # IDs of application templates to include in order

attribute_list => [], # IDs of custom attributes to include in order

license_list => [], # IDs of licenses to include in order

login => [ # login parameters for order: password, login, URL

'password',

'login',

'URL',

],

domain_hash => { # domain hash: per-domain configuration hashes, 'ext_data' for registrar

'domain.com' => {

dm_action => 'dns_hosting', # domain action

period => undef, # registration period in years

dns_hosting => 1, # is DNS hosting enabled?

is_default => 1, # is default domain in this order?

hosting_destination => undef, # ID of subscription to assign domain to

ns_list => [], # list of nameservers (non-empty disables DNS hosting!): [hostname, IP], [hostname, IP], ...

contact_hash => {}, # domain contacts, 0 or undef to get from account contacts: { admin => NN, billing => undef, owner => undef }

whois_privacy => 0, # is WHOIS privacy enabled?

},

ext_data => {},

},

for_trial => 0, # is subscription trial?

sb_plan => undef, # Sitebuilder site ID for provisioning

description => 'Generated through XML API',

});

print "Order #$order->{id} has been successfully generated, provisioning initiated.\n";

################################################################################

# below is code for order generation, alter it *only* to archieve special functionality

use SOAP::Lite ();

my $client;

sub place_order {

my $order_details = shift;

$order_details->{is_free} = 1;

# place order and return its structure

return $client->ns('HSPC/API/Billing/1.0')->place_order($order_details)->result;

}

BEGIN {

# create XML API client object

$client = SOAP::Lite

->proxy('http://localhost:8080/hspc/xml-api')

->on_fault(sub {

print 'SOAP Fault: ' . $_[1]->faultcode . ' - ' . $_[1]->faultstring . "\n";

exit(1);

});

# open session: receive session ID for provider

my $sid = $client->ns('HSPC/API/1.0')->session_open({ account_id => 1 })->result->{session_id};

# put session ID to outgoing requests' HTTP headers

$client->transport->http_request->header('HSPC-SID' => $sid);

}

END {

# close session

$client->ns('HSPC/API/1.0')->session_close;

}

Please send us your feedback on this help page