Arango-Tango
view release on metacpan or search on metacpan
lib/Arango/Tango.pm view on Meta::CPAN
# ABSTRACT: A simple interface to ArangoDB REST API
package Arango::Tango;
$Arango::Tango::VERSION = '0.020';
use base 'Arango::Tango::API';
use Arango::Tango::Database;
use Arango::Tango::Collection;
use strict;
use warnings;
use HTTP::Tiny;
use JSON;
use MIME::Base64 3.11 'encode_base64url';
use URI::Encode qw(uri_encode);
BEGIN {
Arango::Tango::API::_install_methods "Arango::Tango" => {
engine => { rest => [ get => '_api/engine' ] },
cluster_endpoints => { rest => [ get => '_api/cluster/endpoints' ] },
server_id => { rest => [ get => '_admin/server/id' ] },
status => { rest => [ get => '_admin/status' ] },
time => { rest => [ get => '_admin/time' ] },
statistics => { rest => [ get => '_admin/statistics' ] },
statistics_description => { rest => [ get => '_admin/statistics-description' ] },
target_version => { rest => [ get => '_admin/database/target-version' ] },
log_level => { rest => [ get => '_admin/log/level' ] },
server_role => { rest => [ get => '_admin/server/role' ] },
server_mode => { rest => [ get => '_admin/server/mode' ] },
server_availability => { rest => [ get => '_admin/server/availability' ] },
list_users => { rest => [ get => '_api/user' ] },
current_database => { rest => [ get => '_api/database/current' ] },
version => { rest => [ get => '_api/version' ], schema => { details => { type => 'boolean' } }},
delete_database => {
signature => [ 'name' ],
rest => [ delete => '_api/database/{name}' ]
},
delete_user => {
signature => [ 'username' ],
rest => [ delete => '_api/user/{username}' ]
},
replace_user => {
signature => [ 'username' ],
rest => [ put => '_api/user/{username}' ],
schema => { password => { type => 'string' },
active => { type => 'boolean' },
extra => { type => 'object', additionalProperties => 1 }}},
user => {
signature => [ 'username' ],
rest => [ get => '_api/user/{username}' ] },
update_user => {
signature => [ 'user' ],
rest => [ patch => '_api/user/{user}' ],
schema => { password => { type => 'string' },
active => { type => 'boolean' },
extra => { type => 'object', additionalProperties => 1 }}},
user_databases => {
signature => [ 'username' ],
rest => [ get => '_api/user/{username}/database' ],
schema => { full => {type => 'boolean' }}},
get_access_level => {
signature => ['username','database','?collection'],
rest => [ get => '_api/user/{username}/database/{database}/{collection}' ],
},
clear_access_level => {
signature => ['username','database','?collection'],
rest => [ delete => '_api/user/{username}/database/{database}/{collection}' ],
},
set_access_level => {
signature => ['username', 'grant', 'database', '?collection'],
lib/Arango/Tango.pm view on Meta::CPAN
Sets the database or the collection access level for a specific user.
=item C<clear_access_level>
$db->clear_access_level("john", "myDatabase");
$db->clear_access_level("john", "myDatabase", $collection);
Clears the database or the collection access level for a specific user.
=back
=head2 Querying Server Metadata
=over 4
=item C<target_version>
my $ans = $db->target_version;
$target_version = $ans->{target_version}; # might change in the future...
Returns the database version that this server requires.
The version is returned in the version attribute of the result.
=item C<log>
my $logs = $db-a>log(upto => "warning");
Returns fatal, error, warning or info log messages from the serverâs global log.
=item C<log_level>
my $log_levels = $db->log_level();
Returns the serverâs current log level settings.
=item C<server_availability>
my $info = $db->server_availability();
Return availability information about a server.
=item C<server_id>
my $id = $db->server_id();
Returns the id of a server in a cluster. The request will fail if the server is not running in cluster mode.
=item C<server_mode>
my $mode = $db->server_mode();
Return mode information about a server.
=item C<server_role>
my $mode = $db->server_role();
Returns the role of a server in a cluster.
=item C<cluster_endpoints>
my $endpoints = $db->cluster_endpoints;
Returns an object with an attribute endpoints, which contains an array
of objects, which each have the attribute endpoint, whose value is a
string with the endpoint description. There is an entry for each
coordinator in the cluster. This method only works on coordinators in
cluster mode. In case of an error the error attribute is set to true.
=item C<version>
my $version_info = $db->version;
my $detailed_info = $db->version( 'details' => 1 );
Returns a hash reference with basic server info. Detailed information can be requested with the C<details> option.
=item C<engine>
my $engine = $db->engine;
Returns the storage engine the server is configured to use.
=item C<statistics>
my $stats = $db->statistics;
Read the statistics of a server.
=item C<statistics_description>
my $stats_desc = $db->statistics_description;
Statistics description
=item C<status>
my $status = $db->status;
Return status information
=item C<time>
my $time = $db->time;
Return system time
=item C<error>
my $error = $db->error;
Get latest Arango::Tango error message. Note that this message is not cleared, thus it should only
be queried whenever a method dies.
The die value is '-1' for Arango::Tango errors. Otherwise, is the HTTP code returned by the server, if not equal to success.
=back
=head1 CAVEATS
=head2 Options Validation
Most optional options are validated and fitted using
C<JSON::Scheme::Fit>. This means that the module will try to remove
invalid options and adapt values from valid options to valid values.
While this can make some mistakes silently, it was preferred to dying
at any structure problem.
( run in 1.004 second using v1.01-cache-2.11-cpan-9169edd2b0e )