| 1 | # OpenSearch::Client is an unofficial client for OpenSearch. | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # It is derived from Search::Elasticsearch version 7.714 | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # License details from that work are contained in the NOTICE | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # file distributed with this work. | ||||||||||||||||||||||||||||||||||||||||||
| 5 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # OpenSearch::Client | ||||||||||||||||||||||||||||||||||||||||||
| 7 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # Copyright 2026 Mark Dootson | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||||||||||||
| 10 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||||||||||||||||||||||||||||||||||
| 11 | # you may not use this file except in compliance with the License. | ||||||||||||||||||||||||||||||||||||||||||
| 12 | # You may obtain a copy of the License at | ||||||||||||||||||||||||||||||||||||||||||
| 13 | # | ||||||||||||||||||||||||||||||||||||||||||
| 14 | # http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||||||||||||||||||||||||||||||||||
| 15 | # | ||||||||||||||||||||||||||||||||||||||||||
| 16 | # Unless required by applicable law or agreed to in writing, software | ||||||||||||||||||||||||||||||||||||||||||
| 17 | # distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||||||||||||||||||||||||||||||||||
| 18 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||||||||||||||||||||||||||||||||||
| 19 | # See the License for the specific language governing permissions and | ||||||||||||||||||||||||||||||||||||||||||
| 20 | # limitations under the License. | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | package OpenSearch::Client; | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 61 | ▶ | use Moo 2.001000 (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 61 | ▶ | use OpenSearch::Client::Util qw(parse_params load_plugin); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 61 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 61 | our $VERSION = '3.007011'; | |||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 61 | my %Default_Plugins = ( | |||||||||||||||||||||||||||||||||||||||||
| 32 | client => [ 'OpenSearch::Client::Core', '3_0::Direct' ], | ||||||||||||||||||||||||||||||||||||||||||
| 33 | cxn_factory => [ 'OpenSearch::Client::Cxn::Factory', '' ], | ||||||||||||||||||||||||||||||||||||||||||
| 34 | cxn_pool => [ 'OpenSearch::Client::CxnPool', 'Static' ], | ||||||||||||||||||||||||||||||||||||||||||
| 35 | logger => [ 'OpenSearch::Client::Logger', 'LogAny' ], | ||||||||||||||||||||||||||||||||||||||||||
| 36 | serializer => [ 'OpenSearch::Client::Serializer', 'JSON' ], | ||||||||||||||||||||||||||||||||||||||||||
| 37 | transport => [ 'OpenSearch::Client::Transport', '' ], | ||||||||||||||||||||||||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 61 | my @Load_Order = qw( | |||||||||||||||||||||||||||||||||||||||||
| 41 | serializer | ||||||||||||||||||||||||||||||||||||||||||
| 42 | logger | ||||||||||||||||||||||||||||||||||||||||||
| 43 | cxn_factory | ||||||||||||||||||||||||||||||||||||||||||
| 44 | cxn_pool | ||||||||||||||||||||||||||||||||||||||||||
| 45 | transport | ||||||||||||||||||||||||||||||||||||||||||
| 46 | client | ||||||||||||||||||||||||||||||||||||||||||
| 47 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | #=================================== | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 100 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=10 SCAR=24.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | #=================================== | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 100 | my ( $class, $params ) = parse_params(@_); | |||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 100 | ▶ | $params->{cxn} ||= 'HTTPTiny'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$params->{"cxn"} ||= "HTTPTiny"
MC/DC100%1/1
$params->{"cxn"} ||= "HTTPTiny"
$params->{"cxn"}
Truth table100%2/2
A
A= $params->{"cxn"}
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 100 | ▶ | my $plugins = delete $params->{plugins} || []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $params->{'plugins'} || []
MC/DC0%0/1
delete $params->{'plugins'} || []
delete $params->{'plugins'}
Truth table50%1/2
A
A= delete $params->{'plugins'}
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 100 | ▶ | $plugins = [$plugins] unless ref $plugins eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | { | ||||||||||||||||||||||||||||||||||||||||||
| 59 | 100 | my $username = delete $params->{username}; | |||||||||||||||||||||||||||||||||||||||||
| 60 | 100 | my $password = delete $params->{password}; | |||||||||||||||||||||||||||||||||||||||||
| 61 | 100 | ▶ | if (!$params->{userinfo} && $username && $password) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
not $params->{"userinfo"} and $username and $password
not $params->{"userinfo"} and $username
MC/DC0%0/3
not $params->{"userinfo"} and $username and $password
not $params->{"userinfo"}
$username
$password
Truth table50%2/4
not(A) and B and C
A= not $params->{"userinfo"}B= $usernameC= $password
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | $params->{userinfo} = sprintf('%s:%s', $username , $password ); | |||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 100 | for my $name (@Load_Order) { | |||||||||||||||||||||||||||||||||||||||||
| 67 | 600 | my ( $base, $default ) = @{ $Default_Plugins{$name} }; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 600 | ▶ | my $sub_class = $params->{$name} || $default; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$params->{$name} || $default
MC/DC100%2/2
$params->{$name} || $default
$params->{$name}
$default
Truth table100%3/3
A || B
A= $params->{$name}B= $default
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 600 | my $plugin_class = load_plugin( $base, $sub_class ); | |||||||||||||||||||||||||||||||||||||||||
| 70 | 600 | $params->{$name} = $plugin_class->new($params); | |||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | 100 | for my $name (@$plugins) { | |||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | my $plugin_class | |||||||||||||||||||||||||||||||||||||||||
| 75 | = load_plugin( 'OpenSearch::Client::Plugin', $name ); | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | $plugin_class->_init_plugin($params); | |||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 100 | return $params->{client}; | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 61 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | __END__ | ||||||||||||||||||||||||||||||||||||||||||