strict;
use warnings;
use Path::Tiny;
use Moo::Role;
use MooseX::MungeHas;
use IPC::Run3;
use JSON;
use Module::Runtime qw/ use_module /;
use List::AllUtils qw/ uniq /;
use experimental 'postdere
f export /, @query], undef, \my $out;
return @{ from_json $out };
}
sub import_task {
my( $self, $task ) = @_;
my $in = to_json $task;
run3 [qw/ task rc.recurrence=no import /], \
he tasks.
=head2 import_task
$tw->import_task( \%task )
Equivalent to
$ task import <json representation of %task>
=head2 calc
$result = $tw->calc( qw/ today + 3d / );
Equivalent t
;
use common::sense;
use Plack::Request::WithEncoding;
use Plack::Response;
use Log::Defer;
use JSON::XS;
use Data::Dumper;
sub new {
my ($class, %args) = @_;
my $self = \%args;
bless
eval { encode_json($msg) };
if ($@) {
$encoded_msg = eval { encode_json(_json_clean($msg)) };
if ($@) {
$encoded_msg = "Failed to JSON clean: " . Dum
}) {
$self->logger->warn("sending JSON error: $body->{error}");
}
return $self->respond_raw($http_code // 200, 'application/json', encode_json($body));
}
sub done {
die shift->
regexp => qr!$disp_route!,
code => \&display_editfile,
);
# Setup a route to return json data of the file
my $save_route = $plugin->save_route;
my $save_method = $plugin->save_metho
$@ ) {
$status_message = "Could not write changes to file.";
}
}
$app->send_as( JSON => { save_message => $status_message } );
}
=back
=head1 AUTHOR
Hagop "Jack" Bilemjian, C<< <
use Path::Tiny;
use Hash::Merge qw/merge /;
use List::AllUtils qw/ reduce pairmap pairmap /;
use JSON;
use experimental 'postderef';
with 'Taskwarrior::Kusarigama::Core';
has raw_args => (
is
hod = join '_', 'run', $event;
my @plugins = $self->plugins->@*;
my @tasks = map { from_json($_) } <STDIN>;
try {
$self->$method(\@plugins,@tasks);
}
catch {
say
on_add($task) for grep { $_->DOES('Taskwarrior::Kusarigama::Hook::OnAdd') } @$plugins;
say to_json($task);
say for $self->feedback->@*;
}
# TODO document the $old, $new, $diff
sub run_modif
package Catmandu::Store::Resolver::Bag;
use Moo;
use JSON;
use Catmandu::Sane;
use Catmandu::Store::Resolver::API;
with 'Catmandu::Bag';
has api => (is => 'lazy');
has pid => (is => 'rw');
sub _
RSION = '0.06';
use strict;
use warnings;
use Moo;
use Catmandu::Sane;
use LWP::UserAgent;
use JSON;
use Catmandu::CA::API::Login;
has url => (is => 'ro', required => 1);
has url_query => (
;
my $response = $self->ua->get($url);
if ($response->is_success) {
return decode_json($response->decoded_content);
} elsif ($response->code == 404) {
return {};
} else
f->token);
my $response = $self->ua->put($url, Content => $data, Content_type => 'application/json');
if (!$response->is_success) {
Catmandu::HTTPError->throw({
code
package Net::CheckHost;
use strict;
use warnings;
our $VERSION = 0.05;
use JSON;
use LWP::UserAgent;
use URI;
sub new {
my ($class, @args) = @_;
bless {
gateway => 'https://chec
gin::CheckHost v' . $VERSION,
'Content-Type' => 'application/json',
'Accept' => 'application/json',
]
);
}
sub request {
my $self = shift;
my $http_
($http_response->status_line)
unless $http_response->is_success;
my $response = decode_json($http_response->decoded_content);
if ($response->{error}) {
my $error = $response->{
ent::Task';
use Armadito::Agent::Storage;
use Data::Dumper;
use MIME::Base64;
use Try::Tiny;
use JSON;
sub new {
my ( $class, %params ) = @_;
my $self = $class->SUPER::new(%params);
if ( $param
se ) = @_;
$self->{logger}->info( "Error Response : " . $response->content() );
my $obj = from_json( $response->content(), { utf8 => 1 } );
$self->{logger}->error( Dumper($obj) );
return $self;
= @_;
my $json_text = to_json( $self->{jobj} );
my $response = $self->{glpi_client}->sendRequest(
"url" => $self->{agent}->{config}->{server}[0] . "/api/jobs",
message => $json_text,
meth
ten::Yourls;
use strict;
use warnings;
use Carp ();
use File::HomeDir ();
use File::Spec ();
use JSON::MaybeXS;
use Path::Tiny qw(path);
use Scalar::Util qw(blessed);
use URI ();
use base qw( WWW::S
password server signature),
];
return [@{$attrs}];
}
}
# _json_request (static, private)
sub _json_request {
my $url = shift;
Carp::croak("Invalid URI object") unless $ur
ation/json}) {
Carp::croak("Unexpected response: $content");
}
my $json = decode_json($content);
Carp::croak("Invalid data returned: $content") unless $json;
return $json;
}
#
e 'Armadito::Agent::Task';
use Armadito::Agent::Tools::File qw( readFile );
use Data::Dumper;
use JSON;
sub new {
my ( $class, %params ) = @_;
my $self = $class->SUPER::new(%params);
if ( $param
$self = $self->SUPER::run(%params);
$self->_setEnrollmentKey();
my $json_text = to_json( $self->{jobj} );
print $json_text. "\n";
my $response = $self->{glpi_client}->sendRequest(
"url"
: " . $response->content() . "\n" );
if ( $response->content() =~ /^\s*\{/ ) {
my $obj = from_json( $response->content(), { utf8 => 1 } );
$self->{logger}->error( $obj->{message} );
}
return $
:Task:State>. Ask for Armadito Antivirus state using AV's API REST protocol and then send it in a json formatted POST request to Armadito plugin for GLPI.
=head1 FUNCTIONS
=head2 run ( $self, %param
Armadito Antivirus on-demand scan using AV's API REST protocol and then send a brief report in a json formatted POST request to Armadito plugin for GLPI.
=head1 FUNCTIONS
=head2 run ( $self, %param
rmadito module. Set task's default logger.
=head2 getJobj ( $self )
Return unblessed object for json ecnapsulation.
=head2 getVersion ( $self )
Return Antivirus Version by using RESTful API /versi
ask inherits from L<Armadito::Agent::Task:Alerts>. Get Armadito Antivirus alerts and send them as json messages to armadito glpi plugin.
=head1 FUNCTIONS
=head2 run ( $self, %params )
Run the task.
warnings;
use base 'Armadito::Agent::Task';
use Armadito::Agent::Storage;
use Data::Dumper;
use JSON;
sub new {
my ( $class, %params ) = @_;
my $self = $class->SUPER::new(%params);
if ( $param
= @_;
$self->{logger}->info( "Successful Response : " . $response->content() );
my $obj = from_json( $response->content(), { utf8 => 1 } );
if ( defined( $obj->{jobs} ) && ref( $obj->{jobs} ) eq
se ) = @_;
$self->{logger}->info( "Error Response : " . $response->content() );
my $obj = from_json( $response->content(), { utf8 => 1 } );
$self->{logger}->error( Dumper($obj) );
return $self;
strict;
use warnings;
use base 'Armadito::Agent::Task';
use MIME::Base64;
use Data::Dumper;
use JSON;
sub new {
my ( $class, %params ) = @_;
my $self = $class->SUPER::new(%params);
if ( $param
se ) = @_;
$self->{logger}->info( "Error Response : " . $response->content() );
my $obj = from_json( $response->content(), { utf8 => 1 } );
$self->{logger}->error( Dumper($obj) );
return $self;
fos;
my $json_text = to_json( $self->{jobj} );
my $response = $self->{glpi_client}->sendRequest(
"url" => $self->{agent}->{config}->{server}[0] . "/api/schedulers",
message => $json_text,
m
:Task::State;
use strict;
use warnings;
use base 'Armadito::Agent::Task';
use Data::Dumper;
use JSON;
sub new {
my ( $class, %params ) = @_;
my $self = $class->SUPER::new(%params);
if ( $param
teobj;
my $json_text = to_json( $self->{jobj} );
my $response = $self->{glpi_client}->sendRequest(
"url" => $self->{agent}->{config}->{server}[0] . "/api/states",
message => $json_text,
met
se ) = @_;
$self->{logger}->info( "Error Response : " . $response->content() );
my $obj = from_json( $response->content(), { utf8 => 1 } );
$self->{logger}->error( Dumper($obj) );
return $self;
e Armadito::Agent::Task::Alerts;
use strict;
use warnings;
use base 'Armadito::Agent::Task';
use JSON;
use Data::Dumper;
sub new {
my ( $class, %params ) = @_;
my $self = $class->SUPER::new(%para
se ) = @_;
$self->{logger}->info( "Error Response : " . $response->content() );
my $obj = from_json( $response->content(), { utf8 => 1 } );
$self->{logger}->error( Dumper($obj) );
return $self;
my $json_text = to_json( $self->{jobj} );
$self->{logger}->debug($json_text);
my $response = $self->{glpi_client}->sendRequest(
"url" => $self->{glpi_url} . "/api/alerts",
message => $json_te
Armadito::Agent::Task::AVConfig;
use strict;
use warnings;
use base 'Armadito::Agent::Task';
use JSON;
use Data::Dumper;
sub new {
my ( $class, %params ) = @_;
my $self = $class->SUPER::new(%para
se ) = @_;
$self->{logger}->info( "Error Response : " . $response->content() );
my $obj = from_json( $response->content(), { utf8 => 1 } );
$self->{logger}->error( Dumper($obj) );
return $self;
$json_text = to_json( $self->{jobj} );
$self->{logger}->debug($json_text);
my $response = $self->{glpi_client}->sendRequest(
"url" => $self->{glpi_url} . "/api/avconfigs",
message => $json_t
:Reddit::Response;
$WebService::Reddit::Response::VERSION = '0.000003';
use Moo;
use JSON::MaybeXS qw( decode_json );
use Types::Standard qw( Bool InstanceOf Maybe HashRef );
has content => (
is
my $self = shift;
my $content = $self->raw->decoded_content;
return $content ? decode_json($content) : undef;
}
sub _build_success {
my $self = shift;
return $self->raw->is_succes
item raw
An L<HTTP::Response> object.
=back
=head1 METHODS
=head2 content
This is the parsed JSON body of the response. Generally this will be a C<HashRef>.
=head2 raw
Returns the raw L<HTTP::