File Coverage

blib/lib/OpenSearch/Parameters/Document/Index.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::Document::Index;
2 4     4   3005 use strict;
  4         10  
  4         252  
3 4     4   25 use warnings;
  4         11  
  4         217  
4 4     4   23 use feature qw(state);
  4         10  
  4         499  
5 4     4   31 use Types::Standard qw(Str Bool Int Enum HashRef);
  4         9  
  4         32  
6 4     4   26247 use Types::Common::String qw(NonEmptyStr);
  4         10  
  4         42  
7 4     4   4991 use Moo::Role;
  4         10  
  4         49  
8              
9             with 'OpenSearch::Parameters';
10              
11             has 'index' => (
12             is => 'rw',
13             isa => NonEmptyStr,
14             required => 1,
15             );
16              
17             # create if _doc does not exist
18             has 'create' => (
19             is => 'rw',
20             isa => Bool,
21             );
22              
23             has 'id' => (
24             is => 'rw',
25             isa => Str,
26             );
27              
28             has 'doc' => (
29             is => 'rw',
30             isa => HashRef,
31             required => 1,
32             );
33              
34             has 'if_seq_no' => (
35             is => 'rw',
36             isa => Int,
37             );
38              
39             has 'if_primary_term' => (
40             is => 'rw',
41             isa => Int,
42             );
43              
44             has 'op_type' => (
45             is => 'rw',
46             isa => Enum[qw(index create)],
47             );
48              
49             has 'pipeline' => (
50             is => 'rw',
51             isa => Str,
52             );
53              
54             has 'routing' => (
55             is => 'rw',
56             isa => Str,
57             );
58              
59             has 'refresh' => (
60             is => 'rw',
61             isa => Enum[qw(true false wait_for)],
62             );
63              
64             has 'timeout' => (
65             is => 'rw',
66             isa => Str,
67             );
68              
69             has 'version' => (
70             is => 'rw',
71             isa => Int,
72             );
73              
74             has 'version_type' => (
75             is => 'rw',
76             isa => Enum[qw(internal external external_gte)],
77             );
78              
79             has 'wait_for_active_shards' => (
80             is => 'rw',
81             isa => Str,
82             );
83              
84             has 'require_alias' => (
85             is => 'rw',
86             isa => Bool,
87             );
88              
89             around [
90             qw/
91             index create id doc if_seq_no if_primary_term op_type pipeline routing refresh timeout
92             version version_type wait_for_active_shards require_alias
93             /
94             ] => sub {
95             my $orig = shift;
96             my $self = shift;
97              
98             if (@_) {
99             $self->$orig(@_);
100             return ($self);
101             }
102             return ( $self->$orig );
103             };
104              
105             sub api_spec {
106 0     0 0   state $s = +{
107             index => {
108             encode_func => 'as_is',
109             type => 'path',
110             },
111             create => {
112             encode_func => 'as_is',
113             type => 'path',
114             },
115             id => {
116             encode_func => 'as_is',
117             type => 'path',
118             },
119             doc => {
120             encode_func => 'as_is',
121             type => 'body',
122             },
123             if_seq_no => {
124             encode_func => 'as_is',
125             type => 'body',
126             },
127             if_primary_term => {
128             encode_func => 'as_is',
129             type => 'body',
130             },
131             op_type => {
132             encode_func => 'as_is',
133             type => 'body',
134             },
135             pipeline => {
136             encode_func => 'as_is',
137             type => 'body',
138             },
139             routing => {
140             encode_func => 'as_is',
141             type => 'body',
142             },
143             refresh => {
144             encode_func => 'as_is',
145             type => 'body',
146             },
147             timeout => {
148             encode_func => 'as_is',
149             type => 'url',
150             },
151             version => {
152             encode_func => 'as_is',
153             type => 'url',
154             },
155             version_type => {
156             encode_func => 'as_is',
157             type => 'url',
158             },
159             wait_for_active_shards => {
160             encode_func => 'as_is',
161             type => 'url',
162             },
163             require_alias => {
164             encode_func => 'encode_bool',
165             type => 'url',
166             }
167             };
168             }
169              
170             1;