use strict;
use warnings;
use base qw(
ArangoDB2::Base
);
use Data::Dumper;
use JSON::XS;
my $JSON = JSON::XS->new->utf8;
my @PARAMS = qw(
active changePassword extra name passwd
);
##
my $res = $self->arango->http->post(
$self->api_path('user'),
undef,
$JSON->encode($args),
) or return;
# if request was success copy args to self
$self->_build
ango->http->patch(
$self->api_path('user', delete $args->{name}),
undef,
$JSON->encode($args),
) or return;
# if request was success copy args to self
$self->_build
# version
#
# GET /_api/version
#
# Returns the server name and version number. The response is a JSON object with the following attributes:
#
# server: will always contain arango
# version: the serve
minor will be numeric, and sub may contain a number or a textual version.
# details: an optional JSON object with additional details. This is returned only if the details URL parameter is set to true
rs. The only validation that takes place is to
insure that bool parameters have properly encoded JSON true and false values.
=head1 METHODS
=over 4
=item new
=item admin
=item database
=item da
nted REST clients
=head1 SYNOPSIS
package Your::API;
use base qw(Rest::Client::Builder);
use JSON;
sub new {
my ($class) = @_;
my $self;
$self = $class->SUPER::new({
on_request => sub
{
my ($self, $method, $path, $args) = @_;
return sprintf("%s %s %s\n", $method, $path, encode_json($args));
}
my $api = Your::API->new();
print $api->resource->get({ value => 1 });
# output:
ide any methods of any API object:
package Your::API;
use base qw(Rest::Client::Builder);
use JSON;
sub new {
my ($class) = @_;
my $self;
$self = $class->SUPER::new({
on_request => sub
our $VERSION = '0.04';
use Algorithm::ConsistentHash::JumpHash;
use Moose;
use JSON::XS qw(encode_json decode_json);
with 'ShardedKV::Continuum';
has '_orig_continuum_spec' => (
is => 'ro',
);
serialize {
my $self = shift;
encode_json( $self->_orig_continuum_spec )
}
sub deserialize {
my $class = shift;
return $class->new(from => decode_json( $_[1] ));
}
sub clone {
my $self = s
Data::Dumper;
use JSON::XS;
# parameters that can be set when creating index or
# are returned when creating/getting index
our @PARAMS = qw(
byteSize constraint fields geoJson id ignoreNull
isNewlyCreated minLength size type unique
);
my $JSON = JSON::XS->new->utf8;
# byteSize
#
# get/set byteSize
sub byteSize { shift->_get_set('byteSize', @_) }
# constraint
#
# get/set constraint v
my $res = $self->arango->http->post(
$self->api_path('index'),
$args,
$JSON->encode($index),
) or return;
# get name from id
my($name) = $res->{id} =~ m{/(\d+)$}
se qw(
ArangoDB2::Base
);
use Data::Dumper;
use JSON::XS;
use ArangoDB2::Document;
use ArangoDB2::Edge;
use ArangoDB2::Index;
my $JSON = JSON::XS->new->utf8;
# params that can be set when crea
$res = $self->arango->http->post(
$self->api_path('collection'),
undef,
$JSON->encode($args),
) or return;
# copy response data to instance
$self->_build_self($res
# if args are passed then set with PUT
? $self->arango->http->put($path, undef, $JSON->encode($args))
# otherwise get properties
: $self->arango->http->get($path);
ArangoDB2::Admin;
use strict;
use warnings;
use base qw(
ArangoDB2::Base
);
use JSON::XS;
my $JSON = JSON::XS->new->utf8;
###############
# API METHODS #
###############
# echo
#
# GET /_a
($self, $args) = @_;
# process args
$args = $self->_build_args($args, ['program','returnAsJSON']);
my $program = delete $args->{program};
# make request
return $self->arango->http-
roperties';
# make request
return $args
? $self->arango->http->put($path, undef, $JSON->encode($args))
: $self->arango->http->get($path);
}
####################
# PROPERTY MET
;
use base qw(
ArangoDB2::HTTP
);
use Data::Dumper;
use JSON::XS;
use LWP::UserAgent;
use Scalar::Util qw(weaken);
my $JSON = JSON::XS->new->utf8;
sub new
{
my($class, $arango) = @_;
_;
if ($response->is_success) {
my $res = eval { $JSON->decode($response->content) };
# if content is not valid JSON then return entire content
return $response->content u
rangoDB2::HTTP
);
use Data::Dumper;
use HTTP::Response;
use JSON::XS;
use Scalar::Util qw(weaken);
use WWW::Curl::Easy;
my $JSON = JSON::XS->new->utf8;
sub new
{
my($class, $arango) = @_;
;
return;
}
# decode response, assuming JSON
my $res = eval { $JSON->decode($$response) };
# if content is not valid JSON then return entire content
return $$response unles
package WebService::Bandcamp;
use JSON::XS;
use Cache::LRU;
use Net::DNS::Lite;
use Furl;
use URI;
use URI::QueryParam;
use Carp;
use Moo;
use namespace::clean;
our $VERSION = "0.06";
$Net::DNS::Lit
com',
path_query => "$path$query",
method => 'GET',
);
my $data = decode_json( $content );
if ( defined $data->{error} ) {
my $code = $data->{error};
my $m
e warnings;
use base qw(
ArangoDB2::Base
);
use Data::Dumper;
use JSON::XS;
use ArangoDB2::Graph::Vertex;
my $JSON = JSON::XS->new->utf8;
# create
#
# POST /_api/gharial/graph-name/vertex
s
->post(
$self->api_path('gharial', $self->graph->name, 'vertex'),
undef,
$JSON->encode({collection => $args->{name}}),
) or return;
# set name
$self->name($args->{n
ct;
use warnings;
use base qw(
ArangoDB2::Graph::Vertex
);
use Data::Dumper;
use JSON::XS;
my $JSON = JSON::XS->new->utf8;
# POST /_api/gharial/graph-name/edge/collection-name
sub create
{
se warnings;
use base qw(
ArangoDB2::Base
);
use Data::Dumper;
use JSON::XS;
use ArangoDB2::Graph::Edge;
my $JSON = JSON::XS->new->utf8;
# create
#
# POST /_api/gharial/graph-name/edge
sub
tp->post(
$self->api_path('gharial', $self->graph->name, 'edge'),
undef,
$JSON->encode($args),
) or return;
# set name
$self->name($name);
# update parent graph
$self->api_path('gharial', $self->graph->name, 'edge', $self->name),
undef,
$JSON->encode($args),
) or return;
# set name
$self->name($name);
# update parent graph
use strict;
use warnings;
use base qw(
ArangoDB2::Base
);
use Data::Dumper;
use JSON::XS;
my $JSON = JSON::XS->new->utf8;
# create
#
# POST /_api/gharial/graph-name/vertex/collection-name
s
h('gharial', $self->graph->name, $self->_class, $self->collection->name),
$args,
$JSON->encode($data),
) or return;
# get response data
$res = $res->{$self->_class}
aph->name, $self->_class, $self->collection->name, delete $args->{name}),
$args,
$JSON->encode($data),
) or return;
# get response data
$res = $res->{$self->_class}
( such as serializers )
# be configurable as well and they can't really be defined as-is in JSON
{
type => 'driver',
name => 'myproject.roflmayo',
config => {
t.roflmayo');
# Do stuff with $cache and get default behaviour
# User creates ~/.chi/config.json
[
{
'type' : 'driver',
'name' : 'myproject.roflmayo',
'config': {
onfig_paths => ['./foo'] )
Would automatically attempt to load any files called
foo.yml
foo.json
foo.ini
And load them with the relevant helpers.
See L<< C<Config::Any>|Config::Any >> for de
use strict;
use warnings;
use base qw(
ArangoDB2::Base
);
use Data::Dumper;
use JSON::XS;
my $JSON = JSON::XS->new->utf8;
###############
# API METHODS #
###############
# applierConfig
#
uild our own response
my $ret = {};
# response is newline separated JSON log entries
$ret->{log} = [ map { $JSON->decode($_) } split(/\n/, $res->content) ];
# get response header valu
the collection to dump. Accepts string or L<ArangoDB2::COllection> object.
=item configuration
JSON representation of the configuration
=item from
Lower bound tick value for results.
=item inclu
use warnings;
use base qw(
ArangoDB2::Base
);
use Data::Dumper;
use JSON::XS;
use ArangoDB2::Cursor;
my $JSON = JSON::XS->new->utf8;
# new
#
# create new instance
sub new
{
my($class,
my $res = $self->arango->http->post(
$self->api_path('cursor'),
undef,
$JSON->encode($args),
) or return;
return ArangoDB2::Cursor->new($self->arango, $self->databas
return $self->arango->http->post(
$self->api_path('explain'),
undef,
$JSON->encode({query => $self->query}),
);
}
# parse
#
# POST /_api/query
sub parse
{
my($self
B2::Base
);
use Data::Dumper;
use JSON::XS;
use ArangoDB2::Graph::EdgeDefinition;
use ArangoDB2::Graph::VertexCollection;
use ArangoDB2::Traversal;
my $JSON = JSON::XS->new->utf8;
# create
#
# P
my $res = $self->arango->http->post(
$self->api_path('gharial'),
undef,
$JSON->encode($args),
) or return;
# copy param data from res to self
$self->_build_self($r
to a global object.
sub new { bless \do{my $thing = $_[1]}, $_[0] }
sub value { undef }
*TO_JSON=*value;
sub typeof { 'undefined' }
sub id { 'undef' }
sub primitive { 1 }
sub to_primitive {
$self,$$self[1]->upgrade(@_)
);
}
sub value { warn caller if !ref $_[0];shift->[0] }
sub TO_JSON { \(0+shift->[0]) }
sub exists { !1 }
sub typeof { 'boolean' }
sub class { 'Boolean' }
s