App-ElasticSearch-Utilities

 view release on metacpan or  search on metacpan

lib/App/ElasticSearch/Utilities.pm  view on Meta::CPAN

        es_indices_meta
        es_index_valid
        es_index_bases
        es_index_strip_date
        es_index_days_old
        es_index_shards
        es_index_segments
        es_index_stats
        es_index_fields
        es_settings
        es_node_stats
        es_segment_stats
        es_close_index
        es_open_index
        es_delete_index
        es_optimize_index
        es_apply_index_settings
        es_local_index_meta
        es_flatten_hash
        es_human_count
        es_human_size
        es_format_numeric
    )],
    groups => {
        config  => [qw(es_utils_initialize es_globals)],
        default => [qw(es_utils_initialize es_connect es_indices es_request)],
        human   => [qw(es_human_count es_human_size es_format_numeric)],
        indices => [qw(:default es_indices_meta)],
        index   => [qw(
            :default es_index_valid es_index_fields es_index_days_old es_index_bases
            es_index_strip_date es_index_shards es_index_segments es_index_stats
        )],
        maintenance => [qw(
            es_close_index es_open_index es_delete_index es_optimize_index
            es_apply_index_settings
        )],
    },
};


use App::ElasticSearch::Utilities::Connection;
use App::ElasticSearch::Utilities::VersionHacks qw(_fix_version_request);

# Collectors
sub _copy_argv       { $COPY_ARGV    = 1 }
sub _preprocess_argv { $ARGV_AT_INIT = 1 }
sub _delay_argv      { $ARGV_AT_INIT = 0 }


# Global Variables
our %_GLOBALS = ();
my  %DEF      = ();
my  %PATTERN_REGEX = (
    '*'  => qr/.*/,
    ANY  => qr/.*/,
    DATE => qr/
        (?<datestr>
                (?<year>\d{4})              # Extract 4 digits for the year
                (?:(?<datesep>[\-.]))?      # Optionally, look for . - as a separator
                (?<month>\d{2})             # Two digits for the month
                \g{datesep}                 # Whatever the date separator was in the previous match
                (?<day>\d{2})               # Two digits for the day
                (?![a-zA-Z0-9])             # Zero width negative look ahead, not alphanumeric
        )
    /x,
);
my $PATTERN;

{
    ## no critic (ProhibitNoWarnings)
    no warnings;
    INIT {
        return if $_init_complete++;
        es_utils_initialize() if $ARGV_AT_INIT;
    }
    ## use critic
}


{
    # Argument Parsing Block
    my @argv_original = ();
    my $parsed_argv = 0;
    sub _parse_options {
        my ($opt_ref) = @_;
        my @opt_spec = qw(
            local
            host=s
            port=i
            timeout=i
            keep-proxy
            index=s
            pattern=s
            base|index-basename=s
            days=i
            noop!
            proto=s
            http-username=s
            password-exec=s
            master-only|M
            insecure
            capath=s
            cacert=s
            cert=s
            key=s
        );

        my $argv;
        my %opt;
        if( defined $opt_ref && is_arrayref($opt_ref) ) {
            # If passed an argv array, use that
            $argv = $COPY_ARGV ? [ @{ $opt_ref } ] : $opt_ref;
        }
        else {
            # Ensure multiple calls to cli_helpers_initialize() yield the same results
            if ( $parsed_argv ) {
                ## no critic
                @ARGV = @argv_original;
                ## use critic
            }
            else {



( run in 3.134 seconds using v1.01-cache-2.11-cpan-5837b0d9d2c )