NAME

MToken::Client - Client for interaction with MToken server

VIRSION

Version 1.00

SYNOPSIS

use MToken::Client;

my $clinet = new MToken::Client(
    uri => "http://localhost/mtoken",
);
my $status = $clinet->check;

if ($status) {
print STDOUT $client->response;
} else {
print STDERR $clinet->error;
}

DESCRIPTION

Client for interaction with MToken server

METHODS

new
my $client = new MToken::Client(
    uri     => "http://localhost/mtoken",
    user    => $user, # optional
    password    => $password, # optional
    timeout => $timeout, # default: 180
);

Returns client

check
my $status = $client->check;

Returns check-status of server. 0 - Error; 1 - Ok

See README file for details of data format

code
my $code = $clinet->code;

Returns HTTP code of the response

credentials
$client->credentials("username", "password", "realm")

Set credentials for User Agent by Realm (name of basic authentication)

del
my $status = $clinet->del(
    file => $filename,
);

Request for deleting of the file on server by filename. The method returns status of operation: 0 - Error; 1 - Ok

See README file for details of data format

download
my $status = $clinet->download(
    file => $filename,
);

Request for download file on server by filename. The method returns status of operation: 0 - Error; 1 - Ok

See README file for details of data format

error
print $clinet->error;

Returns error string

info
my $status = $clinet->info(
    file => $filename,
);

Request for getting information about file on server by filename. The method returns status of operation: 0 - Error; 1 - Ok

See README file for details of data format

list
my $status = $clinet->list();

Request for getting list of files on server. The method returns status of operation: 0 - Error; 1 - Ok

See README file for details of data format

remove
my $status = $clinet->remove("filename");

Remove file from server by name and returns status value

req
my $request = $clinet->req;

Returns request hash

request
my $json = $clinet->request("METHOD", "PATH", "DATA");

Send request

res
my $response = $clinet->res;

Returns response hash

status
my $status = $clinet->status;

Returns object status value. 0 - Error; 1 - Ok

update
my $status = $clinet->update("filename");

Update file on server by name and returns status value

upload
$status = $clinet->upload(
    file    => $file,
    filename=> $filename,
    sha1    => $sha1, # Optional
    md5     => $md5,  # Optional
    size    => $filesize,

);

Request for uploading of backup on server. The method returns status of operation: 0 - Error; 1 - Ok

See README file for details of data format

HISTORY

See CHANGES file

DEPENDENCIES

LWP, mod_perl2, CTK

TO DO

See TODO file

BUGS

* none noted

SEE ALSO

perl, CTK, mod_perl2

AUTHOR

Sergey Lepenkov (Serz Minus) http://www.serzik.com <abalama@cpan.org>

COPYRIGHT

Copyright (C) 1998-2017 D&D Corporation. All Rights Reserved

LICENSE

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

See LICENSE file