API-PleskExpand
view release on metacpan or search on metacpan
1.00 May 25 20:08:15 SAMST 2008
- The first public release
1.01 Jun 1 19:07:04 SAMST 2008
- Fix syntax error in Build.PL :(
- Fix errors in documentation
1.02 Jun 8 13:32:18 SAMST 2008
- Full support all ways of choosing a Plesk server, where the client will be created (autoselect and manual)
1.03 Jun 14 12:16:24 SAMST 2008
- Fix documentation, add tests
1.04 Jun 22 05:21:18 SAMST 2008
- Add ability to attaching domains and accounts to templates
1.05 Jul 29 23:33:12 SAMST 2008
- New function -- get all domains from Expand
1.06 Jul 31 17:34:55 SAMST 2008
- Fixed Build.pl ( Test::LongString not in prereqs_build list but required )
- Add URI.pm as required module
1.07 Sep 12 01:04:09 SAMST 2008
- New function -- get all accounts from Expand
- Fix function "get all domains from Expand" -- bug with one field answer
lib/API/PleskExpand/Accounts.pm view on Meta::CPAN
=head1 METHODS
=over 3
=item create()
Params:
'select' => 'optimal',
'template-id' => 1,
'attach_to_template' => 1, # attach account to a certain template
'general_info' => {
login => 'plesk_login',
pname => 'perldonal name',
passwd => 'userpasswd',
status => 0, # active
cname => '', # company name
phone => '',
fax => '',
email => '',
address => '',
lib/API/PleskExpand/Accounts.pm view on Meta::CPAN
# STATIC
sub create {
my %params = @_;
if (ref $params{'general_info'} eq 'HASH') {
my $template = '';
if ($params{'template-id'}) {
$template = create_node('tmpl_id', $params{'template-id'}) .
( $params{'attach_to_template'} ? create_node('attach_to_template', '') : '' );
} else {
return ''; # template required
}
my $select = '';
if ($params{'select'}) {
if ( $params{'group_id'} ) {
$select = create_node( 'server_auto', create_node( $params{'select'}, '') .
lib/API/PleskExpand/Domains.pm view on Meta::CPAN
=item create()
Params:
dname => 'yandex.ru', # domain name
client_id => 9, # add domain to client with certain id
'template-id' => 1, # domain template id
ftp_login => 'nrgsdasd', # username for ftp
ftp_password => 'dasdasd', # password for ftp account
attach_to_template => 1, # attach domain to template ? 1 -- yes, 0 -- no
Return:
$VAR1 = bless( {
'answer_data' => [ {
'server_id' => '1',
'status' => 'ok',
'expiration' => '-1',
'tmpl_id' => '1',
'client_id' => '16',
lib/API/PleskExpand/Domains.pm view on Meta::CPAN
my %params = @_;
return '' unless $params{'dname'} &&
#$params{'ip'} &&
$params{'client_id'} &&
$params{'ftp_login'} &&
$params{'ftp_password'} &&
$params{'template-id'};
$params{'attach_to_template'} ||= '';
my $hosting_block = create_node('hosting',
generate_info_block(
'vrt_hst',
'ftp_login' => $params{'ftp_login'},
'ftp_password' => $params{'ftp_password'},
)
);
my $template_block = create_node('tmpl_id', $params{'template-id'}) .
( $params{'attach_to_template'} ? create_node('attach_to_template', '') : '' );
return create_node( 'add_use_template',
create_node(
'gen_setup',
create_node( 'name', $params{dname} ) .
create_node( 'client_id', $params{client_id} ) .
create_node( 'status', 0)
) . $hosting_block . '<!-- create_domain -->' . $template_block
);
}
is_string($create_request, $_, 'create account test') for
'<add_use_template><gen_info><address></address><city></city><cname></cname>' .
'<country>RU</country><email></email><fax></fax><login>suxdffffxx</login>' .
'<passwd>1234d5678</passwd><pcode></pcode><phone></phone><pname>stdsdffafff</pname>' .
'<state></state><status>0</status></gen_info><!-- create_client -->' .
'<tmpl_id>1</tmpl_id><server_auto><optimal></optimal></server_auto></add_use_template>';
$create_request = API::PleskExpand::Accounts::create(
%create_account_data,
'attach_to_template' => 1
);
is_string($create_request, $_, 'create account test') for
'<add_use_template><gen_info><address></address><city></city><cname></cname>' .
'<country>RU</country><email></email><fax></fax><login>suxdffffxx</login>' .
'<passwd>1234d5678</passwd><pcode></pcode><phone></phone><pname>stdsdffafff</pname>' .
'<state></state><status>0</status></gen_info><!-- create_client -->' .
'<tmpl_id>1</tmpl_id><attach_to_template></attach_to_template><server_auto>' .
'<optimal></optimal></server_auto></add_use_template>';
is_deeply(
API::PleskExpand::Accounts::create( %create_account_data, select => ''),
'',
'Manual select without server_id param'
);
like(
my $create_domain = API::PleskExpand::Domains::create( %new_domain_data );
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></add_use_template>';
$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'
},
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 => '',
fax => '',
email => '',
address => '',
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(
( run in 0.457 second using v1.01-cache-2.11-cpan-88abd93f124 )