NAME
Net::EtcDv2::Node - A object oriented Perl module to stat entries in an EtcD v2 API key/value store
VERSION
Version 0.0.3
SYNOPSIS
use feature say;
use Data::Dumper;
use Net::EtcDv2::EntryStat;
# create an un-authenticated object for an etcd running on localhost on
# port 2379
my $foo = Net::EtcDv2::EntryStat->new(
'host' => "http://localhost",
'port' => 2379
);
my $stat_struct = $foo->stat('/myDir');
say Dumper $stat_struct;
# outputs the following if '/myDir' exists and is a directory
# $VAR1 = {
# 'type' => 'dir',
# 'uri' => 'http://localhost:2379/myDir',
# 'ace' => '*:POST, GET, OPTIONS, PUT, DELETE',
# 'entryId' => 'cdf818194f3b8d32:23'
# };
#
# The ACE is the access allowed methods and and origin for that path, and
# the 'entryId' is made up from the cluster ID and the etcd item index ID
DESCRIPTION
The Net::EtcDv2::EntryStat module is an internal module to the Net::EtcDv2 distribution. It allows code to stat key/value entries in an etcd cluster.
METHODS
new
The constructor for the class. For now, we only support HTTP basic authentication.
If the DEBUG environment variable is set, the class will emit debugging output on STDERR.
Parameters:
- class, SCALAR: The class name
- args, HASH: A hash of named parameters:
- host: the hostname of the etcd endpoint
- port: the port number of the etcd endpoint
- user: the username authorized for the etcd environment
- password: the password for the user authorized for the etcd
environment
stat
This method takes a path and gathers information about the etcd object. If the item doesn't exist, it throws an exception (error code 6).
Parameters:
- self, SCALAR REF: the object reference
- path, SCALAR: the path segment of the URI to get info for
Return type:
- stat_struct: HASH: the stat information for the path
Exceptions:
If the object is not found (HTTP 404), the method will emit error ENXIO
ls
This method, like stat, takes a path and gathers information about the etcd object. If the item doesn't exist, it throws an exception (error code 6).
Unlike stat
, it only returns in the JSON response the node name, type, and whether it has any children. In addition, while stat
only returns specific information about the named node, ls can do recursive listing, and if the item requested was a directory, it's immediate children; any child items are nested in the response.
Parameters:
- self, SCALAR REF: the object reference
- path, SCALAR: the path segment of the URI to get info for
- recursive, SCALAR boolean [OPTIONAL]: Whether to recursively descend into
sub directories
Return type:
- status, SCALAR boolean: Whether the listing was successful or not
- stat_struct: HASH: the stat information for the path
Exceptions:
If the object is not found (HTTP 404), the method will emit error ENXIO