NAME

MToken::Client - Client for interaction with MToken server

VIRSION

Version 1.02

SYNOPSIS

use MToken::Client;

my $clinet = MToken::Client->new(
    url => "https://localhost:8642",
    username            => "username", # optional
    password            => "password", # optional
    pwcache             => "/path/to/pwcache.tmp",
    pwcache_ttl         => 300, # 5 min. Default
    max_redirects       => 2, # Default: 10
    connect_timeout     => 3, # Default: 10 sec
    inactivity_timeout  => 5, # Default: 30 sec
    request_timeout     => 10, # Default: 5 min (300 sec)
);
my $status = $client->check();

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

DESCRIPTION

Client for interaction with MToken server

new

my $clinet = MToken::Client->new(
    url => "https://localhost:8642",
    username            => "username", # optional
    password            => "password", # optional
    pwcache             => "/path/to/pwcache.tmp",
    pwcache_ttl         => 300, # 5 min. Default
    max_redirects       => 2, # Default: 10
    connect_timeout     => 3, # Default: 10 sec
    inactivity_timeout  => 5, # Default: 30 sec
    request_timeout     => 10, # Default: 5 min (300 sec)
);

Returns client

max_redirects

Maximum number of redirects the user agent will follow before it fails. Default - 10

password

Default password for basic authentication

pwcache

Full path to file of password cache

pwcache_ttl

Time to Live of pwcache file. Default - 300 sec

*timeout

Timeout for connections, requests and inactivity periods in seconds.

ua

The Mojo UserAgent object

url

Full URL of the WEB Server

username

Default username for basic authentication

METHODS

check

my $status = $client->check;
my $status = $client->check(URL);

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

my $userinfo = $client->credentials($MOJO_URL_OBJECT, 1)

Gets credentials for User Agent

download

my $status = $client->download(TOKEN_NAME => TARBALL_FILE_PATH);

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

error

print $clinet->error;

Returns error string

info

my $status = $clinet->info();
my $status = $clinet->info( TOKEN_NAME );

Request for getting information about token storage or about list of stored token tarballs.

remove

my $status = $client->remove(TOKEN_NAME => TARBALL_FILE_NAME);

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

req

my $request = $clinet->req;

Returns Mojo::Message::Request object

request

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

Send request

res

my $response = $clinet->res;

Returns Mojo::Message::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

tx

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

Works with Mojo::Transaction object, interface with it

ua

my $ua = $clinet->ua;

Returns Mojo::UserAgent object

upload

my $status = $client->upload(TOKEN_NAME => TARBALL_FILE_PATH);

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

url

my $url_object = $clinet->url;

Returns Mojo::URL object

HISTORY

See Changes file

DEPENDENCIES

Mojolicious

TO DO

See TODO file

SEE ALSO

CTK, Mojo::UserAgent

AUTHOR

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

COPYRIGHT

Copyright (C) 1998-2021 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/