NAME

Net::Plesk - Perl extension for Plesk XML Remote API

SYNOPSIS

  use Net::Plesk;

  my $plesk = new Net::Plesk (
    'POST'      => 'https://plesk.sample.com:8443/enterprise/control/agent.php',
    ':HTTP_AUTH_LOGIN' => '1357948',
    ':HTTP_AUTH_PASSWD' => 'password',
  );

  # client_get

  my $clientname = 'tofu_beast';
  my $response = $plesk->client_get( $clientname );
  die $response->errortext unless $response->is_success;
  my $clientID = $response->id;

  # client_add

  unless $clientID {
    my $clientname = 'Tofu Beast';
    my $login      = 'tofu_beast';
    my $password   = 'manyninjas';
    my $response = $plesk->client_add( $clientname,
                                       $login,
				       $password,
				       $phone,
				       $fax,
				       $email,
				       $address,
				       $city,
				       $state,
				       $postcode,
				       $country,
	                              );
    die $response->errortext unless $response->is_success;
    $clientID = $response->id;
    print "$clientname created with ID $clientID\n";
  }

  # client_ippool_add_ip

  my $ipaddress = '192.168.8.45';
  my $response = $plesk->client_ippool_add_ip( $clientID, $ipaddress );
  die $response->errortext unless $response->is_success;

  # domain_get

  my $domain = 'basilisk.jp';
  my $response = $plesk->domain_get( $domain );
  die $response->errortext unless $response->is_success;
  my $domainID = $response->id;

  # domain_add

  my $domain = 'basilisk.jp';
  my $clientID = 17;
  my $ipaddr = '192.168.8.45';
  my $response = $plesk->domain_add( $domain, $clientID, $ipaddr );
  die $response->errortext unless $response->is_success;
  my $domainID = $response->id;

  # domain_del

  my $domain = 'basilisk.jp';
  my $response = $plesk->domain_add( $domain );
  die $response->errortext unless $response->is_success;

  # mail_add 

  my $username = 'tofu_beast';
  my $response = $plesk->mail_add( $domainID, $username, 'password' );
  die $response->errortext unless $response->is_success;
  my $uid = $response->id;
  print "$username created: uid $uid\n";

  # mail_remove

  $response = $plesk->mail_remove( 'username' );
  if ( $response->is_success ) {
    print "mailbox removed";
  } else {
    print "error removing mailbox: ". $response->errortext;
  }

  # mail_set

  my $enabled = ($user_balance <= 0);
  $response = $plesk->mail_set( $domainID, 'username', 'password', $enabled );
  die $response->errortext unless $response->is_success;

DESCRIPTION

This module implements a client interface to SWSOFT's Plesk Remote API, enabling a perl application to talk to a Plesk managed server. This documentation assumes that you are familiar with the Plesk documentation available from SWSOFT (API 1.4.0.0 or later).

A new Net::Plesk object must be created with the new method. Once this has been done, all Plesk commands are accessed via method calls on the object.

METHODS

new OPTION => VALUE ...

Creates a new Net::Plesk object. The URL, :HTTP_AUTH_LOGIN, and :HTTP_AUTH_PASSWD options are required.

AUTOLOADed methods

Not all Plesk methods are available. See the Plesk documentation for methods, arguments and return values. See Net::Plesk::Method for available methods.

Responses are returned as Net::Plesk::Response objects. See Net::Plesk::Response.

BUGS

Multiple request packets not tested. 

SEE ALSO

SWSOFT Plesk Remote API documentation (1.4.0.0 or later)

AUTHOR

Jeff Finucane <jeff@cmh.net>

COPYRIGHT AND LICENSE

Copyright (C) 2006 Jeff Finucane

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.