;
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->
ION
C<PONAPI::Document::Builder::Resource> is used internally by
C<PONAPI::Document> to build C<{json:api}> documents. Generally,
these will be created by C<< PONAPI::Document->add_resources >>, whi
# ABSTRACT: a {json:api} document building class
package PONAPI::Document;
use strict;
use warnings;
use parent 'PONAPI::Document::Builder::Document';
1;
__END__
=pod
=encoding UTF-8
=head1 NAM
E
PONAPI::Document - a {json:api} document building class
=head1 VERSION
version 0.001002
=head1 SYNOPSIS
use PONAPI::Document;
my $document = PONAPI::Document->new(
version =>
turn a valid {json:api} document
# as a perl hash, which you can later turn into JSON.
my $result = $document->build;
=head1 DESCRIPTION
C<PONAPI::Document> lets you build {json:api} complia
SCRIPTION
This module implements the L<member name restrictions|http://jsonapi.org/format/#document-member-names>
from the {json:api} specification; it can be used by repositories
to implement strict
use Encode;
use Exporter 'import';
my @EXPORT = ();
my @EXPORT_OK = qw(get post put delete);
use JSON;
use MIME::Base64;
use REST::Client;
# ABSTRACT: Perl client to the Foreman API
sub new {
m
my $headers = $self->set_headers();
$client->GET($path, $headers);
my $response = decode_json(decode_utf8($client->responseContent()));
return $response;
}
sub post {
my ($self, $pa
croak 'The #2 argument to post() must be a hash' if ref($_[2]) ne 'HASH';
$params = JSON::encode_json($params);
my $client = $self->create_client();
my $headers = $self->set_headers();
file created by our parent before the fork
use IO::Select;
use JSON::XS;
use Scalar::Util qw/blessed/;
my $setup_has_been_run;
my $json;
my $sel;
sub handle_worker {
eval {
handle_worker_wr
AnyEvent::Util::fh_nonblocking $fh, 0;
AnyEvent::Util::fh_nonblocking $monitor_fh, 0;
$json = JSON::XS->new->utf8;
$sel = IO::Select->new;
$sel->add($fh, $monitor_fh);
while(1) {
m
TR};
POSIX::_exit(1);
} elsif ($read_rv == 0) {
POSIX::_exit(1);
}
for my $input ($json->incr_parse($buf)) {
my $output;
my $output_meta = {};
my $cmd = shift @$input;
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;
}
#
rict;
use warnings;
use utf8;
use Carp;
use JSON::MaybeXS qw/JSON/;
our $VERSION = "0.008";
=head1 NAME
Locale::Meta - Multilanguage support loading json structures based on Locale::Wolowitz.
=hea
d1 VERSION
version 0.008
=head1 SYNOPSIS
#in ./i18n/file.json
{
"en": {
"color": {
"trans" : "color"
"meta": {
"searchable": 1,
}
}
},
ency of the
file names as part of the definition of the language, to manage a new json data structure
for the .json files definitions, and also, add a meta field in order to be
able to extend the u
{json:api} document building tools
package PONAPI::Tools;
use strict;
use warnings;
our $VERSION = '0.001002';
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
PONAPI::Tools - PONAPI-Tools - {json:
building tools
=head1 VERSION
version 0.001002
=head1 DESCRIPTION
Various tools for building {json:api} compatiable documents.
Used by L<PONAPI::Server>
For information about creating documents,
protocol between the client and the worker process is currently JSON-based, all arguments and return values must be serializable to JSON. This includes most perl scalars like strings, a limited range
Document hung_worker_timeout and SIGALRM stuff
Wire protocol:
- Support something other than JSON? Sereal?
- Document the protocol?
need tests for the following features:
- checkout_done sig
package WWW::Shorten::Naver;
use strict;
use warnings;
use Carp ();
use JSON::MaybeXS;
use URI ();
use Scalar::Util qw(blessed);
use parent qw( WWW::Shorten::generic Exporter );
our @EXPORT = qw(new V
ation/json}) {
Carp::croak("Unexpected response: $content");
}
my $json = decode_json($content);
Carp::croak("Invalid data returned: $content") unless $json;
return $json->{res
e JSON;
has field_list => (is => 'ro', required => 1);
has query => (is => 'lazy');
sub _build_query {
my $self = shift;
if (scalar @{$self->field_list} == 0) {
return encode_json(
printf('%s', $field);
$query->{'bundles'}->{$def} = {
'returnAsArray' => JSON::true,
'locale' => 'nl_BE'
};
}
return encode_json($query);
}
1;
__END__
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
Catmandu::Sane;
use Data::Dumper qw(Dumper);
use LWP::UserAgent;
use HTTP::Request::Common;
use JSON;
has username => (is => 'ro', required => 1);
has password => (is => 'ro', required => 1);
has u
nse = $self->ua->request($request);
if ($response->is_success) {
my $content = decode_json($response->decoded_content);
return $content->{'authToken'};
} else {
Catmand
package Net::Hadoop::WebHDFS;
use strict;
use warnings;
use Carp;
use JSON::XS qw//;
use Furl;
use File::Spec;
use URI;
use Try::Tiny;
use constant GENERIC_FS_ACTION_WITH_NO_PATH => '';
our $VERS
my $res = $self->operate_requests('PUT', $path, 'MKDIRS', \%options);
$self->check_success_json($res, 'boolean');
}
$OPT_TABLE{MKDIRS} = ['permission'];
sub mkdirs { (shift)->mkdir(@_); }
# cu
rate_requests('PUT', $path, 'RENAME', {%options, destination => $dest});
$self->check_success_json($res, 'boolean');
}
# curl -i -X DELETE "http://<host>:<port>/webhdfs/v1/<path>?op=DELETE
#
package Catmandu::CA::API;
use strict;
use warnings;
use Catmandu::Sane;
use Moo;
use JSON;
use Catmandu::CA::API::QueryBuilder;
use Catmandu::CA::API::Request;
has username => (is => 'ro', requ
password => $self->password,
lang => $self->lang
);
return $r->put(encode_json($data));
}
sub update {
my ($self, $id, $data) = @_;
my $r = Catmandu::CA::API::Request-
password => $self->password,
lang => $self->lang
);
return $r->put(encode_json($data));
}
sub delete {
my ($self, $id) = @_;
my $r = Catmandu::CA::API::Request->new(
t( $url, json => $payload );
my $response = $tx->success();
unless( $response ) {
my $error = $tx->error();
die( sprintf( 'Error: %s', $error->{message} ) )
}
return $response->json();
}
su
$error = $tx->error();
die( sprintf( 'Error: %s', $error->{message} ) )
}
return $response->json();
}
__PACKAGE__->meta()->make_immutable();
1;
__END__
=pod
=head1 NAME
Facebook::Messenger
->()';
shift @$request;
}
$self->_install_timeout_timer;
$self->{worker}->push_write( json => [ 'do', {}, @$request, ], );
my $timer;
if ($self->{log_defer_object}) {
$timer = $s
lete $self->{cmd_handler};
$self->_try_to_fill_requests;
};
$self->{worker}->push_read( json => $self->{cmd_handler} );
}
sub DESTROY {
my ($self) = @_;
$self->{client}->remove_pending
$self->{client}->populate_workers if $self->{client};
} else {
$worker->push_write( json => [ 'dn', {} ] );
$self->{client}->make_worker_available($worker) if $self->{client};
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
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