API-PleskExpand
view release on metacpan or search on metacpan
Build.PL
Changes
lib/API/PleskExpand.pm
lib/API/PleskExpand/Accounts.pm
lib/API/PleskExpand/Domains.pm
Makefile.PL
MANIFEST This list of files
README
t/expand.t
t/TestData.pm
META.yml Module meta-data (added by MakeMaker)
lib/API/PleskExpand.pm view on Meta::CPAN
use API::Plesk;
use base 'API::Plesk';
use Data::Dumper;
use Carp;
our $VERSION = '1.07';
=head1 NAME
API::PleskExpand - OOP interface to the Plesk Expand XML API (http://www.parallels.com/en/products/plesk/expand/).
=head1 SYNOPSIS
use API::PleskExpand;
use API::Plesk::Response;
my $expand_client = API::PleskExpand->new(%params);
my $res = $expand_client->Func_Module->operation_type(%params);
if ($res->is_success) {
$res->get_data; # return arr ref of answer blocks
}
=head1 DESCRIPTION
At present the module provides interaction with Plesk Expand 2.2.4 (API 2.2.4.1). Complete support of operations with Accounts, partial support of work with domains. Support of addition of domains to user Accounts.
API::PleskExpand module gives the convenient interface for addition of new functions. Extensions represent modules in a folder Plesk with definitions of demanded functions. Each demanded operation is described by two functions: op and op_response_par...
lib/API/PleskExpand.pm view on Meta::CPAN
}
=item AUTOLOADed methods
All other methods are loaded by Autoload from corresponding modules.
Execute some operations (see API::PleskExpand::* modules documentation).
Example:
my $res = $expand_client->Func_Module->operation_type(%params);
# Func_Module -- module in API/PleskExpand folder
# operation_type -- sub which defined in Func_Module.
# params hash used as @_ for operation_type sub.
=back
=cut
lib/API/PleskExpand.pm view on Meta::CPAN
$self->{'url'},
$xml_packet_struct,
headers => $headers
);
}
1;
__END__
=head1 SEE ALSO
Plesk Expand XML RPC API http://www.parallels.com/en/products/plesk/expand/
=head1 AUTHOR
Odintsov Pavel E<lt>nrg[at]cpan.orgE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2008 by NRG
This library is free software; you can redistribute it and/or modify
t/TestData.pm view on Meta::CPAN
package TestData;
use strict;
use warnings;
my $online_expand_url = 'https://your.true.host.ru:8442/webgate.php';
our %online_expand_valid_params = (
api_version => $ENV{'expand_api_version'} || '2.2.4.1',
username => $ENV{'expand_username'} || 'root',
password => $ENV{'expand_password'} || 'qwerty',
url => $ENV{'expand_url'} || $online_expand_url,
debug => '',
request_debug => '',
);
BEGIN {
plan tests => $ENV{online_stress_tests} ? 34 : 28;
use_ok( 'API::PleskExpand' );
use_ok( 'API::PleskExpand::Accounts' );
use_ok( 'API::PleskExpand::Domains' );
use_ok( 'API::Plesk::Response');
}
my $expand_client = API::PleskExpand->new( %TestData::online_expand_valid_params);
isa_ok( $expand_client, 'API::PleskExpand', 'STATIC call new' );
# Calling undefined method from Plesk.pm
{
our $our_warning;
local $SIG{__DIE__} = sub { $our_warning = shift; }; # confess <=> die
eval { API::PleskExpand->new(%TestData::online_expand_valid_params)->aaa__bbbccc() };
like($our_warning, qr/aaa__bbbccc/,
'Checking AUTOLOAD by calling undefined method.');
}
my %create_account_data = (
'select' => 'optimal',
'template-id' => 1,
'general_info' => {
login => 'suxdffffxx',
$create_domain = API::PleskExpand::Domains::create( %new_domain_data, attach_to_template => 1 );
is_string( $create_domain, $_, 'modify account test') for
'<add_use_template><gen_setup><name>y2a1ddsdfandex.ru</name>' .
'<client_id>16</client_id><status>0</status></gen_setup>' .
'<hosting><vrt_hst><ftp_login>nrddgddsdasd</ftp_login>' .
'<ftp_password>dadsdasd</ftp_password></vrt_hst></hosting>' .
'<!-- create_domain --><tmpl_id>1</tmpl_id>' .
'<attach_to_template></attach_to_template></add_use_template>';
$expand_client->{dump_headers} = 1; # debugg =)
is_deeply(
$expand_client->_execute_query('<add_use_template><!-- create_domain --></add_use_template>'),
{
':HTTP_AUTH_LOGIN' => $TestData::online_expand_valid_params{'username'},
':HTTP_AUTH_PASSWD' => $TestData::online_expand_valid_params{'password'},
':HTTP_AUTH_OP' => 'exp_plesk_domain'
},
'test request headers'
);
is_deeply(
$expand_client->_execute_query('<add_use_template><!-- create_client --></add_use_template>'),
{
':HTTP_AUTH_LOGIN' => $TestData::online_expand_valid_params{'username'},
':HTTP_AUTH_PASSWD' => $TestData::online_expand_valid_params{'password'},
':HTTP_AUTH_OP' => 'exp_plesk_client'
},
'exp_plesk_client'
);
$expand_client->{dump_headers} = 0;
my $req_answer1 = {
errtext => "[Operator] Client already exists. Plesk client 'hello_medved' is exist.",
server_id => 1,
status => 'error',
tmpl_id => 1,
expiration => -1,
errcode => 4203,
};
exit unless $ENV{'online_stress_tests'};
my ($domain_template_id, $client_template_id);
$domain_template_id = $client_template_id = $ENV{template_id} || 1;
diag "Online tests start!";
# 5 tests -- full set !!!
my $login = $ENV{'online_stress_tests_login'} || 'expandtestaccount';
my $create_account_result = $expand_client->Accounts->create(
'select' => 'optimal',
'template-id' => $client_template_id,
'attach_to_template' => 1,
'general_info' => {
login => $login,
pname => $login,
passwd => 'asdasdasd',
status => 0,
cname => '',
phone => '',
);
if ($create_account_result->is_success) {
#warn Dumper $create_account_result;
my $client_id = $create_account_result->{answer_data}->[0]->{id};
my $server_id = $create_account_result->{answer_data}->[0]->{server_id};
pass "Account succcessful created!";
my $deactivate_result = $expand_client->Accounts->modify(
general_info => { status => 16 }, # deactivate!
id => $client_id,
);
if ($deactivate_result->is_success) {
pass "Deactivation success!";
my $activate_result = $expand_client->Accounts->modify(
general_info => { status => 0 }, # activate!
id => $client_id,
);
my $plesk_id = $activate_result->get_data->[0]->{plesk_client_id};
if ($activate_result->is_success) {
pass "Activation success!";
my $create_domain = $expand_client->Domains->create(
dname => $login . '.ru',
client_id => $client_id,
'template-id' => $domain_template_id,
'attach_to_template' => 1,
ftp_login => $login,
ftp_password => 'afsfsaf',
);
if ($create_domain->is_success) {
pass "Create domain successful";
my $nop_result = $expand_client->Accounts->modify(
general_info => { }, # blank operation
id => $client_id,
);
if ($nop_result->is_success && $nop_result->get_data->[0]->{plesk_client_id} eq $plesk_id) {
pass "Get plesk_id $plesk_id success";
my $delete_result = $expand_client->Accounts->delete(
id => $client_id,
);
if ( $delete_result->is_success ) {
pass "Delete account success";
} else {
fail "Remove account failed";
exit;
}
( run in 0.871 second using v1.01-cache-2.11-cpan-97f6503c9c8 )