App-ElasticSearch-Utilities
view release on metacpan or search on metacpan
lib/App/ElasticSearch/Utilities/Connection.pm view on Meta::CPAN
package App::ElasticSearch::Utilities::Connection;
# ABSTRACT: Abstract the connection element
use v5.16;
use warnings;
our $VERSION = '9.0'; # VERSION
use App::ElasticSearch::Utilities::HTTPRequest;
use App::ElasticSearch::Utilities::VersionHacks qw(_fix_version_request);
use CLI::Helpers qw(:output);
use JSON::MaybeXS;
use LWP::UserAgent;
use Module::Load;
use Ref::Util qw(is_ref is_arrayref is_hashref);
use Types::Standard qw( Enum HashRef InstanceOf Int Str );
use URI;
use URI::QueryParam;
use Moo;
use namespace::autoclean;
has 'host' => (
is => 'ro',
isa => Str,
default => sub { 'localhost' },
);
has 'port' => (
is => 'ro',
isa => Int,
default => sub { 9200 },
);
has 'proto' => (
is => 'rw',
isa => Enum[qw(http https)],
default => sub { 'http' },
);
has 'timeout' => (
is => 'ro',
isa => Int,
default => sub { 10 },
);
has 'username' => (
is => 'ro',
isa => Str,
default => sub { $ENV{USER} },
);
has 'password' => (
is => 'ro',
);
has 'ssl_opts' => (
is => 'ro',
isa => HashRef,
default => sub { {} },
);
has 'version' => (
is => 'lazy',
isa => Str,
init_arg => undef,
);
sub _build_version {
my $self = shift;
# Retry with TLS and/or Auth
my $resp = $self->request('/',{skip_version_check => 1});
my $err;
if( $resp->is_success ) {
( run in 0.800 second using v1.01-cache-2.11-cpan-2aafcb1aa8b )