File Coverage

blib/lib/OpenSearch/Parameters/Index/Stats.pm
Criterion Covered Total %
statement 18 19 94.7
branch n/a
condition n/a
subroutine 6 7 85.7
pod 0 1 0.0
total 24 27 88.8


line stmt bran cond sub pod time code
1             package OpenSearch::Parameters::Index::Stats;
2 4     4   2568 use strict;
  4         11  
  4         187  
3 4     4   23 use warnings;
  4         9  
  4         219  
4 4     4   24 use feature qw(state);
  4         10  
  4         473  
5 4     4   27 use Types::Standard qw(Str Bool ArrayRef Enum);
  4         10  
  4         32  
6 4     4   9195 use Types::Common::String qw(NonEmptyStr);
  4         12  
  4         40  
7 4     4   4380 use Moo::Role;
  4         11  
  4         36  
8              
9             with 'OpenSearch::Parameters';
10              
11             my $StatsMetrics = Enum[
12             qw(_all completion docs fielddata flush get indexing merge query_cache refresh refresh_cache search segments store translog warmer)
13             ];
14              
15             has 'index' => (
16             is => 'rw',
17             isa => Str,
18             );
19              
20             has 'metric' => (
21             is => 'rw',
22             # TODO: type checks works, but encode_func is not applied for path arguments
23             #isa => ArrayRef[$StatsMetrics] | Str,
24             isa => NonEmptyStr,
25             );
26              
27             has 'expand_wildcards' => (
28             is => 'rw',
29             isa => Str
30             );
31              
32             has 'fields' => (
33             is => 'rw',
34             isa => Str,
35             );
36              
37             has 'completions_fields' => (
38             is => 'rw',
39             isa => Str,
40             );
41              
42             has 'fielddata_fields' => (
43             is => 'rw',
44             isa => Str,
45             );
46              
47             has 'forbid_closed_indices' => (
48             is => 'rw',
49             isa => Bool,
50             );
51              
52             has 'groups' => (
53             is => 'rw',
54             isa => Str,
55             );
56              
57             has 'level' => (
58             is => 'rw',
59             isa => Str,
60             );
61              
62             has 'include_segment_file_sizes' => (
63             is => 'rw',
64             isa => Bool,
65             );
66              
67             # TODO: Handle ARRAYREF getter for path parameters. i.e.: metrics
68             around [
69             qw/index metric expand_wildcards fields completions_fields fielddata_fields forbid_closed_indices groups level include_segment_file_sizes
70             /
71             ] => sub {
72             my $orig = shift;
73             my $self = shift;
74              
75             if (@_) {
76             $self->$orig(@_);
77             return ($self);
78             }
79             return ( $self->$orig );
80             };
81              
82             sub api_spec {
83 0     0 0   state $s = +{
84             index => {
85             encode_func => 'as_is',
86             type => 'path',
87             },
88             metric => {
89             encode_func => 'as_is',
90             type => 'path',
91             },
92             expand_wildcards => {
93             encode_func => 'as_is',
94             type => 'url',
95             },
96             fields => {
97             encode_func => 'as_is',
98             type => 'url',
99             },
100             completions_fields => {
101             encode_func => 'as_is',
102             type => 'url',
103             },
104             fielddata_fields => {
105             encode_func => 'as_is',
106             type => 'url',
107             },
108             forbid_closed_indices => {
109             encode_func => 'encode_bool',
110             type => 'url',
111             },
112             groups => {
113             encode_func => 'as_is',
114             type => 'url',
115             },
116             level => {
117             encode_func => 'as_is',
118             type => 'url',
119             },
120             include_segment_file_sizes => {
121             encode_func => 'encode_bool',
122             type => 'url',
123             }
124             };
125             }
126              
127             1;