# 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
;
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
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+)$}
use strict;
use warnings;
use base qw(
ArangoDB2::Base
);
use Data::Dumper;
use JSON::XS;
my $JSON = JSON::XS->new->utf8;
# action
#
# get/set action
sub action { shift->_get_set('action',
return $self->arango->http->post(
$self->api_path('transaction'),
undef,
$JSON->encode($args),
);
}
# lockTimeout
#
# get/set lockTimeout
sub lockTimeout { shift->_get_set
warnings;
use base qw(
ArangoDB2::Base
);
use Data::Dumper;
use JSON::XS;
use URI::Escape qw(uri_escape);
my $JSON = JSON::XS->new->utf8;
###############
# API METHODS #
###############
#
equest
my $res = $self->arango->http->post(
'/_api/endpoint',
undef,
$JSON->encode($args),
) or return;
# if request was success copy args to self
$self->_build
use strict;
use warnings;
use base qw(
ArangoDB2::Base
);
use Data::Dumper;
use JSON::XS;
my $JSON = JSON::XS->new->utf8;
my @PARAMS = qw(
direction edgeCollection expander filter graphNa
return $self->arango->http->post(
$self->api_path('traversal'),
undef,
$JSON->encode($args),
);
}
# expander
#
# get/ set expander
sub expander { shift->_get_set('expand
rator function with this attribute. Note that the value here has to be a string to conform to the JSON standard, which in turn is parsed as function body on the server side. Furthermore note that this
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
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
JSON::XS;
use Scalar::Util qw(reftype);
use ArangoDB2::Collection;
use ArangoDB2::Graph;
use ArangoDB2::Query;
use ArangoDB2::Replication;
use ArangoDB2::Transaction;
use ArangoDB2::User;
my $JSON
= JSON::XS->new->utf8;
# collection
#
# get/create ArangoDB2::Collection object
sub collection
{
my($self, $name) = @_;
if (defined $name) {
# only create one ArangoDB2::Collection
equest
my $res = $self->arango->http->post(
'/_api/database',
undef,
$JSON->encode($args),
) or return;
return $self;
}
# current
#
# GET /_api/database/current
s
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
package ArangoDB2::Base;
use strict;
use warnings;
use Carp qw(croak);
use Data::Dumper;
use JSON::XS;
use Scalar::Util qw(blessed weaken);
# new
#
# Arango organizes data hierarchically: Databas
value or set JSON bool value.
# setting value returns self.
sub _get_set_bool
{
my($self, $param, $value, $validate) = @_;
if (defined $value) {
# accept "true" as JSON bool false
eq "true") {
$value = JSON::XS::true;
}
# accept "false" as JSON bool false
elsif ($value eq "false") {
$value = JSON::XS::false;
}
# 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
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
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
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}
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
use strict;
use warnings;
use base qw(
ArangoDB2::Base
);
use Data::Dumper;
use JSON::XS;
my $JSON = JSON::XS->new->utf8;
# create
#
# POST /_api/document
#
# Query Parameters
#
# collectio
$res = $self->arango->http->post(
$self->api_path($self->_class),
$args,
$JSON->encode($data),
) or return;
# copy response data to instance
$self->_build_self($res
$self->api_path($self->_class, $self->collection->name, $self->name),
$args,
$JSON->encode($data),
) or return;
# copy response data to instance
$self->_build_self($res
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);
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