ArangoDB2
view release on metacpan or search on metacpan
0.11 2014-11-11
* Add WWW::Curl based HTTP backend
0.10 2014-11-04
* Add support for authentication
* Add support for admin API methods
* Change all `patch` method names to `update`
0.09 2014-11-04
* Add support for endpoint API methods
0.08 2014-11-04
* Add support for user API methods
0.07 2014-11-04
* Add support for replication API methods
0.06 2014-11-04
* Add support for traversal API methods
t/09-index.t
t/10-transaction.t
t/11-graph.t
t/12-graph-vertex-collection.t
t/13-graph-edge-definition.t
t/14-graph-vertex.t
t/15-graph-vertex.t
t/16-traversal.t
t/17-replication.t
t/18-user.t
t/19-endpoint.t
t/20-benchmark.t
t/manifest.t
t/pod-coverage.t
t/pod.t
META.yml Module YAML meta-data (added by MakeMaker)
META.json Module JSON meta-data (added by MakeMaker)
lib/ArangoDB2.pm view on Meta::CPAN
use ArangoDB2::Admin;
use ArangoDB2::Database;
use ArangoDB2::Endpoint;
use ArangoDB2::HTTP;
# new
#
# create new ArangoDB2 instance from string argument specifying
# API endpoint or hashref of args
sub new
{
my($class, $uri, $username, $password) = @_;
# create instance
my $self = {};
bless($self, $class);
# set values
$self->uri($uri);
$self->username($username);
$self->password($password);
lib/ArangoDB2.pm view on Meta::CPAN
# only create one instance per ArangoDB2 per database, each ArangoDB2
# keeps its own instances since they may have different credentials
return $self->databases->{$name} ||= ArangoDB2::Database->new($self, $name);
}
# databases
#
# Index of active ArangoDB2::Database objects by name
sub databases { $_[0]->{databases} ||= {} }
# endpoint
#
# ArangoDB2::Endpoint object
sub endpoint
{
my($self, $name) = @_;
return ArangoDB2::Endpoint->new($self, $name);
}
# http
#
# ArangoDB2::HTTP object. This provides normalized interface to
# various HTTP clients.
lib/ArangoDB2.pm view on Meta::CPAN
=over 4
=item new
=item admin
=item database
=item databases
=item endpoint
=item http
=item http_client
Get/set string indicating which HTTP backend to use. Currently supported values are 'lwp' and
'curl'. Using curl requires L<WWW::Curl>, which will be used by default if it is installed.
=back
lib/ArangoDB2.pm view on Meta::CPAN
Returns the server name and version number.
=back
=head1 PROPERTY METHODS
=over 4
=item uri
L<URI> of ArangoDB endpoint.
=item password
Password to use when accessing ArangoDB.
=item username
Username to use when accessing ArangoDB.
=back
lib/ArangoDB2/Endpoint.pm view on Meta::CPAN
my $JSON = JSON::XS->new->utf8;
###############
# API METHODS #
###############
# create
#
# POST /_api/endpoint
sub create
{
my($self, $args) = @_;
# process request args
$args = $self->_build_args($args, ['name', 'databases']);
# use name for endpoint param
$args->{endpoint} = $args->{name};
# make request
my $res = $self->arango->http->post(
'/_api/endpoint',
undef,
$JSON->encode($args),
) or return;
# if request was success copy args to self
$self->_build_self($args, ['name', 'databases']);
return $self;
}
# delete
#
# DELETE /_api/endpoint/{name}
sub delete
{
my($self, $args) = @_;
# process request args
$args = $self->_build_args($args, ['name']);
# make request
return $self->arango->http->delete(
'/_api/endpoint/'.uri_escape( $args->{name} )
);
}
# list
#
# GET /_api/endpoint
sub list
{
my($self) = @_;
return $self->arango->http->get('/_api/endpoint');
}
####################
# PROPERTY METHODS #
####################
sub databases { shift->_get_set('databases', @_) }
1;
__END__
=head1 NAME
ArangoDB2::Endpoint - ArangoDB endpoint API methods
=head1 DESCRIPTION
=head1 API METHODS
=over 4
=item create
POST /_api/endpoint
Connects a new endpoint or reconfigures an existing endpoint.
Parameters:
name
databases
=item delete
DELETE /_api/endpoint/{endpoint}
Parameters:
name
=item list
GET /_api/endpoint
Returns a list of all configured endpoints the server is listening on.
=back
=head1 PROPERTY METHODS
=over 4
=item name
the endpoint specification, e.g. tcp://127.0.0.1:8530
=item databases
a list of database names the endpoint is responsible for.
=back
=head1 AUTHOR
Ersun Warncke, C<< <ersun.warncke at outlook.com> >>
http://ersun.warnckes.com
=head1 COPYRIGHT
lib/ArangoDB2/Replication.pm view on Meta::CPAN
=item serverId
GET /_api/replication/server-id
Returns the servers id. The id is also returned by other replication API methods, and this method is an easy means of determining a server's id.
=item sync
PUT /_api/replication/sync
Starts a full data synchronization from a remote endpoint into the local ArangoDB database.
Parameters:
configuration
=back
=head1 PROPERTY METHODS
=over 4
t/01-arango.t view on Meta::CPAN
version
);
for my $method (@methods) {
can_ok($arango, $method);
}
# test for sub objects accessors
isa_ok($arango->admin, 'ArangoDB2::Admin');
isa_ok($arango->database, 'ArangoDB2::Database');
isa_ok($arango->endpoint, 'ArangoDB2::Endpoint');
isa_ok($arango->http, 'ArangoDB2::HTTP');
isa_ok($arango->uri, 'URI');
# skip tests against the actual ArangoDB2 server unless
# LIVE_TEST env param is set
if (!$ENV{LIVE_TEST}) {
diag("Skipping live API tests - set LIVE_TEST=1 to enable");
done_testing();
exit;
}
t/19-endpoint.t view on Meta::CPAN
use warnings;
use Data::Dumper;
use Test::More;
use ArangoDB2;
my $res;
my $arango = ArangoDB2->new("http://localhost:8529", $ENV{ARANGO_USER}, $ENV{ARANGO_PASS});
my $endpoint = $arango->endpoint;
# test required methods
my @api_methods = qw(
create
delete
list
);
my @methods = qw(
name
databases
);
for my $method (@methods, @api_methods) {
can_ok($endpoint, $method);
}
# skip tests against the actual ArangoDB server unless
# LIVE_TEST env param is set
if (!$ENV{LIVE_TEST}) {
diag("Skipping live API tests - set LIVE_TEST=1 to enable");
done_testing();
exit;
}
# create database
$arango->database("foo")->create;
# create endpoint
$res = $endpoint->name("tcp://localhost:8530")->create({
databases => ["foo"],
});
ok($res, "create endpoint");
# get list
$res = $endpoint->list;
ok($res, "list");
my($end) = grep {$_->{endpoint} eq "tcp://localhost:8530"} @$res;
ok($end, "endpoint exists" );
is_deeply($end->{databases}, ['foo'], "endpoint: databases");
# delete endpoint
$res = $endpoint->delete;
ok($res, "endpoint delete");
# get list
$res = $endpoint->list;
($end) = grep {$_->{endpoint} eq "tcp://localhost:8530"} @$res;
ok(!$end, "endpoint does not exist" );
# delete database
$arango->database("foo")->delete;
done_testing();
( run in 0.725 second using v1.01-cache-2.11-cpan-e5176c747c2 )