From 768bb8adc340acf16fed1db0ed6297f1812c4a48 Mon Sep 17 00:00:00 2001 From: Kim Pepper Date: Sat, 2 Nov 2024 14:07:30 +1100 Subject: [PATCH 01/10] Replace endpoint callable with EndpointFactory Signed-off-by: Kim Pepper Signed-off-by: Kim Pepper Signed-off-by: Kim Pepper --- src/OpenSearch/ClientBuilder.php | 46 +----- src/OpenSearch/EndpointFactory.php | 55 +++++++ src/OpenSearch/EndpointFactoryInterface.php | 21 +++ src/OpenSearch/EndpointInterface.php | 77 ++++++++++ .../Namespaces/AbstractNamespace.php | 4 +- tests/ClientTest.php | 16 +- .../MachineLearningNamespaceTest.php | 137 +++++++++--------- tests/Namespaces/SqlNamespaceTest.php | 26 ++-- util/EndpointProxies/createProxy.php | 5 +- .../indices/refreshSearchAnalyzersProxy.php | 3 +- .../ml/createConnectorProxy.php | 3 +- .../ml/deleteConnectorProxy.php | 3 +- util/EndpointProxies/ml/deployModelProxy.php | 3 +- util/EndpointProxies/ml/getConnectorProxy.php | 3 +- .../EndpointProxies/ml/getConnectorsProxy.php | 3 +- .../ml/getModelGroupsProxy.php | 3 +- util/EndpointProxies/ml/getModelProxy.php | 3 +- util/EndpointProxies/ml/predictProxy.php | 3 +- .../EndpointProxies/ml/undeployModelProxy.php | 3 +- .../ml/updateModelGroupProxy.php | 3 +- .../security/changePasswordProxy.php | 3 +- .../security/createActionGroupProxy.php | 5 +- .../security/createRoleMappingProxy.php | 5 +- .../security/createRoleProxy.php | 3 +- .../security/createTenantProxy.php | 3 +- .../security/createUserProxy.php | 3 +- .../security/getActionGroupsProxy.php | 5 +- .../security/getDistinguishedNamesProxy.php | 5 +- .../security/getRoleMappingsProxy.php | 5 +- .../security/getRolesProxy.php | 5 +- .../security/getTenantsProxy.php | 5 +- .../security/getUsersProxy.php | 4 +- .../security/patchActionGroupsProxy.php | 5 +- .../security/patchRoleMappingsProxy.php | 5 +- .../security/patchRolesProxy.php | 5 +- .../security/patchTenantsProxy.php | 5 +- .../security/patchUsersProxy.php | 5 +- util/EndpointProxies/sql/closeCursorProxy.php | 4 +- util/EndpointProxies/sql/explainProxy.php | 4 +- util/EndpointProxies/sql/queryProxy.php | 4 +- util/NamespaceEndpoint.php | 3 +- util/template/client-class | 11 +- util/template/endpoint-function | 5 +- util/template/endpoint-function-bool | 5 +- util/template/new-namespace | 2 +- 45 files changed, 309 insertions(+), 225 deletions(-) create mode 100644 src/OpenSearch/EndpointFactory.php create mode 100644 src/OpenSearch/EndpointFactoryInterface.php create mode 100644 src/OpenSearch/EndpointInterface.php diff --git a/src/OpenSearch/ClientBuilder.php b/src/OpenSearch/ClientBuilder.php index 1865bc3dd..969e41832 100644 --- a/src/OpenSearch/ClientBuilder.php +++ b/src/OpenSearch/ClientBuilder.php @@ -54,10 +54,7 @@ class ClientBuilder */ private $transport; - /** - * @var callable|null - */ - private $endpoint; + private ?EndpointFactoryInterface $endpointFactory = null; /** * @var NamespaceBuilderInterface[] @@ -182,14 +179,6 @@ public function getTransport(): Transport return $this->transport; } - /** - * Can supply second param to Client::__construct() when invoking manually or with dependency injection - */ - public function getEndpoint(): callable - { - return $this->endpoint; - } - /** * Can supply third param to Client::__construct() when invoking manually or with dependency injection * @@ -325,15 +314,9 @@ public function setConnectionPool($connectionPool, array $args = []): ClientBuil return $this; } - /** - * Set the endpoint - * - * @param callable $endpoint - */ - public function setEndpoint(callable $endpoint): ClientBuilder + public function setEndpointFactory(EndpointFactoryInterface $endpointFactory): ClientBuilder { - $this->endpoint = $endpoint; - + $this->endpointFactory = $endpointFactory; return $this; } @@ -671,21 +654,8 @@ public function build(): Client $this->buildTransport(); - if (is_null($this->endpoint)) { - $serializer = $this->serializer; - - $this->endpoint = function ($class) use ($serializer) { - $fullPath = '\\OpenSearch\\Endpoints\\' . $class; - - $reflection = new ReflectionClass($fullPath); - $constructor = $reflection->getConstructor(); - - if ($constructor && $constructor->getParameters()) { - return new $fullPath($serializer); - } else { - return new $fullPath(); - } - }; + if (is_null($this->endpointFactory)) { + $this->endpointFactory = new EndpointFactory($this->serializer); } $registeredNamespaces = []; @@ -696,12 +666,12 @@ public function build(): Client $registeredNamespaces[$builder->getName()] = $builder->getObject($this->transport, $this->serializer); } - return $this->instantiate($this->transport, $this->endpoint, $registeredNamespaces); + return $this->instantiate($this->transport, $this->endpointFactory, $registeredNamespaces); } - protected function instantiate(Transport $transport, callable $endpoint, array $registeredNamespaces): Client + protected function instantiate(Transport $transport, EndpointFactoryInterface $endpointFactory, array $registeredNamespaces): Client { - return new Client($transport, $endpoint, $registeredNamespaces); + return new Client($transport, $endpointFactory, $registeredNamespaces); } private function buildLoggers(): void diff --git a/src/OpenSearch/EndpointFactory.php b/src/OpenSearch/EndpointFactory.php new file mode 100644 index 000000000..65bb5b362 --- /dev/null +++ b/src/OpenSearch/EndpointFactory.php @@ -0,0 +1,55 @@ + + */ + private array $endpoints = []; + + public function __construct( + protected SerializerInterface $serializer, + ) { + } + + /** + * {@inheritdoc} + */ + public function getEndpoint(string $class): AbstractEndpoint + { + if (!isset($this->endpoints[$class])) { + $this->endpoints[$class] = $this->createEndpoint($class); + } + + return $this->endpoints[$class]; + } + + /** + * Creates an endpoint. + * + * @phpstan-template T of AbstractEndpoint + * @phpstan-param class-string $class + * @phpstan-return T + * @throws \ReflectionException + */ + private function createEndpoint(string $class): AbstractEndpoint + { + $reflection = new ReflectionClass($class); + $constructor = $reflection->getConstructor(); + + if ($constructor && $constructor->getParameters()) { + return new $class($this->serializer); + } + return new $class(); + } + +} diff --git a/src/OpenSearch/EndpointFactoryInterface.php b/src/OpenSearch/EndpointFactoryInterface.php new file mode 100644 index 000000000..2e481fc5c --- /dev/null +++ b/src/OpenSearch/EndpointFactoryInterface.php @@ -0,0 +1,21 @@ + $class + * @phpstan-return T + */ + public function getEndpoint(string $class): AbstractEndpoint; + +} diff --git a/src/OpenSearch/EndpointInterface.php b/src/OpenSearch/EndpointInterface.php new file mode 100644 index 000000000..b9e32e0e5 --- /dev/null +++ b/src/OpenSearch/EndpointInterface.php @@ -0,0 +1,77 @@ +transport = $transport; - $this->endpoints = $endpoints; } /** diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 434706078..b580bae5c 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -413,9 +413,9 @@ public function testExtractArgumentIterable() /** @test */ public function sendRawRequest(): void { - $callable = function () {}; $transport = $this->createMock(OpenSearch\Transport::class); - $client = new OpenSearch\Client($transport, $callable, []); + $endpointFactory = $this->createMock(OpenSearch\EndpointFactoryInterface::class); + $client = new OpenSearch\Client($transport, $endpointFactory, []); $transport->expects($this->once())->method('performRequest')->with('GET', '/', [], null, []); @@ -425,9 +425,9 @@ public function sendRawRequest(): void /** @test */ public function sendRawRequestWithBody(): void { - $callable = function () {}; $transport = $this->createMock(OpenSearch\Transport::class); - $client = new OpenSearch\Client($transport, $callable, []); + $endpointFactory = $this->createMock(OpenSearch\EndpointFactoryInterface::class); + $client = new OpenSearch\Client($transport, $endpointFactory, []); $body = ['query' => ['match' => ['text_entry' => 'long live king']]]; $transport->expects($this->once())->method('performRequest')->with('GET', '/shakespeare/_search', [], $body, []); @@ -438,9 +438,9 @@ public function sendRawRequestWithBody(): void /** @test */ public function sendRawRequestWithParams(): void { - $callable = function () {}; $transport = $this->createMock(OpenSearch\Transport::class); - $client = new OpenSearch\Client($transport, $callable, []); + $endpointFactory = $this->createMock(OpenSearch\EndpointFactoryInterface::class); + $client = new OpenSearch\Client($transport, $endpointFactory, []); $params = ['foo' => 'bar']; $transport->expects($this->once())->method('performRequest')->with('GET', '/_search', $params, null, []); @@ -451,9 +451,9 @@ public function sendRawRequestWithParams(): void /** @test */ public function sendRawRequestWithOptions(): void { - $callable = function () {}; $transport = $this->createMock(OpenSearch\Transport::class); - $client = new OpenSearch\Client($transport, $callable, []); + $endpointFactory = $this->createMock(OpenSearch\EndpointFactoryInterface::class); + $client = new OpenSearch\Client($transport, $endpointFactory, []); $options = ['client' => ['future' => 'lazy']]; $transport->expects($this->once())->method('performRequest')->with('GET', '/', [], null, $options); diff --git a/tests/Namespaces/MachineLearningNamespaceTest.php b/tests/Namespaces/MachineLearningNamespaceTest.php index bb5c1237b..9001bfe9e 100644 --- a/tests/Namespaces/MachineLearningNamespaceTest.php +++ b/tests/Namespaces/MachineLearningNamespaceTest.php @@ -2,6 +2,8 @@ namespace OpenSearch\Tests\Namespaces; +use OpenSearch\EndpointFactory; +use OpenSearch\EndpointFactoryInterface; use OpenSearch\Endpoints\Ml\CreateConnector; use OpenSearch\Endpoints\Ml\DeleteConnector; use OpenSearch\Endpoints\Ml\GetConnector; @@ -37,9 +39,9 @@ class MlNamespaceTest extends TestCase public function testCreatingConnector(): void { - $func = static function () { - return new CreateConnector(); - }; + $endpointFactory = $this->createMock(EndpointFactoryInterface::class); + $endpointFactory->method('getEndpoint') + ->willReturn(new CreateConnector()); $transport = $this->createMock(Transport::class); @@ -51,7 +53,7 @@ public function testCreatingConnector(): void $transport->method('resultOrFuture') ->willReturn([]); - (new MlNamespace($transport, $func))->createConnector([ + (new MlNamespace($transport, $endpointFactory))->createConnector([ 'body' => [ 'foo' => 'bar', ], @@ -61,9 +63,9 @@ public function testCreatingConnector(): void public function testGetConnector(): void { - $func = static function () { - return new GetConnector(); - }; + $endpointFactory = $this->createMock(EndpointFactoryInterface::class); + $endpointFactory->method('getEndpoint') + ->willReturn(new GetConnector()); $transport = $this->createMock(Transport::class); @@ -73,7 +75,7 @@ public function testGetConnector(): void $transport->method('resultOrFuture') ->willReturn([]); - (new MlNamespace($transport, $func))->getConnector([ + (new MlNamespace($transport, $endpointFactory))->getConnector([ 'id' => 'foobar' ]); } @@ -81,9 +83,9 @@ public function testGetConnector(): void public function testGetConnectors(): void { - $func = static function () { - return new GetConnectors(); - }; + $endpointFactory = $this->createMock(EndpointFactoryInterface::class); + $endpointFactory->method('getEndpoint') + ->willReturn(new GetConnectors()); $transport = $this->createMock(Transport::class); @@ -98,7 +100,7 @@ public function testGetConnectors(): void $transport->method('resultOrFuture') ->willReturn([]); - (new MlNamespace($transport, $func))->getConnectors([ + (new MlNamespace($transport, $endpointFactory))->getConnectors([ 'body' => [ 'query' => [ 'match_all' => new \StdClass(), @@ -111,9 +113,9 @@ public function testGetConnectors(): void public function testDeleteConnector(): void { - $func = static function () { - return new DeleteConnector(); - }; + $endpointFactory = $this->createMock(EndpointFactoryInterface::class); + $endpointFactory->method('getEndpoint') + ->willReturn(new DeleteConnector()); $transport = $this->createMock(Transport::class); @@ -123,7 +125,7 @@ public function testDeleteConnector(): void $transport->method('resultOrFuture') ->willReturn([]); - (new MlNamespace($transport, $func))->deleteConnector([ + (new MlNamespace($transport, $endpointFactory))->deleteConnector([ 'connector_id' => 'foobar' ]); } @@ -131,9 +133,9 @@ public function testDeleteConnector(): void public function testRegisterModelGroup(): void { - $func = static function () { - return new RegisterModelGroup(); - }; + $endpointFactory = $this->createMock(EndpointFactoryInterface::class); + $endpointFactory->method('getEndpoint') + ->willReturn(new RegisterModelGroup()); $transport = $this->createMock(Transport::class); @@ -145,7 +147,7 @@ public function testRegisterModelGroup(): void $transport->method('resultOrFuture') ->willReturn([]); - (new MlNamespace($transport, $func))->registerModelGroup([ + (new MlNamespace($transport, $endpointFactory))->registerModelGroup([ 'body' => [ 'foo' => 'bar', ], @@ -155,9 +157,9 @@ public function testRegisterModelGroup(): void public function testGetModelGroups(): void { - $func = static function () { - return new GetModelGroups(); - }; + $endpointFactory = $this->createMock(EndpointFactoryInterface::class); + $endpointFactory->method('getEndpoint') + ->willReturn(new GetModelGroups()); $transport = $this->createMock(Transport::class); @@ -172,7 +174,7 @@ public function testGetModelGroups(): void $transport->method('resultOrFuture') ->willReturn([]); - (new MlNamespace($transport, $func))->getModelGroups([ + (new MlNamespace($transport, $endpointFactory))->getModelGroups([ 'body' => [ 'query' => [ 'match_all' => new \StdClass(), @@ -185,9 +187,9 @@ public function testGetModelGroups(): void public function testUpdateModelGroup(): void { - $func = static function () { - return new UpdateModelGroup(); - }; + $endpointFactory = $this->createMock(EndpointFactoryInterface::class); + $endpointFactory->method('getEndpoint') + ->willReturn(new UpdateModelGroup()); $transport = $this->createMock(Transport::class); @@ -202,7 +204,7 @@ public function testUpdateModelGroup(): void $transport->method('resultOrFuture') ->willReturn([]); - (new MlNamespace($transport, $func))->updateModelGroup([ + (new MlNamespace($transport, $endpointFactory))->updateModelGroup([ 'id' => 'foobar', 'body' => [ 'query' => [ @@ -216,9 +218,9 @@ public function testUpdateModelGroup(): void public function testDeleteModelGroup(): void { - $func = static function () { - return new DeleteModelGroup(); - }; + $endpointFactory = $this->createMock(EndpointFactoryInterface::class); + $endpointFactory->method('getEndpoint') + ->willReturn(new DeleteModelGroup()); $transport = $this->createMock(Transport::class); @@ -228,7 +230,7 @@ public function testDeleteModelGroup(): void $transport->method('resultOrFuture') ->willReturn([]); - (new MlNamespace($transport, $func))->deleteModelGroup([ + (new MlNamespace($transport, $endpointFactory))->deleteModelGroup([ 'id' => 'foobar' ]); } @@ -236,9 +238,9 @@ public function testDeleteModelGroup(): void public function testRegisterModel(): void { - $func = static function () { - return new RegisterModel(); - }; + $endpointFactory = $this->createMock(EndpointFactoryInterface::class); + $endpointFactory->method('getEndpoint') + ->willReturn(new RegisterModel()); $transport = $this->createMock(Transport::class); @@ -250,7 +252,7 @@ public function testRegisterModel(): void $transport->method('resultOrFuture') ->willReturn([]); - (new MlNamespace($transport, $func))->registerModel([ + (new MlNamespace($transport, $endpointFactory))->registerModel([ 'body' => [ 'foo' => 'bar', ], @@ -259,10 +261,9 @@ public function testRegisterModel(): void public function testGetModel(): void { - - $func = static function () { - return new GetModel(); - }; + $endpointFactory = $this->createMock(EndpointFactoryInterface::class); + $endpointFactory->method('getEndpoint') + ->willReturn(new GetModel()); $transport = $this->createMock(Transport::class); @@ -272,17 +273,16 @@ public function testGetModel(): void $transport->method('resultOrFuture') ->willReturn([]); - (new MlNamespace($transport, $func))->getModel([ + (new MlNamespace($transport, $endpointFactory))->getModel([ 'id' => 'foobar', ]); } public function testSearchModels(): void { - - $func = static function () { - return new SearchModels(); - }; + $endpointFactory = $this->createMock(EndpointFactoryInterface::class); + $endpointFactory->method('getEndpoint') + ->willReturn(new SearchModels()); $transport = $this->createMock(Transport::class); @@ -297,7 +297,7 @@ public function testSearchModels(): void $transport->method('resultOrFuture') ->willReturn([]); - (new MlNamespace($transport, $func))->searchModels([ + (new MlNamespace($transport, $endpointFactory))->searchModels([ 'body' => [ 'query' => [ 'match_all' => new \StdClass(), @@ -309,10 +309,9 @@ public function testSearchModels(): void public function testDeployModel(): void { - - $func = static function () { - return new DeployModel(); - }; + $endpointFactory = $this->createMock(EndpointFactoryInterface::class); + $endpointFactory->method('getEndpoint') + ->willReturn(new DeployModel()); $transport = $this->createMock(Transport::class); @@ -322,17 +321,16 @@ public function testDeployModel(): void $transport->method('resultOrFuture') ->willReturn([]); - (new MlNamespace($transport, $func))->deployModel([ + (new MlNamespace($transport, $endpointFactory))->deployModel([ 'model_id' => 'foobar', ]); } public function testUnDeployModel(): void { - - $func = static function () { - return new UndeployModel(); - }; + $endpointFactory = $this->createMock(EndpointFactoryInterface::class); + $endpointFactory->method('getEndpoint') + ->willReturn(new UndeployModel()); $transport = $this->createMock(Transport::class); @@ -342,17 +340,16 @@ public function testUnDeployModel(): void $transport->method('resultOrFuture') ->willReturn([]); - (new MlNamespace($transport, $func))->undeployModel([ + (new MlNamespace($transport, $endpointFactory))->undeployModel([ 'model_id' => 'foobar', ]); } public function testDeleteModel(): void { - - $func = static function () { - return new DeleteModel(); - }; + $endpointFactory = $this->createMock(EndpointFactoryInterface::class); + $endpointFactory->method('getEndpoint') + ->willReturn(new DeleteModel()); $transport = $this->createMock(Transport::class); @@ -362,17 +359,16 @@ public function testDeleteModel(): void $transport->method('resultOrFuture') ->willReturn([]); - (new MlNamespace($transport, $func))->deleteModel([ + (new MlNamespace($transport, $endpointFactory))->deleteModel([ 'id' => 'foobar', ]); } public function testPredict(): void { - - $func = static function () { - return new Predict(); - }; + $endpointFactory = $this->createMock(EndpointFactoryInterface::class); + $endpointFactory->method('getEndpoint') + ->willReturn(new Predict()); $transport = $this->createMock(Transport::class); @@ -384,7 +380,7 @@ public function testPredict(): void $transport->method('resultOrFuture') ->willReturn([]); - (new MlNamespace($transport, $func))->predict([ + (new MlNamespace($transport, $endpointFactory))->predict([ 'id' => 'foobar', 'body' => [ 'foo' => 'bar', @@ -394,10 +390,9 @@ public function testPredict(): void public function testGetTask(): void { - - $func = static function () { - return new GetTask(); - }; + $endpointFactory = $this->createMock(EndpointFactoryInterface::class); + $endpointFactory->method('getEndpoint') + ->willReturn(new GetTask()); $transport = $this->createMock(Transport::class); @@ -407,7 +402,7 @@ public function testGetTask(): void $transport->method('resultOrFuture') ->willReturn([]); - (new MlNamespace($transport, $func))->getTask([ + (new MlNamespace($transport, $endpointFactory))->getTask([ 'id' => 'foobar', ]); } diff --git a/tests/Namespaces/SqlNamespaceTest.php b/tests/Namespaces/SqlNamespaceTest.php index 45dc00974..dae5b5f67 100644 --- a/tests/Namespaces/SqlNamespaceTest.php +++ b/tests/Namespaces/SqlNamespaceTest.php @@ -13,6 +13,8 @@ namespace OpenSearch\Tests\Namespaces; +use OpenSearch\EndpointFactoryInterface; +use OpenSearch\Endpoints\Ml\CreateConnector; use OpenSearch\Endpoints\Sql\CursorClose; use OpenSearch\Endpoints\Sql\Explain; use OpenSearch\Endpoints\Sql\Query; @@ -36,11 +38,11 @@ public function testQuery(): void $transport->method('resultOrFuture') ->willReturn([]); - $func = static function () { - return new Query(); - }; + $endpointFactory = $this->createMock(EndpointFactoryInterface::class); + $endpointFactory->method('getEndpoint') + ->willReturn(new Query()); - (new SqlNamespace($transport, $func))->query([ + (new SqlNamespace($transport, $endpointFactory))->query([ 'query' => 'select * from test', ]); } @@ -56,11 +58,11 @@ public function testExplain(): void $transport->method('resultOrFuture') ->willReturn([]); - $func = static function () { - return new Explain(); - }; + $endpointFactory = $this->createMock(EndpointFactoryInterface::class); + $endpointFactory->method('getEndpoint') + ->willReturn(new Explain()); - (new SqlNamespace($transport, $func))->explain([ + (new SqlNamespace($transport, $endpointFactory))->explain([ 'query' => 'select * from test', ]); } @@ -76,11 +78,11 @@ public function testCloseCursor(): void $transport->method('resultOrFuture') ->willReturn([]); - $func = static function () { - return new CursorClose(); - }; + $endpointFactory = $this->createMock(EndpointFactoryInterface::class); + $endpointFactory->method('getEndpoint') + ->willReturn(new CursorClose()); - (new SqlNamespace($transport, $func))->closeCursor([ + (new SqlNamespace($transport, $endpointFactory))->closeCursor([ 'cursor' => 'fooo', ]); } diff --git a/util/EndpointProxies/createProxy.php b/util/EndpointProxies/createProxy.php index 56a75bf64..027272fbd 100644 --- a/util/EndpointProxies/createProxy.php +++ b/util/EndpointProxies/createProxy.php @@ -30,8 +30,9 @@ public function create(array $params = []) $index = $this->extractArgument($params, 'index'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $id ? $endpointBuilder('Create') : $endpointBuilder('Index'); + $endpoint = $id ? + $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Create::class) + : $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Index::class); $endpoint->setParams($params); $endpoint->setId($id); $endpoint->setIndex($index); diff --git a/util/EndpointProxies/indices/refreshSearchAnalyzersProxy.php b/util/EndpointProxies/indices/refreshSearchAnalyzersProxy.php index 4b0497b86..46ce67170 100644 --- a/util/EndpointProxies/indices/refreshSearchAnalyzersProxy.php +++ b/util/EndpointProxies/indices/refreshSearchAnalyzersProxy.php @@ -12,8 +12,7 @@ public function refreshSearchAnalyzers(array $params = []) { $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\RefreshSearchAnalyzers'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\RefreshSearchAnalyzers::class); $endpoint->setParams($params); $endpoint->setIndex($index); diff --git a/util/EndpointProxies/ml/createConnectorProxy.php b/util/EndpointProxies/ml/createConnectorProxy.php index c9841cfc2..4e7abfe2a 100644 --- a/util/EndpointProxies/ml/createConnectorProxy.php +++ b/util/EndpointProxies/ml/createConnectorProxy.php @@ -13,8 +13,7 @@ public function createConnector(array $params = []): array { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ml\CreateConnector'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\CreateConnector::class); $endpoint->setParams($params); $endpoint->setBody($body); diff --git a/util/EndpointProxies/ml/deleteConnectorProxy.php b/util/EndpointProxies/ml/deleteConnectorProxy.php index b8c7796c5..d677cfdaf 100644 --- a/util/EndpointProxies/ml/deleteConnectorProxy.php +++ b/util/EndpointProxies/ml/deleteConnectorProxy.php @@ -13,8 +13,7 @@ public function deleteConnector(array $params = []): array { $connectorId = $this->extractArgument($params, 'connector_id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ml\DeleteConnector'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\DeleteConnector::class); $endpoint->setParams($params); $endpoint->setConnectorId($connectorId); diff --git a/util/EndpointProxies/ml/deployModelProxy.php b/util/EndpointProxies/ml/deployModelProxy.php index 804e39145..caed9214b 100644 --- a/util/EndpointProxies/ml/deployModelProxy.php +++ b/util/EndpointProxies/ml/deployModelProxy.php @@ -15,8 +15,7 @@ public function deployModel(array $params = []): array { $modelId = $this->extractArgument($params, 'model_id'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ml\DeployModel'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\DeployModel::class); $endpoint->setParams($params); $endpoint->setModelId($modelId); if ($body) { diff --git a/util/EndpointProxies/ml/getConnectorProxy.php b/util/EndpointProxies/ml/getConnectorProxy.php index 5988c7556..739adfc50 100644 --- a/util/EndpointProxies/ml/getConnectorProxy.php +++ b/util/EndpointProxies/ml/getConnectorProxy.php @@ -13,8 +13,7 @@ public function getConnector(array $params = []): array { $id = $this->extractArgument($params, 'id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ml\GetConnector'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\GetConnector::class); $endpoint->setParams($params); $endpoint->setId($id); diff --git a/util/EndpointProxies/ml/getConnectorsProxy.php b/util/EndpointProxies/ml/getConnectorsProxy.php index 55e03fa88..01faad25e 100644 --- a/util/EndpointProxies/ml/getConnectorsProxy.php +++ b/util/EndpointProxies/ml/getConnectorsProxy.php @@ -21,8 +21,7 @@ public function getConnectors(array $params = []): array ]; } $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ml\GetConnectors'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\GetConnectors::class); $endpoint->setBody($body); return $this->performRequest($endpoint); diff --git a/util/EndpointProxies/ml/getModelGroupsProxy.php b/util/EndpointProxies/ml/getModelGroupsProxy.php index 8d7c65764..2126e684a 100644 --- a/util/EndpointProxies/ml/getModelGroupsProxy.php +++ b/util/EndpointProxies/ml/getModelGroupsProxy.php @@ -21,8 +21,7 @@ public function getModelGroups(array $params = []): array ]; } $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ml\GetModelGroups'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\GetModelGroups::class); $endpoint->setBody($body); return $this->performRequest($endpoint); diff --git a/util/EndpointProxies/ml/getModelProxy.php b/util/EndpointProxies/ml/getModelProxy.php index 39e514953..f5afef39e 100644 --- a/util/EndpointProxies/ml/getModelProxy.php +++ b/util/EndpointProxies/ml/getModelProxy.php @@ -13,8 +13,7 @@ public function getModel(array $params = []): array { $id = $this->extractArgument($params, 'id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ml\GetModel'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\GetModel::class); $endpoint->setParams($params); $endpoint->setId($id); diff --git a/util/EndpointProxies/ml/predictProxy.php b/util/EndpointProxies/ml/predictProxy.php index e9b275faa..cc0e8f7d0 100644 --- a/util/EndpointProxies/ml/predictProxy.php +++ b/util/EndpointProxies/ml/predictProxy.php @@ -15,8 +15,7 @@ public function predict(array $params = []): array { $id = $this->extractArgument($params, 'id'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ml\Predict'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\Predict::class); $endpoint->setParams($params); $endpoint->setId($id); $endpoint->setBody($body); diff --git a/util/EndpointProxies/ml/undeployModelProxy.php b/util/EndpointProxies/ml/undeployModelProxy.php index 7711ae313..219f664ff 100644 --- a/util/EndpointProxies/ml/undeployModelProxy.php +++ b/util/EndpointProxies/ml/undeployModelProxy.php @@ -15,8 +15,7 @@ public function undeployModel(array $params = []): array { $modelId = $this->extractArgument($params, 'model_id'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ml\UndeployModel'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\UndeployModel::class); $endpoint->setParams($params); $endpoint->setModelId($modelId); if ($body) { diff --git a/util/EndpointProxies/ml/updateModelGroupProxy.php b/util/EndpointProxies/ml/updateModelGroupProxy.php index 166f048b3..aad4c72ad 100644 --- a/util/EndpointProxies/ml/updateModelGroupProxy.php +++ b/util/EndpointProxies/ml/updateModelGroupProxy.php @@ -15,8 +15,7 @@ public function updateModelGroup(array $params = []): array { $id = $this->extractArgument($params, 'id'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ml\UpdateModelGroup'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\UpdateModelGroup::class); $endpoint->setParams($params); $endpoint->setBody($body); $endpoint->setId($id); diff --git a/util/EndpointProxies/security/changePasswordProxy.php b/util/EndpointProxies/security/changePasswordProxy.php index b99c9e508..69c62c74e 100644 --- a/util/EndpointProxies/security/changePasswordProxy.php +++ b/util/EndpointProxies/security/changePasswordProxy.php @@ -26,8 +26,7 @@ public function changePassword(array $params = []) ]; } - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\ChangePassword'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\ChangePassword::class); $endpoint->setParams($params); $endpoint->setBody($body); diff --git a/util/EndpointProxies/security/createActionGroupProxy.php b/util/EndpointProxies/security/createActionGroupProxy.php index adebb27a6..e252361e9 100644 --- a/util/EndpointProxies/security/createActionGroupProxy.php +++ b/util/EndpointProxies/security/createActionGroupProxy.php @@ -25,9 +25,8 @@ public function createActionGroup(array $params = []) 'allowed_actions' => $this->extractArgument($params, 'allowed_actions'), ]; } - - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\CreateActionGroup'); + + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\CreateActionGroup::class); $endpoint->setParams($params); $endpoint->setActionGroup($action_group); $endpoint->setBody($body); diff --git a/util/EndpointProxies/security/createRoleMappingProxy.php b/util/EndpointProxies/security/createRoleMappingProxy.php index 550fe69bd..65385e636 100644 --- a/util/EndpointProxies/security/createRoleMappingProxy.php +++ b/util/EndpointProxies/security/createRoleMappingProxy.php @@ -29,9 +29,8 @@ public function createRoleMapping(array $params = []) 'users' => $this->extractArgument($params, 'users'), ]); } - - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\CreateRoleMapping'); + + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\CreateRoleMapping::class); $endpoint->setParams($params); $endpoint->setRole($role); $endpoint->setBody($body); diff --git a/util/EndpointProxies/security/createRoleProxy.php b/util/EndpointProxies/security/createRoleProxy.php index a7b92840a..9e0f78daf 100644 --- a/util/EndpointProxies/security/createRoleProxy.php +++ b/util/EndpointProxies/security/createRoleProxy.php @@ -30,8 +30,7 @@ public function createRole(array $params = []) ]); } - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\CreateRole'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\CreateRole::class); $endpoint->setParams($params); $endpoint->setRole($role); $endpoint->setBody($body); diff --git a/util/EndpointProxies/security/createTenantProxy.php b/util/EndpointProxies/security/createTenantProxy.php index f92f6b4fb..9fdc19912 100644 --- a/util/EndpointProxies/security/createTenantProxy.php +++ b/util/EndpointProxies/security/createTenantProxy.php @@ -26,8 +26,7 @@ public function createTenant(array $params = []) ]; } - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\CreateTenant'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\CreateTenant::class); $endpoint->setParams($params); $endpoint->setTenant($tenant); $endpoint->setBody($body); diff --git a/util/EndpointProxies/security/createUserProxy.php b/util/EndpointProxies/security/createUserProxy.php index 452aa96e2..fd79e8c82 100644 --- a/util/EndpointProxies/security/createUserProxy.php +++ b/util/EndpointProxies/security/createUserProxy.php @@ -32,8 +32,7 @@ public function createUser(array $params = []) ]); } - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\CreateUser'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\CreateUser::class); $endpoint->setParams($params); $endpoint->setUsername($username); $endpoint->setBody($body); diff --git a/util/EndpointProxies/security/getActionGroupsProxy.php b/util/EndpointProxies/security/getActionGroupsProxy.php index 9c015db98..d3484cb2a 100644 --- a/util/EndpointProxies/security/getActionGroupsProxy.php +++ b/util/EndpointProxies/security/getActionGroupsProxy.php @@ -17,13 +17,12 @@ */ public function getActionGroups(array $params = []) { - $endpointBuilder = $this->endpoints; if (isset($params['action_group'])) { - $endpoint = $endpointBuilder('Security\GetActionGroup'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetActionGroup::class); $action_group = $this->extractArgument($params, 'action_group'); $endpoint->setActionGroup($action_group); } else { - $endpoint = $endpointBuilder('Security\GetActionGroups'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetActionGroups::class); } $endpoint->setParams($params); diff --git a/util/EndpointProxies/security/getDistinguishedNamesProxy.php b/util/EndpointProxies/security/getDistinguishedNamesProxy.php index e3a478151..a62665780 100644 --- a/util/EndpointProxies/security/getDistinguishedNamesProxy.php +++ b/util/EndpointProxies/security/getDistinguishedNamesProxy.php @@ -19,13 +19,12 @@ */ public function getDistinguishedNames(array $params = []) { - $endpointBuilder = $this->endpoints; if (isset($params['cluster_name'])) { - $endpoint = $endpointBuilder('Security\GetDistinguishedName'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetDistinguishedName::class); $cluster_name = $this->extractArgument($params, 'cluster_name'); $endpoint->setClusterName($cluster_name); } else { - $endpoint = $endpointBuilder('Security\GetDistinguishedNames'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetDistinguishedNames::class); } $endpoint->setParams($params); diff --git a/util/EndpointProxies/security/getRoleMappingsProxy.php b/util/EndpointProxies/security/getRoleMappingsProxy.php index b04a7c298..1128c9502 100644 --- a/util/EndpointProxies/security/getRoleMappingsProxy.php +++ b/util/EndpointProxies/security/getRoleMappingsProxy.php @@ -18,13 +18,12 @@ */ public function getRoleMappings(array $params = []) { - $endpointBuilder = $this->endpoints; if (isset($params['role'])) { - $endpoint = $endpointBuilder('Security\GetRoleMapping'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetRoleMapping::class); $role = $this->extractArgument($params, 'role'); $endpoint->setRole($role); } else { - $endpoint = $endpointBuilder('Security\GetRoleMappings'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetRoleMappings::class); } $endpoint->setParams($params); diff --git a/util/EndpointProxies/security/getRolesProxy.php b/util/EndpointProxies/security/getRolesProxy.php index f90cd7477..480b1f98d 100644 --- a/util/EndpointProxies/security/getRolesProxy.php +++ b/util/EndpointProxies/security/getRolesProxy.php @@ -18,13 +18,12 @@ */ public function getRoles(array $params = []) { - $endpointBuilder = $this->endpoints; if (isset($params['role'])) { - $endpoint = $endpointBuilder('Security\GetRole'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetRole::class); $role = $this->extractArgument($params, 'role'); $endpoint->setRole($role); } else { - $endpoint = $endpointBuilder('Security\GetRoles'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetRoles::class); } $endpoint->setParams($params); diff --git a/util/EndpointProxies/security/getTenantsProxy.php b/util/EndpointProxies/security/getTenantsProxy.php index 698748020..13bba49b2 100644 --- a/util/EndpointProxies/security/getTenantsProxy.php +++ b/util/EndpointProxies/security/getTenantsProxy.php @@ -18,13 +18,12 @@ */ public function getTenants(array $params = []) { - $endpointBuilder = $this->endpoints; if (isset($params['tenant'])) { - $endpoint = $endpointBuilder('Security\GetTenant'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetTenant::class); $tenant = $this->extractArgument($params, 'tenant'); $endpoint->setTenant($tenant); } else { - $endpoint = $endpointBuilder('Security\GetTenants'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetTenants::class); } $endpoint->setParams($params); diff --git a/util/EndpointProxies/security/getUsersProxy.php b/util/EndpointProxies/security/getUsersProxy.php index 923861558..35c9a2574 100644 --- a/util/EndpointProxies/security/getUsersProxy.php +++ b/util/EndpointProxies/security/getUsersProxy.php @@ -21,11 +21,11 @@ public function getUsers(array $params = []): array $endpointBuilder = $this->endpoints; if (isset($params['username'])) { - $endpoint = $endpointBuilder('Security\GetUser'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetUser::class); $username = $this->extractArgument($params, 'username'); $endpoint->setUsername($username); } else { - $endpoint = $endpointBuilder('Security\GetUsers'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetUsers::class); } $endpoint->setParams($params); diff --git a/util/EndpointProxies/security/patchActionGroupsProxy.php b/util/EndpointProxies/security/patchActionGroupsProxy.php index e262947e2..ef0d1bba9 100644 --- a/util/EndpointProxies/security/patchActionGroupsProxy.php +++ b/util/EndpointProxies/security/patchActionGroupsProxy.php @@ -23,13 +23,12 @@ public function patchActionGroups(array $params = []) $body = $this->extractArgument($params, 'ops') ?? []; } - $endpointBuilder = $this->endpoints; if (isset($params['action_group'])) { - $endpoint = $endpointBuilder('Security\PatchActionGroup'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PatchActionGroup::class); $action_group = $this->extractArgument($params, 'action_group'); $endpoint->setActionGroup($action_group); } else { - $endpoint = $endpointBuilder('Security\PatchActionGroups'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PatchActionGroups::class); } $endpoint->setParams($params); $endpoint->setBody($body); diff --git a/util/EndpointProxies/security/patchRoleMappingsProxy.php b/util/EndpointProxies/security/patchRoleMappingsProxy.php index f7ac213b9..6f71092e9 100644 --- a/util/EndpointProxies/security/patchRoleMappingsProxy.php +++ b/util/EndpointProxies/security/patchRoleMappingsProxy.php @@ -22,13 +22,12 @@ public function patchRoleMappings(array $params = []) $body = $this->extractArgument($params, 'ops') ?? []; } - $endpointBuilder = $this->endpoints; if (isset($params['role'])) { - $endpoint = $endpointBuilder('Security\PatchRoleMapping'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PatchRoleMapping::class); $role = $this->extractArgument($params, 'role'); $endpoint->setRole($role); } else { - $endpoint = $endpointBuilder('Security\PatchRoleMappings'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PatchRoleMappings::class); } $endpoint->setParams($params); $endpoint->setBody($body); diff --git a/util/EndpointProxies/security/patchRolesProxy.php b/util/EndpointProxies/security/patchRolesProxy.php index eed70d9b7..e02cc8e48 100644 --- a/util/EndpointProxies/security/patchRolesProxy.php +++ b/util/EndpointProxies/security/patchRolesProxy.php @@ -22,13 +22,12 @@ public function patchRoles(array $params = []) $body = $this->extractArgument($params, 'ops') ?? []; } - $endpointBuilder = $this->endpoints; if (isset($params['role'])) { - $endpoint = $endpointBuilder('Security\PatchRole'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PatchRole::class); $role = $this->extractArgument($params, 'role'); $endpoint->setRole($role); } else { - $endpoint = $endpointBuilder('Security\PatchRoles'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PatchRoles::class); } $endpoint->setParams($params); diff --git a/util/EndpointProxies/security/patchTenantsProxy.php b/util/EndpointProxies/security/patchTenantsProxy.php index 10d6fa01b..899f0d9a5 100644 --- a/util/EndpointProxies/security/patchTenantsProxy.php +++ b/util/EndpointProxies/security/patchTenantsProxy.php @@ -22,13 +22,12 @@ public function patchTenants(array $params = []) $body = $this->extractArgument($params, 'ops') ?? []; } - $endpointBuilder = $this->endpoints; if (isset($params['tenant'])) { - $endpoint = $endpointBuilder('Security\PatchTenant'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PatchTenant::class); $tenant = $this->extractArgument($params, 'tenant'); $endpoint->setTenant($tenant); } else { - $endpoint = $endpointBuilder('Security\PatchTenants'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PatchTenants::class); } $endpoint->setParams($params); diff --git a/util/EndpointProxies/security/patchUsersProxy.php b/util/EndpointProxies/security/patchUsersProxy.php index 81cba4171..9af53a8a2 100644 --- a/util/EndpointProxies/security/patchUsersProxy.php +++ b/util/EndpointProxies/security/patchUsersProxy.php @@ -22,13 +22,12 @@ public function patchUsers(array $params = []) $body = $this->extractArgument($params, 'ops') ?? []; } - $endpointBuilder = $this->endpoints; if (isset($params['username'])) { - $endpoint = $endpointBuilder('Security\PatchUser'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PatchUser::class); $username = $this->extractArgument($params, 'username'); $endpoint->setUsername($username); } else { - $endpoint = $endpointBuilder('Security\PatchUsers'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PatchUsers::class); } $endpoint->setParams($params); diff --git a/util/EndpointProxies/sql/closeCursorProxy.php b/util/EndpointProxies/sql/closeCursorProxy.php index f8f4502f1..66a7b9bdc 100644 --- a/util/EndpointProxies/sql/closeCursorProxy.php +++ b/util/EndpointProxies/sql/closeCursorProxy.php @@ -11,9 +11,7 @@ */ public function closeCursor(array $params): array { - $endpointBuilder = $this->endpoints; - - $endpoint = $endpointBuilder('Sql\Close'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Sql\Close::class); $endpoint->setBody(array_filter([ 'cursor' => $this->extractArgument($params, 'cursor'), ])); diff --git a/util/EndpointProxies/sql/explainProxy.php b/util/EndpointProxies/sql/explainProxy.php index ac0a89cef..16ecf4a13 100644 --- a/util/EndpointProxies/sql/explainProxy.php +++ b/util/EndpointProxies/sql/explainProxy.php @@ -11,12 +11,10 @@ */ public function explain(array $params): array { - $endpointBuilder = $this->endpoints; - $body = $this->extractArgument($params, 'body') ?? []; $query = $this->extractArgument($params, 'query'); - $endpoint = $endpointBuilder('Sql\Explain'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Sql\Explain::class); $endpoint->setBody(array_merge($body, [ 'query' => $query, ])); diff --git a/util/EndpointProxies/sql/queryProxy.php b/util/EndpointProxies/sql/queryProxy.php index b4d2e439d..886810aef 100644 --- a/util/EndpointProxies/sql/queryProxy.php +++ b/util/EndpointProxies/sql/queryProxy.php @@ -15,9 +15,7 @@ */ public function query(array $params): array { - $endpointBuilder = $this->endpoints; - - $endpoint = $endpointBuilder('Sql\Query'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Sql\Query::class); $body = $this->extractArgument($params, 'body') ?? []; $endpoint->setBody(array_merge($body, array_filter([ 'query' => $this->extractArgument($params, 'query'), diff --git a/util/NamespaceEndpoint.php b/util/NamespaceEndpoint.php index b8c7dfb4e..5c748fee9 100644 --- a/util/NamespaceEndpoint.php +++ b/util/NamespaceEndpoint.php @@ -138,7 +138,8 @@ protected function renderEndpoint(Endpoint $endpoint): string } else { $endpointClass = NamespaceEndpoint::normalizeName($endpoint->namespace) . '\\' . $endpoint->getClassName(); } - return str_replace(':EndpointClass', $endpointClass, $code); + $fullClass = '\\OpenSearch\\Endpoints\\' . $endpointClass; + return str_replace(':EndpointClass', $fullClass, $code); } public static function normalizeName(string $name): string diff --git a/util/template/client-class b/util/template/client-class index e3ed316fa..c494e672d 100644 --- a/util/template/client-class +++ b/util/template/client-class @@ -46,10 +46,7 @@ class Client */ protected $params; - /** - * @var callable - */ - protected $endpoints; + protected EndpointFactoryInterface $endpointFactory; /** * @var NamespaceBuilderInterface[] @@ -61,13 +58,13 @@ class Client * Client constructor * * @param Transport $transport - * @param callable $endpoint + * @param EndpointFactoryInterface $endpointFactory * @param NamespaceBuilderInterface[] $registeredNamespaces */ - public function __construct(Transport $transport, callable $endpoint, array $registeredNamespaces) + public function __construct(Transport $transport, EndpointFactoryInterface $endpointFactory, array $registeredNamespaces) { $this->transport = $transport; - $this->endpoints = $endpoint; + $this->endpointFactory = $endpointFactory; :new-namespaces $this->registeredNamespaces = $registeredNamespaces; } diff --git a/util/template/endpoint-function b/util/template/endpoint-function index d5d0a0541..a96c37c51 100644 --- a/util/template/endpoint-function +++ b/util/template/endpoint-function @@ -2,9 +2,8 @@ public function :endpoint(array $params = []) { :extract - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder(':EndpointClass'); + $endpoint = $this->endpointFactory->getEndpoint(:EndpointClass::class); $endpoint->setParams($params); :setparam return $this->performRequest($endpoint); - } \ No newline at end of file + } diff --git a/util/template/endpoint-function-bool b/util/template/endpoint-function-bool index d4e6945d9..d4c90d6d4 100644 --- a/util/template/endpoint-function-bool +++ b/util/template/endpoint-function-bool @@ -5,9 +5,8 @@ // manually make this verbose so we can check status code $params['client']['verbose'] = true; - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder(':EndpointClass'); + $endpoint = $this->endpointFactory->getEndpoint(:EndpointClass::class); $endpoint->setParams($params); :setparam return BooleanRequestWrapper::performRequest($endpoint, $this->transport); - } \ No newline at end of file + } diff --git a/util/template/new-namespace b/util/template/new-namespace index 3c4b354ce..1a7bff8bd 100644 --- a/util/template/new-namespace +++ b/util/template/new-namespace @@ -1 +1 @@ - $this->:name = new :namespace($transport, $endpoint); + $this->:name = new :namespace($transport, $this->endpointFactory); From 5aff51ab9a9e0c325dae35072216224e187ef9c0 Mon Sep 17 00:00:00 2001 From: Kim Pepper Date: Wed, 6 Nov 2024 10:06:37 +1100 Subject: [PATCH 02/10] Add BC for deprecated property Signed-off-by: Kim Pepper --- src/OpenSearch/ClientBuilder.php | 31 ++++++++++++++++ src/OpenSearch/LegacyEndpointFactory.php | 37 +++++++++++++++++++ .../Namespaces/AbstractNamespace.php | 15 +++++++- .../Traits/DeprecatedPropertyTrait.php | 23 ++++++++++++ util/template/client-class | 34 +++++++++++++++-- 5 files changed, 136 insertions(+), 4 deletions(-) create mode 100644 src/OpenSearch/LegacyEndpointFactory.php create mode 100644 src/OpenSearch/Traits/DeprecatedPropertyTrait.php diff --git a/src/OpenSearch/ClientBuilder.php b/src/OpenSearch/ClientBuilder.php index 969e41832..66ec0622b 100644 --- a/src/OpenSearch/ClientBuilder.php +++ b/src/OpenSearch/ClientBuilder.php @@ -41,12 +41,16 @@ use GuzzleHttp\Ring\Client\CurlHandler; use GuzzleHttp\Ring\Client\CurlMultiHandler; use GuzzleHttp\Ring\Client\Middleware; +use OpenSearch\Traits\DeprecatedPropertyTrait; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; use ReflectionClass; class ClientBuilder { + + use DeprecatedPropertyTrait; + public const ALLOWED_METHODS_FROM_CONFIG = ['includePortInHostHeader']; /** @@ -56,6 +60,11 @@ class ClientBuilder private ?EndpointFactoryInterface $endpointFactory = null; + /** + * @var callable|null + */ + private $endpoint; + /** * @var NamespaceBuilderInterface[] */ @@ -179,6 +188,14 @@ public function getTransport(): Transport return $this->transport; } + /** + * Can supply second param to Client::__construct() when invoking manually or with dependency injection + */ + public function getEndpoint(): callable + { + return $this->endpoint; + } + /** * Can supply third param to Client::__construct() when invoking manually or with dependency injection * @@ -314,6 +331,20 @@ public function setConnectionPool($connectionPool, array $args = []): ClientBuil return $this; } + /** + * Set the endpoint + * + * @param callable $endpoint + */ + public function setEndpoint(callable $endpoint): ClientBuilder + { + @trigger_error(__METHOD__ . '() is deprecated in 2.3.2 and will be removed in 3.0.0. Use \OpenSearch\ClientBuilder::setEndpointFactory() instead.', E_USER_DEPRECATED); + $this->endpoint = $endpoint; + $this->endpointFactory = new LegacyEndpointFactory($endpoint); + + return $this; + } + public function setEndpointFactory(EndpointFactoryInterface $endpointFactory): ClientBuilder { $this->endpointFactory = $endpointFactory; diff --git a/src/OpenSearch/LegacyEndpointFactory.php b/src/OpenSearch/LegacyEndpointFactory.php new file mode 100644 index 000000000..ca4e79b78 --- /dev/null +++ b/src/OpenSearch/LegacyEndpointFactory.php @@ -0,0 +1,37 @@ +endpoints = $endpoints; + } + + /** + * {@inheritdoc} + */ + public function getEndpoint(string $class): AbstractEndpoint + { + $endpointBuilder = $this->endpoints; + return $endpointBuilder($class); + } + +} diff --git a/src/OpenSearch/Namespaces/AbstractNamespace.php b/src/OpenSearch/Namespaces/AbstractNamespace.php index c1ea75611..b5a3e19ec 100644 --- a/src/OpenSearch/Namespaces/AbstractNamespace.php +++ b/src/OpenSearch/Namespaces/AbstractNamespace.php @@ -23,23 +23,36 @@ use OpenSearch\EndpointFactoryInterface; use OpenSearch\Endpoints\AbstractEndpoint; +use OpenSearch\LegacyEndpointFactory; +use OpenSearch\Traits\DeprecatedPropertyTrait; use OpenSearch\Transport; abstract class AbstractNamespace { + + use DeprecatedPropertyTrait; + /** * @var \OpenSearch\Transport */ protected $transport; + protected EndpointFactoryInterface $endpointFactory; + /** * @var callable */ protected $endpoints; - public function __construct(Transport $transport, protected readonly EndpointFactoryInterface $endpointFactory) + public function __construct(Transport $transport, callable|EndpointFactoryInterface $endpointFactory) { $this->transport = $transport; + if (is_callable($endpointFactory)) { + @trigger_error('Passing a callable to AbstractNamespace is deprecated in 2.3.2 and will be removed in 3.0.0. Pass an instance of \OpenSearch\EndpointFactoryInterface instead.', E_USER_DEPRECATED); + $this->endpoints = $endpointFactory; + $endpointFactory = new LegacyEndpointFactory($endpointFactory); + } + $this->endpointFactory = $endpointFactory; } /** diff --git a/src/OpenSearch/Traits/DeprecatedPropertyTrait.php b/src/OpenSearch/Traits/DeprecatedPropertyTrait.php new file mode 100644 index 000000000..9f9fb19fc --- /dev/null +++ b/src/OpenSearch/Traits/DeprecatedPropertyTrait.php @@ -0,0 +1,23 @@ +endpoints; + } + return null; + } + +} diff --git a/util/template/client-class b/util/template/client-class index c494e672d..883a1f7f4 100644 --- a/util/template/client-class +++ b/util/template/client-class @@ -27,6 +27,8 @@ use OpenSearch\Endpoints\AbstractEndpoint; use OpenSearch\Namespaces\NamespaceBuilderInterface; use OpenSearch\Namespaces\BooleanRequestWrapper; :use-namespaces +use OpenSearch\Traits\DeprecatedPropertyTrait; + /** * Class Client * @@ -34,6 +36,9 @@ use OpenSearch\Namespaces\BooleanRequestWrapper; */ class Client { + + use DeprecatedPropertyTrait; + const VERSION = '2.3.1'; /** @@ -48,6 +53,11 @@ class Client protected EndpointFactoryInterface $endpointFactory; + /** + * @var callable + */ + protected $endpoints; + /** * @var NamespaceBuilderInterface[] */ @@ -57,19 +67,37 @@ class Client /** * Client constructor * - * @param Transport $transport - * @param EndpointFactoryInterface $endpointFactory + * @param Transport $transport + * @param callable|EndpointFactoryInterface $endpointFactory * @param NamespaceBuilderInterface[] $registeredNamespaces */ - public function __construct(Transport $transport, EndpointFactoryInterface $endpointFactory, array $registeredNamespaces) + public function __construct(Transport $transport, callable|EndpointFactoryInterface $endpointFactory, array $registeredNamespaces) { $this->transport = $transport; + if (is_callable($endpointFactory)) { + @trigger_error('Passing a callable to AbstractNamespace is deprecated in 2.3.2 and will be removed in 3.0.0. Pass an instance of \OpenSearch\EndpointFactoryInterface instead.', E_USER_DEPRECATED); + $this->endpoints = $endpointFactory; + $endpointFactory = new LegacyEndpointFactory($endpointFactory); + } $this->endpointFactory = $endpointFactory; :new-namespaces $this->registeredNamespaces = $registeredNamespaces; } :endpoints :functions + + /** + * Checks for access to deprecated properties. + */ + public function __get(string $name): mixed + { + if ($name === 'endpoints') { + @trigger_error('The $callable property is deprecated in 2.3.2 and will be removed in 3.0.0. Use $endpointFactory instead.', E_USER_DEPRECATED); + return $this->endpoints; + } + return null; + } + /** * Catchall for registered namespaces * From de431ebcb9a634cbe1cf9b4f8ddbc77acd7741f9 Mon Sep 17 00:00:00 2001 From: Kim Pepper Date: Thu, 7 Nov 2024 08:48:06 +1100 Subject: [PATCH 03/10] Address feedback Signed-off-by: Kim Pepper --- src/OpenSearch/ClientBuilder.php | 16 ++++++---------- src/OpenSearch/EndpointInterface.php | 4 ++++ src/OpenSearch/LegacyEndpointFactory.php | 2 ++ .../Traits/DeprecatedPropertyTrait.php | 2 ++ util/template/client-class | 7 +++++-- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/OpenSearch/ClientBuilder.php b/src/OpenSearch/ClientBuilder.php index 66ec0622b..e0e63ba18 100644 --- a/src/OpenSearch/ClientBuilder.php +++ b/src/OpenSearch/ClientBuilder.php @@ -24,9 +24,12 @@ use Aws\Credentials\CredentialProvider; use Aws\Credentials\Credentials; use Aws\Credentials\CredentialsInterface; +use GuzzleHttp\Ring\Client\CurlHandler; +use GuzzleHttp\Ring\Client\CurlMultiHandler; +use GuzzleHttp\Ring\Client\Middleware; +use OpenSearch\Common\Exceptions\AuthenticationConfigException; use OpenSearch\Common\Exceptions\InvalidArgumentException; use OpenSearch\Common\Exceptions\RuntimeException; -use OpenSearch\Common\Exceptions\AuthenticationConfigException; use OpenSearch\ConnectionPool\AbstractConnectionPool; use OpenSearch\ConnectionPool\Selectors\RoundRobinSelector; use OpenSearch\ConnectionPool\Selectors\SelectorInterface; @@ -38,9 +41,6 @@ use OpenSearch\Namespaces\NamespaceBuilderInterface; use OpenSearch\Serializers\SerializerInterface; use OpenSearch\Serializers\SmartSerializer; -use GuzzleHttp\Ring\Client\CurlHandler; -use GuzzleHttp\Ring\Client\CurlMultiHandler; -use GuzzleHttp\Ring\Client\Middleware; use OpenSearch\Traits\DeprecatedPropertyTrait; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; @@ -60,11 +60,6 @@ class ClientBuilder private ?EndpointFactoryInterface $endpointFactory = null; - /** - * @var callable|null - */ - private $endpoint; - /** * @var NamespaceBuilderInterface[] */ @@ -335,11 +330,12 @@ public function setConnectionPool($connectionPool, array $args = []): ClientBuil * Set the endpoint * * @param callable $endpoint + * + * @deprecated in 2.3.2 and will be removed in 3.0.0. Use \OpenSearch\ClientBuilder::setEndpointFactory() instead. */ public function setEndpoint(callable $endpoint): ClientBuilder { @trigger_error(__METHOD__ . '() is deprecated in 2.3.2 and will be removed in 3.0.0. Use \OpenSearch\ClientBuilder::setEndpointFactory() instead.', E_USER_DEPRECATED); - $this->endpoint = $endpoint; $this->endpointFactory = new LegacyEndpointFactory($endpoint); return $this; diff --git a/src/OpenSearch/EndpointInterface.php b/src/OpenSearch/EndpointInterface.php index b9e32e0e5..c28c63ef8 100644 --- a/src/OpenSearch/EndpointInterface.php +++ b/src/OpenSearch/EndpointInterface.php @@ -36,6 +36,8 @@ public function getParams(): array; /** * Get the options. + * + * @return array */ public function getOptions(): array; @@ -71,6 +73,8 @@ public function getBody(): array|string; /** * Set the body of the request. + * + * @param array $body */ public function setBody(array $body): static; diff --git a/src/OpenSearch/LegacyEndpointFactory.php b/src/OpenSearch/LegacyEndpointFactory.php index ca4e79b78..40f649b4d 100644 --- a/src/OpenSearch/LegacyEndpointFactory.php +++ b/src/OpenSearch/LegacyEndpointFactory.php @@ -30,6 +30,8 @@ public function __construct(callable $endpoints) */ public function getEndpoint(string $class): AbstractEndpoint { + // We need to strip the base namespace from the class name for BC. + $class = str_replace('OpenSearch\\Endpoints\\', '', $class); $endpointBuilder = $this->endpoints; return $endpointBuilder($class); } diff --git a/src/OpenSearch/Traits/DeprecatedPropertyTrait.php b/src/OpenSearch/Traits/DeprecatedPropertyTrait.php index 9f9fb19fc..d99327517 100644 --- a/src/OpenSearch/Traits/DeprecatedPropertyTrait.php +++ b/src/OpenSearch/Traits/DeprecatedPropertyTrait.php @@ -4,6 +4,8 @@ /** * Provides a standard way to announce deprecated properties. + * + * @internal */ trait DeprecatedPropertyTrait { diff --git a/util/template/client-class b/util/template/client-class index 883a1f7f4..2ed911ecf 100644 --- a/util/template/client-class +++ b/util/template/client-class @@ -75,10 +75,13 @@ class Client { $this->transport = $transport; if (is_callable($endpointFactory)) { - @trigger_error('Passing a callable to AbstractNamespace is deprecated in 2.3.2 and will be removed in 3.0.0. Pass an instance of \OpenSearch\EndpointFactoryInterface instead.', E_USER_DEPRECATED); - $this->endpoints = $endpointFactory; + @trigger_error('Passing a callable as the $endpointFactory param in ' . __METHOD__ . ' is deprecated in 2.3.2 and will be removed in 3.0.0. Pass an instance of \OpenSearch\EndpointFactoryInterface instead.', E_USER_DEPRECATED); + $endpoints = $endpointFactory; $endpointFactory = new LegacyEndpointFactory($endpointFactory); + } else { + $endpoints = $endpointFactory->getEndpoint(...); } + $this->endpoints = $endpoints; $this->endpointFactory = $endpointFactory; :new-namespaces $this->registeredNamespaces = $registeredNamespaces; From 356ba07c92889cacf7240c30c278ebf30c9f8be3 Mon Sep 17 00:00:00 2001 From: Kim Pepper Date: Fri, 8 Nov 2024 11:36:26 +1100 Subject: [PATCH 04/10] Remove trait and fix bc Signed-off-by: Kim Pepper --- src/OpenSearch/ClientBuilder.php | 8 +++--- .../Namespaces/AbstractNamespace.php | 13 +++++----- .../Traits/DeprecatedPropertyTrait.php | 25 ------------------- util/template/client-class | 4 +-- 4 files changed, 12 insertions(+), 38 deletions(-) delete mode 100644 src/OpenSearch/Traits/DeprecatedPropertyTrait.php diff --git a/src/OpenSearch/ClientBuilder.php b/src/OpenSearch/ClientBuilder.php index e0e63ba18..f8f5bef5e 100644 --- a/src/OpenSearch/ClientBuilder.php +++ b/src/OpenSearch/ClientBuilder.php @@ -41,16 +41,12 @@ use OpenSearch\Namespaces\NamespaceBuilderInterface; use OpenSearch\Serializers\SerializerInterface; use OpenSearch\Serializers\SmartSerializer; -use OpenSearch\Traits\DeprecatedPropertyTrait; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; use ReflectionClass; class ClientBuilder { - - use DeprecatedPropertyTrait; - public const ALLOWED_METHODS_FROM_CONFIG = ['includePortInHostHeader']; /** @@ -185,10 +181,12 @@ public function getTransport(): Transport /** * Can supply second param to Client::__construct() when invoking manually or with dependency injection + * + * @deprecated in 2.3.2 and will be removed in 3.0.0. Use \OpenSearch\ClientBuilder::getEndpointFactory() instead. */ public function getEndpoint(): callable { - return $this->endpoint; + return fn ($c) => $this->endpointFactory->getEndpoint('OpenSearch\\Endpoints\\' . $c); } /** diff --git a/src/OpenSearch/Namespaces/AbstractNamespace.php b/src/OpenSearch/Namespaces/AbstractNamespace.php index b5a3e19ec..ae498effd 100644 --- a/src/OpenSearch/Namespaces/AbstractNamespace.php +++ b/src/OpenSearch/Namespaces/AbstractNamespace.php @@ -24,14 +24,10 @@ use OpenSearch\EndpointFactoryInterface; use OpenSearch\Endpoints\AbstractEndpoint; use OpenSearch\LegacyEndpointFactory; -use OpenSearch\Traits\DeprecatedPropertyTrait; use OpenSearch\Transport; abstract class AbstractNamespace { - - use DeprecatedPropertyTrait; - /** * @var \OpenSearch\Transport */ @@ -41,6 +37,8 @@ abstract class AbstractNamespace /** * @var callable + * + * @deprecated in 2.3.2 and will be removed in 3.0.0. Use $endpointFactory property instead. */ protected $endpoints; @@ -48,10 +46,13 @@ public function __construct(Transport $transport, callable|EndpointFactoryInterf { $this->transport = $transport; if (is_callable($endpointFactory)) { - @trigger_error('Passing a callable to AbstractNamespace is deprecated in 2.3.2 and will be removed in 3.0.0. Pass an instance of \OpenSearch\EndpointFactoryInterface instead.', E_USER_DEPRECATED); - $this->endpoints = $endpointFactory; + @trigger_error('Passing a callable as $endpointFactory param to ' . __METHOD__ . '() is deprecated in 2.3.2 and will be removed in 3.0.0. Pass an instance of \OpenSearch\EndpointFactoryInterface instead.', E_USER_DEPRECATED); + $endpoints = $endpointFactory; $endpointFactory = new LegacyEndpointFactory($endpointFactory); + } else { + $endpoints = fn ($c) => $endpointFactory->getEndpoint('OpenSearch\\Endpoints\\' . $c); } + $this->endpoints = $endpoints; $this->endpointFactory = $endpointFactory; } diff --git a/src/OpenSearch/Traits/DeprecatedPropertyTrait.php b/src/OpenSearch/Traits/DeprecatedPropertyTrait.php deleted file mode 100644 index d99327517..000000000 --- a/src/OpenSearch/Traits/DeprecatedPropertyTrait.php +++ /dev/null @@ -1,25 +0,0 @@ -endpoints; - } - return null; - } - -} diff --git a/util/template/client-class b/util/template/client-class index 2ed911ecf..68a203797 100644 --- a/util/template/client-class +++ b/util/template/client-class @@ -79,7 +79,7 @@ class Client $endpoints = $endpointFactory; $endpointFactory = new LegacyEndpointFactory($endpointFactory); } else { - $endpoints = $endpointFactory->getEndpoint(...); + $endpoints = fn ($c) => $endpointFactory->getEndpoint('OpenSearch\\Endpoints\\' . $c); } $this->endpoints = $endpoints; $this->endpointFactory = $endpointFactory; @@ -95,7 +95,7 @@ class Client public function __get(string $name): mixed { if ($name === 'endpoints') { - @trigger_error('The $callable property is deprecated in 2.3.2 and will be removed in 3.0.0. Use $endpointFactory instead.', E_USER_DEPRECATED); + @trigger_error('The $endpoints property is deprecated in 2.3.2 and will be removed in 3.0.0. Use $endpointFactory instead.', E_USER_DEPRECATED); return $this->endpoints; } return null; From 653dc94dda3684be764186bde87d2024f1f2dd86 Mon Sep 17 00:00:00 2001 From: Kim Pepper Date: Wed, 13 Nov 2024 09:40:52 +1100 Subject: [PATCH 05/10] Addressed feedback Signed-off-by: Kim Pepper --- util/template/client-class | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/util/template/client-class b/util/template/client-class index 68a203797..f4346b5fc 100644 --- a/util/template/client-class +++ b/util/template/client-class @@ -37,8 +37,6 @@ use OpenSearch\Traits\DeprecatedPropertyTrait; class Client { - use DeprecatedPropertyTrait; - const VERSION = '2.3.1'; /** @@ -51,10 +49,12 @@ class Client */ protected $params; - protected EndpointFactoryInterface $endpointFactory; + private EndpointFactoryInterface $endpointFactory; /** * @var callable + * + * @deprecated in 2.3.2 and will be removed in 3.0.0. */ protected $endpoints; @@ -79,7 +79,10 @@ class Client $endpoints = $endpointFactory; $endpointFactory = new LegacyEndpointFactory($endpointFactory); } else { - $endpoints = fn ($c) => $endpointFactory->getEndpoint('OpenSearch\\Endpoints\\' . $c); + $endpoints = function ($c) { + @trigger_error('The $endpoints property is deprecated in 2.3.2 and will be removed in 3.0.0.', E_USER_DEPRECATED); + $endpointFactory->getEndpoint('OpenSearch\\Endpoints\\' . $c); + }; } $this->endpoints = $endpoints; $this->endpointFactory = $endpointFactory; @@ -90,15 +93,10 @@ class Client :functions /** - * Checks for access to deprecated properties. + * Gets the endpoint factory. */ - public function __get(string $name): mixed - { - if ($name === 'endpoints') { - @trigger_error('The $endpoints property is deprecated in 2.3.2 and will be removed in 3.0.0. Use $endpointFactory instead.', E_USER_DEPRECATED); - return $this->endpoints; - } - return null; + protected function getEndpointFactory(): EndpointFactoryInterface { + return $this->endpointFactory; } /** From 68442d550463a5ab2c3e61cdac3e595b1455fecc Mon Sep 17 00:00:00 2001 From: Kim Pepper Date: Thu, 14 Nov 2024 06:08:47 +1100 Subject: [PATCH 06/10] Address feedback Signed-off-by: Kim Pepper --- src/OpenSearch/Namespaces/AbstractNamespace.php | 5 ++++- util/template/client-class | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/OpenSearch/Namespaces/AbstractNamespace.php b/src/OpenSearch/Namespaces/AbstractNamespace.php index ae498effd..ec908dca1 100644 --- a/src/OpenSearch/Namespaces/AbstractNamespace.php +++ b/src/OpenSearch/Namespaces/AbstractNamespace.php @@ -50,7 +50,10 @@ public function __construct(Transport $transport, callable|EndpointFactoryInterf $endpoints = $endpointFactory; $endpointFactory = new LegacyEndpointFactory($endpointFactory); } else { - $endpoints = fn ($c) => $endpointFactory->getEndpoint('OpenSearch\\Endpoints\\' . $c); + $endpoints = function ($c) use ($endpointFactory) { + @trigger_error('The $endpoints property is deprecated in 2.3.2 and will be removed in 3.0.0.', E_USER_DEPRECATED); + return $endpointFactory->getEndpoint('OpenSearch\\Endpoints\\' . $c); + }; } $this->endpoints = $endpoints; $this->endpointFactory = $endpointFactory; diff --git a/util/template/client-class b/util/template/client-class index f4346b5fc..e9d1ab1cd 100644 --- a/util/template/client-class +++ b/util/template/client-class @@ -81,7 +81,7 @@ class Client } else { $endpoints = function ($c) { @trigger_error('The $endpoints property is deprecated in 2.3.2 and will be removed in 3.0.0.', E_USER_DEPRECATED); - $endpointFactory->getEndpoint('OpenSearch\\Endpoints\\' . $c); + return $endpointFactory->getEndpoint('OpenSearch\\Endpoints\\' . $c); }; } $this->endpoints = $endpoints; From 567f12937e7419ae4eeb3cf5150877560e805329 Mon Sep 17 00:00:00 2001 From: Kim Pepper Date: Thu, 14 Nov 2024 06:25:03 +1100 Subject: [PATCH 07/10] Added changelog and deprecation trigger Signed-off-by: Kim Pepper --- CHANGELOG.md | 1 + src/OpenSearch/ClientBuilder.php | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c6aedc22..70f545a4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Increased min version of `ezimuel/ringphp` to `^1.2.2` - Changed fluent setters to return static ### Deprecated +- Passing a callable to for retrieving endpoints is deprecated and replaced with passing an EndpointFactory ([#237](https://github.com/opensearch-project/opensearch-php/pull/237)) ### Removed - Removed support for PHP 7.3 and 7.4 ### Fixed diff --git a/src/OpenSearch/ClientBuilder.php b/src/OpenSearch/ClientBuilder.php index f8f5bef5e..a075e36f9 100644 --- a/src/OpenSearch/ClientBuilder.php +++ b/src/OpenSearch/ClientBuilder.php @@ -186,6 +186,7 @@ public function getTransport(): Transport */ public function getEndpoint(): callable { + @trigger_error(__METHOD__ . '() is deprecated in 2.3.2 and will be removed in 3.0.0. Use \OpenSearch\ClientBuilder::getEndpointFactory() instead.', E_USER_DEPRECATED); return fn ($c) => $this->endpointFactory->getEndpoint('OpenSearch\\Endpoints\\' . $c); } From bbdd8517283eeec0d9ea4bdad0e3c6a6be78e05c Mon Sep 17 00:00:00 2001 From: Kim Pepper Date: Fri, 15 Nov 2024 08:47:15 +1100 Subject: [PATCH 08/10] Update changelog Signed-off-by: Kim Pepper --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70f545a4e..d116cab0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Increased min version of `ezimuel/ringphp` to `^1.2.2` - Changed fluent setters to return static ### Deprecated -- Passing a callable to for retrieving endpoints is deprecated and replaced with passing an EndpointFactory ([#237](https://github.com/opensearch-project/opensearch-php/pull/237)) +- Passing a callable to \OpenSearch\ClientBuilder::setEndpoint() is deprecated and replaced with passing an EndpointFactory to \OpenSearch\ClientBuilder::setEndpointFactory() ([#237](https://github.com/opensearch-project/opensearch-php/pull/237)) ### Removed - Removed support for PHP 7.3 and 7.4 ### Fixed From d69d2acb4e15e6d1ea20f4e750285d987b35b5e3 Mon Sep 17 00:00:00 2001 From: Kim Pepper Date: Fri, 15 Nov 2024 10:49:26 +1100 Subject: [PATCH 09/10] Generate API Signed-off-by: Kim Pepper --- CHANGELOG.md | 1 + src/OpenSearch/Client.php | 336 ++++++++++-------- .../AsynchronousSearchNamespace.php | 16 +- src/OpenSearch/Namespaces/CatNamespace.php | 124 +++---- .../Namespaces/ClusterNamespace.php | 100 +++--- .../Namespaces/DanglingIndicesNamespace.php | 14 +- .../Namespaces/FlowFrameworkNamespace.php | 40 +-- .../Namespaces/IndicesNamespace.php | 333 +++++++++-------- src/OpenSearch/Namespaces/IngestNamespace.php | 20 +- .../Namespaces/InsightsNamespace.php | 4 +- src/OpenSearch/Namespaces/IsmNamespace.php | 60 ++-- src/OpenSearch/Namespaces/KnnNamespace.php | 34 +- src/OpenSearch/Namespaces/ListNamespace.php | 12 +- src/OpenSearch/Namespaces/MlNamespace.php | 70 ++-- src/OpenSearch/Namespaces/NodesNamespace.php | 22 +- .../Namespaces/NotificationsNamespace.php | 36 +- .../Namespaces/ObservabilityNamespace.php | 28 +- src/OpenSearch/Namespaces/PplNamespace.php | 16 +- src/OpenSearch/Namespaces/QueryNamespace.php | 20 +- .../Namespaces/RemoteStoreNamespace.php | 4 +- .../Namespaces/RollupsNamespace.php | 24 +- .../Namespaces/SearchPipelineNamespace.php | 12 +- .../Namespaces/SecurityNamespace.php | 314 ++++++++-------- .../Namespaces/SnapshotNamespace.php | 46 +-- src/OpenSearch/Namespaces/SqlNamespace.php | 30 +- src/OpenSearch/Namespaces/TasksNamespace.php | 12 +- .../Namespaces/TransformsNamespace.php | 32 +- src/OpenSearch/Namespaces/WlmNamespace.php | 28 +- 28 files changed, 891 insertions(+), 897 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d116cab0e..c7334481b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Fixed - Fixed PHP 8.4 deprecations ### Updated APIs +- Updated opensearch-php APIs to reflect [opensearch-api-specification@398481e](https://github.com/opensearch-project/opensearch-api-specification/commit/398481e5bd1cc590d947c35379c47096f2114f00) - Updated opensearch-php APIs to reflect [opensearch-api-specification@6bb1fed](https://github.com/opensearch-project/opensearch-api-specification/commit/6bb1fed0a2c7cf094a5ecfdb01f0306a4b9f8eba) - Updated opensearch-php APIs to reflect [opensearch-api-specification@07e329e](https://github.com/opensearch-project/opensearch-api-specification/commit/07e329e8d01fd0576de6a0a3c35412fd5a9163db) - Updated opensearch-php APIs to reflect [opensearch-api-specification@1db1840](https://github.com/opensearch-project/opensearch-api-specification/commit/1db184063a463c5180a2cc824b1efc1aeebfd5eb) diff --git a/src/OpenSearch/Client.php b/src/OpenSearch/Client.php index 683e99bd8..80478db96 100644 --- a/src/OpenSearch/Client.php +++ b/src/OpenSearch/Client.php @@ -57,6 +57,7 @@ use OpenSearch\Namespaces\TasksNamespace; use OpenSearch\Namespaces\TransformsNamespace; use OpenSearch\Namespaces\WlmNamespace; +use OpenSearch\Traits\DeprecatedPropertyTrait; /** * Class Client @@ -77,8 +78,12 @@ class Client */ protected $params; + private EndpointFactoryInterface $endpointFactory; + /** * @var callable + * + * @deprecated in 2.3.2 and will be removed in 3.0.0. */ protected $endpoints; @@ -246,45 +251,56 @@ class Client /** * Client constructor * - * @param Transport $transport - * @param callable $endpoint + * @param Transport $transport + * @param callable|EndpointFactoryInterface $endpointFactory * @param NamespaceBuilderInterface[] $registeredNamespaces */ - public function __construct(Transport $transport, callable $endpoint, array $registeredNamespaces) + public function __construct(Transport $transport, callable|EndpointFactoryInterface $endpointFactory, array $registeredNamespaces) { $this->transport = $transport; - $this->endpoints = $endpoint; - $this->asyncSearch = new AsyncSearchNamespace($transport, $endpoint); - $this->asynchronousSearch = new AsynchronousSearchNamespace($transport, $endpoint); - $this->cat = new CatNamespace($transport, $endpoint); - $this->cluster = new ClusterNamespace($transport, $endpoint); - $this->danglingIndices = new DanglingIndicesNamespace($transport, $endpoint); - $this->dataFrameTransformDeprecated = new DataFrameTransformDeprecatedNamespace($transport, $endpoint); - $this->flowFramework = new FlowFrameworkNamespace($transport, $endpoint); - $this->indices = new IndicesNamespace($transport, $endpoint); - $this->ingest = new IngestNamespace($transport, $endpoint); - $this->insights = new InsightsNamespace($transport, $endpoint); - $this->ism = new IsmNamespace($transport, $endpoint); - $this->knn = new KnnNamespace($transport, $endpoint); - $this->list = new ListNamespace($transport, $endpoint); - $this->ml = new MlNamespace($transport, $endpoint); - $this->monitoring = new MonitoringNamespace($transport, $endpoint); - $this->nodes = new NodesNamespace($transport, $endpoint); - $this->notifications = new NotificationsNamespace($transport, $endpoint); - $this->observability = new ObservabilityNamespace($transport, $endpoint); - $this->ppl = new PplNamespace($transport, $endpoint); - $this->query = new QueryNamespace($transport, $endpoint); - $this->remoteStore = new RemoteStoreNamespace($transport, $endpoint); - $this->rollups = new RollupsNamespace($transport, $endpoint); - $this->searchPipeline = new SearchPipelineNamespace($transport, $endpoint); - $this->searchableSnapshots = new SearchableSnapshotsNamespace($transport, $endpoint); - $this->security = new SecurityNamespace($transport, $endpoint); - $this->snapshot = new SnapshotNamespace($transport, $endpoint); - $this->sql = new SqlNamespace($transport, $endpoint); - $this->ssl = new SslNamespace($transport, $endpoint); - $this->tasks = new TasksNamespace($transport, $endpoint); - $this->transforms = new TransformsNamespace($transport, $endpoint); - $this->wlm = new WlmNamespace($transport, $endpoint); + if (is_callable($endpointFactory)) { + @trigger_error('Passing a callable as the $endpointFactory param in ' . __METHOD__ . ' is deprecated in 2.3.2 and will be removed in 3.0.0. Pass an instance of \OpenSearch\EndpointFactoryInterface instead.', E_USER_DEPRECATED); + $endpoints = $endpointFactory; + $endpointFactory = new LegacyEndpointFactory($endpointFactory); + } else { + $endpoints = function ($c) { + @trigger_error('The $endpoints property is deprecated in 2.3.2 and will be removed in 3.0.0.', E_USER_DEPRECATED); + return $endpointFactory->getEndpoint('OpenSearch\\Endpoints\\' . $c); + }; + } + $this->endpoints = $endpoints; + $this->endpointFactory = $endpointFactory; + $this->asyncSearch = new AsyncSearchNamespace($transport, $this->endpointFactory); + $this->asynchronousSearch = new AsynchronousSearchNamespace($transport, $this->endpointFactory); + $this->cat = new CatNamespace($transport, $this->endpointFactory); + $this->cluster = new ClusterNamespace($transport, $this->endpointFactory); + $this->danglingIndices = new DanglingIndicesNamespace($transport, $this->endpointFactory); + $this->dataFrameTransformDeprecated = new DataFrameTransformDeprecatedNamespace($transport, $this->endpointFactory); + $this->flowFramework = new FlowFrameworkNamespace($transport, $this->endpointFactory); + $this->indices = new IndicesNamespace($transport, $this->endpointFactory); + $this->ingest = new IngestNamespace($transport, $this->endpointFactory); + $this->insights = new InsightsNamespace($transport, $this->endpointFactory); + $this->ism = new IsmNamespace($transport, $this->endpointFactory); + $this->knn = new KnnNamespace($transport, $this->endpointFactory); + $this->list = new ListNamespace($transport, $this->endpointFactory); + $this->ml = new MlNamespace($transport, $this->endpointFactory); + $this->monitoring = new MonitoringNamespace($transport, $this->endpointFactory); + $this->nodes = new NodesNamespace($transport, $this->endpointFactory); + $this->notifications = new NotificationsNamespace($transport, $this->endpointFactory); + $this->observability = new ObservabilityNamespace($transport, $this->endpointFactory); + $this->ppl = new PplNamespace($transport, $this->endpointFactory); + $this->query = new QueryNamespace($transport, $this->endpointFactory); + $this->remoteStore = new RemoteStoreNamespace($transport, $this->endpointFactory); + $this->rollups = new RollupsNamespace($transport, $this->endpointFactory); + $this->searchPipeline = new SearchPipelineNamespace($transport, $this->endpointFactory); + $this->searchableSnapshots = new SearchableSnapshotsNamespace($transport, $this->endpointFactory); + $this->security = new SecurityNamespace($transport, $this->endpointFactory); + $this->snapshot = new SnapshotNamespace($transport, $this->endpointFactory); + $this->sql = new SqlNamespace($transport, $this->endpointFactory); + $this->ssl = new SslNamespace($transport, $this->endpointFactory); + $this->tasks = new TasksNamespace($transport, $this->endpointFactory); + $this->transforms = new TransformsNamespace($transport, $this->endpointFactory); + $this->wlm = new WlmNamespace($transport, $this->endpointFactory); $this->registeredNamespaces = $registeredNamespaces; } @@ -317,14 +333,14 @@ public function bulk(array $params = []) $index = $this->extractArgument($params, 'index'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Bulk'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Bulk::class); $endpoint->setParams($params); $endpoint->setIndex($index); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Allows to perform multiple index/update/delete operations using request response streaming. * @@ -355,14 +371,14 @@ public function bulkStream(array $params = []) $index = $this->extractArgument($params, 'index'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('BulkStream'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\BulkStream::class); $endpoint->setParams($params); $endpoint->setIndex($index); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Explicitly clears the search context for a scroll. * @@ -372,7 +388,7 @@ public function bulkStream(array $params = []) * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-". - * $params['body'] = (array) Comma-separated list of scroll IDs to clear if none was specified via the scroll_id parameter + * $params['body'] = (array) Comma-separated list of scroll IDs to clear if none was specified using the `scroll_id` parameter * * @param array $params Associative array of parameters * @return array @@ -382,25 +398,25 @@ public function clearScroll(array $params = []) $scroll_id = $this->extractArgument($params, 'scroll_id'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('ClearScroll'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\ClearScroll::class); $endpoint->setParams($params); $endpoint->setScrollId($scroll_id); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Returns number of documents matching a query. * - * $params['index'] = (array) Comma-separated list of data streams, indices, and aliases to search. Supports wildcards (`*`). To search all data streams and indices, omit this parameter or use `*` or `_all`. - * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indices.This behavior applies even if the request targets other open indices. + * $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases to search. Supports wildcards (`*`). To search all data streams and indexes, omit this parameter or use `*` or `_all`. + * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes.This behavior applies even if the request targets other open indexes. * $params['analyze_wildcard'] = (boolean) If `true`, wildcard and prefix queries are analyzed.This parameter can only be used when the `q` query string parameter is specified. (Default = false) * $params['analyzer'] = (string) Analyzer to use for the query string.This parameter can only be used when the `q` query string parameter is specified. * $params['default_operator'] = (enum) The default operator for query string query: `AND` or `OR`.This parameter can only be used when the `q` query string parameter is specified. (Options = and,or) * $params['df'] = (string) Field to use as default where no field prefix is given in the query string.This parameter can only be used when the `q` query string parameter is specified. * $params['expand_wildcards'] = (any) Type of index that wildcard patterns can match.If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.Supports comma-separated values, such as `open,hidden`. - * $params['ignore_throttled'] = (boolean) If `true`, concrete, expanded or aliased indices are ignored when frozen. + * $params['ignore_throttled'] = (boolean) If `true`, concrete, expanded or aliased indexes are ignored when frozen. * $params['ignore_unavailable'] = (boolean) If `false`, the request returns an error if it targets a missing or closed index. * $params['lenient'] = (boolean) If `true`, format-based query failures (such as providing text to a numeric field) in the query string will be ignored. * $params['min_score'] = (number) Sets the minimum `_score` value that documents must have to be included in the result. @@ -423,20 +439,20 @@ public function count(array $params = []) $index = $this->extractArgument($params, 'index'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Count'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Count::class); $endpoint->setParams($params); $endpoint->setIndex($index); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Creates point in time context. * - * $params['index'] = (array) Comma-separated list of indices; use `_all` or empty string to perform the operation on all indices. (Required) + * $params['index'] = (array) Comma-separated list of indexes; use `_all` or empty string to perform the operation on all indexes. (Required) * $params['allow_partial_pit_creation'] = (boolean) Allow if point in time can be created with partial failures. - * $params['expand_wildcards'] = (any) Whether to expand wildcard expression to concrete indices that are open, closed or both. + * $params['expand_wildcards'] = (any) Whether to expand wildcard expression to concrete indexes that are open, closed or both. * $params['keep_alive'] = (string) Specify the keep alive for point in time. * $params['preference'] = (string) Specify the node or shard the operation should be performed on. (Default = random) * $params['routing'] = (any) Comma-separated list of specific routing values. @@ -453,13 +469,13 @@ public function createPit(array $params = []) { $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('CreatePit'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\CreatePit::class); $endpoint->setParams($params); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** * Removes a document from the index. * @@ -487,14 +503,14 @@ public function delete(array $params = []) $id = $this->extractArgument($params, 'id'); $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Delete'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Delete::class); $endpoint->setParams($params); $endpoint->setId($id); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** * Deletes all active point in time searches. * @@ -509,20 +525,20 @@ public function delete(array $params = []) */ public function deleteAllPits(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('DeleteAllPits'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\DeleteAllPits::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Deletes documents matching the provided query. * - * $params['index'] = (array) Comma-separated list of data streams, indices, and aliases to search. Supports wildcards (`*`). To search all data streams or indices, omit this parameter or use `*` or `_all`. (Required) + * $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases to search. Supports wildcards (`*`). To search all data streams or indexes, omit this parameter or use `*` or `_all`. (Required) * $params['_source'] = (array) True or false to return the _source field or not, or a list of fields to return. * $params['_source_excludes'] = (array) List of fields to exclude from the returned _source field. * $params['_source_includes'] = (array) List of fields to extract and return from the _source field. - * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indices.This behavior applies even if the request targets other open indices.For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`. + * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes.This behavior applies even if the request targets other open indexes.For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`. * $params['analyze_wildcard'] = (boolean) If `true`, wildcard and prefix queries are analyzed. (Default = false) * $params['analyzer'] = (string) Analyzer to use for the query string. * $params['conflicts'] = (enum) What to do if delete by query hits version conflicts: `abort` or `proceed`. (Options = abort,proceed) @@ -547,7 +563,7 @@ public function deleteAllPits(array $params = []) * $params['slices'] = (any) The number of slices this task should be divided into. * $params['sort'] = (array) A comma-separated list of : pairs. * $params['stats'] = (array) Specific `tag` of the request for logging and statistical purposes. - * $params['terminate_after'] = (integer) Maximum number of documents to collect for each shard.If a query reaches this limit, OpenSearch terminates the query early.OpenSearch collects documents before sorting.Use with caution.OpenSearch applies this parameter to each shard handling the request.When possible, let OpenSearch perform early termination automatically.Avoid specifying this parameter for requests that target data streams with backing indices across multiple data tiers. + * $params['terminate_after'] = (integer) Maximum number of documents to collect for each shard.If a query reaches this limit, OpenSearch terminates the query early.OpenSearch collects documents before sorting.Use with caution.OpenSearch applies this parameter to each shard handling the request.When possible, let OpenSearch perform early termination automatically.Avoid specifying this parameter for requests that target data streams with backing indexes across multiple data tiers. * $params['timeout'] = (string) Period each deletion request waits for active shards. * $params['version'] = (boolean) If `true`, returns the document version as part of a hit. * $params['wait_for_active_shards'] = (any) The number of shard copies that must be active before proceeding with the operation.Set to all or any positive integer up to the total number of shards in the index (`number_of_replicas+1`). @@ -567,14 +583,14 @@ public function deleteByQuery(array $params = []) $index = $this->extractArgument($params, 'index'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('DeleteByQuery'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\DeleteByQuery::class); $endpoint->setParams($params); $endpoint->setIndex($index); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Changes the number of requests per second for a particular Delete By Query operation. * @@ -593,13 +609,13 @@ public function deleteByQueryRethrottle(array $params = []) { $task_id = $this->extractArgument($params, 'task_id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('DeleteByQueryRethrottle'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\DeleteByQueryRethrottle::class); $endpoint->setParams($params); $endpoint->setTaskId($task_id); return $this->performRequest($endpoint); } + /** * Deletes one or more point in time searches based on the IDs passed. * @@ -617,13 +633,13 @@ public function deletePit(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('DeletePit'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\DeletePit::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Deletes a script. * @@ -644,18 +660,18 @@ public function deleteScript(array $params = []) { $id = $this->extractArgument($params, 'id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('DeleteScript'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\DeleteScript::class); $endpoint->setParams($params); $endpoint->setId($id); return $this->performRequest($endpoint); } + /** * Returns information about whether a document exists in an index. * * $params['id'] = (string) Identifier of the document. (Required) - * $params['index'] = (string) Comma-separated list of data streams, indices, and aliases. Supports wildcards (`*`). (Required) + * $params['index'] = (string) Comma-separated list of data streams, indexes, and aliases. Supports wildcards (`*`). (Required) * $params['_source'] = (any) `true` or `false` to return the `_source` field or not, or a list of fields to return. * $params['_source_excludes'] = (any) A comma-separated list of source fields to exclude in the response. * $params['_source_includes'] = (any) A comma-separated list of source fields to include in the response. @@ -683,19 +699,19 @@ public function exists(array $params = []): bool // manually make this verbose so we can check status code $params['client']['verbose'] = true; - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Exists'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Exists::class); $endpoint->setParams($params); $endpoint->setId($id); $endpoint->setIndex($index); return BooleanRequestWrapper::performRequest($endpoint, $this->transport); } + /** * Returns information about whether a document source exists in an index. * * $params['id'] = (string) Identifier of the document. (Required) - * $params['index'] = (string) Comma-separated list of data streams, indices, and aliases. Supports wildcards (`*`). (Required) + * $params['index'] = (string) Comma-separated list of data streams, indexes, and aliases. Supports wildcards (`*`). (Required) * $params['_source'] = (any) `true` or `false` to return the `_source` field or not, or a list of fields to return. * $params['_source_excludes'] = (any) A comma-separated list of source fields to exclude in the response. * $params['_source_includes'] = (any) A comma-separated list of source fields to include in the response. @@ -722,14 +738,14 @@ public function existsSource(array $params = []): bool // manually make this verbose so we can check status code $params['client']['verbose'] = true; - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('ExistsSource'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\ExistsSource::class); $endpoint->setParams($params); $endpoint->setId($id); $endpoint->setIndex($index); return BooleanRequestWrapper::performRequest($endpoint, $this->transport); } + /** * Returns information about why a specific matches (or doesn't match) a query. * @@ -763,8 +779,7 @@ public function explain(array $params = []) $index = $this->extractArgument($params, 'index'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Explain'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Explain::class); $endpoint->setParams($params); $endpoint->setId($id); $endpoint->setIndex($index); @@ -772,14 +787,15 @@ public function explain(array $params = []) return $this->performRequest($endpoint); } + /** - * Returns the information about the capabilities of fields among multiple indices. + * Returns the information about the capabilities of fields among multiple indexes. * - * $params['index'] = (array) Comma-separated list of data streams, indices, and aliases used to limit the request. Supports wildcards (*). To target all data streams and indices, omit this parameter or use * or _all. - * $params['allow_no_indices'] = (boolean) If false, the request returns an error if any wildcard expression, index alias,or `_all` value targets only missing or closed indices. This behavior applies even if the request targets other open indices. For example, a requesttargeting `foo*,bar*` returns an error if an index starts with foo but no index starts with bar. + * $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (*). To target all data streams and indexes, omit this parameter or use * or _all. + * $params['allow_no_indices'] = (boolean) If false, the request returns an error if any wildcard expression, index alias,or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. For example, a requesttargeting `foo*,bar*` returns an error if an index starts with foo but no index starts with bar. * $params['expand_wildcards'] = (any) Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. * $params['fields'] = (any) Comma-separated list of fields to retrieve capabilities for. Wildcard (`*`) expressions are supported. - * $params['ignore_unavailable'] = (boolean) If `true`, missing or closed indices are not included in the response. + * $params['ignore_unavailable'] = (boolean) If `true`, missing or closed indexes are not included in the response. * $params['include_unmapped'] = (boolean) If true, unmapped fields are included in the response. (Default = false) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) @@ -796,14 +812,14 @@ public function fieldCaps(array $params = []) $index = $this->extractArgument($params, 'index'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('FieldCaps'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\FieldCaps::class); $endpoint->setParams($params); $endpoint->setIndex($index); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Returns a document. * @@ -833,14 +849,14 @@ public function get(array $params = []) $id = $this->extractArgument($params, 'id'); $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Get'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Get::class); $endpoint->setParams($params); $endpoint->setId($id); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** * Lists all active point in time searches. * @@ -855,12 +871,12 @@ public function get(array $params = []) */ public function getAllPits(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('GetAllPits'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\GetAllPits::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Returns a script. * @@ -880,13 +896,13 @@ public function getScript(array $params = []) { $id = $this->extractArgument($params, 'id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('GetScript'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\GetScript::class); $endpoint->setParams($params); $endpoint->setId($id); return $this->performRequest($endpoint); } + /** * Returns all script contexts. * @@ -901,12 +917,12 @@ public function getScript(array $params = []) */ public function getScriptContext(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('GetScriptContext'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\GetScriptContext::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Returns available script types, languages and contexts. * @@ -921,12 +937,12 @@ public function getScriptContext(array $params = []) */ public function getScriptLanguages(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('GetScriptLanguages'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\GetScriptLanguages::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Returns the source of a document. * @@ -955,14 +971,14 @@ public function getSource(array $params = []) $id = $this->extractArgument($params, 'id'); $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('GetSource'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\GetSource::class); $endpoint->setParams($params); $endpoint->setId($id); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** * Creates or updates a document in an index. * @@ -995,8 +1011,7 @@ public function index(array $params = []) $id = $this->extractArgument($params, 'id'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Index'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Index::class); $endpoint->setParams($params); $endpoint->setIndex($index); $endpoint->setId($id); @@ -1004,6 +1019,7 @@ public function index(array $params = []) return $this->performRequest($endpoint); } + /** * Returns basic information about the cluster. * @@ -1018,12 +1034,12 @@ public function index(array $params = []) */ public function info(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Info'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Info::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Allows to get multiple documents in one request. * @@ -1051,18 +1067,18 @@ public function mget(array $params = []) $index = $this->extractArgument($params, 'index'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Mget'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Mget::class); $endpoint->setParams($params); $endpoint->setIndex($index); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Allows to execute several search operations in one request. * - * $params['index'] = (array) Comma-separated list of data streams, indices, and index aliases to search. + * $params['index'] = (array) Comma-separated list of data streams, indexes, and index aliases to search. * $params['ccs_minimize_roundtrips'] = (boolean) If true, network roundtrips between the coordinating node and remote clusters are minimized for cross-cluster search requests. (Default = true) * $params['max_concurrent_searches'] = (integer) Maximum number of concurrent searches the multi search API can execute. * $params['max_concurrent_shard_requests'] = (integer) Maximum number of concurrent shard requests that each sub-search request executes per node. (Default = 5) @@ -1085,18 +1101,18 @@ public function msearch(array $params = []) $index = $this->extractArgument($params, 'index'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Msearch'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Msearch::class); $endpoint->setParams($params); $endpoint->setIndex($index); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Allows to execute several search template operations in one request. * - * $params['index'] = (array) Comma-separated list of data streams, indices, and aliases to search. Supports wildcards (`*`). To search all data streams and indices, omit this parameter or use `*`. + * $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases to search. Supports wildcards (`*`). To search all data streams and indexes, omit this parameter or use `*`. * $params['ccs_minimize_roundtrips'] = (boolean) If `true`, network round-trips are minimized for cross-cluster search requests. (Default = true) * $params['max_concurrent_searches'] = (integer) Maximum number of concurrent searches the API can run. * $params['rest_total_hits_as_int'] = (boolean) If `true`, the response returns `hits.total` as an integer.If `false`, it returns `hits.total` as an object. (Default = false) @@ -1117,14 +1133,14 @@ public function msearchTemplate(array $params = []) $index = $this->extractArgument($params, 'index'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('MsearchTemplate'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\MsearchTemplate::class); $endpoint->setParams($params); $endpoint->setIndex($index); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Returns multiple termvectors in one request. * @@ -1156,14 +1172,14 @@ public function mtermvectors(array $params = []) $index = $this->extractArgument($params, 'index'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('MTermVectors'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\MTermVectors::class); $endpoint->setParams($params); $endpoint->setIndex($index); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Returns whether the cluster is running. * @@ -1181,12 +1197,12 @@ public function ping(array $params = []): bool // manually make this verbose so we can check status code $params['client']['verbose'] = true; - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ping'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ping::class); $endpoint->setParams($params); return BooleanRequestWrapper::performRequest($endpoint, $this->transport); } + /** * Creates or updates a script. * @@ -1211,8 +1227,7 @@ public function putScript(array $params = []) $context = $this->extractArgument($params, 'context'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('PutScript'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\PutScript::class); $endpoint->setParams($params); $endpoint->setId($id); $endpoint->setContext($context); @@ -1220,13 +1235,14 @@ public function putScript(array $params = []) return $this->performRequest($endpoint); } + /** * Allows to evaluate the quality of ranked search results over a set of typical search queries. * - * $params['index'] = (array) Comma-separated list of data streams, indices, and index aliases used to limit the request. Wildcard (`*`) expressions are supported. To target all data streams and indices in a cluster, omit this parameter or use `_all` or `*`. - * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indices. This behavior applies even if the request targets other open indices. For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`. - * $params['expand_wildcards'] = (any) Whether to expand wildcard expression to concrete indices that are open, closed or both. - * $params['ignore_unavailable'] = (boolean) If `true`, missing or closed indices are not included in the response. + * $params['index'] = (array) Comma-separated list of data streams, indexes, and index aliases used to limit the request. Wildcard (`*`) expressions are supported. To target all data streams and indexes in a cluster, omit this parameter or use `_all` or `*`. + * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`. + * $params['expand_wildcards'] = (any) Whether to expand wildcard expression to concrete indexes that are open, closed or both. + * $params['ignore_unavailable'] = (boolean) If `true`, missing or closed indexes are not included in the response. * $params['search_type'] = (enum) Search operation type (Options = dfs_query_then_fetch,query_then_fetch) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) @@ -1243,14 +1259,14 @@ public function rankEval(array $params = []) $index = $this->extractArgument($params, 'index'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('RankEval'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\RankEval::class); $endpoint->setParams($params); $endpoint->setIndex($index); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Allows to copy documents from one index to another, optionally filtering the sourcedocuments by a query, changing the destination index settings, or fetching thedocuments from a remote cluster. * @@ -1276,13 +1292,13 @@ public function reindex(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Reindex'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Reindex::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Changes the number of requests per second for a particular Reindex operation. * @@ -1301,13 +1317,13 @@ public function reindexRethrottle(array $params = []) { $task_id = $this->extractArgument($params, 'task_id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('ReindexRethrottle'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\ReindexRethrottle::class); $endpoint->setParams($params); $endpoint->setTaskId($task_id); return $this->performRequest($endpoint); } + /** * Allows to use the Mustache language to pre-render a search definition. * @@ -1327,14 +1343,14 @@ public function renderSearchTemplate(array $params = []) $id = $this->extractArgument($params, 'id'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('RenderSearchTemplate'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\RenderSearchTemplate::class); $endpoint->setParams($params); $endpoint->setId($id); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Allows an arbitrary script to be executed and a result to be returned. * @@ -1352,13 +1368,13 @@ public function scriptsPainlessExecute(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('ScriptsPainlessExecute'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\ScriptsPainlessExecute::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Allows to retrieve a large numbers of results from a single search request. * @@ -1380,22 +1396,22 @@ public function scroll(array $params = []) $scroll_id = $this->extractArgument($params, 'scroll_id'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Scroll'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Scroll::class); $endpoint->setParams($params); $endpoint->setScrollId($scroll_id); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Returns results matching a query. * - * $params['index'] = (array) Comma-separated list of data streams, indices, and aliases to search. Supports wildcards (`*`). To search all data streams and indices, omit this parameter or use `*` or `_all`. + * $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases to search. Supports wildcards (`*`). To search all data streams and indexes, omit this parameter or use `*` or `_all`. * $params['_source'] = (any) Indicates which source fields are returned for matching documents.These fields are returned in the `hits._source` property of the search response.Valid values are:`true` to return the entire document source;`false` to not return the document source;`` to return the source fields that are specified as a comma-separated list (supports wildcard (`*`) patterns). * $params['_source_excludes'] = (any) A comma-separated list of source fields to exclude from the response.You can also use this parameter to exclude fields from the subset specified in `_source_includes` query parameter.If the `_source` parameter is `false`, this parameter is ignored. * $params['_source_includes'] = (any) A comma-separated list of source fields to include in the response.If this parameter is specified, only these source fields are returned.You can exclude fields from this subset using the `_source_excludes` query parameter.If the `_source` parameter is `false`, this parameter is ignored. - * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indices.This behavior applies even if the request targets other open indices.For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`. + * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes.This behavior applies even if the request targets other open indexes.For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`. * $params['allow_partial_search_results'] = (boolean) If true, returns partial results if there are shard request timeouts or shard failures. If false, returns an error with no partial results. (Default = true) * $params['analyze_wildcard'] = (boolean) If true, wildcard and prefix queries are analyzed.This parameter can only be used when the q query string parameter is specified. (Default = false) * $params['analyzer'] = (string) Analyzer to use for the query string.This parameter can only be used when the q query string parameter is specified. @@ -1408,7 +1424,7 @@ public function scroll(array $params = []) * $params['expand_wildcards'] = (any) Type of index that wildcard patterns can match.If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.Supports comma-separated values, such as `open,hidden`. * $params['explain'] = (boolean) If `true`, returns detailed information about score computation as part of a hit. * $params['from'] = (integer) Starting document offset.Needs to be non-negative.By default, you cannot page through more than 10,000 hits using the `from` and `size` parameters.To page through more hits, use the `search_after` parameter. (Default = 0) - * $params['ignore_throttled'] = (boolean) If `true`, concrete, expanded or aliased indices will be ignored when frozen. + * $params['ignore_throttled'] = (boolean) If `true`, concrete, expanded or aliased indexes will be ignored when frozen. * $params['ignore_unavailable'] = (boolean) If `false`, the request returns an error if it targets a missing or closed index. * $params['include_named_queries_score'] = (boolean) Indicates whether hit.matched_queries should be rendered as a map that includes the name of the matched query associated with its score (true) or as an array containing the name of the matched queries (false) (Default = false) * $params['lenient'] = (boolean) If `true`, format-based query failures (such as providing text to a numeric field) in the query string will be ignored.This parameter can only be used when the `q` query string parameter is specified. @@ -1432,7 +1448,7 @@ public function scroll(array $params = []) * $params['suggest_mode'] = (enum) Specifies the suggest mode.This parameter can only be used when the `suggest_field` and `suggest_text` query string parameters are specified. (Options = always,missing,popular) * $params['suggest_size'] = (integer) Number of suggestions to return.This parameter can only be used when the `suggest_field` and `suggest_text` query string parameters are specified. * $params['suggest_text'] = (string) The source text for which the suggestions should be returned.This parameter can only be used when the `suggest_field` and `suggest_text` query string parameters are specified. - * $params['terminate_after'] = (integer) Maximum number of documents to collect for each shard.If a query reaches this limit, OpenSearch terminates the query early.OpenSearch collects documents before sorting.Use with caution.OpenSearch applies this parameter to each shard handling the request.When possible, let OpenSearch perform early termination automatically.Avoid specifying this parameter for requests that target data streams with backing indices across multiple data tiers.If set to `0` (default), the query does not terminate early. + * $params['terminate_after'] = (integer) Maximum number of documents to collect for each shard.If a query reaches this limit, OpenSearch terminates the query early.OpenSearch collects documents before sorting.Use with caution.OpenSearch applies this parameter to each shard handling the request.When possible, let OpenSearch perform early termination automatically.Avoid specifying this parameter for requests that target data streams with backing indexes across multiple data tiers.If set to `0` (default), the query does not terminate early. * $params['timeout'] = (string) Specifies the period of time to wait for a response from each shard.If no response is received before the timeout expires, the request fails and returns an error. * $params['track_scores'] = (boolean) If `true`, calculate and return document scores, even if the scores are not used for sorting. * $params['track_total_hits'] = (any) Number of hits matching the query to count accurately.If `true`, the exact number of hits is returned at the cost of some performance.If `false`, the response does not include the total number of hits matching the query. @@ -1453,19 +1469,19 @@ public function search(array $params = []) $index = $this->extractArgument($params, 'index'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Search'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Search::class); $endpoint->setParams($params); $endpoint->setIndex($index); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** - * Returns information about the indices and shards that a search request would be executed against. + * Returns information about the indexes and shards that a search request would be executed against. * - * $params['index'] = (array) Returns the indices and shards that a search request would be executed against. - * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indices.This behavior applies even if the request targets other open indices.For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`. + * $params['index'] = (array) Returns the indexes and shards that a search request would be executed against. + * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes.This behavior applies even if the request targets other open indexes.For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`. * $params['expand_wildcards'] = (any) Type of index that wildcard patterns can match.If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.Supports comma-separated values, such as `open,hidden`.Valid values are: `all`, `open`, `closed`, `hidden`, `none`. * $params['ignore_unavailable'] = (boolean) If `false`, the request returns an error if it targets a missing or closed index. * $params['local'] = (boolean) If `true`, the request retrieves information from the local node only. (Default = false) @@ -1484,22 +1500,22 @@ public function searchShards(array $params = []) { $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('SearchShards'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\SearchShards::class); $endpoint->setParams($params); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** * Allows to use the Mustache language to pre-render a search definition. * - * $params['index'] = (array) Comma-separated list of data streams, indices, and aliases to search. Supports wildcards (*). - * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indices.This behavior applies even if the request targets other open indices.For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`. + * $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases to search. Supports wildcards (*). + * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes.This behavior applies even if the request targets other open indexes.For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`. * $params['ccs_minimize_roundtrips'] = (boolean) If `true`, network round-trips are minimized for cross-cluster search requests. (Default = true) * $params['expand_wildcards'] = (any) Type of index that wildcard patterns can match.If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.Supports comma-separated values, such as `open,hidden`.Valid values are: `all`, `open`, `closed`, `hidden`, `none`. * $params['explain'] = (boolean) If `true`, the response includes additional details about score computation as part of a hit. - * $params['ignore_throttled'] = (boolean) If `true`, specified concrete, expanded, or aliased indices are not included in the response when throttled. + * $params['ignore_throttled'] = (boolean) If `true`, specified concrete, expanded, or aliased indexes are not included in the response when throttled. * $params['ignore_unavailable'] = (boolean) If `false`, the request returns an error if it targets a missing or closed index. * $params['preference'] = (string) Specifies the node or shard the operation should be performed on.Random by default. (Default = random) * $params['profile'] = (boolean) If `true`, the query execution is profiled. @@ -1523,14 +1539,14 @@ public function searchTemplate(array $params = []) $index = $this->extractArgument($params, 'index'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('SearchTemplate'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\SearchTemplate::class); $endpoint->setParams($params); $endpoint->setIndex($index); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Returns information and statistics about terms in the fields of a particular document. * @@ -1563,8 +1579,7 @@ public function termvectors(array $params = []) $id = $this->extractArgument($params, 'id'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('TermVectors'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\TermVectors::class); $endpoint->setParams($params); $endpoint->setIndex($index); $endpoint->setId($id); @@ -1572,6 +1587,7 @@ public function termvectors(array $params = []) return $this->performRequest($endpoint); } + /** * Updates a document with a script or partial document. * @@ -1605,8 +1621,7 @@ public function update(array $params = []) $index = $this->extractArgument($params, 'index'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Update'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Update::class); $endpoint->setParams($params); $endpoint->setId($id); $endpoint->setIndex($index); @@ -1614,14 +1629,15 @@ public function update(array $params = []) return $this->performRequest($endpoint); } + /** * Performs an update on every document in the index without changing the source,for example to pick up a mapping change. * - * $params['index'] = (array) Comma-separated list of data streams, indices, and aliases to search. Supports wildcards (`*`). To search all data streams or indices, omit this parameter or use `*` or `_all`. (Required) + * $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases to search. Supports wildcards (`*`). To search all data streams or indexes, omit this parameter or use `*` or `_all`. (Required) * $params['_source'] = (array) True or false to return the _source field or not, or a list of fields to return. * $params['_source_excludes'] = (array) List of fields to exclude from the returned _source field. * $params['_source_includes'] = (array) List of fields to extract and return from the _source field. - * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indices.This behavior applies even if the request targets other open indices.For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`. + * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes.This behavior applies even if the request targets other open indexes.For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`. * $params['analyze_wildcard'] = (boolean) If `true`, wildcard and prefix queries are analyzed. (Default = false) * $params['analyzer'] = (string) Analyzer to use for the query string. * $params['conflicts'] = (enum) What to do if update by query hits version conflicts: `abort` or `proceed`. (Options = abort,proceed) @@ -1647,7 +1663,7 @@ public function update(array $params = []) * $params['slices'] = (any) The number of slices this task should be divided into. * $params['sort'] = (array) A comma-separated list of : pairs. * $params['stats'] = (array) Specific `tag` of the request for logging and statistical purposes. - * $params['terminate_after'] = (integer) Maximum number of documents to collect for each shard.If a query reaches this limit, OpenSearch terminates the query early.OpenSearch collects documents before sorting.Use with caution.OpenSearch applies this parameter to each shard handling the request.When possible, let OpenSearch perform early termination automatically.Avoid specifying this parameter for requests that target data streams with backing indices across multiple data tiers. + * $params['terminate_after'] = (integer) Maximum number of documents to collect for each shard.If a query reaches this limit, OpenSearch terminates the query early.OpenSearch collects documents before sorting.Use with caution.OpenSearch applies this parameter to each shard handling the request.When possible, let OpenSearch perform early termination automatically.Avoid specifying this parameter for requests that target data streams with backing indexes across multiple data tiers. * $params['timeout'] = (string) Period each update request waits for the following operations: dynamic mapping updates, waiting for active shards. * $params['version'] = (boolean) If `true`, returns the document version as part of a hit. * $params['wait_for_active_shards'] = (any) The number of shard copies that must be active before proceeding with the operation.Set to `all` or any positive integer up to the total number of shards in the index (`number_of_replicas+1`). @@ -1667,14 +1683,14 @@ public function updateByQuery(array $params = []) $index = $this->extractArgument($params, 'index'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('UpdateByQuery'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\UpdateByQuery::class); $endpoint->setParams($params); $endpoint->setIndex($index); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Changes the number of requests per second for a particular Update By Query operation. * @@ -1693,13 +1709,13 @@ public function updateByQueryRethrottle(array $params = []) { $task_id = $this->extractArgument($params, 'task_id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('UpdateByQueryRethrottle'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\UpdateByQueryRethrottle::class); $endpoint->setParams($params); $endpoint->setTaskId($task_id); return $this->performRequest($endpoint); } + /** * Proxy function to createPointInTime() to prevent BC break. * This API will be removed in a future version. Use 'createPit' API instead. @@ -1736,8 +1752,9 @@ public function create(array $params = []) $index = $this->extractArgument($params, 'index'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $id ? $endpointBuilder('Create') : $endpointBuilder('Index'); + $endpoint = $id ? + $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Create::class) + : $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Index::class); $endpoint->setParams($params); $endpoint->setId($id); $endpoint->setIndex($index); @@ -1971,6 +1988,15 @@ public function wlm(): WlmNamespace return $this->wlm; } + + /** + * Gets the endpoint factory. + */ + protected function getEndpointFactory(): EndpointFactoryInterface + { + return $this->endpointFactory; + } + /** * Catchall for registered namespaces * diff --git a/src/OpenSearch/Namespaces/AsynchronousSearchNamespace.php b/src/OpenSearch/Namespaces/AsynchronousSearchNamespace.php index e71fe0a48..98a1837a9 100644 --- a/src/OpenSearch/Namespaces/AsynchronousSearchNamespace.php +++ b/src/OpenSearch/Namespaces/AsynchronousSearchNamespace.php @@ -41,13 +41,13 @@ public function delete(array $params = []) { $id = $this->extractArgument($params, 'id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('AsynchronousSearch\Delete'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\AsynchronousSearch\Delete::class); $endpoint->setParams($params); $endpoint->setId($id); return $this->performRequest($endpoint); } + /** * Get partial responses from asynchronous search. * @@ -65,13 +65,13 @@ public function get(array $params = []) { $id = $this->extractArgument($params, 'id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('AsynchronousSearch\Get'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\AsynchronousSearch\Get::class); $endpoint->setParams($params); $endpoint->setId($id); return $this->performRequest($endpoint); } + /** * Perform an asynchronous search. * @@ -92,13 +92,13 @@ public function search(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('AsynchronousSearch\Search'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\AsynchronousSearch\Search::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Monitoring of asynchronous searches that are running, completed, and/or persisted. * @@ -113,10 +113,10 @@ public function search(array $params = []) */ public function stats(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('AsynchronousSearch\Stats'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\AsynchronousSearch\Stats::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + } diff --git a/src/OpenSearch/Namespaces/CatNamespace.php b/src/OpenSearch/Namespaces/CatNamespace.php index a9e38ef7d..712260128 100644 --- a/src/OpenSearch/Namespaces/CatNamespace.php +++ b/src/OpenSearch/Namespaces/CatNamespace.php @@ -31,10 +31,10 @@ class CatNamespace extends AbstractNamespace { /** - * Shows information about currently configured aliases to indices including filter and routing infos. + * Shows information about currently configured aliases to indexes including filter and routing info. * * $params['name'] = (array) A comma-separated list of aliases to retrieve. Supports wildcards (`*`). To retrieve all aliases, omit this parameter or use `*` or `_all`. - * $params['expand_wildcards'] = (any) Whether to expand wildcard expression to concrete indices that are open, closed or both. + * $params['expand_wildcards'] = (any) Whether to expand wildcard expression to concrete indexes that are open, closed or both. * $params['format'] = (string) A short version of the Accept header, e.g. json, yaml. * $params['h'] = (array) Comma-separated list of column names to display. * $params['help'] = (boolean) Return help information. (Default = false) @@ -54,13 +54,13 @@ public function aliases(array $params = []) { $name = $this->extractArgument($params, 'name'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cat\Aliases'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cat\Aliases::class); $endpoint->setParams($params); $endpoint->setName($name); return $this->performRequest($endpoint); } + /** * Lists all active point-in-time segments. * @@ -81,12 +81,12 @@ public function aliases(array $params = []) */ public function allPitSegments(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cat\AllPitSegments'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cat\AllPitSegments::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Provides a snapshot of how many shards are allocated to each data node and how much disk space they are using. * @@ -113,13 +113,13 @@ public function allocation(array $params = []) { $node_id = $this->extractArgument($params, 'node_id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cat\Allocation'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cat\Allocation::class); $endpoint->setParams($params); $endpoint->setNodeId($node_id); return $this->performRequest($endpoint); } + /** * Returns information about the cluster-manager node. * @@ -142,16 +142,16 @@ public function allocation(array $params = []) */ public function clusterManager(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cat\ClusterManager'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cat\ClusterManager::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** - * Provides quick access to the document count of the entire cluster, or individual indices. + * Provides quick access to the document count of the entire cluster, or individual indexes. * - * $params['index'] = (array) Comma-separated list of data streams, indices, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indices, omit this parameter or use `*` or `_all`. + * $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. * $params['format'] = (string) A short version of the Accept header, e.g. json, yaml. * $params['h'] = (array) Comma-separated list of column names to display. * $params['help'] = (boolean) Return help information. (Default = false) @@ -170,13 +170,13 @@ public function count(array $params = []) { $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cat\Count'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cat\Count::class); $endpoint->setParams($params); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** * Shows how much heap memory is currently being used by fielddata on every data node in the cluster. * @@ -200,13 +200,13 @@ public function fielddata(array $params = []) { $fields = $this->extractArgument($params, 'fields'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cat\Fielddata'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cat\Fielddata::class); $endpoint->setParams($params); $endpoint->setFields($fields); return $this->performRequest($endpoint); } + /** * Returns a concise representation of the cluster health. * @@ -228,12 +228,12 @@ public function fielddata(array $params = []) */ public function health(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cat\Health'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cat\Health::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Returns help for the Cat APIs. * @@ -248,22 +248,22 @@ public function health(array $params = []) */ public function help(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cat\Help'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cat\Help::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** - * Returns information about indices: number of primaries and replicas, document counts, disk size, ... + * Returns information about indexes: number of primaries and replicas, document counts, disk size, ... * - * $params['index'] = (array) Comma-separated list of data streams, indices, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indices, omit this parameter or use `*` or `_all`. + * $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. * $params['bytes'] = (enum) The unit used to display byte values. (Options = b,g,gb,k,kb,m,mb,p,pb,t,tb) * $params['cluster_manager_timeout'] = (string) Operation timeout for connection to cluster-manager node. * $params['expand_wildcards'] = (any) The type of index that wildcard patterns can match. * $params['format'] = (string) A short version of the Accept header, e.g. json, yaml. * $params['h'] = (array) Comma-separated list of column names to display. - * $params['health'] = (enum) The health status used to limit returned indices. By default, the response includes indices of any health status. (Options = green,red,yellow) + * $params['health'] = (enum) The health status used to limit returned indexes. By default, the response includes indexes of any health status. (Options = green,red,yellow) * $params['help'] = (boolean) Return help information. (Default = false) * $params['include_unloaded_segments'] = (boolean) If true, the response includes information from segments that are not loaded into memory. (Default = false) * $params['local'] = (boolean) Return local information, do not retrieve the state from cluster-manager node. (Default = false) @@ -285,13 +285,13 @@ public function indices(array $params = []) { $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cat\Indices'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cat\Indices::class); $endpoint->setParams($params); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** * Returns information about the cluster-manager node. * @@ -314,12 +314,12 @@ public function indices(array $params = []) */ public function master(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cat\Master'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cat\Master::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Returns information about custom node attributes. * @@ -342,12 +342,12 @@ public function master(array $params = []) */ public function nodeattrs(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cat\NodeAttrs'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cat\NodeAttrs::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Returns basic statistics about performance of cluster nodes. * @@ -373,12 +373,12 @@ public function nodeattrs(array $params = []) */ public function nodes(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cat\Nodes'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cat\Nodes::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Returns a concise representation of the cluster pending tasks. * @@ -402,12 +402,12 @@ public function nodes(array $params = []) */ public function pendingTasks(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cat\PendingTasks'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cat\PendingTasks::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * List segments for one or several PITs. * @@ -430,13 +430,13 @@ public function pitSegments(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cat\PitSegments'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cat\PitSegments::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Returns information about installed plugins across nodes node. * @@ -459,16 +459,16 @@ public function pitSegments(array $params = []) */ public function plugins(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cat\Plugins'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cat\Plugins::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Returns information about index shard recoveries, both on-going completed. * - * $params['index'] = (array) A comma-separated list of data streams, indices, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indices, omit this parameter or use `*` or `_all`. + * $params['index'] = (array) A comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. * $params['active_only'] = (boolean) If `true`, the response only includes ongoing shard recoveries. (Default = false) * $params['bytes'] = (enum) The unit used to display byte values. (Options = b,g,gb,k,kb,m,mb,p,pb,t,tb) * $params['detailed'] = (boolean) If `true`, the response includes detailed information about shard recoveries. (Default = false) @@ -491,13 +491,13 @@ public function recovery(array $params = []) { $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cat\Recovery'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cat\Recovery::class); $endpoint->setParams($params); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** * Returns information about snapshot repositories registered in the cluster. * @@ -520,27 +520,27 @@ public function recovery(array $params = []) */ public function repositories(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cat\Repositories'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cat\Repositories::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Returns information about both on-going and latest completed Segment Replication events. * * $params['index'] = (array) Comma-separated list or wildcard expression of index names to limit the returned information. * $params['active_only'] = (boolean) If `true`, the response only includes ongoing segment replication events. (Default = false) - * $params['allow_no_indices'] = (boolean) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified). + * $params['allow_no_indices'] = (boolean) Whether to ignore if a wildcard indexes expression resolves into no concrete indexes. (This includes `_all` string or when no indexes have been specified). * $params['bytes'] = (enum) The unit in which to display byte values. (Options = b,g,gb,k,kb,m,mb,p,pb,t,tb) * $params['completed_only'] = (boolean) If `true`, the response only includes latest completed segment replication events. (Default = false) * $params['detailed'] = (boolean) If `true`, the response includes detailed information about segment replications. (Default = false) - * $params['expand_wildcards'] = (any) Whether to expand wildcard expression to concrete indices that are open, closed or both. + * $params['expand_wildcards'] = (any) Whether to expand wildcard expression to concrete indexes that are open, closed or both. * $params['format'] = (string) A short version of the Accept header, e.g. json, yaml. * $params['h'] = (array) Comma-separated list of column names to display. * $params['help'] = (boolean) Return help information. (Default = false) - * $params['ignore_throttled'] = (boolean) Whether specified concrete, expanded or aliased indices should be ignored when throttled. - * $params['ignore_unavailable'] = (boolean) Whether specified concrete indices should be ignored when unavailable (missing or closed). + * $params['ignore_throttled'] = (boolean) Whether specified concrete, expanded or aliased indexes should be ignored when throttled. + * $params['ignore_unavailable'] = (boolean) Whether specified concrete indexes should be ignored when unavailable (missing or closed). * $params['s'] = (array) Comma-separated list of column names or column aliases to sort by. * $params['shards'] = (array) Comma-separated list of shards to display. * $params['time'] = (enum) The unit in which to display time values. (Options = d,h,m,micros,ms,nanos,s) @@ -559,17 +559,17 @@ public function segmentReplication(array $params = []) { $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cat\SegmentReplication'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cat\SegmentReplication::class); $endpoint->setParams($params); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** * Provides low-level information about the segments in the shards of an index. * - * $params['index'] = (array) A comma-separated list of data streams, indices, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indices, omit this parameter or use `*` or `_all`. + * $params['index'] = (array) A comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. * $params['bytes'] = (enum) The unit used to display byte values. (Options = b,g,gb,k,kb,m,mb,p,pb,t,tb) * $params['cluster_manager_timeout'] = (string) Operation timeout for connection to cluster-manager node. * $params['format'] = (string) A short version of the Accept header, e.g. json, yaml. @@ -591,17 +591,17 @@ public function segments(array $params = []) { $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cat\Segments'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cat\Segments::class); $endpoint->setParams($params); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** * Provides a detailed view of shard allocation on nodes. * - * $params['index'] = (array) A comma-separated list of data streams, indices, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indices, omit this parameter or use `*` or `_all`. + * $params['index'] = (array) A comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. * $params['bytes'] = (enum) The unit used to display byte values. (Options = b,g,gb,k,kb,m,mb,p,pb,t,tb) * $params['cluster_manager_timeout'] = (string) Operation timeout for connection to cluster-manager node. * $params['format'] = (string) A short version of the Accept header, e.g. json, yaml. @@ -625,13 +625,13 @@ public function shards(array $params = []) { $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cat\Shards'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cat\Shards::class); $endpoint->setParams($params); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** * Returns all snapshots in a specific repository. * @@ -658,13 +658,13 @@ public function snapshots(array $params = []) { $repository = $this->extractArgument($params, 'repository'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cat\Snapshots'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cat\Snapshots::class); $endpoint->setParams($params); $endpoint->setRepository($repository); return $this->performRequest($endpoint); } + /** * Returns information about the tasks currently executing on one or more nodes in the cluster. * @@ -689,12 +689,12 @@ public function snapshots(array $params = []) */ public function tasks(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cat\Tasks'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cat\Tasks::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Returns information about existing templates. * @@ -720,13 +720,13 @@ public function templates(array $params = []) { $name = $this->extractArgument($params, 'name'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cat\Templates'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cat\Templates::class); $endpoint->setParams($params); $endpoint->setName($name); return $this->performRequest($endpoint); } + /** * Returns cluster-wide thread pool statistics per node.By default the active, queue and rejected statistics are returned for all thread pools. * @@ -753,11 +753,11 @@ public function threadPool(array $params = []) { $thread_pool_patterns = $this->extractArgument($params, 'thread_pool_patterns'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cat\ThreadPool'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cat\ThreadPool::class); $endpoint->setParams($params); $endpoint->setThreadPoolPatterns($thread_pool_patterns); return $this->performRequest($endpoint); } + } diff --git a/src/OpenSearch/Namespaces/ClusterNamespace.php b/src/OpenSearch/Namespaces/ClusterNamespace.php index 016d3e824..a67c9878e 100644 --- a/src/OpenSearch/Namespaces/ClusterNamespace.php +++ b/src/OpenSearch/Namespaces/ClusterNamespace.php @@ -49,13 +49,13 @@ public function allocationExplain(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cluster\AllocationExplain'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cluster\AllocationExplain::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Deletes a component template. * @@ -76,13 +76,13 @@ public function deleteComponentTemplate(array $params = []) { $name = $this->extractArgument($params, 'name'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cluster\DeleteComponentTemplate'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cluster\DeleteComponentTemplate::class); $endpoint->setParams($params); $endpoint->setName($name); return $this->performRequest($endpoint); } + /** * Delete any existing decommission. * @@ -97,12 +97,12 @@ public function deleteComponentTemplate(array $params = []) */ public function deleteDecommissionAwareness(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cluster\DeleteDecommissionAwareness'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cluster\DeleteDecommissionAwareness::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Clears cluster voting config exclusions. * @@ -118,12 +118,12 @@ public function deleteDecommissionAwareness(array $params = []) */ public function deleteVotingConfigExclusions(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cluster\DeleteVotingConfigExclusions'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cluster\DeleteVotingConfigExclusions::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Delete weighted shard routing weights. * @@ -140,13 +140,13 @@ public function deleteWeightedRouting(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cluster\DeleteWeightedRouting'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cluster\DeleteWeightedRouting::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Returns information about whether a particular component template exist. * @@ -170,13 +170,13 @@ public function existsComponentTemplate(array $params = []): bool // manually make this verbose so we can check status code $params['client']['verbose'] = true; - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cluster\ExistsComponentTemplate'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cluster\ExistsComponentTemplate::class); $endpoint->setParams($params); $endpoint->setName($name); return BooleanRequestWrapper::performRequest($endpoint, $this->transport); } + /** * Returns one or more component templates. * @@ -197,13 +197,13 @@ public function getComponentTemplate(array $params = []) { $name = $this->extractArgument($params, 'name'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cluster\GetComponentTemplate'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cluster\GetComponentTemplate::class); $endpoint->setParams($params); $endpoint->setName($name); return $this->performRequest($endpoint); } + /** * Get details and status of decommissioned attribute. * @@ -221,13 +221,13 @@ public function getDecommissionAwareness(array $params = []) { $awareness_attribute_name = $this->extractArgument($params, 'awareness_attribute_name'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cluster\GetDecommissionAwareness'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cluster\GetDecommissionAwareness::class); $endpoint->setParams($params); $endpoint->setAwarenessAttributeName($awareness_attribute_name); return $this->performRequest($endpoint); } + /** * Returns cluster settings. * @@ -247,12 +247,12 @@ public function getDecommissionAwareness(array $params = []) */ public function getSettings(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cluster\GetSettings'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cluster\GetSettings::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Fetches weighted shard routing weights. * @@ -270,21 +270,21 @@ public function getWeightedRouting(array $params = []) { $attribute = $this->extractArgument($params, 'attribute'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cluster\GetWeightedRouting'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cluster\GetWeightedRouting::class); $endpoint->setParams($params); $endpoint->setAttribute($attribute); return $this->performRequest($endpoint); } + /** * Returns basic information about the health of the cluster. * - * $params['index'] = (array) Comma-separated list of data streams, indices, and index aliases used to limit the request. Wildcard expressions (*) are supported. To target all data streams and indices in a cluster, omit this parameter or use `_all` or `*`. + * $params['index'] = (array) Comma-separated list of data streams, indexes, and index aliases used to limit the request. Wildcard expressions (*) are supported. To target all data streams and indexes in a cluster, omit this parameter or use `_all` or `*`. * $params['awareness_attribute'] = (string) The awareness attribute for which the health is required. * $params['cluster_manager_timeout'] = (string) Operation timeout for connection to cluster-manager node. - * $params['expand_wildcards'] = (any) Whether to expand wildcard expression to concrete indices that are open, closed or both. - * $params['level'] = (enum) Can be one of cluster, indices or shards. Controls the details level of the health information returned. (Options = awareness_attributes,cluster,indices,shards) + * $params['expand_wildcards'] = (any) Whether to expand wildcard expression to concrete indexes that are open, closed or both. + * $params['level'] = (enum) Can be one of cluster, indexes or shards. Controls the details level of the health information returned. (Options = awareness_attributes,cluster,indices,shards) * $params['local'] = (boolean) If true, the request retrieves information from the local node only. Defaults to false, which means information is retrieved from the master node. (Default = false) * $params['master_timeout'] = (string) Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. * $params['timeout'] = (string) Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. @@ -307,13 +307,13 @@ public function health(array $params = []) { $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cluster\Health'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cluster\Health::class); $endpoint->setParams($params); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** * Returns a list of any cluster-level changes (e.g. create index, update mapping,allocate or fail shard) which have not yet been executed. * @@ -331,12 +331,12 @@ public function health(array $params = []) */ public function pendingTasks(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cluster\PendingTasks'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cluster\PendingTasks::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Updates the cluster voting config exclusions by node ids or node names. * @@ -354,16 +354,16 @@ public function pendingTasks(array $params = []) */ public function postVotingConfigExclusions(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cluster\PostVotingConfigExclusions'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cluster\PostVotingConfigExclusions::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Creates or updates a component template. * - * $params['name'] = (string) Name of the component template to create. OpenSearch includes the following built-in component templates: `logs-mappings`; 'logs-settings`; `metrics-mappings`; `metrics-settings`;`synthetics-mapping`; `synthetics-settings`. OpenSearch Agent uses these templates to configure backing indices for its data streams. If you use OpenSearch Agent and want to overwrite one of these templates, set the `version` for your replacement template higher than the current version. If you don't use OpenSearch Agent and want to disable all built-in component and index templates, set `stack.templates.enabled` to `false` using the cluster update settings API. + * $params['name'] = (string) Name of the component template to create. OpenSearch includes the following built-in component templates: `logs-mappings`; 'logs-settings`; `metrics-mappings`; `metrics-settings`;`synthetics-mapping`; `synthetics-settings`. OpenSearch Agent uses these templates to configure backing indexes for its data streams. If you use OpenSearch Agent and want to overwrite one of these templates, set the `version` for your replacement template higher than the current version. If you don't use OpenSearch Agent and want to disable all built-in component and index templates, set `stack.templates.enabled` to `false` using the cluster update settings API. * $params['cluster_manager_timeout'] = (string) Operation timeout for connection to cluster-manager node. * $params['create'] = (boolean) If `true`, this request cannot replace or update existing component templates. (Default = false) * $params['master_timeout'] = (string) Period to wait for a connection to the master node.If no response is received before the timeout expires, the request fails and returns an error. @@ -383,14 +383,14 @@ public function putComponentTemplate(array $params = []) $name = $this->extractArgument($params, 'name'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cluster\PutComponentTemplate'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cluster\PutComponentTemplate::class); $endpoint->setParams($params); $endpoint->setName($name); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Decommissions an awareness attribute. * @@ -410,14 +410,14 @@ public function putDecommissionAwareness(array $params = []) $awareness_attribute_name = $this->extractArgument($params, 'awareness_attribute_name'); $awareness_attribute_value = $this->extractArgument($params, 'awareness_attribute_value'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cluster\PutDecommissionAwareness'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cluster\PutDecommissionAwareness::class); $endpoint->setParams($params); $endpoint->setAwarenessAttributeName($awareness_attribute_name); $endpoint->setAwarenessAttributeValue($awareness_attribute_value); return $this->performRequest($endpoint); } + /** * Updates the cluster settings. * @@ -439,13 +439,13 @@ public function putSettings(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cluster\PutSettings'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cluster\PutSettings::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Updates weighted shard routing weights. * @@ -464,14 +464,14 @@ public function putWeightedRouting(array $params = []) $attribute = $this->extractArgument($params, 'attribute'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cluster\PutWeightedRouting'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cluster\PutWeightedRouting::class); $endpoint->setParams($params); $endpoint->setAttribute($attribute); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Returns the information about configured remote clusters. * @@ -486,12 +486,12 @@ public function putWeightedRouting(array $params = []) */ public function remoteInfo(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cluster\RemoteInfo'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cluster\RemoteInfo::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Allows to manually change the allocation of individual shards in the cluster. * @@ -516,23 +516,23 @@ public function reroute(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cluster\Reroute'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cluster\Reroute::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Returns a comprehensive information about the state of the cluster. * * $params['metric'] = (array) Limit the information returned to the specified metrics - * $params['index'] = (array) A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - * $params['allow_no_indices'] = (boolean) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * $params['index'] = (array) A comma-separated list of index names; use `_all` or empty string to perform the operation on all indexes + * $params['allow_no_indices'] = (boolean) Whether to ignore if a wildcard indexes expression resolves into no concrete indexes. (This includes `_all` string or when no indexes have been specified) * $params['cluster_manager_timeout'] = (string) Operation timeout for connection to cluster-manager node. - * $params['expand_wildcards'] = (any) Whether to expand wildcard expression to concrete indices that are open, closed or both. + * $params['expand_wildcards'] = (any) Whether to expand wildcard expression to concrete indexes that are open, closed or both. * $params['flat_settings'] = (boolean) Return settings in flat format. (Default = false) - * $params['ignore_unavailable'] = (boolean) Whether specified concrete indices should be ignored when unavailable (missing or closed) + * $params['ignore_unavailable'] = (boolean) Whether specified concrete indexes should be ignored when unavailable (missing or closed) * $params['local'] = (boolean) Return local information, do not retrieve the state from cluster-manager node. (Default = false) * $params['master_timeout'] = (string) Specify timeout for connection to master * $params['wait_for_metadata_version'] = (integer) Wait for the metadata version to be equal or greater than the specified metadata version @@ -551,14 +551,14 @@ public function state(array $params = []) $metric = $this->extractArgument($params, 'metric'); $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cluster\State'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cluster\State::class); $endpoint->setParams($params); $endpoint->setMetric($metric); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** * Returns high-level overview of cluster statistics. * @@ -582,8 +582,7 @@ public function stats(array $params = []) $metric = $this->extractArgument($params, 'metric'); $node_id = $this->extractArgument($params, 'node_id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cluster\Stats'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Cluster\Stats::class); $endpoint->setParams($params); $endpoint->setIndexMetric($index_metric); $endpoint->setMetric($metric); @@ -591,4 +590,5 @@ public function stats(array $params = []) return $this->performRequest($endpoint); } + } diff --git a/src/OpenSearch/Namespaces/DanglingIndicesNamespace.php b/src/OpenSearch/Namespaces/DanglingIndicesNamespace.php index 814d99a15..fd1518dbc 100644 --- a/src/OpenSearch/Namespaces/DanglingIndicesNamespace.php +++ b/src/OpenSearch/Namespaces/DanglingIndicesNamespace.php @@ -51,13 +51,13 @@ public function deleteDanglingIndex(array $params = []) { $index_uuid = $this->extractArgument($params, 'index_uuid'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('DanglingIndices\DeleteDanglingIndex'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\DanglingIndices\DeleteDanglingIndex::class); $endpoint->setParams($params); $endpoint->setIndexUuid($index_uuid); return $this->performRequest($endpoint); } + /** * Imports the specified dangling index. * @@ -79,15 +79,15 @@ public function importDanglingIndex(array $params = []) { $index_uuid = $this->extractArgument($params, 'index_uuid'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('DanglingIndices\ImportDanglingIndex'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\DanglingIndices\ImportDanglingIndex::class); $endpoint->setParams($params); $endpoint->setIndexUuid($index_uuid); return $this->performRequest($endpoint); } + /** - * Returns all dangling indices. + * Returns all dangling indexes. * * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) @@ -100,10 +100,10 @@ public function importDanglingIndex(array $params = []) */ public function listDanglingIndices(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('DanglingIndices\ListDanglingIndices'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\DanglingIndices\ListDanglingIndices::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + } diff --git a/src/OpenSearch/Namespaces/FlowFrameworkNamespace.php b/src/OpenSearch/Namespaces/FlowFrameworkNamespace.php index a9564927a..791f569c7 100644 --- a/src/OpenSearch/Namespaces/FlowFrameworkNamespace.php +++ b/src/OpenSearch/Namespaces/FlowFrameworkNamespace.php @@ -45,13 +45,13 @@ public function create(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('FlowFramework\Create'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\FlowFramework\Create::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Delete a workflow. * @@ -70,13 +70,13 @@ public function delete(array $params = []) { $workflow_id = $this->extractArgument($params, 'workflow_id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('FlowFramework\Delete'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\FlowFramework\Delete::class); $endpoint->setParams($params); $endpoint->setWorkflowId($workflow_id); return $this->performRequest($endpoint); } + /** * Deprovision workflow's resources when you no longer need it. * @@ -95,13 +95,13 @@ public function deprovision(array $params = []) { $workflow_id = $this->extractArgument($params, 'workflow_id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('FlowFramework\Deprovision'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\FlowFramework\Deprovision::class); $endpoint->setParams($params); $endpoint->setWorkflowId($workflow_id); return $this->performRequest($endpoint); } + /** * Get a workflow. * @@ -119,13 +119,13 @@ public function get(array $params = []) { $workflow_id = $this->extractArgument($params, 'workflow_id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('FlowFramework\Get'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\FlowFramework\Get::class); $endpoint->setParams($params); $endpoint->setWorkflowId($workflow_id); return $this->performRequest($endpoint); } + /** * Get the provisioning deployment status until it is complete. * @@ -144,13 +144,13 @@ public function getStatus(array $params = []) { $workflow_id = $this->extractArgument($params, 'workflow_id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('FlowFramework\GetStatus'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\FlowFramework\GetStatus::class); $endpoint->setParams($params); $endpoint->setWorkflowId($workflow_id); return $this->performRequest($endpoint); } + /** * Get a list of workflow steps. * @@ -166,12 +166,12 @@ public function getStatus(array $params = []) */ public function getSteps(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('FlowFramework\GetSteps'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\FlowFramework\GetSteps::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Provisioning a workflow. This API is also executed when the Create or Update Workflow API is called with the provision parameter set to true. * @@ -190,14 +190,14 @@ public function provision(array $params = []) $workflow_id = $this->extractArgument($params, 'workflow_id'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('FlowFramework\Provision'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\FlowFramework\Provision::class); $endpoint->setParams($params); $endpoint->setWorkflowId($workflow_id); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Search for workflows by using a query matching a field. * @@ -214,13 +214,13 @@ public function search(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('FlowFramework\Search'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\FlowFramework\Search::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Search for workflows by using a query matching a field. * @@ -237,13 +237,13 @@ public function searchState(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('FlowFramework\SearchState'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\FlowFramework\SearchState::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Update a workflow. You can only update a complete workflow if it has not yet been provisioned. * @@ -267,12 +267,12 @@ public function update(array $params = []) $workflow_id = $this->extractArgument($params, 'workflow_id'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('FlowFramework\Update'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\FlowFramework\Update::class); $endpoint->setParams($params); $endpoint->setWorkflowId($workflow_id); $endpoint->setBody($body); return $this->performRequest($endpoint); } + } diff --git a/src/OpenSearch/Namespaces/IndicesNamespace.php b/src/OpenSearch/Namespaces/IndicesNamespace.php index dff41e4ed..568359c51 100644 --- a/src/OpenSearch/Namespaces/IndicesNamespace.php +++ b/src/OpenSearch/Namespaces/IndicesNamespace.php @@ -34,11 +34,11 @@ class IndicesNamespace extends AbstractNamespace * Adds a block to an index. * * $params['block'] = (string) The block to add (one of read, write, read_only or metadata) - * $params['index'] = (array) A comma separated list of indices to add a block to - * $params['allow_no_indices'] = (boolean) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * $params['index'] = (array) A comma separated list of indexes to add a block to + * $params['allow_no_indices'] = (boolean) Whether to ignore if a wildcard indexes expression resolves into no concrete indexes. (This includes `_all` string or when no indexes have been specified) * $params['cluster_manager_timeout'] = (string) Operation timeout for connection to cluster-manager node. - * $params['expand_wildcards'] = (any) Whether to expand wildcard expression to concrete indices that are open, closed or both. - * $params['ignore_unavailable'] = (boolean) Whether specified concrete indices should be ignored when unavailable (missing or closed) + * $params['expand_wildcards'] = (any) Whether to expand wildcard expression to concrete indexes that are open, closed or both. + * $params['ignore_unavailable'] = (boolean) Whether specified concrete indexes should be ignored when unavailable (missing or closed) * $params['master_timeout'] = (string) Specify timeout for connection to master * $params['timeout'] = (string) Explicit operation timeout * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) @@ -55,14 +55,14 @@ public function addBlock(array $params = []) $block = $this->extractArgument($params, 'block'); $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\AddBlock'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\AddBlock::class); $endpoint->setParams($params); $endpoint->setBlock($block); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** * Performs the analysis process on a text and return the tokens breakdown of the text. * @@ -82,19 +82,19 @@ public function analyze(array $params = []) $index = $this->extractArgument($params, 'index'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\Analyze'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\Analyze::class); $endpoint->setParams($params); $endpoint->setIndex($index); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** - * Clears all or specific caches for one or more indices. + * Clears all or specific caches for one or more indexes. * - * $params['index'] = (array) Comma-separated list of data streams, indices, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indices, omit this parameter or use `*` or `_all`. - * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indices.This behavior applies even if the request targets other open indices. + * $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. + * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes.This behavior applies even if the request targets other open indexes. * $params['expand_wildcards'] = (any) Type of index that wildcard patterns can match.If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.Supports comma-separated values, such as `open,hidden`.Valid values are: `all`, `open`, `closed`, `hidden`, `none`. * $params['fielddata'] = (boolean) If `true`, clears the fields cache.Use the `fields` parameter to clear the cache of specific fields only. * $params['fields'] = (any) Comma-separated list of field names used to limit the `fielddata` parameter. @@ -115,13 +115,13 @@ public function clearCache(array $params = []) { $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\ClearCache'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\ClearCache::class); $endpoint->setParams($params); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** * Clones an index. * @@ -149,8 +149,7 @@ public function clone(array $params = []) $target = $this->extractArgument($params, 'target'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\CloneIndices'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\CloneIndices::class); $endpoint->setParams($params); $endpoint->setIndex($index); $endpoint->setTarget($target); @@ -158,11 +157,12 @@ public function clone(array $params = []) return $this->performRequest($endpoint); } + /** * Closes an index. * * $params['index'] = (array) Comma-separated list or wildcard expression of index names used to limit the request. - * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indices.This behavior applies even if the request targets other open indices. + * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes.This behavior applies even if the request targets other open indexes. * $params['cluster_manager_timeout'] = (string) Operation timeout for connection to cluster-manager node. * $params['expand_wildcards'] = (any) Type of index that wildcard patterns can match.If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.Supports comma-separated values, such as `open,hidden`.Valid values are: `all`, `open`, `closed`, `hidden`, `none`. * $params['ignore_unavailable'] = (boolean) If `false`, the request returns an error if it targets a missing or closed index. @@ -182,13 +182,13 @@ public function close(array $params = []) { $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\Close'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\Close::class); $endpoint->setParams($params); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** * Creates an index with optional settings and mappings. * @@ -212,14 +212,14 @@ public function create(array $params = []) $index = $this->extractArgument($params, 'index'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\Create'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\Create::class); $endpoint->setParams($params); $endpoint->setIndex($index); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Creates or updates a data stream. * @@ -239,14 +239,14 @@ public function createDataStream(array $params = []) $name = $this->extractArgument($params, 'name'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\CreateDataStream'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\CreateDataStream::class); $endpoint->setParams($params); $endpoint->setName($name); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Provides statistics on operations happening in a data stream. * @@ -264,18 +264,18 @@ public function dataStreamsStats(array $params = []) { $name = $this->extractArgument($params, 'name'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\DataStreamsStats'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\DataStreamsStats::class); $endpoint->setParams($params); $endpoint->setName($name); return $this->performRequest($endpoint); } + /** * Deletes an index. * - * $params['index'] = (array) Comma-separated list of indices to delete. You cannot specify index aliases. By default, this parameter does not support wildcards (`*`) or `_all`. To use wildcards or `_all`, set the `action.destructive_requires_name` cluster setting to `false`. - * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indices.This behavior applies even if the request targets other open indices. (Default = false) + * $params['index'] = (array) Comma-separated list of indexes to delete. You cannot specify index aliases. By default, this parameter does not support wildcards (`*`) or `_all`. To use wildcards or `_all`, set the `action.destructive_requires_name` cluster setting to `false`. + * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes.This behavior applies even if the request targets other open indexes. (Default = false) * $params['cluster_manager_timeout'] = (string) Operation timeout for connection to cluster-manager node. * $params['expand_wildcards'] = (any) Type of index that wildcard patterns can match.If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.Supports comma-separated values, such as `open,hidden`.Valid values are: `all`, `open`, `closed`, `hidden`, `none`. * $params['ignore_unavailable'] = (boolean) If `false`, the request returns an error if it targets a missing or closed index. (Default = false) @@ -294,17 +294,17 @@ public function delete(array $params = []) { $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\Delete'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\Delete::class); $endpoint->setParams($params); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** * Deletes an alias. * - * $params['index'] = (array) Comma-separated list of data streams or indices used to limit the request. Supports wildcards (`*`). (Required) + * $params['index'] = (array) Comma-separated list of data streams or indexes used to limit the request. Supports wildcards (`*`). (Required) * $params['name'] = (array) Comma-separated list of aliases to remove. Supports wildcards (`*`). To remove all aliases, use `*` or `_all`. (Required) * $params['cluster_manager_timeout'] = (string) Operation timeout for connection to cluster-manager node. * $params['master_timeout'] = (string) Period to wait for a connection to the master node.If no response is received before the timeout expires, the request fails and returns an error. @@ -323,14 +323,14 @@ public function deleteAlias(array $params = []) $index = $this->extractArgument($params, 'index'); $name = $this->extractArgument($params, 'name'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\DeleteAlias'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\DeleteAlias::class); $endpoint->setParams($params); $endpoint->setIndex($index); $endpoint->setName($name); return $this->performRequest($endpoint); } + /** * Deletes a data stream. * @@ -348,13 +348,13 @@ public function deleteDataStream(array $params = []) { $name = $this->extractArgument($params, 'name'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\DeleteDataStream'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\DeleteDataStream::class); $endpoint->setParams($params); $endpoint->setName($name); return $this->performRequest($endpoint); } + /** * Deletes an index template. * @@ -375,13 +375,13 @@ public function deleteIndexTemplate(array $params = []) { $name = $this->extractArgument($params, 'name'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\DeleteIndexTemplate'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\DeleteIndexTemplate::class); $endpoint->setParams($params); $endpoint->setName($name); return $this->performRequest($endpoint); } + /** * Deletes an index template. * @@ -402,18 +402,18 @@ public function deleteTemplate(array $params = []) { $name = $this->extractArgument($params, 'name'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\DeleteTemplate'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\DeleteTemplate::class); $endpoint->setParams($params); $endpoint->setName($name); return $this->performRequest($endpoint); } + /** * Returns information about whether a particular index exists. * - * $params['index'] = (array) Comma-separated list of data streams, indices, and aliases. Supports wildcards (`*`). - * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indices.This behavior applies even if the request targets other open indices. (Default = false) + * $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases. Supports wildcards (`*`). + * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes.This behavior applies even if the request targets other open indexes. (Default = false) * $params['cluster_manager_timeout'] = (string) Operation timeout for connection to cluster-manager node. * $params['expand_wildcards'] = (any) Type of index that wildcard patterns can match.If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.Supports comma-separated values, such as `open,hidden`.Valid values are: `all`, `open`, `closed`, `hidden`, `none`. * $params['flat_settings'] = (boolean) If `true`, returns settings in flat format. (Default = false) @@ -436,21 +436,21 @@ public function exists(array $params = []): bool // manually make this verbose so we can check status code $params['client']['verbose'] = true; - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\Exists'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\Exists::class); $endpoint->setParams($params); $endpoint->setIndex($index); return BooleanRequestWrapper::performRequest($endpoint, $this->transport); } + /** * Returns information about whether a particular alias exists. * * $params['name'] = (array) Comma-separated list of aliases to check. Supports wildcards (`*`). (Required) - * $params['index'] = (array) Comma-separated list of data streams or indices used to limit the request. Supports wildcards (`*`). To target all data streams and indices, omit this parameter or use `*` or `_all`. - * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indices.This behavior applies even if the request targets other open indices. + * $params['index'] = (array) Comma-separated list of data streams or indexes used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. + * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes.This behavior applies even if the request targets other open indexes. * $params['expand_wildcards'] = (any) Type of index that wildcard patterns can match.If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.Supports comma-separated values, such as `open,hidden`.Valid values are: `all`, `open`, `closed`, `hidden`, `none`. - * $params['ignore_unavailable'] = (boolean) If `false`, requests that include a missing data stream or index in the target indices or data streams return an error. + * $params['ignore_unavailable'] = (boolean) If `false`, requests that include a missing data stream or index in the target indexes or data streams return an error. * $params['local'] = (boolean) If `true`, the request retrieves information from the local node only. (Default = false) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) @@ -469,14 +469,14 @@ public function existsAlias(array $params = []): bool // manually make this verbose so we can check status code $params['client']['verbose'] = true; - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\ExistsAlias'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\ExistsAlias::class); $endpoint->setParams($params); $endpoint->setName($name); $endpoint->setIndex($index); return BooleanRequestWrapper::performRequest($endpoint, $this->transport); } + /** * Returns information about whether a particular index template exists. * @@ -501,13 +501,13 @@ public function existsIndexTemplate(array $params = []): bool // manually make this verbose so we can check status code $params['client']['verbose'] = true; - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\ExistsIndexTemplate'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\ExistsIndexTemplate::class); $endpoint->setParams($params); $endpoint->setName($name); return BooleanRequestWrapper::performRequest($endpoint, $this->transport); } + /** * Returns information about whether a particular index template exists. * @@ -532,18 +532,18 @@ public function existsTemplate(array $params = []): bool // manually make this verbose so we can check status code $params['client']['verbose'] = true; - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\ExistsTemplate'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\ExistsTemplate::class); $endpoint->setParams($params); $endpoint->setName($name); return BooleanRequestWrapper::performRequest($endpoint, $this->transport); } + /** - * Performs the flush operation on one or more indices. + * Performs the flush operation on one or more indexes. * - * $params['index'] = (array) Comma-separated list of data streams, indices, and aliases to flush. Supports wildcards (`*`). To flush all data streams and indices, omit this parameter or use `*` or `_all`. - * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indices.This behavior applies even if the request targets other open indices. + * $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases to flush. Supports wildcards (`*`). To flush all data streams and indexes, omit this parameter or use `*` or `_all`. + * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes.This behavior applies even if the request targets other open indexes. * $params['expand_wildcards'] = (any) Type of index that wildcard patterns can match.If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.Supports comma-separated values, such as `open,hidden`.Valid values are: `all`, `open`, `closed`, `hidden`, `none`. * $params['force'] = (boolean) If `true`, the request forces a flush even if there are no changes to commit to the index. * $params['ignore_unavailable'] = (boolean) If `false`, the request returns an error if it targets a missing or closed index. @@ -561,21 +561,21 @@ public function flush(array $params = []) { $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\Flush'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\Flush::class); $endpoint->setParams($params); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** - * Performs the force merge operation on one or more indices. + * Performs the force merge operation on one or more indexes. * - * $params['index'] = (array) A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - * $params['allow_no_indices'] = (boolean) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - * $params['expand_wildcards'] = (any) Whether to expand wildcard expression to concrete indices that are open, closed or both. + * $params['index'] = (array) A comma-separated list of index names; use `_all` or empty string to perform the operation on all indexes + * $params['allow_no_indices'] = (boolean) Whether to ignore if a wildcard indexes expression resolves into no concrete indexes. (This includes `_all` string or when no indexes have been specified) + * $params['expand_wildcards'] = (any) Whether to expand wildcard expression to concrete indexes that are open, closed or both. * $params['flush'] = (boolean) Specify whether the index should be flushed after performing the operation. (Default = true) - * $params['ignore_unavailable'] = (boolean) Whether specified concrete indices should be ignored when unavailable (missing or closed) + * $params['ignore_unavailable'] = (boolean) Whether specified concrete indexes should be ignored when unavailable (missing or closed) * $params['max_num_segments'] = (number) The number of larger segments into which smaller segments are merged.Set this parameter to 1 to merge all segments into one segment.The default behavior is to perform the merge as necessary. * $params['only_expunge_deletes'] = (boolean) Specify whether the operation should only expunge deleted documents * $params['primary_only'] = (boolean) Specify whether the operation should only perform on primary shards. Defaults to false. (Default = false) @@ -593,18 +593,18 @@ public function forcemerge(array $params = []) { $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\ForceMerge'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\ForceMerge::class); $endpoint->setParams($params); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** - * Returns information about one or more indices. + * Returns information about one or more indexes. * - * $params['index'] = (array) Comma-separated list of data streams, indices, and index aliases used to limit the request. Wildcard expressions (*) are supported. - * $params['allow_no_indices'] = (boolean) If false, the request returns an error if any wildcard expression, index alias, or _all value targets onlymissing or closed indices. This behavior applies even if the request targets other open indices. For example,a request targeting foo*,bar* returns an error if an index starts with foo but no index starts with bar. (Default = false) + * $params['index'] = (array) Comma-separated list of data streams, indexes, and index aliases used to limit the request. Wildcard expressions (*) are supported. + * $params['allow_no_indices'] = (boolean) If false, the request returns an error if any wildcard expression, index alias, or _all value targets onlymissing or closed indexes. This behavior applies even if the request targets other open indexes. For example,a request targeting foo*,bar* returns an error if an index starts with foo but no index starts with bar. (Default = false) * $params['cluster_manager_timeout'] = (string) Operation timeout for connection to cluster-manager node. * $params['expand_wildcards'] = (any) Type of index that wildcard expressions can match. If the request can target data streams, this argumentdetermines whether wildcard expressions match hidden data streams. Supports comma-separated values,such as open,hidden. * $params['flat_settings'] = (boolean) If true, returns settings in flat format. (Default = false) @@ -625,19 +625,19 @@ public function get(array $params = []) { $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\Get'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\Get::class); $endpoint->setParams($params); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** * Returns an alias. * * $params['name'] = (array) Comma-separated list of aliases to retrieve. Supports wildcards (`*`). To retrieve all aliases, omit this parameter or use `*` or `_all`. - * $params['index'] = (array) Comma-separated list of data streams or indices used to limit the request. Supports wildcards (`*`). To target all data streams and indices, omit this parameter or use `*` or `_all`. - * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indices.This behavior applies even if the request targets other open indices. + * $params['index'] = (array) Comma-separated list of data streams or indexes used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. + * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes.This behavior applies even if the request targets other open indexes. * $params['expand_wildcards'] = (any) Type of index that wildcard patterns can match.If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.Supports comma-separated values, such as `open,hidden`.Valid values are: `all`, `open`, `closed`, `hidden`, `none`. * $params['ignore_unavailable'] = (boolean) If `false`, the request returns an error if it targets a missing or closed index. * $params['local'] = (boolean) If `true`, the request retrieves information from the local node only. (Default = false) @@ -655,14 +655,14 @@ public function getAlias(array $params = []) $name = $this->extractArgument($params, 'name'); $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\GetAlias'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\GetAlias::class); $endpoint->setParams($params); $endpoint->setName($name); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** * Returns data streams. * @@ -680,19 +680,19 @@ public function getDataStream(array $params = []) { $name = $this->extractArgument($params, 'name'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\GetDataStream'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\GetDataStream::class); $endpoint->setParams($params); $endpoint->setName($name); return $this->performRequest($endpoint); } + /** * Returns mapping for one or more fields. * * $params['fields'] = (array) Comma-separated list or wildcard expression of fields used to limit returned information. (Required) - * $params['index'] = (array) Comma-separated list of data streams, indices, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indices, omit this parameter or use `*` or `_all`. - * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indices.This behavior applies even if the request targets other open indices. + * $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. + * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes.This behavior applies even if the request targets other open indexes. * $params['expand_wildcards'] = (any) Type of index that wildcard patterns can match.If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.Supports comma-separated values, such as `open,hidden`.Valid values are: `all`, `open`, `closed`, `hidden`, `none`. * $params['ignore_unavailable'] = (boolean) If `false`, the request returns an error if it targets a missing or closed index. * $params['include_defaults'] = (boolean) If `true`, return all default settings in the response. @@ -711,14 +711,14 @@ public function getFieldMapping(array $params = []) $fields = $this->extractArgument($params, 'fields'); $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\GetFieldMapping'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\GetFieldMapping::class); $endpoint->setParams($params); $endpoint->setFields($fields); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** * Returns an index template. * @@ -740,18 +740,18 @@ public function getIndexTemplate(array $params = []) { $name = $this->extractArgument($params, 'name'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\GetIndexTemplate'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\GetIndexTemplate::class); $endpoint->setParams($params); $endpoint->setName($name); return $this->performRequest($endpoint); } + /** - * Returns mappings for one or more indices. + * Returns mappings for one or more indexes. * - * $params['index'] = (array) Comma-separated list of data streams, indices, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indices, omit this parameter or use `*` or `_all`. - * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indices.This behavior applies even if the request targets other open indices. + * $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. + * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes.This behavior applies even if the request targets other open indexes. * $params['cluster_manager_timeout'] = (string) Operation timeout for connection to cluster-manager node. * $params['expand_wildcards'] = (any) Type of index that wildcard patterns can match.If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.Supports comma-separated values, such as `open,hidden`.Valid values are: `all`, `open`, `closed`, `hidden`, `none`. * $params['ignore_unavailable'] = (boolean) If `false`, the request returns an error if it targets a missing or closed index. @@ -770,19 +770,19 @@ public function getMapping(array $params = []) { $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\GetMapping'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\GetMapping::class); $endpoint->setParams($params); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** - * Returns settings for one or more indices. + * Returns settings for one or more indexes. * * $params['name'] = (array) Comma-separated list or wildcard expression of settings to retrieve. - * $params['index'] = (array) Comma-separated list of data streams, indices, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indices, omit this parameter or use `*` or `_all`. - * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, indexalias, or `_all` value targets only missing or closed indices. Thisbehavior applies even if the request targets other open indices. Forexample, a request targeting `foo*,bar*` returns an error if an indexstarts with foo but no index starts with `bar`. + * $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. + * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, indexalias, or `_all` value targets only missing or closed indexes. Thisbehavior applies even if the request targets other open indexes. Forexample, a request targeting `foo*,bar*` returns an error if an indexstarts with foo but no index starts with `bar`. * $params['cluster_manager_timeout'] = (string) Operation timeout for connection to cluster-manager node. * $params['expand_wildcards'] = (any) Type of index that wildcard patterns can match.If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.Supports comma-separated values, such as `open,hidden`. * $params['flat_settings'] = (boolean) If `true`, returns settings in flat format. (Default = false) @@ -804,14 +804,14 @@ public function getSettings(array $params = []) $name = $this->extractArgument($params, 'name'); $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\GetSettings'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\GetSettings::class); $endpoint->setParams($params); $endpoint->setName($name); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** * Returns an index template. * @@ -833,20 +833,20 @@ public function getTemplate(array $params = []) { $name = $this->extractArgument($params, 'name'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\GetTemplate'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\GetTemplate::class); $endpoint->setParams($params); $endpoint->setName($name); return $this->performRequest($endpoint); } + /** * The _upgrade API is no longer useful and will be removed. * - * $params['index'] = (array) Comma-separated list of indices; use `_all` or empty string to perform the operation on all indices. - * $params['allow_no_indices'] = (boolean) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified). - * $params['expand_wildcards'] = (any) Whether to expand wildcard expression to concrete indices that are open, closed or both. - * $params['ignore_unavailable'] = (boolean) Whether specified concrete indices should be ignored when unavailable (missing or closed). + * $params['index'] = (array) Comma-separated list of indexes; use `_all` or empty string to perform the operation on all indexes. + * $params['allow_no_indices'] = (boolean) Whether to ignore if a wildcard indexes expression resolves into no concrete indexes. (This includes `_all` string or when no indexes have been specified). + * $params['expand_wildcards'] = (any) Whether to expand wildcard expression to concrete indexes that are open, closed or both. + * $params['ignore_unavailable'] = (boolean) Whether specified concrete indexes should be ignored when unavailable (missing or closed). * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) @@ -860,18 +860,18 @@ public function getUpgrade(array $params = []) { $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\GetUpgrade'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\GetUpgrade::class); $endpoint->setParams($params); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** * Opens an index. * - * $params['index'] = (array) Comma-separated list of data streams, indices, and aliases used to limit the request. Supports wildcards (`*`). By default, you must explicitly name the indices you using to limit the request. To limit a request using `_all`, `*`, or other wildcard expressions, change the `action.destructive_requires_name` setting to false. You can update this setting in the `opensearch.yml` file or using the cluster update settings API. - * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indices.This behavior applies even if the request targets other open indices. + * $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). By default, you must explicitly name the indexes you using to limit the request. To limit a request using `_all`, `*`, or other wildcard expressions, change the `action.destructive_requires_name` setting to false. You can update this setting in the `opensearch.yml` file or using the cluster update settings API. + * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes.This behavior applies even if the request targets other open indexes. * $params['cluster_manager_timeout'] = (string) Operation timeout for connection to cluster-manager node. * $params['expand_wildcards'] = (any) Type of index that wildcard patterns can match.If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.Supports comma-separated values, such as `open,hidden`.Valid values are: `all`, `open`, `closed`, `hidden`, `none`. * $params['ignore_unavailable'] = (boolean) If `false`, the request returns an error if it targets a missing or closed index. @@ -893,18 +893,18 @@ public function open(array $params = []) { $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\Open'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\Open::class); $endpoint->setParams($params); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** * Creates or updates an alias. * * $params['name'] = (string) Alias to update. If the alias doesn't exist, the request creates it. Index alias names support date math. - * $params['index'] = (array) Comma-separated list of data streams or indices to add. Supports wildcards (`*`). Wildcard patterns that match both data streams and indices return an error. + * $params['index'] = (array) Comma-separated list of data streams or indexes to add. Supports wildcards (`*`). Wildcard patterns that match both data streams and indexes return an error. * $params['cluster_manager_timeout'] = (string) Operation timeout for connection to cluster-manager node. * $params['master_timeout'] = (string) Period to wait for a connection to the master node.If no response is received before the timeout expires, the request fails and returns an error. * $params['timeout'] = (string) Period to wait for a response.If no response is received before the timeout expires, the request fails and returns an error. @@ -924,8 +924,7 @@ public function putAlias(array $params = []) $index = $this->extractArgument($params, 'index'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\PutAlias'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\PutAlias::class); $endpoint->setParams($params); $endpoint->setName($name); $endpoint->setIndex($index); @@ -933,6 +932,7 @@ public function putAlias(array $params = []) return $this->performRequest($endpoint); } + /** * Creates or updates an index template. * @@ -956,19 +956,19 @@ public function putIndexTemplate(array $params = []) $name = $this->extractArgument($params, 'name'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\PutIndexTemplate'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\PutIndexTemplate::class); $endpoint->setParams($params); $endpoint->setName($name); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Updates the index mappings. * - * $params['index'] = (array) A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices. - * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indices.This behavior applies even if the request targets other open indices. + * $params['index'] = (array) A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indexes. + * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes.This behavior applies even if the request targets other open indexes. * $params['cluster_manager_timeout'] = (string) Operation timeout for connection to cluster-manager node. * $params['expand_wildcards'] = (any) Type of index that wildcard patterns can match.If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.Supports comma-separated values, such as `open,hidden`.Valid values are: `all`, `open`, `closed`, `hidden`, `none`. * $params['ignore_unavailable'] = (boolean) If `false`, the request returns an error if it targets a missing or closed index. @@ -990,23 +990,23 @@ public function putMapping(array $params = []) $index = $this->extractArgument($params, 'index'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\PutMapping'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\PutMapping::class); $endpoint->setParams($params); $endpoint->setIndex($index); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Updates the index settings. * - * $params['index'] = (array) Comma-separated list of data streams, indices, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indices, omit this parameter or use `*` or `_all`. - * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, indexalias, or `_all` value targets only missing or closed indices. Thisbehavior applies even if the request targets other open indices. Forexample, a request targeting `foo*,bar*` returns an error if an indexstarts with `foo` but no index starts with `bar`. + * $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. + * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, indexalias, or `_all` value targets only missing or closed indexes. Thisbehavior applies even if the request targets other open indexes. Forexample, a request targeting `foo*,bar*` returns an error if an indexstarts with `foo` but no index starts with `bar`. * $params['cluster_manager_timeout'] = (string) Operation timeout for connection to cluster-manager node. * $params['expand_wildcards'] = (any) Type of index that wildcard patterns can match. If the request can targetdata streams, this argument determines whether wildcard expressions matchhidden data streams. Supports comma-separated values, such as`open,hidden`. * $params['flat_settings'] = (boolean) If `true`, returns settings in flat format. (Default = false) - * $params['ignore_unavailable'] = (boolean) Whether specified concrete indices should be ignored when unavailable (missing or closed). + * $params['ignore_unavailable'] = (boolean) Whether specified concrete indexes should be ignored when unavailable (missing or closed). * $params['master_timeout'] = (string) Period to wait for a connection to the master node. If no response isreceived before the timeout expires, the request fails and returns anerror. * $params['preserve_existing'] = (boolean) If `true`, existing index settings remain unchanged. (Default = false) * $params['timeout'] = (string) Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. @@ -1024,14 +1024,14 @@ public function putSettings(array $params = []) $index = $this->extractArgument($params, 'index'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\PutSettings'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\PutSettings::class); $endpoint->setParams($params); $endpoint->setIndex($index); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Creates or updates an index template. * @@ -1055,18 +1055,18 @@ public function putTemplate(array $params = []) $name = $this->extractArgument($params, 'name'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\PutTemplate'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\PutTemplate::class); $endpoint->setParams($params); $endpoint->setName($name); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Returns information about ongoing index shard recoveries. * - * $params['index'] = (array) Comma-separated list of data streams, indices, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indices, omit this parameter or use `*` or `_all`. + * $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. * $params['active_only'] = (boolean) If `true`, the response only includes ongoing shard recoveries. (Default = false) * $params['detailed'] = (boolean) If `true`, the response includes detailed information about shard recoveries. (Default = false) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) @@ -1082,18 +1082,18 @@ public function recovery(array $params = []) { $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\Recovery'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\Recovery::class); $endpoint->setParams($params); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** - * Performs the refresh operation in one or more indices. + * Performs the refresh operation in one or more indexes. * - * $params['index'] = (array) Comma-separated list of data streams, indices, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indices, omit this parameter or use `*` or `_all`. - * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indices.This behavior applies even if the request targets other open indices. + * $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. + * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes.This behavior applies even if the request targets other open indexes. * $params['expand_wildcards'] = (any) Type of index that wildcard patterns can match.If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.Supports comma-separated values, such as `open,hidden`.Valid values are: `all`, `open`, `closed`, `hidden`, `none`. * $params['ignore_unavailable'] = (boolean) If `false`, the request returns an error if it targets a missing or closed index. * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) @@ -1109,17 +1109,17 @@ public function refresh(array $params = []) { $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\Refresh'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\Refresh::class); $endpoint->setParams($params); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** - * Returns information about any matching indices, aliases, and data streams. + * Returns information about any matching indexes, aliases, and data streams. * - * $params['name'] = (array) Comma-separated name(s) or index pattern(s) of the indices, aliases, and data streams to resolve. Resources on remote clusters can be specified using the ``:`` syntax. + * $params['name'] = (array) Comma-separated name(s) or index pattern(s) of the indexes, aliases, and data streams to resolve. Resources on remote clusters can be specified using the ``:`` syntax. * $params['expand_wildcards'] = (any) Type of index that wildcard patterns can match.If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.Supports comma-separated values, such as `open,hidden`.Valid values are: `all`, `open`, `closed`, `hidden`, `none`. * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) @@ -1134,13 +1134,13 @@ public function resolveIndex(array $params = []) { $name = $this->extractArgument($params, 'name'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\ResolveIndex'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\ResolveIndex::class); $endpoint->setParams($params); $endpoint->setName($name); return $this->performRequest($endpoint); } + /** * Updates an alias to point to a new index when the existing indexis considered to be too large or too old. * @@ -1167,8 +1167,7 @@ public function rollover(array $params = []) $new_index = $this->extractArgument($params, 'new_index'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\Rollover'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\Rollover::class); $endpoint->setParams($params); $endpoint->setAlias($alias); $endpoint->setNewIndex($new_index); @@ -1176,11 +1175,12 @@ public function rollover(array $params = []) return $this->performRequest($endpoint); } + /** * Provides low-level information about segments in a Lucene index. * - * $params['index'] = (array) Comma-separated list of data streams, indices, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indices, omit this parameter or use `*` or `_all`. - * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indices.This behavior applies even if the request targets other open indices. + * $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. + * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes.This behavior applies even if the request targets other open indexes. * $params['expand_wildcards'] = (any) Type of index that wildcard patterns can match.If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.Supports comma-separated values, such as `open,hidden`.Valid values are: `all`, `open`, `closed`, `hidden`, `none`. * $params['ignore_unavailable'] = (boolean) If `false`, the request returns an error if it targets a missing or closed index. * $params['verbose'] = (boolean) If `true`, the request returns a verbose response. (Default = false) @@ -1197,20 +1197,20 @@ public function segments(array $params = []) { $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\Segments'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\Segments::class); $endpoint->setParams($params); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** - * Provides store information for shard copies of indices. + * Provides store information for shard copies of indexes. * - * $params['index'] = (array) List of data streams, indices, and aliases used to limit the request. - * $params['allow_no_indices'] = (boolean) If false, the request returns an error if any wildcard expression, index alias, or _allvalue targets only missing or closed indices. This behavior applies even if the requesttargets other open indices. + * $params['index'] = (array) List of data streams, indexes, and aliases used to limit the request. + * $params['allow_no_indices'] = (boolean) If false, the request returns an error if any wildcard expression, index alias, or _allvalue targets only missing or closed indexes. This behavior applies even if the requesttargets other open indexes. * $params['expand_wildcards'] = (any) Type of index that wildcard patterns can match. If the request can target data streams,this argument determines whether wildcard expressions match hidden data streams. - * $params['ignore_unavailable'] = (boolean) If true, missing or closed indices are not included in the response. + * $params['ignore_unavailable'] = (boolean) If true, missing or closed indexes are not included in the response. * $params['status'] = (any) List of shard health statuses used to limit the request. * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) @@ -1225,13 +1225,13 @@ public function shardStores(array $params = []) { $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\ShardStores'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\ShardStores::class); $endpoint->setParams($params); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** * Allow to shrink an existing index into a new index with fewer primary shards. * @@ -1260,8 +1260,7 @@ public function shrink(array $params = []) $target = $this->extractArgument($params, 'target'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\Shrink'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\Shrink::class); $endpoint->setParams($params); $endpoint->setIndex($index); $endpoint->setTarget($target); @@ -1269,6 +1268,7 @@ public function shrink(array $params = []) return $this->performRequest($endpoint); } + /** * Simulate matching the given index name against the index templates in the system. * @@ -1292,14 +1292,14 @@ public function simulateIndexTemplate(array $params = []) $name = $this->extractArgument($params, 'name'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\SimulateIndexTemplate'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\SimulateIndexTemplate::class); $endpoint->setParams($params); $endpoint->setName($name); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Simulate resolving the given template name or body. * @@ -1322,14 +1322,14 @@ public function simulateTemplate(array $params = []) $name = $this->extractArgument($params, 'name'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\SimulateTemplate'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\SimulateTemplate::class); $endpoint->setParams($params); $endpoint->setName($name); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Allows you to split an existing index into a new index with more primary shards. * @@ -1358,8 +1358,7 @@ public function split(array $params = []) $target = $this->extractArgument($params, 'target'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\Split'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\Split::class); $endpoint->setParams($params); $endpoint->setIndex($index); $endpoint->setTarget($target); @@ -1367,16 +1366,17 @@ public function split(array $params = []) return $this->performRequest($endpoint); } + /** * Provides statistics on operations happening in an index. * * $params['metric'] = (array) Limit the information returned the specific metrics. - * $params['index'] = (array) A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * $params['index'] = (array) A comma-separated list of index names; use `_all` or empty string to perform the operation on all indexes * $params['completion_fields'] = (any) Comma-separated list or wildcard expressions of fields to include in fielddata and suggest statistics. * $params['expand_wildcards'] = (any) Type of index that wildcard patterns can match. If the request can target data streams, this argumentdetermines whether wildcard expressions match hidden data streams. Supports comma-separated values,such as `open,hidden`. * $params['fielddata_fields'] = (any) Comma-separated list or wildcard expressions of fields to include in fielddata statistics. * $params['fields'] = (any) Comma-separated list or wildcard expressions of fields to include in the statistics. - * $params['forbid_closed_indices'] = (boolean) If true, statistics are not collected from closed indices. (Default = true) + * $params['forbid_closed_indices'] = (boolean) If true, statistics are not collected from closed indexes. (Default = true) * $params['groups'] = (any) Comma-separated list of search groups to include in the search statistics. * $params['include_segment_file_sizes'] = (boolean) If true, the call reports the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested). (Default = false) * $params['include_unloaded_segments'] = (boolean) If true, the response includes information from segments that are not loaded into memory. (Default = false) @@ -1395,14 +1395,14 @@ public function stats(array $params = []) $metric = $this->extractArgument($params, 'metric'); $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\Stats'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\Stats::class); $endpoint->setParams($params); $endpoint->setMetric($metric); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** * Updates index aliases. * @@ -1423,20 +1423,20 @@ public function updateAliases(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\UpdateAliases'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\UpdateAliases::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * The _upgrade API is no longer useful and will be removed. * - * $params['index'] = (array) Comma-separated list of indices; use `_all` or empty string to perform the operation on all indices. - * $params['allow_no_indices'] = (boolean) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified). - * $params['expand_wildcards'] = (any) Whether to expand wildcard expression to concrete indices that are open, closed or both. - * $params['ignore_unavailable'] = (boolean) Whether specified concrete indices should be ignored when unavailable (missing or closed). + * $params['index'] = (array) Comma-separated list of indexes; use `_all` or empty string to perform the operation on all indexes. + * $params['allow_no_indices'] = (boolean) Whether to ignore if a wildcard indexes expression resolves into no concrete indexes. (This includes `_all` string or when no indexes have been specified). + * $params['expand_wildcards'] = (any) Whether to expand wildcard expression to concrete indexes that are open, closed or both. + * $params['ignore_unavailable'] = (boolean) Whether specified concrete indexes should be ignored when unavailable (missing or closed). * $params['only_ancient_segments'] = (boolean) If true, only ancient (an older Lucene major release) segments will be upgraded. * $params['wait_for_completion'] = (boolean) Should this request wait until the operation has completed before returning. (Default = false) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) @@ -1452,19 +1452,19 @@ public function upgrade(array $params = []) { $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\Upgrade'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\Upgrade::class); $endpoint->setParams($params); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** * Allows a user to validate a potentially expensive query without executing it. * - * $params['index'] = (array) Comma-separated list of data streams, indices, and aliases to search. Supports wildcards (`*`). To search all data streams or indices, omit this parameter or use `*` or `_all`. + * $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases to search. Supports wildcards (`*`). To search all data streams or indexes, omit this parameter or use `*` or `_all`. * $params['all_shards'] = (boolean) If `true`, the validation is executed on all shards instead of one random shard per index. - * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indices.This behavior applies even if the request targets other open indices. + * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes.This behavior applies even if the request targets other open indexes. * $params['analyze_wildcard'] = (boolean) If `true`, wildcard and prefix queries are analyzed. (Default = false) * $params['analyzer'] = (string) Analyzer to use for the query string.This parameter can only be used when the `q` query string parameter is specified. * $params['default_operator'] = (enum) The default operator for query string query: `AND` or `OR`. (Options = and,or) @@ -1490,14 +1490,14 @@ public function validateQuery(array $params = []) $index = $this->extractArgument($params, 'index'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\ValidateQuery'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\ValidateQuery::class); $endpoint->setParams($params); $endpoint->setIndex($index); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Alias function to getAlias() * @@ -1518,8 +1518,7 @@ public function refreshSearchAnalyzers(array $params = []) { $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Indices\RefreshSearchAnalyzers'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Indices\RefreshSearchAnalyzers::class); $endpoint->setParams($params); $endpoint->setIndex($index); diff --git a/src/OpenSearch/Namespaces/IngestNamespace.php b/src/OpenSearch/Namespaces/IngestNamespace.php index 869667d8d..7e8d4c04c 100644 --- a/src/OpenSearch/Namespaces/IngestNamespace.php +++ b/src/OpenSearch/Namespaces/IngestNamespace.php @@ -50,13 +50,13 @@ public function deletePipeline(array $params = []) { $id = $this->extractArgument($params, 'id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ingest\DeletePipeline'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ingest\DeletePipeline::class); $endpoint->setParams($params); $endpoint->setId($id); return $this->performRequest($endpoint); } + /** * Returns a pipeline. * @@ -76,13 +76,13 @@ public function getPipeline(array $params = []) { $id = $this->extractArgument($params, 'id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ingest\GetPipeline'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ingest\GetPipeline::class); $endpoint->setParams($params); $endpoint->setId($id); return $this->performRequest($endpoint); } + /** * Returns a list of the built-in patterns. * @@ -97,12 +97,12 @@ public function getPipeline(array $params = []) */ public function processorGrok(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ingest\ProcessorGrok'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ingest\ProcessorGrok::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Creates or updates a pipeline. * @@ -125,14 +125,14 @@ public function putPipeline(array $params = []) $id = $this->extractArgument($params, 'id'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ingest\PutPipeline'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ingest\PutPipeline::class); $endpoint->setParams($params); $endpoint->setId($id); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Allows to simulate a pipeline with example documents. * @@ -153,12 +153,12 @@ public function simulate(array $params = []) $id = $this->extractArgument($params, 'id'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ingest\Simulate'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ingest\Simulate::class); $endpoint->setParams($params); $endpoint->setId($id); $endpoint->setBody($body); return $this->performRequest($endpoint); } + } diff --git a/src/OpenSearch/Namespaces/InsightsNamespace.php b/src/OpenSearch/Namespaces/InsightsNamespace.php index 3536cea7a..8017024ff 100644 --- a/src/OpenSearch/Namespaces/InsightsNamespace.php +++ b/src/OpenSearch/Namespaces/InsightsNamespace.php @@ -38,10 +38,10 @@ class InsightsNamespace extends AbstractNamespace */ public function topQueries(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Insights\TopQueries'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Insights\TopQueries::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + } diff --git a/src/OpenSearch/Namespaces/IsmNamespace.php b/src/OpenSearch/Namespaces/IsmNamespace.php index 13d555881..0984716f4 100644 --- a/src/OpenSearch/Namespaces/IsmNamespace.php +++ b/src/OpenSearch/Namespaces/IsmNamespace.php @@ -27,7 +27,7 @@ class IsmNamespace extends AbstractNamespace /** * Adds a policy to an index. * - * $params['index'] = (string) Comma-separated list of data streams, indices, and aliases. Supports wildcards (`*`). + * $params['index'] = (string) Comma-separated list of data streams, indexes, and aliases. Supports wildcards (`*`). * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) @@ -42,18 +42,18 @@ public function addPolicy(array $params = []) $index = $this->extractArgument($params, 'index'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ism\AddPolicy'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ism\AddPolicy::class); $endpoint->setParams($params); $endpoint->setIndex($index); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Updates the managed index policy to a new policy. * - * $params['index'] = (string) Comma-separated list of data streams, indices, and aliases. Supports wildcards (`*`). + * $params['index'] = (string) Comma-separated list of data streams, indexes, and aliases. Supports wildcards (`*`). * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) @@ -68,14 +68,14 @@ public function changePolicy(array $params = []) $index = $this->extractArgument($params, 'index'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ism\ChangePolicy'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ism\ChangePolicy::class); $endpoint->setParams($params); $endpoint->setIndex($index); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Deletes a policy. * @@ -93,13 +93,13 @@ public function deletePolicy(array $params = []) { $policy_id = $this->extractArgument($params, 'policy_id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ism\DeletePolicy'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ism\DeletePolicy::class); $endpoint->setParams($params); $endpoint->setPolicyId($policy_id); return $this->performRequest($endpoint); } + /** * Checks whether the policy exists. * @@ -120,17 +120,17 @@ public function existsPolicy(array $params = []): bool // manually make this verbose so we can check status code $params['client']['verbose'] = true; - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ism\ExistsPolicy'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ism\ExistsPolicy::class); $endpoint->setParams($params); $endpoint->setPolicyId($policy_id); return BooleanRequestWrapper::performRequest($endpoint, $this->transport); } + /** * Gets the currently applied policy on indices. * - * $params['index'] = (string) Comma-separated list of data streams, indices, and aliases. Supports wildcards (`*`). + * $params['index'] = (string) Comma-separated list of data streams, indexes, and aliases. Supports wildcards (`*`). * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) @@ -145,14 +145,14 @@ public function explainPolicy(array $params = []) $index = $this->extractArgument($params, 'index'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ism\ExplainPolicy'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ism\ExplainPolicy::class); $endpoint->setParams($params); $endpoint->setIndex($index); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Gets the policies. * @@ -167,12 +167,12 @@ public function explainPolicy(array $params = []) */ public function getPolicies(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ism\GetPolicies'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ism\GetPolicies::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Gets a policy. * @@ -190,13 +190,13 @@ public function getPolicy(array $params = []) { $policy_id = $this->extractArgument($params, 'policy_id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ism\GetPolicy'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ism\GetPolicy::class); $endpoint->setParams($params); $endpoint->setPolicyId($policy_id); return $this->performRequest($endpoint); } + /** * Gets the policies. * @@ -216,13 +216,13 @@ public function putPolicies(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ism\PutPolicies'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ism\PutPolicies::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Creates or updates a policy. * @@ -243,18 +243,18 @@ public function putPolicy(array $params = []) $policy_id = $this->extractArgument($params, 'policy_id'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ism\PutPolicy'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ism\PutPolicy::class); $endpoint->setParams($params); $endpoint->setPolicyId($policy_id); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Refresh search analyzers in real time. * - * $params['index'] = (string) Comma-separated list of data streams, indices, and aliases. Supports wildcards (`*`). (Required) + * $params['index'] = (string) Comma-separated list of data streams, indexes, and aliases. Supports wildcards (`*`). (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) @@ -268,17 +268,17 @@ public function refreshSearchAnalyzers(array $params = []) { $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ism\RefreshSearchAnalyzers'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ism\RefreshSearchAnalyzers::class); $endpoint->setParams($params); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** * Removes a policy from an index. * - * $params['index'] = (string) Comma-separated list of data streams, indices, and aliases. Supports wildcards (`*`). + * $params['index'] = (string) Comma-separated list of data streams, indexes, and aliases. Supports wildcards (`*`). * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) @@ -292,17 +292,17 @@ public function removePolicy(array $params = []) { $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ism\RemovePolicy'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ism\RemovePolicy::class); $endpoint->setParams($params); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** * Retry the failed action for an index. * - * $params['index'] = (string) Comma-separated list of data streams, indices, and aliases. Supports wildcards (`*`). + * $params['index'] = (string) Comma-separated list of data streams, indexes, and aliases. Supports wildcards (`*`). * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) @@ -317,12 +317,12 @@ public function retryIndex(array $params = []) $index = $this->extractArgument($params, 'index'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ism\RetryIndex'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ism\RetryIndex::class); $endpoint->setParams($params); $endpoint->setIndex($index); $endpoint->setBody($body); return $this->performRequest($endpoint); } + } diff --git a/src/OpenSearch/Namespaces/KnnNamespace.php b/src/OpenSearch/Namespaces/KnnNamespace.php index 4175a572d..d13fa2436 100644 --- a/src/OpenSearch/Namespaces/KnnNamespace.php +++ b/src/OpenSearch/Namespaces/KnnNamespace.php @@ -41,13 +41,13 @@ public function deleteModel(array $params = []) { $model_id = $this->extractArgument($params, 'model_id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Knn\DeleteModel'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Knn\DeleteModel::class); $endpoint->setParams($params); $endpoint->setModelId($model_id); return $this->performRequest($endpoint); } + /** * Used to retrieve information about models present in the cluster. * @@ -65,20 +65,20 @@ public function getModel(array $params = []) { $model_id = $this->extractArgument($params, 'model_id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Knn\GetModel'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Knn\GetModel::class); $endpoint->setParams($params); $endpoint->setModelId($model_id); return $this->performRequest($endpoint); } + /** * Use an OpenSearch query to search for models in the index. * * $params['_source'] = (array) True or false to return the _source field or not, or a list of fields to return. * $params['_source_excludes'] = (array) List of fields to exclude from the returned _source field. * $params['_source_includes'] = (array) List of fields to extract and return from the _source field. - * $params['allow_no_indices'] = (boolean) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified). + * $params['allow_no_indices'] = (boolean) Whether to ignore if a wildcard indexes expression resolves into no concrete indexes. (This includes `_all` string or when no indexes have been specified). * $params['allow_partial_search_results'] = (boolean) Indicate if an error should be returned if there is a partial search failure or timeout. (Default = true) * $params['analyze_wildcard'] = (boolean) Specify whether wildcard and prefix queries should be analyzed. (Default = false) * $params['analyzer'] = (string) The analyzer to use for the query string. @@ -87,11 +87,11 @@ public function getModel(array $params = []) * $params['default_operator'] = (enum) The default operator for query string query (AND or OR). (Options = AND,OR) * $params['df'] = (string) The field to use as default where no field prefix is given in the query string. * $params['docvalue_fields'] = (array) Comma-separated list of fields to return as the docvalue representation of a field for each hit. - * $params['expand_wildcards'] = (any) Whether to expand wildcard expression to concrete indices that are open, closed or both. + * $params['expand_wildcards'] = (any) Whether to expand wildcard expression to concrete indexes that are open, closed or both. * $params['explain'] = (boolean) Specify whether to return detailed information about score computation as part of a hit. * $params['from'] = (integer) Starting offset. (Default = 0) - * $params['ignore_throttled'] = (boolean) Whether specified concrete, expanded or aliased indices should be ignored when throttled. - * $params['ignore_unavailable'] = (boolean) Whether specified concrete indices should be ignored when unavailable (missing or closed). + * $params['ignore_throttled'] = (boolean) Whether specified concrete, expanded or aliased indexes should be ignored when throttled. + * $params['ignore_unavailable'] = (boolean) Whether specified concrete indexes should be ignored when unavailable (missing or closed). * $params['lenient'] = (boolean) Specify whether format-based query failures (such as providing text to a numeric field) should be ignored. * $params['max_concurrent_shard_requests'] = (integer) The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests. (Default = 5) * $params['pre_filter_shard_size'] = (integer) Threshold that enforces a pre-filter round-trip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter round-trip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint. @@ -130,13 +130,13 @@ public function searchModels(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Knn\SearchModels'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Knn\SearchModels::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Provides information about the current status of the k-NN plugin. * @@ -157,14 +157,14 @@ public function stats(array $params = []) $node_id = $this->extractArgument($params, 'node_id'); $stat = $this->extractArgument($params, 'stat'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Knn\Stats'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Knn\Stats::class); $endpoint->setParams($params); $endpoint->setNodeId($node_id); $endpoint->setStat($stat); return $this->performRequest($endpoint); } + /** * Create and train a model that can be used for initializing k-NN native library indexes during indexing. * @@ -184,18 +184,18 @@ public function trainModel(array $params = []) $model_id = $this->extractArgument($params, 'model_id'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Knn\TrainModel'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Knn\TrainModel::class); $endpoint->setParams($params); $endpoint->setModelId($model_id); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Preloads native library files into memory, reducing initial search latency for specified indexes. * - * $params['index'] = (array) Comma-separated list of indices; use `_all` or empty string to perform the operation on all indices. (Required) + * $params['index'] = (array) Comma-separated list of indexes; use `_all` or empty string to perform the operation on all indexes. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) @@ -209,11 +209,11 @@ public function warmup(array $params = []) { $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Knn\Warmup'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Knn\Warmup::class); $endpoint->setParams($params); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + } diff --git a/src/OpenSearch/Namespaces/ListNamespace.php b/src/OpenSearch/Namespaces/ListNamespace.php index 014274532..973e0da33 100644 --- a/src/OpenSearch/Namespaces/ListNamespace.php +++ b/src/OpenSearch/Namespaces/ListNamespace.php @@ -38,12 +38,12 @@ class ListNamespace extends AbstractNamespace */ public function help(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('List\Help'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\List\Help::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Returns paginated information about indexes including number of primaries and replicas, document counts, disk size. * @@ -78,13 +78,13 @@ public function indices(array $params = []) { $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('List\Indices'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\List\Indices::class); $endpoint->setParams($params); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + /** * Returns paginated details of shard allocation on nodes. * @@ -115,11 +115,11 @@ public function shards(array $params = []) { $index = $this->extractArgument($params, 'index'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('List\Shards'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\List\Shards::class); $endpoint->setParams($params); $endpoint->setIndex($index); return $this->performRequest($endpoint); } + } diff --git a/src/OpenSearch/Namespaces/MlNamespace.php b/src/OpenSearch/Namespaces/MlNamespace.php index 596d87fa5..473a754f6 100644 --- a/src/OpenSearch/Namespaces/MlNamespace.php +++ b/src/OpenSearch/Namespaces/MlNamespace.php @@ -41,13 +41,13 @@ public function deleteAgent(array $params = []) { $agent_id = $this->extractArgument($params, 'agent_id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ml\DeleteAgent'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\DeleteAgent::class); $endpoint->setParams($params); $endpoint->setAgentId($agent_id); return $this->performRequest($endpoint); } + /** * Deletes a model. * @@ -65,13 +65,13 @@ public function deleteModel(array $params = []) { $id = $this->extractArgument($params, 'id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ml\DeleteModel'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\DeleteModel::class); $endpoint->setParams($params); $endpoint->setId($id); return $this->performRequest($endpoint); } + /** * Deletes a model group. * @@ -89,13 +89,13 @@ public function deleteModelGroup(array $params = []) { $id = $this->extractArgument($params, 'id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ml\DeleteModelGroup'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\DeleteModelGroup::class); $endpoint->setParams($params); $endpoint->setId($id); return $this->performRequest($endpoint); } + /** * Deletes a task. * @@ -113,13 +113,13 @@ public function deleteTask(array $params = []) { $task_id = $this->extractArgument($params, 'task_id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ml\DeleteTask'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\DeleteTask::class); $endpoint->setParams($params); $endpoint->setTaskId($task_id); return $this->performRequest($endpoint); } + /** * Retrieves a model group. * @@ -137,13 +137,13 @@ public function getModelGroup(array $params = []) { $model_group_id = $this->extractArgument($params, 'model_group_id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ml\GetModelGroup'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\GetModelGroup::class); $endpoint->setParams($params); $endpoint->setModelGroupId($model_group_id); return $this->performRequest($endpoint); } + /** * Retrieves a task. * @@ -161,13 +161,13 @@ public function getTask(array $params = []) { $id = $this->extractArgument($params, 'id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ml\GetTask'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\GetTask::class); $endpoint->setParams($params); $endpoint->setId($id); return $this->performRequest($endpoint); } + /** * Register an agent. * @@ -184,13 +184,13 @@ public function registerAgents(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ml\RegisterAgents'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\RegisterAgents::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Registers a model. * @@ -207,13 +207,13 @@ public function registerModel(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ml\RegisterModel'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\RegisterModel::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Registers a model group. * @@ -230,13 +230,13 @@ public function registerModelGroup(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ml\RegisterModelGroup'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\RegisterModelGroup::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Searches for models. * @@ -253,13 +253,13 @@ public function searchModels(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ml\SearchModels'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\SearchModels::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * $params['body'] = (string) The body of the request (Required) * @@ -271,8 +271,7 @@ public function searchModels(array $params = []) public function createConnector(array $params = []): array { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ml\CreateConnector'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\CreateConnector::class); $endpoint->setParams($params); $endpoint->setBody($body); @@ -289,8 +288,7 @@ public function createConnector(array $params = []): array public function deleteConnector(array $params = []): array { $connectorId = $this->extractArgument($params, 'connector_id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ml\DeleteConnector'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\DeleteConnector::class); $endpoint->setParams($params); $endpoint->setConnectorId($connectorId); @@ -309,8 +307,7 @@ public function deployModel(array $params = []): array { $modelId = $this->extractArgument($params, 'model_id'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ml\DeployModel'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\DeployModel::class); $endpoint->setParams($params); $endpoint->setModelId($modelId); if ($body) { @@ -330,8 +327,7 @@ public function deployModel(array $params = []): array public function getConnector(array $params = []): array { $id = $this->extractArgument($params, 'id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ml\GetConnector'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\GetConnector::class); $endpoint->setParams($params); $endpoint->setId($id); @@ -356,8 +352,7 @@ public function getConnectors(array $params = []): array ]; } $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ml\GetConnectors'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\GetConnectors::class); $endpoint->setBody($body); return $this->performRequest($endpoint); @@ -381,8 +376,7 @@ public function getModelGroups(array $params = []): array ]; } $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ml\GetModelGroups'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\GetModelGroups::class); $endpoint->setBody($body); return $this->performRequest($endpoint); @@ -398,8 +392,7 @@ public function getModelGroups(array $params = []): array public function getModel(array $params = []): array { $id = $this->extractArgument($params, 'id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ml\GetModel'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\GetModel::class); $endpoint->setParams($params); $endpoint->setId($id); @@ -435,8 +428,7 @@ public function predict(array $params = []): array { $id = $this->extractArgument($params, 'id'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ml\Predict'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\Predict::class); $endpoint->setParams($params); $endpoint->setId($id); $endpoint->setBody($body); @@ -456,8 +448,7 @@ public function undeployModel(array $params = []): array { $modelId = $this->extractArgument($params, 'model_id'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ml\UndeployModel'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\UndeployModel::class); $endpoint->setParams($params); $endpoint->setModelId($modelId); if ($body) { @@ -479,8 +470,7 @@ public function updateModelGroup(array $params = []): array { $id = $this->extractArgument($params, 'id'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ml\UpdateModelGroup'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\UpdateModelGroup::class); $endpoint->setParams($params); $endpoint->setBody($body); $endpoint->setId($id); diff --git a/src/OpenSearch/Namespaces/NodesNamespace.php b/src/OpenSearch/Namespaces/NodesNamespace.php index 40486557a..069f6d367 100644 --- a/src/OpenSearch/Namespaces/NodesNamespace.php +++ b/src/OpenSearch/Namespaces/NodesNamespace.php @@ -53,13 +53,13 @@ public function hotThreads(array $params = []) { $node_id = $this->extractArgument($params, 'node_id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Nodes\HotThreads'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Nodes\HotThreads::class); $endpoint->setParams($params); $endpoint->setNodeId($node_id); return $this->performRequest($endpoint); } + /** * Returns information about nodes in the cluster. * @@ -83,8 +83,7 @@ public function info(array $params = []) $metric = $this->extractArgument($params, 'metric'); $node_id = $this->extractArgument($params, 'node_id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Nodes\Info'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Nodes\Info::class); $endpoint->setParams($params); $endpoint->setNodeIdOrMetric($node_id_or_metric); $endpoint->setMetric($metric); @@ -92,6 +91,7 @@ public function info(array $params = []) return $this->performRequest($endpoint); } + /** * Reloads secure settings. * @@ -112,20 +112,20 @@ public function reloadSecureSettings(array $params = []) $node_id = $this->extractArgument($params, 'node_id'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Nodes\ReloadSecureSettings'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Nodes\ReloadSecureSettings::class); $endpoint->setParams($params); $endpoint->setNodeId($node_id); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Returns statistical information about nodes in the cluster. * * $params['node_id'] = (array) Comma-separated list of node IDs or names used to limit returned information. * $params['metric'] = (array) Limit the information returned to the specified metrics - * $params['index_metric'] = (array) Limit the information returned for indices metric to the specific index metrics. It can be used only if indices (or all) metric is specified. + * $params['index_metric'] = (array) Limit the information returned for indexes metric to the specific index metrics. It can be used only if indexes (or all) metric is specified. * $params['completion_fields'] = (any) Comma-separated list or wildcard expressions of fields to include in fielddata and suggest statistics. * $params['fielddata_fields'] = (any) Comma-separated list or wildcard expressions of fields to include in fielddata statistics. * $params['fields'] = (any) Comma-separated list or wildcard expressions of fields to include in the statistics. @@ -149,8 +149,7 @@ public function stats(array $params = []) $metric = $this->extractArgument($params, 'metric'); $index_metric = $this->extractArgument($params, 'index_metric'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Nodes\Stats'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Nodes\Stats::class); $endpoint->setParams($params); $endpoint->setNodeId($node_id); $endpoint->setMetric($metric); @@ -158,6 +157,7 @@ public function stats(array $params = []) return $this->performRequest($endpoint); } + /** * Returns low-level information about REST actions usage on nodes. * @@ -178,12 +178,12 @@ public function usage(array $params = []) $node_id = $this->extractArgument($params, 'node_id'); $metric = $this->extractArgument($params, 'metric'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Nodes\Usage'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Nodes\Usage::class); $endpoint->setParams($params); $endpoint->setNodeId($node_id); $endpoint->setMetric($metric); return $this->performRequest($endpoint); } + } diff --git a/src/OpenSearch/Namespaces/NotificationsNamespace.php b/src/OpenSearch/Namespaces/NotificationsNamespace.php index f83c1ecb4..cf4df692d 100644 --- a/src/OpenSearch/Namespaces/NotificationsNamespace.php +++ b/src/OpenSearch/Namespaces/NotificationsNamespace.php @@ -40,13 +40,13 @@ public function createConfig(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Notifications\CreateConfig'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Notifications\CreateConfig::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Delete a channel configuration. * @@ -64,13 +64,13 @@ public function deleteConfig(array $params = []) { $config_id = $this->extractArgument($params, 'config_id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Notifications\DeleteConfig'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Notifications\DeleteConfig::class); $endpoint->setParams($params); $endpoint->setConfigId($config_id); return $this->performRequest($endpoint); } + /** * Delete multiple channel configurations. * @@ -87,12 +87,12 @@ public function deleteConfig(array $params = []) */ public function deleteConfigs(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Notifications\DeleteConfigs'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Notifications\DeleteConfigs::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Get a specific channel configuration. * @@ -110,13 +110,13 @@ public function getConfig(array $params = []) { $config_id = $this->extractArgument($params, 'config_id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Notifications\GetConfig'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Notifications\GetConfig::class); $endpoint->setParams($params); $endpoint->setConfigId($config_id); return $this->performRequest($endpoint); } + /** * Get multiple channel configurations with filtering. * @@ -173,13 +173,13 @@ public function getConfigs(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Notifications\GetConfigs'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Notifications\GetConfigs::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * List created notification channels. * @@ -194,12 +194,12 @@ public function getConfigs(array $params = []) */ public function listChannels(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Notifications\ListChannels'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Notifications\ListChannels::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * List supported channel configurations. * @@ -214,12 +214,12 @@ public function listChannels(array $params = []) */ public function listFeatures(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Notifications\ListFeatures'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Notifications\ListFeatures::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Send a test notification. * @@ -237,13 +237,13 @@ public function sendTest(array $params = []) { $config_id = $this->extractArgument($params, 'config_id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Notifications\SendTest'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Notifications\SendTest::class); $endpoint->setParams($params); $endpoint->setConfigId($config_id); return $this->performRequest($endpoint); } + /** * Update channel configuration. * @@ -262,12 +262,12 @@ public function updateConfig(array $params = []) $config_id = $this->extractArgument($params, 'config_id'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Notifications\UpdateConfig'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Notifications\UpdateConfig::class); $endpoint->setParams($params); $endpoint->setConfigId($config_id); $endpoint->setBody($body); return $this->performRequest($endpoint); } + } diff --git a/src/OpenSearch/Namespaces/ObservabilityNamespace.php b/src/OpenSearch/Namespaces/ObservabilityNamespace.php index a98912b24..da3217e14 100644 --- a/src/OpenSearch/Namespaces/ObservabilityNamespace.php +++ b/src/OpenSearch/Namespaces/ObservabilityNamespace.php @@ -40,13 +40,13 @@ public function createObject(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Observability\CreateObject'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Observability\CreateObject::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Deletes specific observability object specified by ID. * @@ -64,13 +64,13 @@ public function deleteObject(array $params = []) { $object_id = $this->extractArgument($params, 'object_id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Observability\DeleteObject'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Observability\DeleteObject::class); $endpoint->setParams($params); $endpoint->setObjectId($object_id); return $this->performRequest($endpoint); } + /** * Deletes specific observability objects specified by ID or a list of IDs. * @@ -87,12 +87,12 @@ public function deleteObject(array $params = []) */ public function deleteObjects(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Observability\DeleteObjects'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Observability\DeleteObjects::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Retrieves Local Stats of all observability objects. * @@ -107,12 +107,12 @@ public function deleteObjects(array $params = []) */ public function getLocalstats(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Observability\GetLocalstats'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Observability\GetLocalstats::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Retrieves specific observability object specified by ID. * @@ -130,13 +130,13 @@ public function getObject(array $params = []) { $object_id = $this->extractArgument($params, 'object_id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Observability\GetObject'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Observability\GetObject::class); $endpoint->setParams($params); $endpoint->setObjectId($object_id); return $this->performRequest($endpoint); } + /** * Retrieves list of all observability objects. * @@ -151,12 +151,12 @@ public function getObject(array $params = []) */ public function listObjects(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Observability\ListObjects'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Observability\ListObjects::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Updates an existing observability object. * @@ -175,12 +175,12 @@ public function updateObject(array $params = []) $object_id = $this->extractArgument($params, 'object_id'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Observability\UpdateObject'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Observability\UpdateObject::class); $endpoint->setParams($params); $endpoint->setObjectId($object_id); $endpoint->setBody($body); return $this->performRequest($endpoint); } + } diff --git a/src/OpenSearch/Namespaces/PplNamespace.php b/src/OpenSearch/Namespaces/PplNamespace.php index e7daac876..863e82817 100644 --- a/src/OpenSearch/Namespaces/PplNamespace.php +++ b/src/OpenSearch/Namespaces/PplNamespace.php @@ -42,13 +42,13 @@ public function explain(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ppl\Explain'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ppl\Explain::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Collect metrics for the plugin within the interval. * @@ -65,12 +65,12 @@ public function explain(array $params = []) */ public function getStats(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ppl\GetStats'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ppl\GetStats::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * By a stats endpoint, you are able to collect metrics for the plugin within the interval. * @@ -89,13 +89,13 @@ public function postStats(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ppl\PostStats'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ppl\PostStats::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Send a PPL query to the PPL plugin. * @@ -114,11 +114,11 @@ public function query(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Ppl\Query'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ppl\Query::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + } diff --git a/src/OpenSearch/Namespaces/QueryNamespace.php b/src/OpenSearch/Namespaces/QueryNamespace.php index 8a6f6d28f..15ebf3f24 100644 --- a/src/OpenSearch/Namespaces/QueryNamespace.php +++ b/src/OpenSearch/Namespaces/QueryNamespace.php @@ -41,13 +41,13 @@ public function datasourceDelete(array $params = []) { $datasource_name = $this->extractArgument($params, 'datasource_name'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Query\DatasourceDelete'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Query\DatasourceDelete::class); $endpoint->setParams($params); $endpoint->setDatasourceName($datasource_name); return $this->performRequest($endpoint); } + /** * Retrieves specific datasource specified by name. * @@ -65,13 +65,13 @@ public function datasourceRetrieve(array $params = []) { $datasource_name = $this->extractArgument($params, 'datasource_name'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Query\DatasourceRetrieve'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Query\DatasourceRetrieve::class); $endpoint->setParams($params); $endpoint->setDatasourceName($datasource_name); return $this->performRequest($endpoint); } + /** * Creates a new query datasource. * @@ -88,13 +88,13 @@ public function datasourcesCreate(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Query\DatasourcesCreate'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Query\DatasourcesCreate::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Retrieves list of all datasources. * @@ -109,12 +109,12 @@ public function datasourcesCreate(array $params = []) */ public function datasourcesList(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Query\DatasourcesList'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Query\DatasourcesList::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Updates an existing query datasource. * @@ -131,11 +131,11 @@ public function datasourcesUpdate(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Query\DatasourcesUpdate'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Query\DatasourcesUpdate::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + } diff --git a/src/OpenSearch/Namespaces/RemoteStoreNamespace.php b/src/OpenSearch/Namespaces/RemoteStoreNamespace.php index 5af53a837..a910f508a 100644 --- a/src/OpenSearch/Namespaces/RemoteStoreNamespace.php +++ b/src/OpenSearch/Namespaces/RemoteStoreNamespace.php @@ -43,11 +43,11 @@ public function restore(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('RemoteStore\Restore'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\RemoteStore\Restore::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + } diff --git a/src/OpenSearch/Namespaces/RollupsNamespace.php b/src/OpenSearch/Namespaces/RollupsNamespace.php index 9bc87eac0..4a5a00d28 100644 --- a/src/OpenSearch/Namespaces/RollupsNamespace.php +++ b/src/OpenSearch/Namespaces/RollupsNamespace.php @@ -41,13 +41,13 @@ public function delete(array $params = []) { $id = $this->extractArgument($params, 'id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Rollups\Delete'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Rollups\Delete::class); $endpoint->setParams($params); $endpoint->setId($id); return $this->performRequest($endpoint); } + /** * Get a rollup's current status. * @@ -65,13 +65,13 @@ public function explain(array $params = []) { $id = $this->extractArgument($params, 'id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Rollups\Explain'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Rollups\Explain::class); $endpoint->setParams($params); $endpoint->setId($id); return $this->performRequest($endpoint); } + /** * Get an index rollup. * @@ -89,13 +89,13 @@ public function get(array $params = []) { $id = $this->extractArgument($params, 'id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Rollups\Get'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Rollups\Get::class); $endpoint->setParams($params); $endpoint->setId($id); return $this->performRequest($endpoint); } + /** * Create or update index rollup. * @@ -116,14 +116,14 @@ public function put(array $params = []) $id = $this->extractArgument($params, 'id'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Rollups\Put'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Rollups\Put::class); $endpoint->setParams($params); $endpoint->setId($id); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Start rollup. * @@ -141,13 +141,13 @@ public function start(array $params = []) { $id = $this->extractArgument($params, 'id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Rollups\Start'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Rollups\Start::class); $endpoint->setParams($params); $endpoint->setId($id); return $this->performRequest($endpoint); } + /** * Stop rollup. * @@ -165,11 +165,11 @@ public function stop(array $params = []) { $id = $this->extractArgument($params, 'id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Rollups\Stop'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Rollups\Stop::class); $endpoint->setParams($params); $endpoint->setId($id); return $this->performRequest($endpoint); } + } diff --git a/src/OpenSearch/Namespaces/SearchPipelineNamespace.php b/src/OpenSearch/Namespaces/SearchPipelineNamespace.php index 61b2077fa..c9f294db9 100644 --- a/src/OpenSearch/Namespaces/SearchPipelineNamespace.php +++ b/src/OpenSearch/Namespaces/SearchPipelineNamespace.php @@ -43,13 +43,13 @@ public function delete(array $params = []) { $id = $this->extractArgument($params, 'id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('SearchPipeline\Delete'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\SearchPipeline\Delete::class); $endpoint->setParams($params); $endpoint->setId($id); return $this->performRequest($endpoint); } + /** * Retrieves information about a specified search pipeline. * @@ -68,13 +68,13 @@ public function get(array $params = []) { $id = $this->extractArgument($params, 'id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('SearchPipeline\Get'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\SearchPipeline\Get::class); $endpoint->setParams($params); $endpoint->setId($id); return $this->performRequest($endpoint); } + /** * Creates or replaces the specified search pipeline. * @@ -95,12 +95,12 @@ public function put(array $params = []) $id = $this->extractArgument($params, 'id'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('SearchPipeline\Put'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\SearchPipeline\Put::class); $endpoint->setParams($params); $endpoint->setId($id); $endpoint->setBody($body); return $this->performRequest($endpoint); } + } diff --git a/src/OpenSearch/Namespaces/SecurityNamespace.php b/src/OpenSearch/Namespaces/SecurityNamespace.php index a7fb5b38c..671346036 100644 --- a/src/OpenSearch/Namespaces/SecurityNamespace.php +++ b/src/OpenSearch/Namespaces/SecurityNamespace.php @@ -40,12 +40,12 @@ class SecurityNamespace extends AbstractNamespace */ public function authinfo(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\Authinfo'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\Authinfo::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Returns the authorization token. * @@ -60,12 +60,12 @@ public function authinfo(array $params = []) */ public function authtoken(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\Authtoken'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\Authtoken::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Not supported for cache API. * @@ -80,12 +80,12 @@ public function authtoken(array $params = []) */ public function cache(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\Cache'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\Cache::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Check whether or not an upgrade can be performed and what resources can be updated. * @@ -100,12 +100,12 @@ public function cache(array $params = []) */ public function configUpgradeCheck(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\ConfigUpgradeCheck'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\ConfigUpgradeCheck::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Helps cluster operator upgrade missing defaults and stale default definitions. * @@ -122,15 +122,15 @@ public function configUpgradePerform(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\ConfigUpgradePerform'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\ConfigUpgradePerform::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** - * Creates or replaces the allowlisted APIs. Accessible via Super Admin certificate or REST API permission. + * Creates or replaces the permitted APIs. Accessible using Super Admin certificate or REST API permission. * * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) @@ -145,13 +145,13 @@ public function createAllowlist(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\CreateAllowlist'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\CreateAllowlist::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Creates or replaces the multi-tenancy configuration. Only accessible to admins and users with REST API permissions. * @@ -168,13 +168,13 @@ public function createUpdateTenancyConfig(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\CreateUpdateTenancyConfig'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\CreateUpdateTenancyConfig::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Creates or replaces the specified user. Legacy API. * @@ -193,14 +193,14 @@ public function createUserLegacy(array $params = []) $username = $this->extractArgument($params, 'username'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\CreateUserLegacy'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\CreateUserLegacy::class); $endpoint->setParams($params); $endpoint->setUsername($username); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Delete a specified action group. * @@ -218,13 +218,13 @@ public function deleteActionGroup(array $params = []) { $action_group = $this->extractArgument($params, 'action_group'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\DeleteActionGroup'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\DeleteActionGroup::class); $endpoint->setParams($params); $endpoint->setActionGroup($action_group); return $this->performRequest($endpoint); } + /** * Deletes all distinguished names in the specified cluster or node allow list. Only accessible to super-admins and with rest-api permissions when enabled. * @@ -242,13 +242,13 @@ public function deleteDistinguishedName(array $params = []) { $cluster_name = $this->extractArgument($params, 'cluster_name'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\DeleteDistinguishedName'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\DeleteDistinguishedName::class); $endpoint->setParams($params); $endpoint->setClusterName($cluster_name); return $this->performRequest($endpoint); } + /** * Delete the specified role. * @@ -266,13 +266,13 @@ public function deleteRole(array $params = []) { $role = $this->extractArgument($params, 'role'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\DeleteRole'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\DeleteRole::class); $endpoint->setParams($params); $endpoint->setRole($role); return $this->performRequest($endpoint); } + /** * Deletes the specified role mapping. * @@ -290,13 +290,13 @@ public function deleteRoleMapping(array $params = []) { $role = $this->extractArgument($params, 'role'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\DeleteRoleMapping'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\DeleteRoleMapping::class); $endpoint->setParams($params); $endpoint->setRole($role); return $this->performRequest($endpoint); } + /** * Delete the specified tenant. * @@ -314,13 +314,13 @@ public function deleteTenant(array $params = []) { $tenant = $this->extractArgument($params, 'tenant'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\DeleteTenant'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\DeleteTenant::class); $endpoint->setParams($params); $endpoint->setTenant($tenant); return $this->performRequest($endpoint); } + /** * Delete the specified user. * @@ -338,13 +338,13 @@ public function deleteUser(array $params = []) { $username = $this->extractArgument($params, 'username'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\DeleteUser'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\DeleteUser::class); $endpoint->setParams($params); $endpoint->setUsername($username); return $this->performRequest($endpoint); } + /** * Delete the specified user. Legacy API. * @@ -362,13 +362,13 @@ public function deleteUserLegacy(array $params = []) { $username = $this->extractArgument($params, 'username'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\DeleteUserLegacy'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\DeleteUserLegacy::class); $endpoint->setParams($params); $endpoint->setUsername($username); return $this->performRequest($endpoint); } + /** * Flushes the Security plugin user, authentication, and authorization cache. * @@ -383,12 +383,12 @@ public function deleteUserLegacy(array $params = []) */ public function flushCache(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\FlushCache'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\FlushCache::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Generates On-Behalf-Of token for the current user. * @@ -405,13 +405,13 @@ public function generateOboToken(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\GenerateOboToken'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GenerateOboToken::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Generates authorization token for the given user. * @@ -429,13 +429,13 @@ public function generateUserToken(array $params = []) { $username = $this->extractArgument($params, 'username'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\GenerateUserToken'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GenerateUserToken::class); $endpoint->setParams($params); $endpoint->setUsername($username); return $this->performRequest($endpoint); } + /** * Generates authorization token for the given user. Legacy API. Not Implemented. * @@ -453,13 +453,13 @@ public function generateUserTokenLegacy(array $params = []) { $username = $this->extractArgument($params, 'username'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\GenerateUserTokenLegacy'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GenerateUserTokenLegacy::class); $endpoint->setParams($params); $endpoint->setUsername($username); return $this->performRequest($endpoint); } + /** * Returns account details for the current user. * @@ -474,12 +474,12 @@ public function generateUserTokenLegacy(array $params = []) */ public function getAccountDetails(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\GetAccountDetails'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetAccountDetails::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Retrieves one action group. * @@ -497,13 +497,13 @@ public function getActionGroup(array $params = []) { $action_group = $this->extractArgument($params, 'action_group'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\GetActionGroup'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetActionGroup::class); $endpoint->setParams($params); $endpoint->setActionGroup($action_group); return $this->performRequest($endpoint); } + /** * Retrieves the cluster security certificates. * @@ -520,12 +520,12 @@ public function getActionGroup(array $params = []) */ public function getAllCertificates(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\GetAllCertificates'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetAllCertificates::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Retrieves the current list of allowed API accessible to normal user. * @@ -540,12 +540,12 @@ public function getAllCertificates(array $params = []) */ public function getAllowlist(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\GetAllowlist'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetAllowlist::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Retrieves the audit configuration. * @@ -560,12 +560,12 @@ public function getAllowlist(array $params = []) */ public function getAuditConfiguration(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\GetAuditConfiguration'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetAuditConfiguration::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Retrieves the cluster security certificates. * @@ -580,12 +580,12 @@ public function getAuditConfiguration(array $params = []) */ public function getCertificates(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\GetCertificates'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetCertificates::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Returns the current Security plugin configuration in JSON format. * @@ -600,12 +600,12 @@ public function getCertificates(array $params = []) */ public function getConfiguration(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\GetConfiguration'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetConfiguration::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Retrieves the current security-dashboards plugin configuration. * @@ -620,12 +620,12 @@ public function getConfiguration(array $params = []) */ public function getDashboardsInfo(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\GetDashboardsInfo'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetDashboardsInfo::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Retrieves distinguished names. Only accessible to super-admins and with rest-api permissions when enabled. * @@ -644,13 +644,13 @@ public function getDistinguishedName(array $params = []) { $cluster_name = $this->extractArgument($params, 'cluster_name'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\GetDistinguishedName'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetDistinguishedName::class); $endpoint->setParams($params); $endpoint->setClusterName($cluster_name); return $this->performRequest($endpoint); } + /** * Retrieves the given node's security certificates. * @@ -670,13 +670,13 @@ public function getNodeCertificates(array $params = []) { $node_id = $this->extractArgument($params, 'node_id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\GetNodeCertificates'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetNodeCertificates::class); $endpoint->setParams($params); $endpoint->setNodeId($node_id); return $this->performRequest($endpoint); } + /** * Gets the evaluated REST API permissions for the currently logged in user. * @@ -691,12 +691,12 @@ public function getNodeCertificates(array $params = []) */ public function getPermissionsInfo(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\GetPermissionsInfo'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetPermissionsInfo::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Retrieves one role. * @@ -714,13 +714,13 @@ public function getRole(array $params = []) { $role = $this->extractArgument($params, 'role'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\GetRole'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetRole::class); $endpoint->setParams($params); $endpoint->setRole($role); return $this->performRequest($endpoint); } + /** * Retrieves one role mapping. * @@ -738,13 +738,13 @@ public function getRoleMapping(array $params = []) { $role = $this->extractArgument($params, 'role'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\GetRoleMapping'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetRoleMapping::class); $endpoint->setParams($params); $endpoint->setRole($role); return $this->performRequest($endpoint); } + /** * Retrieves the SSL configuration information. * @@ -760,12 +760,12 @@ public function getRoleMapping(array $params = []) */ public function getSslinfo(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\GetSslinfo'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetSslinfo::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Retrieves multi-tenancy configuration. Only accessible to admins and users with REST API permissions. * @@ -780,12 +780,12 @@ public function getSslinfo(array $params = []) */ public function getTenancyConfig(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\GetTenancyConfig'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetTenancyConfig::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Retrieves one tenant. * @@ -803,13 +803,13 @@ public function getTenant(array $params = []) { $tenant = $this->extractArgument($params, 'tenant'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\GetTenant'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetTenant::class); $endpoint->setParams($params); $endpoint->setTenant($tenant); return $this->performRequest($endpoint); } + /** * Retrieve one internal user. * @@ -827,13 +827,13 @@ public function getUser(array $params = []) { $username = $this->extractArgument($params, 'username'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\GetUser'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetUser::class); $endpoint->setParams($params); $endpoint->setUsername($username); return $this->performRequest($endpoint); } + /** * Retrieve one user. Legacy API. * @@ -851,13 +851,13 @@ public function getUserLegacy(array $params = []) { $username = $this->extractArgument($params, 'username'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\GetUserLegacy'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetUserLegacy::class); $endpoint->setParams($params); $endpoint->setUsername($username); return $this->performRequest($endpoint); } + /** * Retrieve all internal users. Legacy API. * @@ -872,12 +872,12 @@ public function getUserLegacy(array $params = []) */ public function getUsersLegacy(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\GetUsersLegacy'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetUsersLegacy::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Checks to see if the Security plugin is up and running. * @@ -893,12 +893,12 @@ public function getUsersLegacy(array $params = []) */ public function health(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\Health'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\Health::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Migrates security configuration from v6 to v7. * @@ -913,12 +913,12 @@ public function health(array $params = []) */ public function migrate(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\Migrate'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\Migrate::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Updates individual attributes of an action group. * @@ -937,14 +937,14 @@ public function patchActionGroup(array $params = []) $action_group = $this->extractArgument($params, 'action_group'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\PatchActionGroup'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PatchActionGroup::class); $endpoint->setParams($params); $endpoint->setActionGroup($action_group); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Updates the current list of allowed API accessible to normal user. * @@ -961,13 +961,13 @@ public function patchAllowlist(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\PatchAllowlist'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PatchAllowlist::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * A PATCH call is used to update specified fields in the audit configuration. * @@ -984,13 +984,13 @@ public function patchAuditConfiguration(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\PatchAuditConfiguration'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PatchAuditConfiguration::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * A PATCH call is used to update the existing configuration using the REST API. Only accessible by admins and users with rest api access and only when put or patch is enabled. * @@ -1007,13 +1007,13 @@ public function patchConfiguration(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\PatchConfiguration'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PatchConfiguration::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Updates a distinguished cluster name for a specific cluster. Only accessible to super-admins and with rest-api permissions when enabled. * @@ -1032,14 +1032,14 @@ public function patchDistinguishedName(array $params = []) $cluster_name = $this->extractArgument($params, 'cluster_name'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\PatchDistinguishedName'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PatchDistinguishedName::class); $endpoint->setParams($params); $endpoint->setClusterName($cluster_name); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Bulk update of distinguished names. Only accessible to super-admins and with rest-api permissions when enabled. * @@ -1056,13 +1056,13 @@ public function patchDistinguishedNames(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\PatchDistinguishedNames'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PatchDistinguishedNames::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Updates individual attributes of a role. * @@ -1081,14 +1081,14 @@ public function patchRole(array $params = []) $role = $this->extractArgument($params, 'role'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\PatchRole'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PatchRole::class); $endpoint->setParams($params); $endpoint->setRole($role); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Updates individual attributes of a role mapping. * @@ -1107,14 +1107,14 @@ public function patchRoleMapping(array $params = []) $role = $this->extractArgument($params, 'role'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\PatchRoleMapping'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PatchRoleMapping::class); $endpoint->setParams($params); $endpoint->setRole($role); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Add, delete, or modify a single tenant. * @@ -1133,14 +1133,14 @@ public function patchTenant(array $params = []) $tenant = $this->extractArgument($params, 'tenant'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\PatchTenant'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PatchTenant::class); $endpoint->setParams($params); $endpoint->setTenant($tenant); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Updates individual attributes of an internal user. * @@ -1159,14 +1159,14 @@ public function patchUser(array $params = []) $username = $this->extractArgument($params, 'username'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\PatchUser'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PatchUser::class); $endpoint->setParams($params); $endpoint->setUsername($username); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Updates the current security-dashboards plugin configuration. * @@ -1181,12 +1181,12 @@ public function patchUser(array $params = []) */ public function postDashboardsInfo(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\PostDashboardsInfo'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PostDashboardsInfo::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Reload HTTP layer communication certificates. * @@ -1201,12 +1201,12 @@ public function postDashboardsInfo(array $params = []) */ public function reloadHttpCertificates(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\ReloadHttpCertificates'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\ReloadHttpCertificates::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Reload Transport layer communication certificates. * @@ -1221,12 +1221,12 @@ public function reloadHttpCertificates(array $params = []) */ public function reloadTransportCertificates(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\ReloadTransportCertificates'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\ReloadTransportCertificates::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Retrieves the tenant names if any exist. Only accessible to super admins or kibanaserver user. * @@ -1241,12 +1241,12 @@ public function reloadTransportCertificates(array $params = []) */ public function tenantInfo(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\TenantInfo'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\TenantInfo::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Updates the audit configuration. * @@ -1263,13 +1263,13 @@ public function updateAuditConfiguration(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\UpdateAuditConfiguration'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\UpdateAuditConfiguration::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Adds or updates the existing configuration using the REST API. Only accessible by admins and users with rest api access and only when put or patch is enabled. * @@ -1286,13 +1286,13 @@ public function updateConfiguration(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\UpdateConfiguration'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\UpdateConfiguration::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Adds or updates the specified distinguished names in the cluster or node allow list. Only accessible to super-admins and with rest-api permissions when enabled. * @@ -1311,14 +1311,14 @@ public function updateDistinguishedName(array $params = []) $cluster_name = $this->extractArgument($params, 'cluster_name'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\UpdateDistinguishedName'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\UpdateDistinguishedName::class); $endpoint->setParams($params); $endpoint->setClusterName($cluster_name); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Checks whether the v6 security configuration is valid and ready to be migrated to v7. * @@ -1334,12 +1334,12 @@ public function updateDistinguishedName(array $params = []) */ public function validate(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\Validate'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\Validate::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Gets the user identity related information for currently logged in user. * @@ -1354,12 +1354,12 @@ public function validate(array $params = []) */ public function whoAmI(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\WhoAmI'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\WhoAmI::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Gets the user identity related information for currently logged in user. User needs to have access to this endpoint when authorization at REST layer is enabled. * @@ -1374,12 +1374,12 @@ public function whoAmI(array $params = []) */ public function whoAmIProtected(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\WhoAmIProtected'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\WhoAmIProtected::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Changes the password for the current user. * @@ -1404,8 +1404,7 @@ public function changePassword(array $params = []) ]; } - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\ChangePassword'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\ChangePassword::class); $endpoint->setParams($params); $endpoint->setBody($body); @@ -1435,8 +1434,7 @@ public function createActionGroup(array $params = []) ]; } - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\CreateActionGroup'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\CreateActionGroup::class); $endpoint->setParams($params); $endpoint->setActionGroup($action_group); $endpoint->setBody($body); @@ -1471,8 +1469,7 @@ public function createRoleMapping(array $params = []) ]); } - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\CreateRoleMapping'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\CreateRoleMapping::class); $endpoint->setParams($params); $endpoint->setRole($role); $endpoint->setBody($body); @@ -1507,8 +1504,7 @@ public function createRole(array $params = []) ]); } - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\CreateRole'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\CreateRole::class); $endpoint->setParams($params); $endpoint->setRole($role); $endpoint->setBody($body); @@ -1539,8 +1535,7 @@ public function createTenant(array $params = []) ]; } - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\CreateTenant'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\CreateTenant::class); $endpoint->setParams($params); $endpoint->setTenant($tenant); $endpoint->setBody($body); @@ -1577,8 +1572,7 @@ public function createUser(array $params = []) ]); } - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\CreateUser'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\CreateUser::class); $endpoint->setParams($params); $endpoint->setUsername($username); $endpoint->setBody($body); @@ -1616,13 +1610,12 @@ public function getAccount(array $params = []) */ public function getActionGroups(array $params = []) { - $endpointBuilder = $this->endpoints; if (isset($params['action_group'])) { - $endpoint = $endpointBuilder('Security\GetActionGroup'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetActionGroup::class); $action_group = $this->extractArgument($params, 'action_group'); $endpoint->setActionGroup($action_group); } else { - $endpoint = $endpointBuilder('Security\GetActionGroups'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetActionGroups::class); } $endpoint->setParams($params); @@ -1653,13 +1646,12 @@ public function getConfig(array $params = []) */ public function getDistinguishedNames(array $params = []) { - $endpointBuilder = $this->endpoints; if (isset($params['cluster_name'])) { - $endpoint = $endpointBuilder('Security\GetDistinguishedName'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetDistinguishedName::class); $cluster_name = $this->extractArgument($params, 'cluster_name'); $endpoint->setClusterName($cluster_name); } else { - $endpoint = $endpointBuilder('Security\GetDistinguishedNames'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetDistinguishedNames::class); } $endpoint->setParams($params); @@ -1681,13 +1673,12 @@ public function getDistinguishedNames(array $params = []) */ public function getRoleMappings(array $params = []) { - $endpointBuilder = $this->endpoints; if (isset($params['role'])) { - $endpoint = $endpointBuilder('Security\GetRoleMapping'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetRoleMapping::class); $role = $this->extractArgument($params, 'role'); $endpoint->setRole($role); } else { - $endpoint = $endpointBuilder('Security\GetRoleMappings'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetRoleMappings::class); } $endpoint->setParams($params); @@ -1709,13 +1700,12 @@ public function getRoleMappings(array $params = []) */ public function getRoles(array $params = []) { - $endpointBuilder = $this->endpoints; if (isset($params['role'])) { - $endpoint = $endpointBuilder('Security\GetRole'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetRole::class); $role = $this->extractArgument($params, 'role'); $endpoint->setRole($role); } else { - $endpoint = $endpointBuilder('Security\GetRoles'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetRoles::class); } $endpoint->setParams($params); @@ -1737,13 +1727,12 @@ public function getRoles(array $params = []) */ public function getTenants(array $params = []) { - $endpointBuilder = $this->endpoints; if (isset($params['tenant'])) { - $endpoint = $endpointBuilder('Security\GetTenant'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetTenant::class); $tenant = $this->extractArgument($params, 'tenant'); $endpoint->setTenant($tenant); } else { - $endpoint = $endpointBuilder('Security\GetTenants'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetTenants::class); } $endpoint->setParams($params); @@ -1768,11 +1757,11 @@ public function getUsers(array $params = []): array $endpointBuilder = $this->endpoints; if (isset($params['username'])) { - $endpoint = $endpointBuilder('Security\GetUser'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetUser::class); $username = $this->extractArgument($params, 'username'); $endpoint->setUsername($username); } else { - $endpoint = $endpointBuilder('Security\GetUsers'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\GetUsers::class); } $endpoint->setParams($params); @@ -1800,13 +1789,12 @@ public function patchActionGroups(array $params = []) $body = $this->extractArgument($params, 'ops') ?? []; } - $endpointBuilder = $this->endpoints; if (isset($params['action_group'])) { - $endpoint = $endpointBuilder('Security\PatchActionGroup'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PatchActionGroup::class); $action_group = $this->extractArgument($params, 'action_group'); $endpoint->setActionGroup($action_group); } else { - $endpoint = $endpointBuilder('Security\PatchActionGroups'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PatchActionGroups::class); } $endpoint->setParams($params); $endpoint->setBody($body); @@ -1845,13 +1833,12 @@ public function patchRoleMappings(array $params = []) $body = $this->extractArgument($params, 'ops') ?? []; } - $endpointBuilder = $this->endpoints; if (isset($params['role'])) { - $endpoint = $endpointBuilder('Security\PatchRoleMapping'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PatchRoleMapping::class); $role = $this->extractArgument($params, 'role'); $endpoint->setRole($role); } else { - $endpoint = $endpointBuilder('Security\PatchRoleMappings'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PatchRoleMappings::class); } $endpoint->setParams($params); $endpoint->setBody($body); @@ -1878,13 +1865,12 @@ public function patchRoles(array $params = []) $body = $this->extractArgument($params, 'ops') ?? []; } - $endpointBuilder = $this->endpoints; if (isset($params['role'])) { - $endpoint = $endpointBuilder('Security\PatchRole'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PatchRole::class); $role = $this->extractArgument($params, 'role'); $endpoint->setRole($role); } else { - $endpoint = $endpointBuilder('Security\PatchRoles'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PatchRoles::class); } $endpoint->setParams($params); @@ -1912,13 +1898,12 @@ public function patchTenants(array $params = []) $body = $this->extractArgument($params, 'ops') ?? []; } - $endpointBuilder = $this->endpoints; if (isset($params['tenant'])) { - $endpoint = $endpointBuilder('Security\PatchTenant'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PatchTenant::class); $tenant = $this->extractArgument($params, 'tenant'); $endpoint->setTenant($tenant); } else { - $endpoint = $endpointBuilder('Security\PatchTenants'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PatchTenants::class); } $endpoint->setParams($params); @@ -1946,13 +1931,12 @@ public function patchUsers(array $params = []) $body = $this->extractArgument($params, 'ops') ?? []; } - $endpointBuilder = $this->endpoints; if (isset($params['username'])) { - $endpoint = $endpointBuilder('Security\PatchUser'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PatchUser::class); $username = $this->extractArgument($params, 'username'); $endpoint->setUsername($username); } else { - $endpoint = $endpointBuilder('Security\PatchUsers'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PatchUsers::class); } $endpoint->setParams($params); diff --git a/src/OpenSearch/Namespaces/SnapshotNamespace.php b/src/OpenSearch/Namespaces/SnapshotNamespace.php index fc4300718..0adc41e54 100644 --- a/src/OpenSearch/Namespaces/SnapshotNamespace.php +++ b/src/OpenSearch/Namespaces/SnapshotNamespace.php @@ -50,15 +50,15 @@ public function cleanupRepository(array $params = []) { $repository = $this->extractArgument($params, 'repository'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Snapshot\CleanupRepository'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Snapshot\CleanupRepository::class); $endpoint->setParams($params); $endpoint->setRepository($repository); return $this->performRequest($endpoint); } + /** - * Clones indices from one snapshot into another snapshot in the same repository. + * Clones indexes from one snapshot into another snapshot in the same repository. * * $params['repository'] = (string) A repository name * $params['snapshot'] = (string) The name of the snapshot to clone from @@ -82,8 +82,7 @@ public function clone(array $params = []) $target_snapshot = $this->extractArgument($params, 'target_snapshot'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Snapshot\CloneSnapshot'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Snapshot\CloneSnapshot::class); $endpoint->setParams($params); $endpoint->setRepository($repository); $endpoint->setSnapshot($snapshot); @@ -92,6 +91,7 @@ public function clone(array $params = []) return $this->performRequest($endpoint); } + /** * Creates a snapshot in a repository. * @@ -116,8 +116,7 @@ public function create(array $params = []) $snapshot = $this->extractArgument($params, 'snapshot'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Snapshot\Create'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Snapshot\Create::class); $endpoint->setParams($params); $endpoint->setRepository($repository); $endpoint->setSnapshot($snapshot); @@ -125,6 +124,7 @@ public function create(array $params = []) return $this->performRequest($endpoint); } + /** * Creates a repository. * @@ -148,14 +148,14 @@ public function createRepository(array $params = []) $repository = $this->extractArgument($params, 'repository'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Snapshot\CreateRepository'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Snapshot\CreateRepository::class); $endpoint->setParams($params); $endpoint->setRepository($repository); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Deletes a snapshot. * @@ -177,14 +177,14 @@ public function delete(array $params = []) $repository = $this->extractArgument($params, 'repository'); $snapshot = $this->extractArgument($params, 'snapshot'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Snapshot\Delete'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Snapshot\Delete::class); $endpoint->setParams($params); $endpoint->setRepository($repository); $endpoint->setSnapshot($snapshot); return $this->performRequest($endpoint); } + /** * Deletes a repository. * @@ -205,13 +205,13 @@ public function deleteRepository(array $params = []) { $repository = $this->extractArgument($params, 'repository'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Snapshot\DeleteRepository'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Snapshot\DeleteRepository::class); $endpoint->setParams($params); $endpoint->setRepository($repository); return $this->performRequest($endpoint); } + /** * Returns information about a snapshot. * @@ -235,14 +235,14 @@ public function get(array $params = []) $repository = $this->extractArgument($params, 'repository'); $snapshot = $this->extractArgument($params, 'snapshot'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Snapshot\Get'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Snapshot\Get::class); $endpoint->setParams($params); $endpoint->setRepository($repository); $endpoint->setSnapshot($snapshot); return $this->performRequest($endpoint); } + /** * Returns information about a repository. * @@ -263,13 +263,13 @@ public function getRepository(array $params = []) { $repository = $this->extractArgument($params, 'repository'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Snapshot\GetRepository'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Snapshot\GetRepository::class); $endpoint->setParams($params); $endpoint->setRepository($repository); return $this->performRequest($endpoint); } + /** * Restores a snapshot. * @@ -294,8 +294,7 @@ public function restore(array $params = []) $snapshot = $this->extractArgument($params, 'snapshot'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Snapshot\Restore'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Snapshot\Restore::class); $endpoint->setParams($params); $endpoint->setRepository($repository); $endpoint->setSnapshot($snapshot); @@ -303,6 +302,7 @@ public function restore(array $params = []) return $this->performRequest($endpoint); } + /** * Returns information about the status of a snapshot. * @@ -325,14 +325,14 @@ public function status(array $params = []) $repository = $this->extractArgument($params, 'repository'); $snapshot = $this->extractArgument($params, 'snapshot'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Snapshot\Status'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Snapshot\Status::class); $endpoint->setParams($params); $endpoint->setRepository($repository); $endpoint->setSnapshot($snapshot); return $this->performRequest($endpoint); } + /** * Verifies a repository. * @@ -353,11 +353,11 @@ public function verifyRepository(array $params = []) { $repository = $this->extractArgument($params, 'repository'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Snapshot\VerifyRepository'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Snapshot\VerifyRepository::class); $endpoint->setParams($params); $endpoint->setRepository($repository); return $this->performRequest($endpoint); } + } diff --git a/src/OpenSearch/Namespaces/SqlNamespace.php b/src/OpenSearch/Namespaces/SqlNamespace.php index 529297d99..b18300afc 100644 --- a/src/OpenSearch/Namespaces/SqlNamespace.php +++ b/src/OpenSearch/Namespaces/SqlNamespace.php @@ -42,13 +42,13 @@ public function close(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Sql\Close'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Sql\Close::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Collect metrics for the plugin within the interval. * @@ -65,12 +65,12 @@ public function close(array $params = []) */ public function getStats(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Sql\GetStats'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Sql\GetStats::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * By a stats endpoint, you are able to collect metrics for the plugin within the interval. * @@ -89,13 +89,13 @@ public function postStats(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Sql\PostStats'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Sql\PostStats::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Adds SQL settings to the standard OpenSearch cluster settings. * @@ -113,13 +113,13 @@ public function settings(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Sql\Settings'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Sql\Settings::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); - } /** + } + /** * This API will be removed in a future version. Use 'close' API instead. * * $params['cursor'] = (string) The cursor given by the server @@ -129,9 +129,7 @@ public function settings(array $params = []) */ public function closeCursor(array $params): array { - $endpointBuilder = $this->endpoints; - - $endpoint = $endpointBuilder('Sql\Close'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Sql\Close::class); $endpoint->setBody(array_filter([ 'cursor' => $this->extractArgument($params, 'cursor'), ])); @@ -148,12 +146,10 @@ public function closeCursor(array $params): array */ public function explain(array $params): array { - $endpointBuilder = $this->endpoints; - $body = $this->extractArgument($params, 'body') ?? []; $query = $this->extractArgument($params, 'query'); - $endpoint = $endpointBuilder('Sql\Explain'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Sql\Explain::class); $endpoint->setBody(array_merge($body, [ 'query' => $query, ])); @@ -174,9 +170,7 @@ public function explain(array $params): array */ public function query(array $params): array { - $endpointBuilder = $this->endpoints; - - $endpoint = $endpointBuilder('Sql\Query'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Sql\Query::class); $body = $this->extractArgument($params, 'body') ?? []; $endpoint->setBody(array_merge($body, array_filter([ 'query' => $this->extractArgument($params, 'query'), diff --git a/src/OpenSearch/Namespaces/TasksNamespace.php b/src/OpenSearch/Namespaces/TasksNamespace.php index 9a59950d4..9c46d1117 100644 --- a/src/OpenSearch/Namespaces/TasksNamespace.php +++ b/src/OpenSearch/Namespaces/TasksNamespace.php @@ -51,13 +51,13 @@ public function cancel(array $params = []) { $task_id = $this->extractArgument($params, 'task_id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Tasks\Cancel'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Tasks\Cancel::class); $endpoint->setParams($params); $endpoint->setTaskId($task_id); return $this->performRequest($endpoint); } + /** * Returns information about a task. * @@ -77,13 +77,13 @@ public function get(array $params = []) { $task_id = $this->extractArgument($params, 'task_id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Tasks\Get'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Tasks\Get::class); $endpoint->setParams($params); $endpoint->setTaskId($task_id); return $this->performRequest($endpoint); } + /** * Returns a list of tasks. * @@ -105,12 +105,12 @@ public function get(array $params = []) */ public function list(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Tasks\ListTasks'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Tasks\ListTasks::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Proxy function to list() to prevent BC break since 7.4.0 */ diff --git a/src/OpenSearch/Namespaces/TransformsNamespace.php b/src/OpenSearch/Namespaces/TransformsNamespace.php index 342451a28..44716c69d 100644 --- a/src/OpenSearch/Namespaces/TransformsNamespace.php +++ b/src/OpenSearch/Namespaces/TransformsNamespace.php @@ -41,13 +41,13 @@ public function delete(array $params = []) { $id = $this->extractArgument($params, 'id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Transforms\Delete'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Transforms\Delete::class); $endpoint->setParams($params); $endpoint->setId($id); return $this->performRequest($endpoint); } + /** * Returns the status and metadata of a transform job. * @@ -65,13 +65,13 @@ public function explain(array $params = []) { $id = $this->extractArgument($params, 'id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Transforms\Explain'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Transforms\Explain::class); $endpoint->setParams($params); $endpoint->setId($id); return $this->performRequest($endpoint); } + /** * Returns the status and metadata of a transform job. * @@ -89,13 +89,13 @@ public function get(array $params = []) { $id = $this->extractArgument($params, 'id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Transforms\Get'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Transforms\Get::class); $endpoint->setParams($params); $endpoint->setId($id); return $this->performRequest($endpoint); } + /** * Returns a preview of what a transformed index would look like. * @@ -112,13 +112,13 @@ public function preview(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Transforms\Preview'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Transforms\Preview::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Create an index transform, or update a transform if if_seq_no and if_primary_term are provided. * @@ -139,14 +139,14 @@ public function put(array $params = []) $id = $this->extractArgument($params, 'id'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Transforms\Put'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Transforms\Put::class); $endpoint->setParams($params); $endpoint->setId($id); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Returns the details of all transform jobs. * @@ -166,12 +166,12 @@ public function put(array $params = []) */ public function search(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Transforms\Search'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Transforms\Search::class); $endpoint->setParams($params); return $this->performRequest($endpoint); } + /** * Start transform. * @@ -189,13 +189,13 @@ public function start(array $params = []) { $id = $this->extractArgument($params, 'id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Transforms\Start'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Transforms\Start::class); $endpoint->setParams($params); $endpoint->setId($id); return $this->performRequest($endpoint); } + /** * Stop transform. * @@ -213,11 +213,11 @@ public function stop(array $params = []) { $id = $this->extractArgument($params, 'id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Transforms\Stop'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Transforms\Stop::class); $endpoint->setParams($params); $endpoint->setId($id); return $this->performRequest($endpoint); } + } diff --git a/src/OpenSearch/Namespaces/WlmNamespace.php b/src/OpenSearch/Namespaces/WlmNamespace.php index cc45875bd..53670a61d 100644 --- a/src/OpenSearch/Namespaces/WlmNamespace.php +++ b/src/OpenSearch/Namespaces/WlmNamespace.php @@ -25,7 +25,7 @@ class WlmNamespace extends AbstractNamespace { /** - * Creates the specified query group. + * Creates a new query group and sets the resource limits for the new query group. * * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) @@ -40,17 +40,17 @@ public function createQueryGroup(array $params = []) { $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Wlm\CreateQueryGroup'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Wlm\CreateQueryGroup::class); $endpoint->setParams($params); $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** - * Deletes the specified QueryGroup. + * Deletes the specified query group. * - * $params['name'] = (string) QueryGroup name. + * $params['name'] = (string) The name of the query group. * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) @@ -64,17 +64,17 @@ public function deleteQueryGroup(array $params = []) { $name = $this->extractArgument($params, 'name'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Wlm\DeleteQueryGroup'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Wlm\DeleteQueryGroup::class); $endpoint->setParams($params); $endpoint->setName($name); return $this->performRequest($endpoint); } + /** - * Gets the specified QueryGroup or get all if no name is provided. + * Retrieves the specified query group. If no query group is specified, all query groups in the cluster are retrieved. * - * $params['name'] = (string) QueryGroup name. + * $params['name'] = (string) The name of the query group. * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) @@ -88,17 +88,17 @@ public function getQueryGroup(array $params = []) { $name = $this->extractArgument($params, 'name'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Wlm\GetQueryGroup'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Wlm\GetQueryGroup::class); $endpoint->setParams($params); $endpoint->setName($name); return $this->performRequest($endpoint); } + /** * Updates the specified query group. * - * $params['name'] = (string) QueryGroup name. + * $params['name'] = (string) The name of the query group. * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) @@ -113,12 +113,12 @@ public function updateQueryGroup(array $params = []) $name = $this->extractArgument($params, 'name'); $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Wlm\UpdateQueryGroup'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Wlm\UpdateQueryGroup::class); $endpoint->setParams($params); $endpoint->setName($name); $endpoint->setBody($body); return $this->performRequest($endpoint); } + } From 995d450aafed42dd4d179f85782779de76238933 Mon Sep 17 00:00:00 2001 From: Kim Pepper Date: Fri, 15 Nov 2024 10:53:48 +1100 Subject: [PATCH 10/10] Pass factory to closure Signed-off-by: Kim Pepper --- src/OpenSearch/Client.php | 2 +- util/template/client-class | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenSearch/Client.php b/src/OpenSearch/Client.php index 80478db96..43d5aa577 100644 --- a/src/OpenSearch/Client.php +++ b/src/OpenSearch/Client.php @@ -263,7 +263,7 @@ public function __construct(Transport $transport, callable|EndpointFactoryInterf $endpoints = $endpointFactory; $endpointFactory = new LegacyEndpointFactory($endpointFactory); } else { - $endpoints = function ($c) { + $endpoints = function ($c) use ($endpointFactory) { @trigger_error('The $endpoints property is deprecated in 2.3.2 and will be removed in 3.0.0.', E_USER_DEPRECATED); return $endpointFactory->getEndpoint('OpenSearch\\Endpoints\\' . $c); }; diff --git a/util/template/client-class b/util/template/client-class index e9d1ab1cd..999710866 100644 --- a/util/template/client-class +++ b/util/template/client-class @@ -79,7 +79,7 @@ class Client $endpoints = $endpointFactory; $endpointFactory = new LegacyEndpointFactory($endpointFactory); } else { - $endpoints = function ($c) { + $endpoints = function ($c) use ($endpointFactory) { @trigger_error('The $endpoints property is deprecated in 2.3.2 and will be removed in 3.0.0.', E_USER_DEPRECATED); return $endpointFactory->getEndpoint('OpenSearch\\Endpoints\\' . $c); };