June 19, 1012 1.0 CP Customization methods updated according to PBAS v.4.2.
Contents
Changes History 3
Preface 9
Typographi cal Convent i ons .......................................................................................................................... 9
Shell Prompts in Command Examples........................................................................................................ 10
General Conventions................................................................................................................................... 11
XML API 12
Introduction to Parallels Busin e ss Automation - Standard XML API ........................................................ 13
Creating Placeholders for Custom Extended Attributes ................................................................ 205
Customizing Language Packs ................................................................................................................... 206
Language Pack Customization Tools ............................................................................................ 206
Language Pack Customization Sample.......................................................................................... 210
Integration with External Helpdesk 213
External Helpdesk API ............................................................................................................................. 213
Adding New Language Pack 216
Parallels Business Automation - Standard Translation Capabilities ......................................................... 217
Preparing Directories and Files for New Language Pack ......................................................................... 218
Building New Plug-In ............................................................................................................................... 324
Tools 327
Bulk Domain Registration / Transfer ........................................................................................................ 327
Bank Accounts Import .............................................................................................................................. 328
Migration from Parallels Plesk Billing ..................................................................................................... 328
Shell Prompts in Command Examples .................................................................................. 10
General Conventions ............................................................................................................. 11
Typographical Conventions
Before you start using this guide, it is important to understand the documentation conventions
used in it.
The following kinds of formatting in the text identify special information.
Formatting convention Type of Information Example
Special Bold
buttons, or items in a list.
and subsect ions.
Italics
replaced with a real name or
value.
Monospace
files, directories, and do main
names.
Go to the System tab.
Read the Basic Administration
chapter.
The system supports the so
called wildcard character
search.
the
http://docs/common/
licenses directory.
Preface 10
Preformatted
On-screen computer output in
other programming
# ls –al /files
Preformatted Bold
What you type, contrasted
screen computer
# cd /root/rpms/php
Names of keys on the
Key combinations for which
the user must press and hold
your command-line sessions;
source code in XML, C++, or
languages.
with onoutput.
total 14470
CAPITALS
keyboard.
KEY+KEY
down one ke y and the n press
another.
SHIFT, CTRL, ALT
CTRL+P, ALT+F4
Feedback
If you have found a mistake in this guide, or if you have suggestions or ideas on how to improve
this guide, please send your feedback using the online form at
http://www.parallels.com/en/support/usersdoc/. Please include in your report the guide's title,
chapter and section titles, and the fragment of text in which you have found an error.
Shell Prompts in Command
Examples
Command line examples throughout this guide presume that you are using the Bourne-again
shell (bash). Whenever a command can be run as a regular user, we will display it with a dollar
sign prompt. When a command is meant to be run as root, we will display it with a hash mark
prompt:
Bourne-again shell prompt
Bourne-again shell root prompt
$
#
Preface 11
General Conventions
Be aware of the following conventions used in this book.
Chapters in this guide are divided into sections, which, in turn, are subdivided into
subsections. For example, Documentation Conventions is a section, and General Conventions
is a subsection.
When following steps or using examples, be sure to type double-quotes ("), left single-
quotes (`), and right single-quotes (') exactly as shown.
The key referred to as RETURN is labeled ENTER on some keyboards.
The root path usually includes the /bin, /sbin,/usr/bin and /usr/sbin directories, so
the steps in this book show the commands in these directories without absolute path names.
Steps that use commands in other, less common, directories show the absolute paths in the
examples.
XML API has been developed to become primary point of integration with external shopping
carts, billing, and accounting systems and other third-party components.
In This Chapter
Introduction to Parallels Business Automation - Standard XML API .................................. 13
Introduction to Parallels Business
Automation - Standard XML API
Parallels Business Automation - Standard XML API Gate is based on SOAP protocol, currently
maintained by World Wide Web Consortium at http://www.w3c.org and supported by most of
modern programming languages as framework for messages exchange and remote method calls.
Parallels Business Automation - Standard XML API Gate is implemented as mod_perl handler
and inherits from SOAP::Transport::HTTP::Apache, i.e. is based on the functionality
provided by SOAP::Lite module available from CPAN. Please, refer to SOAP::Lite
documentation for general information and this section provides implementation details and
examples.
Module namespaces are package names with '::' included are replaced with '/' - see examples
below.
Security
There are two different strategies used by Parallels Business Automation - St andard XML API
Gate in defining security requirements:
For requests coming from a local machine (directly to backend server without involving
frontend, i.e. originating from the same address space and using http://localhost:8080 or
https://localhost:8443 as Parallels Business Automation - Standard XML API Gate proxy
URL).
For requests coming from remote machines (using frontend for proxying requests to
backend).
Safe packages and methods:
local requests: all packages are considered safe and all their methods are public
remote requests: only packages with namespace starting with HSPC/API are considered as
safe
Authentication and sessions handling:
local requests: authentication by password is possible, but not required, authentication is
possible by account number only,
remote requests: authentication by password is required.
Authentication is done with call to session_open() interface in HSPC/API (on page 18)
namespace and relies on functionality provided by Security Manager.
Interfaces in HSPC/API namespace:
session_open()
Parameters: account_no, e-mail, password
Performs authentication with given parameters (required for remote requests and optional
for local, except for account_no or server_name) and initializes session.
XML API 14
If account_no is set to 0, first account which user has roles in is chosen automatically,
but in this case e-mail and password must be set as well.
If server_name is passed and account_no is empty or missing, account_no is
located by vendor's server name located in server_name parameter.
Returns either unique value to be used as HSPC-SID in next requests (see examples of
clients) or SOAP fault envelope with error message.
session_close()
Performs cleanup of session identified by HSPC-SID header.
Returns undef or SOAP fault envelope with error message.
Configuration
Parallels Business Automation - Standard XML API Gate intended for requests from both
local and remote machines is pre-configured at /hspc/xml-api location.
backend
/etc/hspcd/conf/hspc_xml-api.conf
<Location /hspc/xml-api>
SetHandler perl-script
PerlHandler HSPC::XMLAPI
Order Allow,Deny
Allow from all
</Location>
frontend
/etc/httpd/conf/hspc_frontend.conf:
XML API 15
<VirtualHost _default_:443>
...
SSLEngine on
...
<Location /hspc/xml-api>
Order Deny,Allow
Allow from all
</VirtualHost>
<Location /hspc/xml-api>
Order Deny,Allow
Deny from all
</Location>
Security limitation is set by explicitly allowing /hspc/xml-api location for HTTPS
connections and denying for HTTP connections, so that plain text SOAP envelopes couldn't be
read by intruders.
Parallels Business Automation - Standard XML API Gate could be opened at another locations
as well by configuring backend and frontend server in the same way as described above, i.e. by
adding more Location blocks to backend and frontend servers' configurations.
Servers
Exported methods of packages providing API through Parallels Business Automation - Standard
XML API Gate should rely on the following rules:
in order to be available for remote requests, a package name should start from
HSPC::API:: prefix and have its version set:
our $VERSION = 1.0;
first parameter of each call to exported method is always package name, not reference or
whatever;
$ENV{session} is valid only for requests including session ID returned by
session_open() call, i.e. could be valid for local and always valid for remote requests;
$ENV{security_obj} is valid only for requests including session ID and contains valid
account and user IDs identified by call to session_open() (on page 18);
die with error message to immediately return it in SOAP fault envelope with message as
Notes for HSPstore:
If error code starts with the User prefix, its description is shown to PHP Store visitor, so it
must be localized:
die HSPC::API->fault('UserPassword', string('passwords_do_not_match'));
If error code does not start with the User prefix, its description is not shown to PHP Store
visitor and is only logged to vendor's local log file, so it must not be localized:
XML API 16
die HSPC::API->fault('AuthenRequired', 'Authentication required.');
feel free to return any data structures that you can theo retically ser ialize to XML - and do not
expect an object to arrive at remote side by just returning its blessed reference (guess why it's
just ridiculous).
Examples
HSPC/Test.pm (local requests):
package HSPC::Test;
use strict;
use Data::Dumper;
## returns dump of parameters list, including class name
sub method {
return Dumper(\@_);
}
1;
HSPC/API/Test.pm (remote requests):
package HSPC::API::Test;
use strict;
our $VERSION = 1.0;
## gets/sets parameter with key passed as a parameter
sub param {
my (undef, $key, $value) = @_;
return defined $value
? $ENV{session}->{$key} = $value
: $ENV{session}->{$key};
}
1;
Clients
In order to initialize stable communi cation with Parallels Business Automation - Standard XML
API Gate, first call session_open() in HSPC/API (on page 18) namespace to receive
HSPC-SID value and then add HSPC-SID to either HTTP or SOAP headers to each request
before sending SOAP envelope.
Examples
local.pl:
use SOAP::Lite;
use strict;
my $result = SOAP::Lite
);
if ($client->fault)
die("Fault: {$client->faultstring}");
echo $result;
?>
remote.pl:
use strict;
use SOAP::Lite;
my $client = SOAP::Lite
->proxy('https://192.168.0.100/hspc/xml-api')
->on_fault(sub {die 'Fault: ' . $_[1]->faultstring});
## pass authentication and receive session ID
my $sid = $client->ns('HSPC/API/1.0')->session_open({
email => 'email@provider.com', password => 'password'
})->result->{session_id};
## put session ID to outgoing requests' HTTP headers
$client->transport->http_request->header('HSPC-SID' => $sid);
## make session-dependent calls
$client->ns('HSPC/API/Test/1.0');
$client->param('key' => 'value');
print $client->param('key')->result;
$client->ns('HSPC/API/1.0')->session_close;
remote.php
<? require_once('nusoap.php');
$client = new soap_client('https://192.168.0.100/hspc/xml-api'); // Gate URL
## pass authentication and receive session ID
$sid_result = $client->call('session_open', array (
array ('email' => 'root@provider.com', 'password' => '1q2w3e')
), 'HSPC/API/1.0');
$sid = $sid_result['session_id'];
if ($client->fault)
die("Fault: {$client->faultstring}");
## put session ID to outgoing requests' SOAP headers $client>setHeaders("<HSPC-SID>$sid</HSPC-SID>");
## make session-dependent calls
$client->call('param', array ('key', 'value'), 'HSPC/API/Test/1.0');
if ($client->fault)
die("Fault: {$client->faultstring}");
echo $client->call('param', array ('key'), 'HSPC/API/Test/1.0') . "\n";
if ($client->fault)
die("Fault: {$client->faultstring}");
$client->call('session_close', undef, 'HSPC/API/1.0');
if ($client->fault)
die("Fault: {$client->faultstring}"); ?>
XML API 18
HSPC/API
ID of a vendor account a session is to be
parameter is to be passed in
case of a local Store installation. Optional
Vendor server name used for authentication.
This parameter is to be passed in case of a local
rameter in case
mail. Parameter is to be
specified in case of the Store remote
Registered person password. Parameter is to be
e of the Store remote
The numerical identifier of an account a
session has been opened for. Account ID is
account ID is
session_open
The function opens session with Parallels Business Automation - Standard XML API server.
The input parameters composition depends on the store installation: (local, i.e. Store is installed
on the same server as Parallels Business Automation - Standard or remote, i.e., the Store
installed on a remote server).
In the function call the namespace must be followed by API version number, e.g. HSPC/API/1.0
Note: Sess ion ID return ed by session_open must be included in HTTP Headers or SOAP
Headers for all the other methods called in the frame of each session.
Parameters:
account_id
opened for. This
parameter in case server_name is specified.
server_name
Store installation. Optional pa
account_id is specified.
email Registered person e-
installation together with the password
parameter.
password
specified in cas
installation together with the email parameter.
Returns: {
account_id =>
session_id => }
Parameter Means
account_id
returned in any case, a vendor
then used by the other Store API functions.
session_id The identifier of the opened session.
XML API 19
Common SOAP Faults codes:
Mandatory parameter missing from SOAP
Mandatory parameter missing from SOAP
UserError
method call
WrongParams Invalid method parameters
No specific SOAP Faults codes.
session_close
The function closes session.
In the method call the namespace must be followed by API version number, e.g. HSPC/API/1.0
The function usage is not necessary but recommended.
No parameters.
No return value.
Common SOAP Faults codes:
UserError
method call
WrongParams Invalid method parameters
No specific codes.
XML API 20
HSPC/API/HP
Optional parameter: ID of OS template
selected for a hosing plan. If not passed, then
return the result as if OS
template with the lowest ID (from OSes
included in hosting plan) was passed as
Hosting plan passed as an argument does not
Application(s) passed are incompatible with
check_app_compat
The function checks applications compatibility in Plesk and Virtuozzo Container hosting plans.
Parameters:
hp_sid
app_list
os_tmpl
Returns: result => 1 on success or Fault
SOAP Faults codes:
HPNoApplicationSupport
UserAppIncompat
Hosting plan series key
The list of application templates IDs.
the method will
os_tmpl.
support an application.
each other.
XML API 21
check_license_compat
Hosting plan does not support at least one
The function checks licenses compatibility in hosting plans.
Parameters:
hp_sid
lic_list
Hosting plan series key
The list of licenses IDs
Returns: result => 1 on success or Fault
SOAP Faults codes:
HPNoLicClassSupport
license
HPBaseLicConflict
HPNoBaseForAddon
Base licenses specified are incompatible.
No base license has been specified for an addon license.
XML API 22
get_categorized_plan_list
Optional parameter: The ID of hosting plan
Optional parameter: ID of promotion to be
Optional parameter: ID of account the prices
Optional parameter: Trial site ID. The
efined on redirect from
Optional parameter:Sitebuilder node numeric
Provider account ID is used to get hosting
The method returns the list of hosting plans grouped by categories. Only the basic information is
returned.
The method is similar to get_sellable_plan_list (on page 33). Input parameters are
the same, but output parameters differ: the list of returned hosting plans is grouped by
categories.
Parameters:
type_id
type. Only hosting plans of the type specified
will be returned .
promo_id
applied to hosting plans prices.
account_id
are to be calculated for.
sb_sid
parameter is pred
Sitebuilder.
sb_node
Returns: plan _l is t => HP li st
SOAP Faults codes:
HPProviderNotAllowed
ID assigned in PBAS.
plan details. Only customer or reseller account
ID is allowed as parameter.
XML API 23
get_extended_plan_info
Optional parameter: Hosting plan series key. If
not specified, the information about default
Optional parameter: The ID of promotion to be
account the prices
Optional parameter: Subscription period the
Optional parameter: If this parameter is
ons (custom
Optional parameter: ID of OS template
selected for a hosing plan. If not passed, then
the method will return the result as if OS
template with the lowest ID (from OSes
included in hosting plan) was passed as
The for_trial parameter has been specified, but
Hosting plan series key is not specified and
Provider account ID is used to get hosting plan
details. Only customer or reseller account ID is
The function returns extended information about a hosting plan. Extended information is all the
data not shown in hosting plans listing.
Parameters:
hp_sid
domain hosting plan will be returned.
promo_id
applied to hosting plan prices.
account_id
Optional parameter: ID of
are to be calculated for.
period
discounts are to be calculated for.
for_trial
specified then zero prices for addattributes, applications, etc.) will be returned.
os_tmpl
os_tmpl.
Returns: EXTENDED_HP_INFO (on page 24)
SOAP Faults codes:
HPNoTrial
a hosting plan does not support trial periods.
HPNotFound The hosting plan specified is not found.