ArangoDB2

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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

MANIFEST  view on Meta::CPAN

39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 
 
 
# 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

59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
    # 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

250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
=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

279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
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

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
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> >>
 
 
=head1 COPYRIGHT

lib/ArangoDB2/Replication.pm  view on Meta::CPAN

329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
=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

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
    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

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
 
 
 
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.349 second using v1.01-cache-2.11-cpan-e5176c747c2 )