| 1 | # OpenSearch::Client is an unofficial client for OpenSearch. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # It is derived from Search::Elasticsearch version 7.714 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # License details from the original work are contained in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # NOTICE file distributed with this work. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # OpenSearch::Client | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # Copyright 2026 Mark Dootson | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # you may not use this file except in compliance with the License. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # You may obtain a copy of the License at | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # Unless required by applicable law or agreed to in writing, software | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # See the License for the specific language governing permissions and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # limitations under the License. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | package OpenSearch::Client::Role::Client::Direct; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 56 | $OpenSearch::Client::Role::Client::Direct::VERSION = '3.007011'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 56 | ▶ | use Moo::Role; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 56 | with 'OpenSearch::Client::Role::Client'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 56 | ▶ | use OpenSearch::Client::Util qw(load_plugin is_compat throw); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 56 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 56 | ▶ | use Package::Stash 0.34 (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 56 | ▶ | use Any::URI::Escape qw(uri_escape); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 56 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | #=================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 8 | ▶ | sub parse_request { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_request: called CC=3 SCAR=13.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | #=================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 8 | ▶ | my $defn = shift || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 8 | ▶ | my $params = { ref $_[0] ? %{ shift() } : @_ }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 8 | my $request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 8 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | $request = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | ignore => delete $params->{ignore} || [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | method => $self->_parse_method ( $defn, $params ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | serialize => $defn->{serialize} || 'std', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | path => $self->_parse_path( $defn, $params ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | body => $self->_parse_body( $defn->{body}, $params ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 8 | ▶ | qs => $self->_parse_qs( $defn->{qs}, $params ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%2/4
delete $params->{'ignore'} || []
$defn->{'serialize'} || 'std'
MC/DC0%0/1
delete $params->{'ignore'} || []
delete $params->{'ignore'}
MC/DC0%0/1
$defn->{'serialize'} || 'std'
$defn->{'serialize'}
Truth table50%1/2
A
A= delete $params->{'ignore'}
Truth table50%1/2
A
A= $defn->{'serialize'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | chomp $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | my $name = $defn->{name} || '<unknown method>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$defn->{'name'} || '<unknown method>'
MC/DC0%0/1
$defn->{'name'} || '<unknown method>'
$defn->{'name'}
Truth table0%0/2
A
A= $defn->{'name'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | $self->logger->throw_error( 'Param', "$_ in ($name) request. " ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 8 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 8 | return $request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | #=================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 8 | ▶ | sub _parse_method { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_method: called CC=16 SCAR=29.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | #=================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 8 | my ( $self, $defn, $params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 8 | ▶ | my $method = $defn->{method} || 'GET'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$defn->{'method'} || 'GET'
MC/DC0%0/1
$defn->{'method'} || 'GET'
$defn->{'method'}
Truth table50%1/2
A
A= $defn->{'method'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 8 | ▶ | return $method unless( $method eq 'detect' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 8 | my $dp = $defn->{detect}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 8 | $method = $dp->{method}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 8 | ▶ | return $method unless(defined($params) && ref($params) eq 'HASH'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $params and ref $params eq "HASH"
MC/DC0%0/2
defined $params and ref $params eq "HASH"
defined $params
ref $params eq "HASH"
Truth table33%1/3
A and B
A= defined $paramsB= ref $params eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | ## is there a body param | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 8 | ▶ | if ( $dp->{check}->{body} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 4 | ▶ | return $dp->{alternate} if(exists($params->{body}) && defined($params->{body})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $params->{"body"} and defined $params->{"body"}
MC/DC50%1/2
exists $params->{"body"} and defined $params->{"body"}
exists $params->{"body"}
defined $params->{"body"}
Truth table66%2/3
A and B
A= exists $params->{"body"}B= defined $params->{"body"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | ## are there any optional params | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 6 | ▶ | if ( $dp->{check}->{paths} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
$dp->{"check"}{"paths"} and exists $defn->{"parts"} and defined $defn->{"parts"} and ref $defn->{"parts"} eq "HASH"
$dp->{"check"}{"paths"} and exists $defn->{"parts"} and defined $defn->{"parts"}
$dp->{"check"}{"paths"} and exists $defn->{"parts"}
MC/DC25%1/4
$dp->{"check"}{"paths"} and exists $defn->{"parts"} and defined $defn->{"parts"} and ref $defn->{"parts"} eq "HASH"
$dp->{"check"}{"paths"}
exists $defn->{"parts"}
defined $defn->{"parts"}
ref $defn->{"parts"} eq "HASH"
Truth table40%2/5
A and B and C and D
A= $dp->{"check"}{"paths"}B= exists $defn->{"parts"}C= defined $defn->{"parts"}D= ref $defn->{"parts"} eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | && exists($defn->{parts}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | && defined($defn->{parts}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | && ref($defn->{parts}) eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 4 | my @pathparts = keys %{ $defn->{parts} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 4 | for my $pathpart ( @pathparts ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 7 | ▶ | next if $defn->{parts}->{$pathpart}->{required}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 4 | ▶ | return $dp->{alternate} if(exists($params->{$pathpart}) && defined($params->{$pathpart})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $params->{$pathpart} and defined $params->{$pathpart}
MC/DC50%1/2
exists $params->{$pathpart} and defined $params->{$pathpart}
exists $params->{$pathpart}
defined $params->{$pathpart}
Truth table66%2/3
A and B
A= exists $params->{$pathpart}B= defined $params->{$pathpart}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 4 | return $method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | #=================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 8 | ▶ | sub _parse_path { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_path: called CC=13 SCAR=27.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | #=================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 8 | my ( $self, $defn, $params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | return delete $params->{path} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 8 | ▶ | if $params->{path}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 8 | my $paths = $defn->{paths}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 8 | my $parts = $defn->{parts}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 8 | my %args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 8 | keys %$parts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 56 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 8 | ▶ | while ( my ( $key, $req ) = each %$parts ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 14 | my $val = delete $params->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 14 | ▶ | if ( ref $val eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | die "Param ($key) must contain a single value\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | if @$val > 1 and not $req->{multi}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@$val > 1 and not $req->{"multi"}
MC/DC0%0/2
@$val > 1 and not $req->{"multi"}
@$val > 1
not $req->{"multi"}
Truth table0%0/3
A and not(B)
A= @$val > 1B= not $req->{"multi"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | $val = join ",", @$val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 14 | ▶ | if ( !length $val ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | die "Missing required param ($key)\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 2 | ▶ | if $req->{required}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 2 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 12 | utf8::encode($val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 12 | $args{$key} = uri_escape($val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 8 | PATH: for my $path (@$paths) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 10 | my @keys = keys %{ $path->[0] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 10 | ▶ | next PATH unless @keys == keys %args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 8 | for (@keys) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 12 | ▶ | next PATH unless exists $args{$_}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 8 | my ( $pos, @parts ) = @$path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 8 | for ( keys %$pos ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 12 | $parts[ $pos->{$_} ] = $args{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 8 | return join "/", '', @parts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | throw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | 'Internal', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | "Couldn't determine path", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | { params => $params, defn => $defn } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | #=================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 8 | ▶ | sub _parse_body { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_body: called CC=5 SCAR=21.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | #=================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 8 | my ( $self, $defn, $params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 8 | ▶ | if ( defined $defn ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | die("Missing required param (body)\n") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 8 | ▶ | if $defn->{required} && !$params->{body}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$defn->{"required"} and not $params->{"body"}
MC/DC0%0/2
$defn->{"required"} and not $params->{"body"}
$defn->{"required"}
not $params->{"body"}
Truth table33%1/3
A and not(B)
A= $defn->{"required"}B= not $params->{"body"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 8 | return delete $params->{body}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | die("Unknown param (body)\n") if $params->{body}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | #=================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 8 | ▶ | sub _parse_qs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_qs: called CC=6 SCAR=25.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | #=================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 8 | my ( $self, $handlers, $params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 8 | ▶ | die "No (qs) defined\n" unless $handlers; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 8 | my %qs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 8 | ▶ | if ( my $raw = delete $params->{params} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | die("Arg (params) shoud be a hashref\n") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | unless ref $raw eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | %qs = %$raw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 8 | for my $key ( keys %$params ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | my $handler = $handlers->{$key} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | or die("Unknown param ($key)\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | $qs{$key} = $handler->( delete $params->{$key} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 8 | return \%qs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | #=================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 56 | ▶ | sub _install_api { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_install_api: called CC=7 SCAR=20.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | #=================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 56 | my ( $class, $group ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 56 | my $defns = $class->api; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 56 | my $stash = Package::Stash->new($class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 56 | my $_os_version_stash = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 56 | ▶ | my $group_qr = $group ? qr/$group\./ : qr//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 56 | for my $action ( keys %$defns ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 27104 | ▶ | my ($name) = ( $action =~ /^$group_qr([^.]+)$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 2408 | ▶ | next if $stash->has_symbol( '&' . $name ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 2408 | my %defn = ( name => $name, %{ $defns->{$action} } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 2408 | ▶ | if (exists($defn{os_version})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 2408 | ▶ | $_os_version_stash->{$name} = $defn{os_version} || '1.000000'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$defn{'os_version'} || '1.000000'
MC/DC0%0/1
$defn{'os_version'} || '1.000000'
$defn{'os_version'}
Truth table50%1/2
A
A= $defn{'os_version'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | $_os_version_stash->{$name} = '1.000000'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | $stash->add_symbol( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | '&' . $name => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | shift->perform_request( \%defn, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 2408 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 56 | $stash->add_symbol( '%_api_method_supported_version_stash' => $_os_version_stash ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | #=================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | sub _build_namespace { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_namespace: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | #=================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | my ( $self, $ns ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | my $class = load_plugin( $self->_namespace, [$ns] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | return $class->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | { transport => $self->transport, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | logger => $self->logger | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | #=================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | sub _build_helper { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_helper: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | #=================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | my ( $self, $name, $sub_class ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | my $class = load_plugin( 'OpenSearch::Client', $sub_class ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | is_compat( $name . '_helper_class', $self->transport, $class ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | return $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 56 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||