API-Plesk

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN


2.03 2013-08-19

    - removed Try::Tiny
    - Changes was formated according to CPAN::Changes::Spec
    - fixed tests

2.02 2013-07-10

    - Added DNS zone SOA get (Jari Turkia)
    - Added secret key -based authentication (by Jari Turkia)
    - Fixed warning about uninitialized value
    - subdomain added (Zavarykin Eugeny)
    - is_connection_error modified (Zavarykin Eugeny)
    - fixed warning and bug (Eugen Konkov)
    - .gitignore (Akzhan Abdulin)
    - fixed bug (Ivan Shamal)

2.01 2012-06-25
    
    - Fixed tests

README  view on Meta::CPAN

    This is develover release. Comapatibility with Plesk::API 1.* is not
    implemented yet.

METHODS
    new(%params)
       Create new class instance.

       Required params: username password url

       Additional params: api_version - default 1.6.3.1 debug - default 0
       timeout - default 30 sec.

    send($operator, $operation, $data, %params)
       This method prepare and sends request to Plesk API.

       Returns API::Plesk::Response object.

       $operator - name of operator XML section of Plesk API.

       $operation - mane of operation XML section of Plesk API.

       $data - data hash that is converted to XML and is sended to plesk
       server.

    xml_http_req( $xml )
       Internal method. it implements real request sending to Plesk API.

       Returns array ( $response_xml, $error ).

SEE ALSO

lib/API/Plesk.pm  view on Meta::CPAN

);

# constructor
sub new {
    my $class = shift;
    $class = ref ($class) || $class;

    my $self = {
        username    => '',
        password    => '',
        secret_key  => '',
        url         => '',
        api_version => '1.6.3.1',
        debug       => 0,
        timeout     => 30,
        (@_)
    };

    if (!$self->{secret_key}) {
        confess "Required username!" unless $self->{username};
        confess "Required password!" unless $self->{password};
    }
    confess "Required url!"      unless $self->{url};

    return bless $self, $class;
}

# sends request to Plesk API
sub send {

lib/API/Plesk.pm  view on Meta::CPAN

# Send xml request to plesk api
sub xml_http_req {
    my ($self, $xml) = @_;

    # HTTP::Request undestends only bytes
    utf8::encode($xml) if utf8::is_utf8($xml);

    my $ua = new LWP::UserAgent( parse_head => 0 );
    my $req = new HTTP::Request POST => $self->{url};

    if ($self->{secret_key}) {
        $req->push_header(':KEY',  $self->{secret_key});
    } else {
        $req->push_header(':HTTP_AUTH_LOGIN',  $self->{username});
        $req->push_header(':HTTP_AUTH_PASSWD', $self->{password});
    }
    $req->content_type('text/xml; charset=UTF-8');
    $req->content($xml);

    # LWP6 hack to prevent verification of hostname
    $ua->ssl_opts(verify_hostname => 0) if $ua->can('ssl_opts');

lib/API/Plesk.pm  view on Meta::CPAN

Create new class instance.

Required params:
username
password
url

Additional params:
api_version - default 1.6.3.1
debug       - default 0
timeout     - default 30 sec.

=item send($operator, $operation, $data, %params)

This method prepare and sends request to Plesk API.

Returns API::Plesk::Response object.

$operator - name of operator XML section of Plesk API.

$operation - mane of operation XML section of Plesk API.

$data - data hash that is converted to XML and is sended to plesk server.

=item xml_http_req( $xml )

Internal method. it implements real request sending to Plesk API.

Returns array ( $response_xml, $error ).

=back

lib/API/Plesk/Component.pm  view on Meta::CPAN

            ($key) = grep { exists $params->{$_} } @$key 
        }
        push @sorted, {$key => $params->{$key}}
            if exists $params->{$key};

    }

    return \@sorted;
}

# check hosting xml section
sub check_hosting {
    my ( $self, $params, $required ) = @_;

    unless ( $params->{hosting} ) {
        confess "Required hosting!" if $required;
        return;
    }

    my $hosting = $params->{hosting};
    my $type = delete $hosting->{type};

lib/API/Plesk/Response.pm  view on Meta::CPAN

    $res->is_connection_error;

    # get errors
    $res->error_code;
    $res->error_codes->[0];
    $res->error_text;
    $res->error_texts->[0];
    $res->error;
    $res->errors->[0];

    # get data sections
    $res->data->[0];

    # get result sections
    $res->results->[0];

    # get id and guid
    $res->id;
    $res->guid;


=head1 DESCRIPTION

This class is intended for convenient processing results of Plesk API responses.



( run in 1.063 second using v1.01-cache-2.11-cpan-39bf76dae61 )