App-MBUtiny
view release on metacpan or search on metacpan
lib/App/MBUtiny/Collector/Client.pm view on Meta::CPAN
my @list = $client->list(name => "foo");
Request for getting list of files on collector by name.
The method returns array of info-structures.
See L<App::MBUtiny::Collector::DBI/list>
=head2 report
my @list = $client->report(start => 123456789);
Request for getting report of backup on collector by name.
See L<App::MBUtiny::Collector::DBI/report>
=head2 request
my $struct = $client->request();
Performs request to collector server over L<WWW::MLite::Client>
=head1 HISTORY
See C<Changes> file
=head1 TO DO
See C<TODO> file
=head1 BUGS
* none noted
=head1 SEE ALSO
L<App::MBUtiny>, L<WWW::MLite::Client>
=head1 AUTHOR
Serż Minus (Sergey Lepenkov) L<http://www.serzik.com> E<lt>abalama@cpan.orgE<gt>
=head1 COPYRIGHT
Copyright (C) 1998-2019 D&D Corporation. All Rights Reserved
=head1 LICENSE
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
See C<LICENSE> file and L<https://dev.perl.org/licenses/>
=cut
use vars qw/ $VERSION /;
$VERSION = '1.00';
#use Carp;
#use CTK::TFVals qw/ :ALL /;
use CTK::ConfGenUtil;
#use Try::Tiny;
#use File::Basename qw/basename/;
use base qw/ WWW::MLite::Client /;
use constant {
CONTENT_TYPE => "application/json",
SERIALIZE_FORMAT => 'json',
SR_ATTRS => {
json => [
{ # For serialize
utf8 => 0,
pretty => 1,
allow_nonref => 1,
allow_blessed => 1,
},
{ # For deserialize
utf8 => 0,
allow_nonref => 1,
allow_blessed => 1,
},
],
},
};
sub new {
my $class = shift;
my %params = @_;
$params{sr_attrs} ||= SR_ATTRS;
$params{ua_opts} ||= { agent => "MBUtiny/$VERSION" };
$params{format} ||= SERIALIZE_FORMAT;
$params{content_type} ||= CONTENT_TYPE;
$params{no_check_redirect} //= 1;
return $class->SUPER::new(%params);
}
sub request {
my $self = shift;
my $data = $self->SUPER::request(@_);
my $state = $self->status;
if ($state) {
my $err = _check_response($data);
if ($err) {
$self->status(0);
$self->error($err);
}
}
return $data if is_hash($data);
if ($data) {
$self->status(0);
$self->error("Non serialized content found!");
}
return {
status => $self->status,
error => $self->error,
};
}
sub check {
my $self = shift;
return $self->request();
}
sub add {
( run in 1.046 second using v1.01-cache-2.11-cpan-39bf76dae61 )