NAME

MToken::Client - Client for interaction with MToken server

VIRSION

Version 1.01

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

new

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

Returns client

timeout

Timeout for LWP requests, in seconds.

Default: 180 seconds (5 mins)

ua

The LWP::UserAgent object

uri

URI object, that describes URL of the WEB Server. See url attribute

url

Full URL of the WEB Server. See uri attribute

verbose

Enable verbose mode. Possible boolean value: 0 or 1

Add request and response data to trace stack if verbose is true

Default: false

METHODS

check

my $status = $client->check;

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

cleanup

$client->cleanup;

Cleanup all variable data in object and returns client object

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( $filename );

Request for getting information about file on server by filename or file id. The method returns info as hash

line

my $status_line = $clinet->line;

Returns HTTP status line of response

list

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

Request for getting list of files on server. The method returns array of files

remove

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

Remove file from server by name and returns status value

req

my $request = $clinet->req;

Returns HTTP::Request object

request

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

Send request

res

my $response = $clinet->res;

Returns HTTP::Response object

status

my $status = $clinet->status;

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

trace

my $trace = $client->trace;
print $client->trace("New trace record");

Gets trace stack or pushes new trace record to trace stack

transaction

print $client->transaction;

Gets transaction string

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

CTK, LWP, HTTP::Message

TO DO

See TODO file

BUGS

* none noted

SEE ALSO

CTK, LWP, HTTP::Message, URI

AUTHOR

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

COPYRIGHT

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

LICENSE

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

See LICENSE file and https://dev.perl.org/licenses/