********************************
no Moose;
1;
__END__
=head1 NAME
Zenoss::Router::Process - A JSON/ExtDirect interface to operations on processes
=head1 SYNOPSIS
use Zenoss;
my $api = Ze
defaults and return content.
The documentation for this module was mostly taken from the Zenoss JSON API docs. Keep in mind
that their (Zenoss Monitoring System) programming is based around python,
used to serialiser/deserialise. See Data::Serializer to see
what is available. Defaults to YAML. JSON is anotther that is available.
=cut
class_type 'Data::Serializer';
my $serializer_t = subtype
>meta->make_immutable;
no Moose;
1;
__END__
=head1 NAME
Zenoss - Perl interface to the Zenoss JSON API
=head1 SYNOPSIS
use Zenoss;
use Data::Dumper;
# Create a Zenoss object
my
ponse is now an instance of Zenoss::Response
# now we can do things like
print $response->json();
print $response->http_code();
# get the response in a perl reference
my $ref = $r
severity of 0,1,2,3,4 or 5
my $events = $api->events_query(
{
history => JSON::true,
params => {
severity => [0,1,2,3,4,5],
}
=pod
=head1 NAME
Examples covering the Zenoss JSON API
=head1 OVERVIEW
This page serves as collection of some quick examples designed to get one started. I will
try to add more occasionally.
=h
eviceName => 'newdevice',
deviceClass => '/Server/Linux',
model => JSON::true,
}
);
# Print the JobID that this device will be processed under
m
package Zenoss::Router;
use strict;
use File::Find;
use File::Basename;
use JSON qw{};
use LWP::UserAgent;
use HTTP::Request::Common qw{POST};
use Moose;
use Moose::Util qw {apply_all_roles};
use Zen
***************************************************************
our $JSON_CONTENT_TYPE; *JSON_CONTENT_TYPE = \q{application/json; charset=utf-8};
#************************************************
ease the transaction counter
$self->_increase_transaction_count;
# Build JSON request in HASHREF
my $JSON_DATA = {
action => $args->{'action'},
method => $args->{'method
me API methods
my $response = $api->device_getDevices();
# Print the JSON return
print $response->json;
=head1 DESCRIPTION
This module creates a connection to the Zenoss API, and te
********************************
no Moose;
1;
__END__
=head1 NAME
Zenoss::Router::ZenPack - A JSON/ExtDirect interface to operations on ZenPacks
=head1 SYNOPSIS
use Zenoss;
my $api = Zen
defaults and return content.
The documentation for this module was mostly taken from the Zenoss JSON API docs. Keep in mind
that their (Zenoss Monitoring System) programming is based around python,
*********************************
no Moose;
1;
__END__
=head1 NAME
Zenoss::Router::Report - A JSON/ExtDirect interface to operations on reports
=head1 SYNOPSIS
use Zenoss;
my $api = Zeno
defaults and return content.
The documentation for this module was mostly taken from the Zenoss JSON API docs. Keep in mind
that their (Zenoss Monitoring System) programming is based around python,
*************************************************
# Name: Template.pm
#
# Description: A JSON/ExtDirect interface to operations on templates
#
# Author: Patrick Baker
#
# Version:
# Argument definition
my $definition = {
defaults => {
query => JSON::null,
}
};
# Check the args
$self->_check_args($args, $definition);
#
# Argument definition
my $definition = {
defaults => {
query => JSON::null,
},
required => ['uid'],
};
# Check the args
$self->_check_
de qw( decode_utf8 );
use File::Temp;
use Graph::Easy;
use IPC::Run qw( run binary );
use JSON qw( decode_json );
use Module::Load;
use Text::CSV_XS;
use Text::TEI::Collate::Diff;
use Text::TEI::Colla
( $xml_file ) )
}
$aligner->align( @manuscripts );
# Read from a JSON input.
@manuscripts = $aligner->read_source( $JSON_string );
$aligner->align( @manuscripts );
=head1 DESCRIPTION
Te
ay title for the collation output results, should those
results need a display title (e.g. TEI or JSON output).
=item B<language> - Specify the language module we should use from those
available in T
{
# require JSON::PP;
# $benchmarks{'JSON::PP int'} = sub{JSON::PP::encode_json("9627")};
#} or warn "Unable to require JSON::PP";
eval {
require JSON::XS;
JSON::XS->import('encode_json');
my $arr
y = encode_json(["hello", 9627]);
my $bool = "[true]";
my $float = encode_json([3.14]);
my $hash = encode_json({"hello" => 9627});
my $int = encode_json([9627]);
my $null = encode_json([undef]);
ode_json(["hello"]);
$benchmarks{'JSON::XS int'} = sub {JSON::XS::decode_json($int)};
$benchmarks{'JSON::XS bool'} = sub {JSON::XS::decode_json($bool)};
$benchmarks{'JSON::XS float'} = sub {JSON::X
finition
my $definition = {
defaults => {
history => JSON::false,
limit => JSON::null,
uid => '/zport/dmd'
}
};
# Check the ar
********************************
no Moose;
1;
__END__
=head1 NAME
Zenoss::Router::Service - A JSON/ExtDirect interface to operations on services
=head1 SYNOPSIS
use Zenoss;
my $api = Zen
defaults and return content.
The documentation for this module was mostly taken from the Zenoss JSON API docs. Keep in mind
that their (Zenoss Monitoring System) programming is based around python,
equire JSON::PP;
my $encoded = JSON::PP::encode_json($structure);
$benchmarks{'JSON::PP'} = sub{JSON::PP::decode_json($encoded)};
} or warn "Unable to require JSON::PP";
eval {
require JSON::XS;
my $encoded = JSON::XS::encode_json($structure);
$benchmarks{'JSON::XS'} = sub{JSON::XS::decode_json($encoded)};
} or warn "Unable to require JSON::XS";
eval {
require Convert::Bencode;
my $encode
string - the initial word string that should be parsed into its forms
=item *
json - a hash, presumably read from JSON, that has all the attributes
=item *
empty - a flag to say that this should b
ok( !$word->is_empty, "Word is not empty");
# Initialize a word from a JSON string, check its values
use JSON qw( decode_json );
my $jstring = encode_utf8( '{"c":"Արդ","n":"արդ","punctuation":
"Առդ"}' );
$word = Text::TEI::Collate::Word->new( json => decode_json($jstring), ms_sigil => 'B' );
is( $word->word, 'Առդ', "Got correct JSON word before modification" );
is( $word->canonical_fo
e JSON::PP;
$benchmarks{'JSON::PP'} = sub{JSON::PP::encode_json($structure)};
} or warn "Unable to require JSON::PP";
eval {
require JSON::XS;
$benchmarks{'JSON::XS'} = sub{JSON::XS::encode_json($
structure)};
} or warn "Unable to require JSON::XS";
eval {
require Convert::Bencode;
$benchmarks{'Convert::Bencode'} = sub{Convert::Bencode::bencode($structure)};
} or warn "Unable to require Conv
xing
Directory;
use 5.008;
use strict;
use warnings 'all';
use parent 'CGI::Application';
use JSON 2.00; # The API was changed
use Try::Tiny;
use WWW::USF::Directory;
sub setup {
my ($self) = @_
ults and response
my (@results, $response);
# Set the header to specity JSON
$self->header_add(-type => 'application/json');
try {
# Search the directory
@results = $self->{directory}->searc
il } } @results;
# Return the JSON-encoded results to print
$response = JSON->new->encode(\@results);
}
catch {
# Return an empty JSON list
$response = JSON->new->encode([]);
};
# Return
n = {
defaults => {
updates => JSON::false,
deletion => JSON::false,
sendevent => JSON::false,
sort => 'name',
di
# Argument definition
my $definition = {
defaults => {
monitor => JSON::false,
start => 0,
limit => 50,
sort => 'name',
n = {
defaults => {
updates => JSON::false,
deletion => JSON::false,
sendEvent => JSON::false,
start => 0,
limit
b definition
my $model = EntityModel->new->add_plugin(Web => {
})->load_from(JSON => {
file => $ENV{ENTITYMODEL_JSON_MODEL}
});
# Create the PSGI wrapper
my $app = EntityModel::Web::PSGI->new;
yMQ::Trait::AMQP;
use Moose::Role;
use File::ShareDir;
use AnyEvent;
use AnyEvent::RabbitMQ;
use JSON;
use Try::Tiny;
use Carp qw(croak carp);
has host => (is => "ro", isa => "Str");
has port => (is
er}->method_frame->routing_key;
try { $self->topics->{$topic}->AnyMQ::Topic::publish(JSON::from_json($payload)) }
catch { croak "failed to republsih on $topic: $_" };
};
}
sub new
use strict;
use warnings;
use JSON;
use Text::TNetstrings qw(:all);
use Benchmark qw(cmpthese);
my $structure = {
'resources' => {
'license' => [
'http://opensource.org/licenses/mit-license.php'
y $tn = encode_tnetstrings($structure);
my $json = encode_json($structure);
print "TNetstrings (" . length($tn) . ")
$tn
JSON (" . length($json) . ")
$json
";
cmpthese(-10, {
'TNetstrings' => sub{d
ecode_tnetstrings(encode_tnetstrings($structure))},
'JSON' => sub{decode_json(encode_json($structure))},
});