nse;
{
$SeeAlso::Response::VERSION = '0.71';
}
#ABSTRACT: SeeAlso Simple Response
use JSON::XS qw(encode_json);
use Data::Validate::URI qw(is_uri);
use Text::CSV;
use SeeAlso::Identifier;
use Carp;
);
}
sub uris {
my $self = shift;
return @{ $self->{uris} };
}
sub toJSON {
my ($self, $callback, $json) = @_;
my $response = [
$self->{query}->as_string,
$self->{
return _JSON( $response, $callback, $json );
}
sub as_string {
return $_[0]->toJSON;
}
sub fromJSON {
my ($self, $jsonstring) = @_;
my $json = JSON::XS->new->decode($jsonstring);
$self->util->methods... or not
has _json => (
is => 'rw'
, isa => 'JSON::XS'
, lazy => 1
, required => 1
, default => sub {
require JSON::XS;
return JSON::XS->new->utf8->ascii->relaxed;
}
ent', tied => 1 );
}
# Leave it up to the API implementation to encode the hash/array ref into JSON / Form data / XML / etc.
$req->content( $args{content} ) if defined $args{content};
$req->metho
ncode {
my ( $self, %args ) = @_;
my ( $data );
for ( $args{type} ) {
when ( 'json' ) {
$data = $self->_json->encode( $args{data} );
}
when ( 'xml' ) {
$data = $self->_xml->write( $arg
$req->content ) {
my $json = $self->_encode( type => 'json', data => $data );
$req->content( $json );
$req->headers->header( 'Content-Type' => 'application/json; charset=utf-8' );
#
Uncomment this to view generated JSON content.
# $self->debug( $json );
}
}
, m_scheme => $scheme
, m_host => $host
, m_path_match => qr/^\Q$path\E/
);
# Add response wrapper.
$self
( $res, $ua, $h ) = @_;
if ( my $data = $res->content ) {
$data = $self->_decode( type => 'json', data => $data );
$res->content( $data );
}
}
, m_scheme => $scheme
, m_host => $ho
ngs;
use Carp qw(croak);
use 5.008008;
our $VERSION = '0.03';
use URI;
use URI::QueryParam;
use JSON ();
use LWP::UserAgent;
sub new {
my ($class, %args) = @_;
croak 'Both `base_url` and `
$self->dispatch_request('get', '/api/services.json');
}
sub roles {
my $self = shift;
$self->dispatch_request('get', '/api/roles.json');
}
sub roles_in {
my ($self, $service) = @
('get', "/api/services/${service}/roles.json");
}
sub hosts {
my ($self, %options) = @_;
my $response = $self->dispatch_request('get', '/api/hosts.json');
[
grep {
if
$self->ua->request( $req );
if ( $res->code == 200 ) {
my $data = $self->_decode( type => 'json', data => $res->content );
$data->{expires_at} = time + $data->{expires_in};
$self->merge_c
package AnyEvent::Lingr;
use Mouse;
our $VERSION = '0.07';
use AnyEvent::HTTP;
use Carp;
use JSON;
use Log::Minimal;
use Scalar::Util ();
use Try::Tiny;
use URI;
has ['user', 'password'] => (
ms);
my $cb_wrap = sub {
my ($body, $hdr) = @_;
my $json = try { decode_json $body };
$cb->($json, $hdr);
};
if ($http_method eq 'GET') {
http_get $uri,
sub {
my ($body, $hdr) = @_;
return unless $self;
my $res = try { decode_json $body };
if ($res and $res->{status} eq 'ok') {
if ($res->{counter}) {
' => bless( do{\(my $o = 1)}, 'JSON::Boolean' ),
'owner' => 'c9s',
'has_issues' => bless( do{\(my $o = 0)}, 'JSON::Boolean' ),
1
);
has content_type => (
is => 'rw',
isa => 'Str',
default => 'application/json'
);
sub n_val {
my $self = shift;
if (my $val = shift) {
$self->set_property('n_
and no explicit Object content_type is given in @args, the data will be serialised and stored as JSON.
If $key is passed as C<undef> then an autogenerated key will be provided by Riak.
=item get
content_type => (is => 'rw', isa => 'Str', default => 'application/json');
has location => (is => 'rw', isa => 'Str');
has _jsonize => (is => 'rw', isa => 'Bool', lazy => 1, default => 1);
ha
ucePhase;
{
$Net::Riak::MapReducePhase::VERSION = '0.1702';
}
use Moose;
use Scalar::Util;
use JSON;
has type => (is => 'rw', isa => 'Str', required => 1,);
has function => (is => 'ro', i
', isa => 'Str', default => 'javascript');
has keep => (is => 'rw', isa => 'JSON::Boolean', default => sub {JSON::false});
sub to_array {
my $self = shift;
my $step_def = {
kee
>setup_indexing('bucket_name');
Does the same as :
curl -X PUT -H "content-type:application/json" http://localhost:8098/riak/bucket_name -d '{"props":{"precommit":[{"mod":"riak_search_kv_hook","
earch(
q => 'bucket_name.field:value'
);
Search the index
=over 4
=item wt => 'XML|JSON'
defines the response format (XML is the default value as for Solr/Lucene)
=item q
the query s
le::REST::Object;
{
$Net::Riak::Role::REST::Object::VERSION = '0.1702';
}
use Moose::Role;
use JSON;
sub store_object {
my ($self, $w, $dw, $object) = @_;
my $params = {returnbody => 'tru
}
if (ref $object->data && $object->content_type eq 'application/json') {
$request->content(JSON::encode_json($object->data));
}
else {
$request->content($object->data
if $http_response->content_type;
$obj->data(JSON::decode_json($obj->data))
if $obj->content_type eq 'application/json';
$obj->vclock($http_response->header('X-Riak-Vc
EST::MapReduce;
{
$Net::Riak::Role::REST::MapReduce::VERSION = '0.1702';
}
use Moose::Role;
use JSON;
use Data::Dumper;
sub execute_job {
my ($self, $job, $timeout) = @_;
# save existing t
int($timeout/1000));
}
$job->{timeout} = $timeout;
}
my $content = JSON::encode_json($job);
my $request = $self->new_request(
'POST', [$self->mapred_prefix]
)
success) {
die "MapReduce query failed: ".$response->status_line;
}
return JSON::decode_json($response->content);
}
1;
__END__
=pod
=head1 NAME
Net::Riak::Role::REST::MapReduce
Nakanobu;
use strict;
use warnings;
use base qw/Class::Component::Plugin/;
use JSON::RPC::Common::Marshal::HTTP;
use JSON::RPC::Common::Procedure::Call;
use YAML ();
use LWP::UserAgent;
use Text::Trun
my ($method, $params, $entry_url, $timeout) = @_;
my $marshal = JSON::RPC::Common::Marshal::HTTP->new();
my $call = JSON::RPC::Common::Procedure::Call->new(
method => $method,
;
}
use Moose;
use JSON;
has bucket => (is => 'ro', isa => 'Str', required => 1);
has tag => (is => 'ro', isa => 'Str', required => 1);
has keep => (is => 'rw', isa => 'JSON::Boolean', required
ION = '0.1702';
}
# ABSTRACT: Allows you to build up and run a map/reduce operation on Riak
use JSON;
use Moose;
use Scalar::Util;
use Data::Dumper;
use Net::Riak::LinkPhase;
use Net::Riak::MapRed
my ($self, $bucket, $tag, $keep) = @_;
$bucket ||= '_';
$tag ||= '_';
$keep ||= JSON::false;
$self->add_phase(
Net::Riak::LinkPhase->new(
bucket => $bucket,
type => 'map',
function => $function,
keep => $options{keep} ? JSON::true : JSON::false,
arg => $options{arg} || [],
);
$self->add_phase($map_reduce);
buckets.. are you running riak 0.14+?"
unless $response->is_success;
my $resp = JSON::decode_json($response->content);
return ref ($resp->{buckets}) eq 'ARRAY' ? @{$resp->{buckets}} :
new_request('GET', ["stats"]);
my $response = $self->send_request($request);
return JSON::decode_json($response->content);
}
1;
__END__
=pod
=head1 NAME
Net::Riak::Role::REST - role for R
package App::gh::API;
use warnings;
use strict;
use Carp ();
use LWP::UserAgent;
use URI;
use JSON;
use App::gh::Utils;
use Try::Tiny;
use Net::GitHub;
sub new_ua {
my $class = shift;
my $ua
do{\(my $o = 1)}, 'JSON::Boolean' ),
'has_issues' => $VAR1->{'repository'}{'has_downloads'},
'name' => 'App-gh',
'private' => bless( do{\(my $o = 0)}, 'JSON::Boolean' ),
ole::REST::Search;
{
$Net::Riak::Role::REST::Search::VERSION = '0.1702';
}
use Moose::Role;
use JSON;
#ABSTRACT: Search interface
sub search {
my $self = shift;
my %params = @_;
my $re
>code;
if ($status == 404) {
return;
}
return JSON::decode_json($http_response->content) if $params{wt} =~ /json/i;
$http_response->content;
};
sub setup_indexing {
my (
return;
}
my $precommits = JSON::decode_json($http_response->content)->{props}->{precommit};
for (@$precommits){
return JSON::decode_json($http_response->content) if $_->{mod}
s::Accessor/;
use Data::Recursive::Encode;
use DateTime::Format::ISO8601;
use Hash::AsObject;
use JSON;
use LWP::UserAgent;
use URI;
# Accessors
__PACKAGE__->mk_accessors( qw/ iter / );
# Constructo
ess($response->is_success){
die 'Fetch error: '.$response->status_line;
}
# Decode JSON
my $js_hash = JSON->new->utf8->decode($response->content);
# Encoding
if(defined($self->{encoding})){