diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c7f9851..d1847475 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Fixed - Fixed upcomming PHP 8.4 deprecations ### Updated APIs +- Updated opensearch-php APIs to reflect [opensearch-api-specification@8255f1b](https://github.com/opensearch-project/opensearch-api-specification/commit/8255f1b3761a9d9653475aee18dee6acd904cf71) - Updated opensearch-php APIs to reflect [opensearch-api-specification@cb320b5](https://github.com/opensearch-project/opensearch-api-specification/commit/cb320b5482551c4f28afa26ff0d1653332699722) ### Security ### Dependencies diff --git a/composer.json b/composer.json index 9efae1db..3ca956ae 100644 --- a/composer.json +++ b/composer.json @@ -21,22 +21,33 @@ } ], "require": { - "php": "^7.3 || ^8.0", - "ext-json": ">=1.3.7", + "php": "^8.1", "ext-curl": "*", - "ezimuel/ringphp": "^1.2.2", + "ext-json": ">=1.3.7", + "php-http/async-client-implementation": "^1.0", + "php-http/discovery": "^1.20", + "php-http/guzzle7-adapter": "^1.0", + "psr/http-client": "^1.0", + "psr/http-client-implementation": "^1.0", + "psr/http-factory": "^1.1", + "psr/http-factory-implementation": "^2.4", + "psr/http-message": "^2.0", + "psr/http-message-implementation": "^1.0", "psr/log": "^1|^2|^3", "symfony/yaml": "*" }, "require-dev": { "ext-zip": "*", "aws/aws-sdk-php": "^3.0", - "friendsofphp/php-cs-fixer": "^3.0", - "mockery/mockery": "^1.2", - "phpstan/phpstan": "^1.7.15", - "phpstan/phpstan-mockery": "^1.1.0", - "phpunit/phpunit": "^9.3", - "symfony/finder": "~4.0 || ~5.0" + "friendsofphp/php-cs-fixer": "^v3.64", + "guzzlehttp/psr7": "^2.7", + "mockery/mockery": "^1.6", + "phpstan/phpstan": "^1.12", + "phpstan/phpstan-mockery": "^1.1", + "phpunit/phpunit": "^9.6", + "symfony/finder": "^6.4|^7.0", + "symfony/http-client": "^7.1", + "symfony/http-client-contracts": "^3.5" }, "suggest": { "monolog/monolog": "Allows for client-level logging and tracing", @@ -54,7 +65,10 @@ } }, "config": { - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "php-http/discovery": true + } }, "scripts": { "php-cs": [ diff --git a/samples/index.php b/samples/index.php index b7bb97f8..0c520aa8 100644 --- a/samples/index.php +++ b/samples/index.php @@ -5,17 +5,47 @@ * SPDX-License-Identifier: Apache-2.0 */ +use OpenSearch\Client; + require_once __DIR__ . '/vendor/autoload.php'; -$client = OpenSearch\ClientBuilder::fromConfig([ - 'Hosts' => [ - 'https://localhost:9200' - ], - 'BasicAuthentication' => ['admin', getenv('OPENSEARCH_PASSWORD')], - 'Retries' => 2, - 'SSLVerification' => false +// Guzzle example + +$guzzleClient = new \GuzzleHttp\Client([ + 'base_uri' => 'https://localhost:9200', + 'auth' => ['admin', getenv('OPENSEARCH_PASSWORD')], + 'verify' => false, + 'retries' => 2, + 'headers' => [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + 'User-Agent' => sprintf('opensearch-php/%s (%s; PHP %s)', Client::VERSION, PHP_OS, PHP_VERSION), + ] +]); +$requestFactory = new \OpenSearch\RequestFactory(); +$transport = new OpenSearch\Transport($guzzleClient, $requestFactory); + +$client = (new \OpenSearch\ClientBuilder($transport))->build(); + +$client = new OpenSearch\Client($transport, $requestFactory, $httpFactory); +$info = $client->info(); + +echo "{$info['version']['distribution']}: {$info['version']['number']}\n"; + +// Symfony example + +$symfonyClient = \Symfony\Component\HttpClient\HttpClient::create([ + 'base_uri' => 'https://localhost:9200', + 'auth_basic' => ['admin', getenv('OPENSEARCH_PASSWORD')], + 'verify_peer' => false, + 'max_retries' => 2, + 'headers' => [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ], ]); +$client = new OpenSearch\Client($symfonyClient); $info = $client->info(); echo "{$info['version']['distribution']}: {$info['version']['number']}\n"; diff --git a/src/OpenSearch/Client.php b/src/OpenSearch/Client.php index e679a65e..7597878b 100644 --- a/src/OpenSearch/Client.php +++ b/src/OpenSearch/Client.php @@ -21,18 +21,22 @@ namespace OpenSearch; +use Http\Promise\Promise; use OpenSearch\Common\Exceptions\BadMethodCallException; use OpenSearch\Common\Exceptions\NoNodesAvailableException; use OpenSearch\Endpoints\AbstractEndpoint; use OpenSearch\Namespaces\NamespaceBuilderInterface; use OpenSearch\Namespaces\BooleanRequestWrapper; use OpenSearch\Namespaces\AsyncSearchNamespace; +use OpenSearch\Namespaces\AsynchronousSearchNamespace; use OpenSearch\Namespaces\CatNamespace; use OpenSearch\Namespaces\ClusterNamespace; use OpenSearch\Namespaces\DanglingIndicesNamespace; use OpenSearch\Namespaces\DataFrameTransformDeprecatedNamespace; +use OpenSearch\Namespaces\FlowFrameworkNamespace; use OpenSearch\Namespaces\IndicesNamespace; use OpenSearch\Namespaces\IngestNamespace; +use OpenSearch\Namespaces\IsmNamespace; use OpenSearch\Namespaces\KnnNamespace; use OpenSearch\Namespaces\MlNamespace; use OpenSearch\Namespaces\MonitoringNamespace; @@ -51,6 +55,7 @@ use OpenSearch\Namespaces\SslNamespace; use OpenSearch\Namespaces\TasksNamespace; use OpenSearch\Namespaces\TransformsNamespace; +use Psr\Http\Message\ResponseInterface; /** * Class Client @@ -61,190 +66,106 @@ class Client { public const VERSION = '2.3.1'; - /** - * @var Transport - */ - public $transport; + protected bool $isAsync; - /** - * @var array - */ - protected $params; + protected AsyncSearchNamespace $asyncSearch; - /** - * @var callable - */ - protected $endpoints; + protected AsynchronousSearchNamespace $asynchronousSearch; - /** - * @var NamespaceBuilderInterface[] - */ - protected $registeredNamespaces = []; + protected CatNamespace $cat; - /** - * @var AsyncSearchNamespace - */ - protected $asyncSearch; + protected ClusterNamespace $cluster; - /** - * @var CatNamespace - */ - protected $cat; + protected DanglingIndicesNamespace $danglingIndices; - /** - * @var ClusterNamespace - */ - protected $cluster; + protected DataFrameTransformDeprecatedNamespace $dataFrameTransformDeprecated; - /** - * @var DanglingIndicesNamespace - */ - protected $danglingIndices; + protected FlowFrameworkNamespace $flowFramework; - /** - * @var DataFrameTransformDeprecatedNamespace - */ - protected $dataFrameTransformDeprecated; + protected IndicesNamespace $indices; - /** - * @var IndicesNamespace - */ - protected $indices; + protected IngestNamespace $ingest; - /** - * @var IngestNamespace - */ - protected $ingest; + protected IsmNamespace $ism; - /** - * @var KnnNamespace - */ - protected $knn; + protected KnnNamespace $knn; - /** - * @var MlNamespace - */ - protected $ml; + protected MlNamespace $ml; - /** - * @var MonitoringNamespace - */ - protected $monitoring; + protected MonitoringNamespace $monitoring; - /** - * @var NodesNamespace - */ - protected $nodes; + protected NodesNamespace $nodes; - /** - * @var NotificationsNamespace - */ - protected $notifications; + protected NotificationsNamespace $notifications; - /** - * @var ObservabilityNamespace - */ - protected $observability; + protected ObservabilityNamespace $observability; - /** - * @var PplNamespace - */ - protected $ppl; + protected PplNamespace $ppl; - /** - * @var QueryNamespace - */ - protected $query; + protected QueryNamespace $query; - /** - * @var RemoteStoreNamespace - */ - protected $remoteStore; + protected RemoteStoreNamespace $remoteStore; - /** - * @var RollupsNamespace - */ - protected $rollups; + protected RollupsNamespace $rollups; - /** - * @var SearchPipelineNamespace - */ - protected $searchPipeline; + protected SearchPipelineNamespace $searchPipeline; - /** - * @var SearchableSnapshotsNamespace - */ - protected $searchableSnapshots; + protected SearchableSnapshotsNamespace $searchableSnapshots; - /** - * @var SecurityNamespace - */ - protected $security; + protected SecurityNamespace $security; - /** - * @var SnapshotNamespace - */ - protected $snapshot; + protected SnapshotNamespace $snapshot; - /** - * @var SqlNamespace - */ - protected $sql; + protected SqlNamespace $sql; - /** - * @var SslNamespace - */ - protected $ssl; + protected SslNamespace $ssl; - /** - * @var TasksNamespace - */ - protected $tasks; + protected TasksNamespace $tasks; - /** - * @var TransformsNamespace - */ - protected $transforms; + protected TransformsNamespace $transforms; /** * Client constructor * * @param Transport $transport - * @param callable $endpoint + * @param EndpointFactoryInterface $endpointFactory * @param NamespaceBuilderInterface[] $registeredNamespaces */ - public function __construct(Transport $transport, callable $endpoint, array $registeredNamespaces) - { - $this->transport = $transport; - $this->endpoints = $endpoint; - $this->asyncSearch = new AsyncSearchNamespace($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->indices = new IndicesNamespace($transport, $endpoint); - $this->ingest = new IngestNamespace($transport, $endpoint); - $this->knn = new KnnNamespace($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->registeredNamespaces = $registeredNamespaces; + public function __construct( + protected Transport $transport, + protected EndpointFactoryInterface $endpointFactory, + protected array $registeredNamespaces, + ) { + $this->asyncSearch = new AsyncSearchNamespace($this->transport, $this->endpointFactory); + $this->asynchronousSearch = new AsynchronousSearchNamespace($this->transport, $this->endpointFactory); + $this->cat = new CatNamespace($this->transport, $this->endpointFactory); + $this->cluster = new ClusterNamespace($this->transport, $this->endpointFactory); + $this->danglingIndices = new DanglingIndicesNamespace($this->transport, $this->endpointFactory); + $this->dataFrameTransformDeprecated = new DataFrameTransformDeprecatedNamespace($this->transport, $this->endpointFactory); + $this->flowFramework = new FlowFrameworkNamespace($this->transport, $this->endpointFactory); + $this->indices = new IndicesNamespace($this->transport, $this->endpointFactory); + $this->ingest = new IngestNamespace($this->transport, $this->endpointFactory); + $this->ism = new IsmNamespace($this->transport, $this->endpointFactory); + $this->knn = new KnnNamespace($this->transport, $this->endpointFactory); + $this->ml = new MlNamespace($this->transport, $this->endpointFactory); + $this->monitoring = new MonitoringNamespace($this->transport, $this->endpointFactory); + $this->nodes = new NodesNamespace($this->transport, $this->endpointFactory); + $this->notifications = new NotificationsNamespace($this->transport, $this->endpointFactory); + $this->observability = new ObservabilityNamespace($this->transport, $this->endpointFactory); + $this->ppl = new PplNamespace($this->transport, $this->endpointFactory); + $this->query = new QueryNamespace($this->transport, $this->endpointFactory); + $this->remoteStore = new RemoteStoreNamespace($this->transport, $this->endpointFactory); + $this->rollups = new RollupsNamespace($this->transport, $this->endpointFactory); + $this->searchPipeline = new SearchPipelineNamespace($this->transport, $this->endpointFactory); + $this->searchableSnapshots = new SearchableSnapshotsNamespace($this->transport, $this->endpointFactory); + $this->security = new SecurityNamespace($this->transport, $this->endpointFactory); + $this->snapshot = new SnapshotNamespace($this->transport, $this->endpointFactory); + $this->sql = new SqlNamespace($this->transport, $this->endpointFactory); + $this->ssl = new SslNamespace($this->transport, $this->endpointFactory); + $this->tasks = new TasksNamespace($this->transport, $this->endpointFactory); + $this->transforms = new TransformsNamespace($this->transport, $this->endpointFactory); + } /** @@ -257,14 +178,14 @@ public function __construct(Transport $transport, callable $endpoint, array $reg * $params['pipeline'] = (string) ID of the pipeline to use to preprocess incoming documents.If the index has a default ingest pipeline specified, then setting the value to `_none` disables the default ingest pipeline for this request.If a final pipeline is configured it will always run, regardless of the value of this parameter. * $params['refresh'] = (enum) If `true`, OpenSearch refreshes the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` do nothing with refreshes.Valid values: `true`, `false`, `wait_for`. (Options = false,true,wait_for) * $params['require_alias'] = (boolean) If `true`, the request's actions must target an index alias. (Default = false) - * $params['routing'] = (string) Custom value used to route operations to a specific shard. + * $params['routing'] = (any) Custom value used to route operations to a specific shard. * $params['timeout'] = (string) Period each action waits for the following operations: automatic index creation, dynamic mapping updates, waiting for active shards. * $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`). * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The operation definition and data (action-data pairs), separated by newlines (Required) * * @param array $params Associative array of parameters @@ -275,14 +196,52 @@ 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. + * + * $params['index'] = (string) Name of the data stream, index, or index alias to perform bulk actions on. + * $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 from the response. + * $params['_source_includes'] = (any) A comma-separated list of source fields to include in the response. + * $params['batch_interval'] = (string) Specifies for how long bulk operations should be accumulated into a batch before sending the batch to data nodes. + * $params['batch_size'] = (integer) Specifies how many bulk operations should be accumulated into a batch before sending the batch to data nodes. + * $params['pipeline'] = (string) ID of the pipeline to use to preprocess incoming documents.If the index has a default ingest pipeline specified, then setting the value to `_none` disables the default ingest pipeline for this request.If a final pipeline is configured it will always run, regardless of the value of this parameter. + * $params['refresh'] = (enum) If `true`, OpenSearch refreshes the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` do nothing with refreshes.Valid values: `true`, `false`, `wait_for`. (Options = false,true,wait_for) + * $params['require_alias'] = (boolean) If `true`, the request's actions must target an index alias. (Default = false) + * $params['routing'] = (any) Custom value used to route operations to a specific shard. + * $params['timeout'] = (string) Period each action waits for the following operations: automatic index creation, dynamic mapping updates, waiting for active shards. + * $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`). + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. + * $params['human'] = (boolean) Whether to return human readable values for statistics. + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. + * $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) The operation definition and data (action-data pairs), separated by newlines (Required) + * + * @param array $params Associative array of parameters + * @return array + */ + public function bulkStream(array $params = []) + { + $index = $this->extractArgument($params, 'index'); + $body = $this->extractArgument($params, 'body'); + + $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. * @@ -291,7 +250,7 @@ public function bulk(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 * * @param array $params Associative array of parameters @@ -302,14 +261,14 @@ 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. * @@ -326,13 +285,13 @@ public function clearScroll(array $params = []) * $params['min_score'] = (number) Sets the minimum `_score` value that documents must have to be included in the result. * $params['preference'] = (string) Specifies the node or shard the operation should be performed on.Random by default. (Default = random) * $params['q'] = (string) Query in the Lucene query string syntax. - * $params['routing'] = (string) Custom value used to route operations to a specific shard. - * $params['terminate_after'] = (number) 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. + * $params['routing'] = (any) Custom value used to route operations to a specific shard. + * $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. * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) Query to restrict the results specified with the Query DSL (optional) * * @param array $params Associative array of parameters @@ -343,14 +302,14 @@ 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. * @@ -359,12 +318,12 @@ public function count(array $params = []) * $params['expand_wildcards'] = (any) Whether to expand wildcard expression to concrete indices 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'] = (array) Comma-separated list of specific routing values. + * $params['routing'] = (any) Comma-separated list of specific routing values. * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -373,31 +332,31 @@ 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. * * $params['id'] = (string) Unique identifier for the document. (Required) * $params['index'] = (string) Name of the target index. (Required) - * $params['if_primary_term'] = (number) Only perform the operation if the document has this primary term. - * $params['if_seq_no'] = (number) Only perform the operation if the document has this sequence number. + * $params['if_primary_term'] = (integer) Only perform the operation if the document has this primary term. + * $params['if_seq_no'] = (integer) Only perform the operation if the document has this sequence number. * $params['refresh'] = (enum) If `true`, OpenSearch refreshes the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` do nothing with refreshes.Valid values: `true`, `false`, `wait_for`. (Options = false,true,wait_for) - * $params['routing'] = (string) Custom value used to route operations to a specific shard. + * $params['routing'] = (any) Custom value used to route operations to a specific shard. * $params['timeout'] = (string) Period to wait for active shards. - * $params['version'] = (number) Explicit version number for concurrency control.The specified version must match the current version of the document for the request to succeed. + * $params['version'] = (integer) Explicit version number for concurrency control.The specified version must match the current version of the document for the request to succeed. * $params['version_type'] = (enum) Specific version type: `external`, `external_gte`. (Options = external,external_gte,force,internal) * $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`). * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -407,14 +366,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. * @@ -422,19 +381,19 @@ public function delete(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -449,25 +408,25 @@ public function deleteAllPits(array $params = []) * $params['default_operator'] = (enum) The default operator for query string query: `AND` or `OR`. (Options = and,or) * $params['df'] = (string) Field to use as default where no field prefix is given in the query string. * $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['from'] = (number) Starting offset. (Default = 0) + * $params['from'] = (integer) Starting offset. (Default = 0) * $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['max_docs'] = (number) Maximum number of documents to process.Defaults to all documents. + * $params['max_docs'] = (integer) Maximum number of documents to process.Defaults to all documents. * $params['preference'] = (string) Specifies the node or shard the operation should be performed on.Random by default. (Default = random) * $params['q'] = (string) Query in the Lucene query string syntax. * $params['refresh'] = (boolean) If `true`, OpenSearch refreshes all shards involved in the delete by query after the request completes. * $params['request_cache'] = (boolean) If `true`, the request cache is used for this request.Defaults to the index-level setting. * $params['requests_per_second'] = (number) The throttle for this request in sub-requests per second. (Default = 0) - * $params['routing'] = (string) Custom value used to route operations to a specific shard. + * $params['routing'] = (any) Custom value used to route operations to a specific shard. * $params['scroll'] = (string) Period to retain the search context for scrolling. - * $params['scroll_size'] = (number) Size of the scroll request that powers the operation. (Default = 100) + * $params['scroll_size'] = (integer) Size of the scroll request that powers the operation. (Default = 100) * $params['search_timeout'] = (string) Explicit timeout for each search request.Defaults to no timeout. * $params['search_type'] = (enum) The type of the search operation.Available options: `query_then_fetch`, `dfs_query_then_fetch`. (Options = dfs_query_then_fetch,query_then_fetch) * $params['size'] = (integer) Deprecated, please use `max_docs` instead. * $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'] = (number) 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 indices 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`). @@ -476,7 +435,7 @@ public function deleteAllPits(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The search definition using the Query DSL (Required) * * @param array $params Associative array of parameters @@ -487,14 +446,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. * @@ -504,7 +463,7 @@ public function deleteByQuery(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -513,13 +472,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. * @@ -527,7 +486,7 @@ public function deleteByQueryRethrottle(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The point-in-time ids to be deleted * * @param array $params Associative array of parameters @@ -537,13 +496,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. * @@ -555,7 +514,7 @@ public function deletePit(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -564,13 +523,13 @@ 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. * @@ -582,15 +541,15 @@ public function deleteScript(array $params = []) * $params['preference'] = (string) Specifies the node or shard the operation should be performed on.Random by default. (Default = random) * $params['realtime'] = (boolean) If `true`, the request is real-time as opposed to near-real-time. * $params['refresh'] = (boolean) If `true`, OpenSearch refreshes all shards involved in the delete by query after the request completes. - * $params['routing'] = (string) Target the specified primary shard. + * $params['routing'] = (any) Target the specified primary shard. * $params['stored_fields'] = (any) List of stored fields to return as part of a hit.If no fields are specified, no stored fields are included in the response.If this field is specified, the `_source` parameter defaults to false. - * $params['version'] = (number) Explicit version number for concurrency control.The specified version must match the current version of the document for the request to succeed. + * $params['version'] = (integer) Explicit version number for concurrency control.The specified version must match the current version of the document for the request to succeed. * $params['version_type'] = (enum) Specific version type: `external`, `external_gte`. (Options = external,external_gte,force,internal) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return bool @@ -603,14 +562,14 @@ 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. * @@ -622,14 +581,14 @@ public function exists(array $params = []): bool * $params['preference'] = (string) Specifies the node or shard the operation should be performed on.Random by default. (Default = random) * $params['realtime'] = (boolean) If true, the request is real-time as opposed to near-real-time. * $params['refresh'] = (boolean) If `true`, OpenSearch refreshes all shards involved in the delete by query after the request completes. - * $params['routing'] = (string) Target the specified primary shard. - * $params['version'] = (number) Explicit version number for concurrency control.The specified version must match the current version of the document for the request to succeed. + * $params['routing'] = (any) Target the specified primary shard. + * $params['version'] = (integer) Explicit version number for concurrency control.The specified version must match the current version of the document for the request to succeed. * $params['version_type'] = (enum) Specific version type: `external`, `external_gte`. (Options = external,external_gte,force,internal) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return bool @@ -642,14 +601,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. * @@ -665,13 +624,13 @@ public function existsSource(array $params = []): bool * $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['preference'] = (string) Specifies the node or shard the operation should be performed on.Random by default. (Default = random) * $params['q'] = (string) Query in the Lucene query string syntax. - * $params['routing'] = (string) Custom value used to route operations to a specific shard. + * $params['routing'] = (any) Custom value used to route operations to a specific shard. * $params['stored_fields'] = (any) A comma-separated list of stored fields to return in the response. * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The query definition using the Query DSL * * @param array $params Associative array of parameters @@ -683,8 +642,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); @@ -692,6 +650,7 @@ public function explain(array $params = []) return $this->performRequest($endpoint); } + /** * Returns the information about the capabilities of fields among multiple indices. * @@ -705,7 +664,7 @@ public function explain(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) An index filter specified with the Query DSL * * @param array $params Associative array of parameters @@ -716,14 +675,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. * @@ -735,15 +694,15 @@ public function fieldCaps(array $params = []) * $params['preference'] = (string) Specifies the node or shard the operation should be performed on. Random by default. (Default = random) * $params['realtime'] = (boolean) If `true`, the request is real-time as opposed to near-real-time. * $params['refresh'] = (boolean) If true, OpenSearch refreshes the affected shards to make this operation visible to search. If false, do nothing with refreshes. - * $params['routing'] = (string) Target the specified primary shard. + * $params['routing'] = (any) Target the specified primary shard. * $params['stored_fields'] = (any) List of stored fields to return as part of a hit.If no fields are specified, no stored fields are included in the response.If this field is specified, the `_source` parameter defaults to false. - * $params['version'] = (number) Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed. + * $params['version'] = (integer) Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed. * $params['version_type'] = (enum) Specific version type: internal, external, external_gte. (Options = external,external_gte,force,internal) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -753,14 +712,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. * @@ -768,19 +727,19 @@ public function get(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -791,7 +750,7 @@ public function getAllPits(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -800,13 +759,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. * @@ -814,19 +773,19 @@ public function getScript(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -834,19 +793,19 @@ public function getScriptContext(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -858,14 +817,14 @@ public function getScriptLanguages(array $params = []) * $params['preference'] = (string) Specifies the node or shard the operation should be performed on. Random by default. (Default = random) * $params['realtime'] = (boolean) Boolean) If true, the request is real-time as opposed to near-real-time. * $params['refresh'] = (boolean) If true, OpenSearch refreshes the affected shards to make this operation visible to search. If false, do nothing with refreshes. - * $params['routing'] = (string) Target the specified primary shard. - * $params['version'] = (number) Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed. + * $params['routing'] = (any) Target the specified primary shard. + * $params['version'] = (integer) Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed. * $params['version_type'] = (enum) Specific version type: internal, external, external_gte. (Options = external,external_gte,force,internal) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -875,35 +834,35 @@ 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. * * $params['index'] = (string) Name of the data stream or index to target. (Required) * $params['id'] = (string) Unique identifier for the document. - * $params['if_primary_term'] = (number) Only perform the operation if the document has this primary term. - * $params['if_seq_no'] = (number) Only perform the operation if the document has this sequence number. + * $params['if_primary_term'] = (integer) Only perform the operation if the document has this primary term. + * $params['if_seq_no'] = (integer) Only perform the operation if the document has this sequence number. * $params['op_type'] = (enum) Set to create to only index the document if it does not already exist (put if absent).If a document with the specified `_id` already exists, the indexing operation will fail.Same as using the `/_create` endpoint.Valid values: `index`, `create`.If document id is specified, it defaults to `index`.Otherwise, it defaults to `create`. (Options = create,index) * $params['pipeline'] = (string) ID of the pipeline to use to preprocess incoming documents.If the index has a default ingest pipeline specified, then setting the value to `_none` disables the default ingest pipeline for this request.If a final pipeline is configured it will always run, regardless of the value of this parameter. * $params['refresh'] = (enum) If `true`, OpenSearch refreshes the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` do nothing with refreshes.Valid values: `true`, `false`, `wait_for`. (Options = false,true,wait_for) * $params['require_alias'] = (boolean) If `true`, the destination must be an index alias. (Default = false) - * $params['routing'] = (string) Custom value used to route operations to a specific shard. + * $params['routing'] = (any) Custom value used to route operations to a specific shard. * $params['timeout'] = (string) Period the request waits for the following operations: automatic index creation, dynamic mapping updates, waiting for active shards. - * $params['version'] = (number) Explicit version number for concurrency control.The specified version must match the current version of the document for the request to succeed. + * $params['version'] = (integer) Explicit version number for concurrency control.The specified version must match the current version of the document for the request to succeed. * $params['version_type'] = (enum) Specific version type: `external`, `external_gte`. (Options = external,external_gte,force,internal) * $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`). * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The document (Required) * * @param array $params Associative array of parameters @@ -915,8 +874,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); @@ -924,6 +882,7 @@ public function index(array $params = []) return $this->performRequest($endpoint); } + /** * Returns basic information about the cluster. * @@ -931,19 +890,19 @@ public function index(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -954,13 +913,13 @@ public function info(array $params = []) * $params['preference'] = (string) Specifies the node or shard the operation should be performed on. Random by default. (Default = random) * $params['realtime'] = (boolean) If `true`, the request is real-time as opposed to near-real-time. * $params['refresh'] = (boolean) If `true`, the request refreshes relevant shards before retrieving documents. - * $params['routing'] = (string) Custom value used to route operations to a specific shard. + * $params['routing'] = (any) Custom value used to route operations to a specific shard. * $params['stored_fields'] = (any) If `true`, retrieves the document fields stored in the index rather than the document `_source`. * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) Document identifiers; can be either `docs` (containing full document information) or `ids` (when index is provided in the URL. (Required) * * @param array $params Associative array of parameters @@ -971,22 +930,22 @@ 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['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'] = (number) Maximum number of concurrent searches the multi search API can execute. - * $params['max_concurrent_shard_requests'] = (number) Maximum number of concurrent shard requests that each sub-search request executes per node. (Default = 5) - * $params['pre_filter_shard_size'] = (number) Defines a threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method i.e., if date filters are mandatory to match but the shard bounds and the query are disjoint. + * $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) + * $params['pre_filter_shard_size'] = (integer) Defines a threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method i.e., if date filters are mandatory to match but the shard bounds and the query are disjoint. * $params['rest_total_hits_as_int'] = (boolean) If true, hits.total are returned as an integer in the response. Defaults to false, which returns an object. (Default = false) * $params['search_type'] = (enum) Indicates whether global term and document frequencies should be used when scoring returned documents. (Options = dfs_query_then_fetch,query_then_fetch) * $params['typed_keys'] = (boolean) Specifies whether aggregation and suggester names should be prefixed by their respective types in the response. @@ -994,7 +953,7 @@ public function mget(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The request definitions (metadata-search request definition pairs), separated by newlines (Required) * * @param array $params Associative array of parameters @@ -1005,20 +964,20 @@ 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['ccs_minimize_roundtrips'] = (boolean) If `true`, network round-trips are minimized for cross-cluster search requests. (Default = true) - * $params['max_concurrent_searches'] = (number) Maximum number of concurrent searches the API can run. + * $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) * $params['search_type'] = (enum) The type of the search operation.Available options: `query_then_fetch`, `dfs_query_then_fetch`. (Options = dfs_query_then_fetch,query_then_fetch) * $params['typed_keys'] = (boolean) If `true`, the response prefixes aggregation and suggester names with their respective types. @@ -1026,7 +985,7 @@ public function msearch(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The request definitions (metadata-search request definition pairs), separated by newlines (Required) * * @param array $params Associative array of parameters @@ -1037,14 +996,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. * @@ -1057,15 +1016,15 @@ public function msearchTemplate(array $params = []) * $params['positions'] = (boolean) If `true`, the response includes term positions. (Default = true) * $params['preference'] = (string) Specifies the node or shard the operation should be performed on.Random by default. (Default = random) * $params['realtime'] = (boolean) If true, the request is real-time as opposed to near-real-time. (Default = true) - * $params['routing'] = (string) Custom value used to route operations to a specific shard. + * $params['routing'] = (any) Custom value used to route operations to a specific shard. * $params['term_statistics'] = (boolean) If true, the response includes term frequency and document frequency. (Default = false) - * $params['version'] = (number) If `true`, returns the document version as part of a hit. + * $params['version'] = (integer) If `true`, returns the document version as part of a hit. * $params['version_type'] = (enum) Specific version type. (Options = external,external_gte,force,internal) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) Define ids, documents, parameters or a list of parameters per document here. You must at least provide a list of document ids. See documentation. * * @param array $params Associative array of parameters @@ -1076,14 +1035,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. * @@ -1091,7 +1050,7 @@ public function mtermvectors(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return bool @@ -1101,12 +1060,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. * @@ -1119,7 +1078,7 @@ public function ping(array $params = []): bool * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The document (Required) * * @param array $params Associative array of parameters @@ -1131,8 +1090,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); @@ -1140,6 +1098,7 @@ 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. * @@ -1147,12 +1106,12 @@ public function putScript(array $params = []) * $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['search_type'] = (string) Search operation type + * $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. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The ranking evaluation search definition, including search requests, document ratings and ranking metric definition. (Required) * * @param array $params Associative array of parameters @@ -1163,14 +1122,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. * @@ -1186,7 +1145,7 @@ public function rankEval(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The search definition using the Query DSL and the prototype for the index request. (Required) * * @param array $params Associative array of parameters @@ -1196,13 +1155,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. * @@ -1212,7 +1171,7 @@ public function reindex(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -1221,13 +1180,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. * @@ -1236,7 +1195,7 @@ public function reindexRethrottle(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The search definition template and its params * * @param array $params Associative array of parameters @@ -1247,14 +1206,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. * @@ -1262,7 +1221,7 @@ public function renderSearchTemplate(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The script to execute * * @param array $params Associative array of parameters @@ -1272,13 +1231,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. * @@ -1289,7 +1248,7 @@ public function scriptsPainlessExecute(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The scroll ID if not passed by URL or query parameter. * * @param array $params Associative array of parameters @@ -1300,14 +1259,14 @@ 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. * @@ -1319,7 +1278,7 @@ public function scroll(array $params = []) * $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. - * $params['batched_reduce_size'] = (number) The number of shard results that should be reduced at once on the coordinating node.This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large. (Default = 512) + * $params['batched_reduce_size'] = (integer) The number of shard results that should be reduced at once on the coordinating node.This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large. (Default = 512) * $params['cancel_after_time_interval'] = (string) The time after which the search request will be canceled.Request-level parameter takes precedence over `cancel_after_time_interval` cluster setting. * $params['ccs_minimize_roundtrips'] = (boolean) If true, network round-trips between the coordinating node and the remote clusters are minimized when executing cross-cluster search (CCS) requests. (Default = true) * $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) @@ -1327,32 +1286,32 @@ public function scroll(array $params = []) * $params['docvalue_fields'] = (any) A comma-separated list of fields to return as the docvalue representation for each hit. * $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'] = (number) 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['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_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. - * $params['max_concurrent_shard_requests'] = (number) Defines 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['max_concurrent_shard_requests'] = (integer) Defines 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['phase_took'] = (boolean) Indicates whether to return phase-level `took` time values in the response. (Default = false) - * $params['pre_filter_shard_size'] = (number) Defines a threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold.This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method (if date filters are mandatory to match but the shard bounds and the query are disjoint).When unspecified, the pre-filter phase is executed if any of these conditions is met:the request targets more than 128 shards;the request targets one or more read-only index;the primary sort of the query targets an indexed field. + * $params['pre_filter_shard_size'] = (integer) Defines a threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold.This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method (if date filters are mandatory to match but the shard bounds and the query are disjoint).When unspecified, the pre-filter phase is executed if any of these conditions is met:the request targets more than 128 shards;the request targets one or more read-only index;the primary sort of the query targets an indexed field. * $params['preference'] = (string) Nodes and shards used for the search.By default, OpenSearch selects from eligible nodes and shards using adaptive replica selection, accounting for allocation awareness. Valid values are:`_only_local` to run the search only on shards on the local node;`_local` to, if possible, run the search on shards on the local node, or if not, select shards using the default method;`_only_nodes:,` to run the search on only the specified nodes IDs, where, if suitable shards exist on more than one selected node, use shards on those nodes using the default method, or if none of the specified nodes are available, select shards from any available node using the default method;`_prefer_nodes:,` to if possible, run the search on the specified nodes IDs, or if not, select shards using the default method;`_shards:,` to run the search only on the specified shards;`` (any string that does not start with `_`) to route searches with the same `` to the same shards in the same order. (Default = random) * $params['q'] = (string) Query in the Lucene query string syntax using query parameter search.Query parameter searches do not support the full OpenSearch Query DSL but are handy for testing. * $params['request_cache'] = (boolean) If `true`, the caching of search results is enabled for requests where `size` is `0`.Defaults to index level settings. * $params['rest_total_hits_as_int'] = (boolean) Indicates whether `hits.total` should be rendered as an integer or an object in the rest search response. (Default = false) - * $params['routing'] = (string) Custom value used to route operations to a specific shard. + * $params['routing'] = (any) Custom value used to route operations to a specific shard. * $params['scroll'] = (string) Period to retain the search context for scrolling. See Scroll search results.By default, this value cannot exceed `1d` (24 hours).You can change this limit using the `search.max_keep_alive` cluster-level setting. * $params['search_pipeline'] = (string) Customizable sequence of processing stages applied to search queries. * $params['search_type'] = (enum) How distributed term frequencies are calculated for relevance scoring. (Options = dfs_query_then_fetch,query_then_fetch) * $params['seq_no_primary_term'] = (boolean) If `true`, returns sequence number and primary term of the last modification of each hit. - * $params['size'] = (number) Defines the number of hits to return.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 = 10) + * $params['size'] = (integer) Defines the number of hits to return.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 = 10) * $params['sort'] = (any) A comma-separated list of : pairs. * $params['stats'] = (array) Specific `tag` of the request for logging and statistical purposes. * $params['stored_fields'] = (any) A comma-separated list of stored fields to return as part of a hit.If no fields are specified, no stored fields are included in the response.If this field is specified, the `_source` parameter defaults to `false`.You can pass `_source: true` to return both source fields and stored fields in the search response. * $params['suggest_field'] = (string) Specifies which field to use for suggestions. * $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'] = (number) 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_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'] = (number) 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 indices 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. @@ -1362,7 +1321,7 @@ public function scroll(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The search definition using the Query DSL * * @param array $params Associative array of parameters @@ -1373,14 +1332,14 @@ 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. * @@ -1390,12 +1349,12 @@ public function search(array $params = []) * $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) * $params['preference'] = (string) Specifies the node or shard the operation should be performed on.Random by default. (Default = random) - * $params['routing'] = (string) Custom value used to route operations to a specific shard. + * $params['routing'] = (any) Custom value used to route operations to a specific shard. * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -1404,13 +1363,13 @@ 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. * @@ -1424,7 +1383,7 @@ public function searchShards(array $params = []) * $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. * $params['rest_total_hits_as_int'] = (boolean) If true, hits.total are rendered as an integer in the response. (Default = false) - * $params['routing'] = (string) Custom value used to route operations to a specific shard. + * $params['routing'] = (any) Custom value used to route operations to a specific shard. * $params['scroll'] = (string) Specifies how long a consistent view of the indexshould be maintained for scrolled search. * $params['search_type'] = (enum) The type of the search operation. (Options = dfs_query_then_fetch,query_then_fetch) * $params['typed_keys'] = (boolean) If `true`, the response prefixes aggregation and suggester names with their respective types. @@ -1432,7 +1391,7 @@ public function searchShards(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The search definition template and its params (Required) * * @param array $params Associative array of parameters @@ -1443,14 +1402,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. * @@ -1463,15 +1422,15 @@ public function searchTemplate(array $params = []) * $params['positions'] = (boolean) If `true`, the response includes term positions. (Default = true) * $params['preference'] = (string) Specifies the node or shard the operation should be performed on.Random by default. (Default = random) * $params['realtime'] = (boolean) If true, the request is real-time as opposed to near-real-time. (Default = true) - * $params['routing'] = (string) Custom value used to route operations to a specific shard. + * $params['routing'] = (any) Custom value used to route operations to a specific shard. * $params['term_statistics'] = (boolean) If `true`, the response includes term frequency and document frequency. (Default = false) - * $params['version'] = (number) If `true`, returns the document version as part of a hit. + * $params['version'] = (integer) If `true`, returns the document version as part of a hit. * $params['version_type'] = (enum) Specific version type. (Options = external,external_gte,force,internal) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) Define parameters and or supply a document to get termvectors for. See documentation. * * @param array $params Associative array of parameters @@ -1483,8 +1442,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); @@ -1492,6 +1450,7 @@ public function termvectors(array $params = []) return $this->performRequest($endpoint); } + /** * Updates a document with a script or partial document. * @@ -1500,20 +1459,20 @@ public function termvectors(array $params = []) * $params['_source'] = (any) Set to false to disable source retrieval. You can also specify a comma-separatedlist of the fields you want to retrieve. * $params['_source_excludes'] = (any) Specify the source fields you want to exclude. * $params['_source_includes'] = (any) Specify the source fields you want to retrieve. - * $params['if_primary_term'] = (number) Only perform the operation if the document has this primary term. - * $params['if_seq_no'] = (number) Only perform the operation if the document has this sequence number. + * $params['if_primary_term'] = (integer) Only perform the operation if the document has this primary term. + * $params['if_seq_no'] = (integer) Only perform the operation if the document has this sequence number. * $params['lang'] = (string) The script language. (Default = painless) * $params['refresh'] = (enum) If 'true', OpenSearch refreshes the affected shards to make this operationvisible to search, if 'wait_for' then wait for a refresh to make this operationvisible to search, if 'false' do nothing with refreshes. (Options = false,true,wait_for) * $params['require_alias'] = (boolean) If true, the destination must be an index alias. (Default = false) - * $params['retry_on_conflict'] = (number) Specify how many times should the operation be retried when a conflict occurs. (Default = 0) - * $params['routing'] = (string) Custom value used to route operations to a specific shard. + * $params['retry_on_conflict'] = (integer) Specify how many times should the operation be retried when a conflict occurs. (Default = 0) + * $params['routing'] = (any) Custom value used to route operations to a specific shard. * $params['timeout'] = (string) Period to wait for dynamic mapping updates and active shards.This guarantees OpenSearch waits for at least the timeout before failing.The actual wait time could be longer, particularly when multiple waits occur. * $params['wait_for_active_shards'] = (any) The number of shard copies that must be active before proceeding with the operations.Set to 'all' or any positive integer up to the total number of shards in the index(number_of_replicas+1). Defaults to 1 meaning the primary shard. * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The request definition requires either `script` or partial `doc` (Required) * * @param array $params Associative array of parameters @@ -1525,8 +1484,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); @@ -1534,6 +1492,7 @@ 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. * @@ -1548,26 +1507,26 @@ public function update(array $params = []) * $params['default_operator'] = (enum) The default operator for query string query: `AND` or `OR`. (Options = and,or) * $params['df'] = (string) Field to use as default where no field prefix is given in the query string. * $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['from'] = (number) Starting offset. (Default = 0) + * $params['from'] = (integer) Starting offset. (Default = 0) * $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['max_docs'] = (number) Maximum number of documents to process.Defaults to all documents. + * $params['max_docs'] = (integer) Maximum number of documents to process.Defaults to all documents. * $params['pipeline'] = (string) ID of the pipeline to use to preprocess incoming documents.If the index has a default ingest pipeline specified, then setting the value to `_none` disables the default ingest pipeline for this request.If a final pipeline is configured it will always run, regardless of the value of this parameter. * $params['preference'] = (string) Specifies the node or shard the operation should be performed on.Random by default. (Default = random) * $params['q'] = (string) Query in the Lucene query string syntax. * $params['refresh'] = (boolean) If `true`, OpenSearch refreshes affected shards to make the operation visible to search. * $params['request_cache'] = (boolean) If `true`, the request cache is used for this request. * $params['requests_per_second'] = (number) The throttle for this request in sub-requests per second. (Default = 0) - * $params['routing'] = (string) Custom value used to route operations to a specific shard. + * $params['routing'] = (any) Custom value used to route operations to a specific shard. * $params['scroll'] = (string) Period to retain the search context for scrolling. - * $params['scroll_size'] = (number) Size of the scroll request that powers the operation. (Default = 100) + * $params['scroll_size'] = (integer) Size of the scroll request that powers the operation. (Default = 100) * $params['search_timeout'] = (string) Explicit timeout for each search request. * $params['search_type'] = (enum) The type of the search operation. Available options: `query_then_fetch`, `dfs_query_then_fetch`. (Options = dfs_query_then_fetch,query_then_fetch) * $params['size'] = (integer) Deprecated, please use `max_docs` instead. * $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'] = (number) 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 indices 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`). @@ -1576,7 +1535,7 @@ public function update(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The search definition using the Query DSL * * @param array $params Associative array of parameters @@ -1587,14 +1546,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. * @@ -1604,7 +1563,7 @@ public function updateByQuery(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -1613,13 +1572,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. @@ -1648,7 +1607,7 @@ public function createPointInTime(array $params = []) * $params['body'] = (array) The document (Required) * * @param array $params Associative array of parameters - * @return array + * @return \Http\Promise\Promise|\Psr\Http\Message\ResponseInterface */ public function create(array $params = []) { @@ -1680,6 +1639,13 @@ public function asyncSearch(): AsyncSearchNamespace { return $this->asyncSearch; } + /** + * Returns the asynchronousSearch namespace + */ + public function asynchronousSearch(): AsynchronousSearchNamespace + { + return $this->asynchronousSearch; + } /** * Returns the cat namespace */ @@ -1708,6 +1674,13 @@ public function dataFrameTransformDeprecated(): DataFrameTransformDeprecatedName { return $this->dataFrameTransformDeprecated; } + /** + * Returns the flowFramework namespace + */ + public function flowFramework(): FlowFrameworkNamespace + { + return $this->flowFramework; + } /** * Returns the indices namespace */ @@ -1722,6 +1695,13 @@ public function ingest(): IngestNamespace { return $this->ingest; } + /** + * Returns the ism namespace + */ + public function ism(): IsmNamespace + { + return $this->ism; + } /** * Returns the knn namespace */ @@ -1883,34 +1863,57 @@ public function extractArgument(array &$params, string $arg) } /** - * Sends a raw request to the cluster - * @return callable|array - * @throws NoNodesAvailableException + * Check if the client is running in async mode. */ - public function request(string $method, string $uri, array $attributes = []) + public function isAsync(): bool + { + return $this->isAsync; + } + + /** + * Set the client to run in async mode. + */ + public function setAsync(bool $isAsync): static + { + $this->isAsync = $isAsync; + return $this; + } + + /** + * Sends a raw request to the cluster. + * + * @throws \Psr\Http\Client\ClientExceptionInterface|\Exception + */ + public function request(string $method, string $uri, array $attributes = []): Promise|ResponseInterface { $params = $attributes['params'] ?? []; $body = $attributes['body'] ?? null; - $options = $attributes['options'] ?? []; - $promise = $this->transport->performRequest($method, $uri, $params, $body, $options); + $request = $this->transport->createRequest($method, $uri, $params, $body); - return $this->transport->resultOrFuture($promise, $options); + if ($this->isAsync()) { + return $this->transport->sendAsyncRequest($request); + } + return $this->transport->sendRequest($request); } /** - * @return callable|array + * Perform the request. + * + * @throws \Psr\Http\Client\ClientExceptionInterface|\Exception */ - private function performRequest(AbstractEndpoint $endpoint) + private function performRequest(EndpointInterface $endpoint): Promise|ResponseInterface { - $promise = $this->transport->performRequest( + $request = $this->transport->createRequest( $endpoint->getMethod(), $endpoint->getURI(), $endpoint->getParams(), $endpoint->getBody(), - $endpoint->getOptions() ); - - return $this->transport->resultOrFuture($promise, $endpoint->getOptions()); + if ($this->isAsync()) { + return $this->transport->sendAsyncRequest($request); + } + return $this->transport->sendRequest($request); } + } diff --git a/src/OpenSearch/ClientBuilder.php b/src/OpenSearch/ClientBuilder.php index 1865bc3d..bcaa99c0 100644 --- a/src/OpenSearch/ClientBuilder.php +++ b/src/OpenSearch/ClientBuilder.php @@ -21,558 +21,56 @@ namespace OpenSearch; -use Aws\Credentials\CredentialProvider; -use Aws\Credentials\Credentials; -use Aws\Credentials\CredentialsInterface; -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; -use OpenSearch\ConnectionPool\StaticNoPingConnectionPool; -use OpenSearch\Connections\ConnectionFactory; -use OpenSearch\Connections\ConnectionFactoryInterface; -use OpenSearch\Connections\ConnectionInterface; -use OpenSearch\Handlers\SigV4Handler; 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 Psr\Log\LoggerInterface; -use Psr\Log\NullLogger; -use ReflectionClass; class ClientBuilder { public const ALLOWED_METHODS_FROM_CONFIG = ['includePortInHostHeader']; /** - * @var Transport|null + * @var array */ - private $transport; + private array $registeredNamespacesBuilders = []; /** - * @var callable|null + * The serializer. */ - private $endpoint; + private ?SerializerInterface $serializer = null; /** - * @var NamespaceBuilderInterface[] + * The endpoint factory. */ - private $registeredNamespacesBuilders = []; + private ?EndpointFactory $endpointFactory = null; /** - * @var ConnectionFactoryInterface|null + * Create a new ClientBuilder. */ - private $connectionFactory; - - /** - * @var callable|null - */ - private $handler; - - /** - * @var LoggerInterface|null - */ - private $logger; - - /** - * @var LoggerInterface|null - */ - private $tracer; - - /** - * @var string|AbstractConnectionPool - */ - private $connectionPool = StaticNoPingConnectionPool::class; - - /** - * @var string|SerializerInterface|null - */ - private $serializer = SmartSerializer::class; - - /** - * @var string|SelectorInterface|null - */ - private $selector = RoundRobinSelector::class; - - /** - * @var array - */ - private $connectionPoolArgs = [ - 'randomizeHosts' => true - ]; - - /** - * @var array|null - */ - private $hosts; - - /** - * @var array - */ - private $connectionParams; - - /** - * @var int|null - */ - private $retries; - - /** - * @var null|callable - */ - private $sigV4CredentialProvider; - - /** - * @var null|string - */ - private $sigV4Region; - - /** - * @var null|string - */ - private $sigV4Service; - - /** - * @var bool - */ - private $sniffOnStart = false; - - /** - * @var null|array - */ - private $sslCert; - - /** - * @var null|array - */ - private $sslKey; - - /** - * @var null|bool|string - */ - private $sslVerification; - - /** - * @var bool - */ - private $includePortInHostHeader = false; - - /** - * @var string|null - */ - private $basicAuthentication = null; - - /** - * Create an instance of ClientBuilder - */ - public static function create(): ClientBuilder - { - return new self(); - } - - /** - * Can supply first param to Client::__construct() when invoking manually or with dependency injection - */ - 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 - * - * @return NamespaceBuilderInterface[] - */ - public function getRegisteredNamespacesBuilders(): array - { - return $this->registeredNamespacesBuilders; - } - - /** - * Build a new client from the provided config. Hash keys - * should correspond to the method name e.g. ['connectionPool'] - * corresponds to setConnectionPool(). - * - * Missing keys will use the default for that setting if applicable - * - * Unknown keys will throw an exception by default, but this can be silenced - * by setting `quiet` to true - * - * @param array $config - * @param bool $quiet False if unknown settings throw exception, true to silently - * ignore unknown settings - * @throws Common\Exceptions\RuntimeException - */ - public static function fromConfig(array $config, bool $quiet = false): Client - { - $builder = new self(); - foreach ($config as $key => $value) { - $method = in_array($key, self::ALLOWED_METHODS_FROM_CONFIG, true) ? $key : "set$key"; - $reflection = new ReflectionClass($builder); - if ($reflection->hasMethod($method)) { - $func = $reflection->getMethod($method); - if ($func->getNumberOfParameters() > 1) { - $builder->$method(...$value); - } else { - $builder->$method($value); - } - unset($config[$key]); - } - } - - if ($quiet === false && count($config) > 0) { - $unknown = implode(array_keys($config)); - throw new RuntimeException("Unknown parameters provided: $unknown"); - } - return $builder->build(); - } - - /** - * Get the default handler - * - * @param array $multiParams - * @param array $singleParams - * @throws \RuntimeException - */ - public static function defaultHandler(array $multiParams = [], array $singleParams = []): callable - { - $future = null; - if (extension_loaded('curl')) { - $config = array_merge([ 'mh' => curl_multi_init() ], $multiParams); - if (function_exists('curl_reset')) { - $default = new CurlHandler($singleParams); - $future = new CurlMultiHandler($config); - } else { - $default = new CurlMultiHandler($config); - } - } else { - throw new \RuntimeException('OpenSearch-PHP requires cURL, or a custom HTTP handler.'); - } - - return $future ? Middleware::wrapFuture($default, $future) : $default; - } - - /** - * Get the multi handler for async (CurlMultiHandler) - * - * @throws \RuntimeException - */ - public static function multiHandler(array $params = []): CurlMultiHandler - { - if (function_exists('curl_multi_init')) { - return new CurlMultiHandler(array_merge([ 'mh' => curl_multi_init() ], $params)); - } - - throw new \RuntimeException('CurlMulti handler requires cURL.'); - } - - /** - * Get the handler instance (CurlHandler) - * - * @throws \RuntimeException - */ - public static function singleHandler(): CurlHandler - { - if (function_exists('curl_reset')) { - return new CurlHandler(); - } - - throw new \RuntimeException('CurlSingle handler requires cURL.'); - } - - /** - * Set connection Factory - * - * @param ConnectionFactoryInterface $connectionFactory - */ - public function setConnectionFactory(ConnectionFactoryInterface $connectionFactory): ClientBuilder + public function __construct(protected readonly Transport $transport) { - $this->connectionFactory = $connectionFactory; - - return $this; - } - - /** - * Set the connection pool (default is StaticNoPingConnectionPool) - * - * @param AbstractConnectionPool|string $connectionPool - * @param array $args - * @throws \InvalidArgumentException - */ - public function setConnectionPool($connectionPool, array $args = []): ClientBuilder - { - if (is_string($connectionPool)) { - $this->connectionPool = $connectionPool; - $this->connectionPoolArgs = $args; - } elseif (is_object($connectionPool)) { - $this->connectionPool = $connectionPool; - } else { - throw new InvalidArgumentException("Serializer must be a class path or instantiated object extending AbstractConnectionPool"); - } - - return $this; - } - - /** - * Set the endpoint - * - * @param callable $endpoint - */ - public function setEndpoint(callable $endpoint): ClientBuilder - { - $this->endpoint = $endpoint; - - return $this; - } - - /** - * Register namespace - * - * @param NamespaceBuilderInterface $namespaceBuilder - */ - public function registerNamespace(NamespaceBuilderInterface $namespaceBuilder): ClientBuilder - { - $this->registeredNamespacesBuilders[] = $namespaceBuilder; - - return $this; - } - - /** - * Set the transport - * - * @param Transport $transport - */ - public function setTransport(Transport $transport): ClientBuilder - { - $this->transport = $transport; - - return $this; - } - - /** - * Set the HTTP handler (cURL is default) - * - * @param mixed $handler - */ - public function setHandler($handler): ClientBuilder - { - $this->handler = $handler; - - return $this; - } - - /** - * Set the PSR-3 Logger - * - * @param LoggerInterface $logger - */ - public function setLogger(LoggerInterface $logger): ClientBuilder - { - $this->logger = $logger; - - return $this; - } - - /** - * Set the PSR-3 tracer - * - * @param LoggerInterface $tracer - */ - public function setTracer(LoggerInterface $tracer): ClientBuilder - { - $this->tracer = $tracer; - - return $this; } /** * Set the serializer - * - * @param \OpenSearch\Serializers\SerializerInterface|string $serializer - */ - public function setSerializer($serializer): ClientBuilder - { - $this->parseStringOrObject($serializer, $this->serializer, 'SerializerInterface'); - - return $this; - } - - /** - * Set the hosts (nodes) - * - * @param array $hosts - */ - public function setHosts(array $hosts): ClientBuilder - { - $this->hosts = $hosts; - - return $this; - } - - /** - * Set Basic access authentication - * - * @see https://en.wikipedia.org/wiki/Basic_access_authentication - * @param string $username - * @param string $password - * - * @throws AuthenticationConfigException - */ - public function setBasicAuthentication(string $username, string $password): ClientBuilder - { - $this->basicAuthentication = $username.':'.$password; - - return $this; - } - - /** - * Set connection parameters - * - * @param array $params - */ - public function setConnectionParams(array $params): ClientBuilder - { - $this->connectionParams = $params; - - return $this; - } - - /** - * Set number or retries (default is equal to number of nodes) - * - * @param int $retries */ - public function setRetries(int $retries): ClientBuilder + public function setSerializer(SerializerInterface $serializer): static { - $this->retries = $retries; - + $this->serializer = $serializer; return $this; } - /** - * Set the selector algorithm - * - * @param \OpenSearch\ConnectionPool\Selectors\SelectorInterface|string $selector - */ - public function setSelector($selector): ClientBuilder + public function setEndpointFactory(?EndpointFactory $endpointFactory): static { - $this->parseStringOrObject($selector, $this->selector, 'SelectorInterface'); - + $this->endpointFactory = $endpointFactory; return $this; } - /** - * Set the credential provider for SigV4 request signing. The value provider should be a - * callable object that will return - * - * @param callable|bool|array|CredentialsInterface|null $credentialProvider - */ - public function setSigV4CredentialProvider($credentialProvider): ClientBuilder + private function getEndpointFactory(): EndpointFactoryInterface { - if ($credentialProvider !== null && $credentialProvider !== false) { - $this->sigV4CredentialProvider = $this->normalizeCredentialProvider($credentialProvider); + if ($this->endpointFactory) { + return $this->endpointFactory; } - - return $this; - } - - /** - * Set the region for SigV4 signing. - * - * @param string|null $region - */ - public function setSigV4Region($region): ClientBuilder - { - $this->sigV4Region = $region; - - return $this; - } - - /** - * Set the service for SigV4 signing. - * - * @param string|null $service - */ - public function setSigV4Service($service): ClientBuilder - { - $this->sigV4Service = $service; - - return $this; - } - - /** - * Set sniff on start - * - * @param bool $sniffOnStart enable or disable sniff on start - */ - - public function setSniffOnStart(bool $sniffOnStart): ClientBuilder - { - $this->sniffOnStart = $sniffOnStart; - - return $this; - } - - /** - * Set SSL certificate - * - * @param string $cert The name of a file containing a PEM formatted certificate. - * @param string $password if the certificate requires a password - */ - public function setSSLCert(string $cert, ?string $password = null): ClientBuilder - { - $this->sslCert = [$cert, $password]; - - return $this; - } - - /** - * Set SSL key - * - * @param string $key The name of a file containing a private SSL key - * @param string $password if the private key requires a password - */ - public function setSSLKey(string $key, ?string $password = null): ClientBuilder - { - $this->sslKey = [$key, $password]; - - return $this; - } - - /** - * Set SSL verification - * - * @param bool|string $value - */ - public function setSSLVerification($value = true): ClientBuilder - { - $this->sslVerification = $value; - - return $this; - } - - /** - * Include the port in Host header - * - * @see https://github.com/elastic/elasticsearch-php/issues/993 - */ - public function includePortInHostHeader(bool $enable): ClientBuilder - { - $this->includePortInHostHeader = $enable; - - return $this; + return $this->endpointFactory = new EndpointFactory($this->serializer); } /** @@ -580,114 +78,6 @@ public function includePortInHostHeader(bool $enable): ClientBuilder */ public function build(): Client { - $this->buildLoggers(); - - if (is_null($this->handler)) { - $this->handler = ClientBuilder::defaultHandler(); - } - - if (!is_null($this->sigV4CredentialProvider)) { - if (is_null($this->sigV4Region)) { - throw new RuntimeException("A region must be supplied for SigV4 request signing."); - } - - if (is_null($this->sigV4Service)) { - $this->setSigV4Service("es"); - } - - $this->handler = new SigV4Handler($this->sigV4Region, $this->sigV4Service, $this->sigV4CredentialProvider, $this->handler); - } - - $sslOptions = null; - if (isset($this->sslKey)) { - $sslOptions['ssl_key'] = $this->sslKey; - } - if (isset($this->sslCert)) { - $sslOptions['cert'] = $this->sslCert; - } - if (isset($this->sslVerification)) { - $sslOptions['verify'] = $this->sslVerification; - } - - if (!is_null($sslOptions)) { - $sslHandler = function (callable $handler, array $sslOptions) { - return function (array $request) use ($handler, $sslOptions) { - // Add our custom headers - foreach ($sslOptions as $key => $value) { - $request['client'][$key] = $value; - } - - // Send the request using the handler and return the response. - return $handler($request); - }; - }; - $this->handler = $sslHandler($this->handler, $sslOptions); - } - - if (is_null($this->serializer)) { - $this->serializer = new SmartSerializer(); - } elseif (is_string($this->serializer)) { - $this->serializer = new $this->serializer(); - } - - $this->connectionParams['client']['port_in_header'] = $this->includePortInHostHeader; - - if (! is_null($this->basicAuthentication)) { - if (isset($this->connectionParams['client']['curl']) === false) { - $this->connectionParams['client']['curl'] = []; - } - - $this->connectionParams['client']['curl'] += [ - CURLOPT_HTTPAUTH => CURLAUTH_BASIC, - CURLOPT_USERPWD => $this->basicAuthentication - ]; - } - - if (is_null($this->connectionFactory)) { - // Make sure we are setting Content-Type and Accept (unless the user has explicitly - // overridden it - if (! isset($this->connectionParams['client']['headers'])) { - $this->connectionParams['client']['headers'] = []; - } - if (! isset($this->connectionParams['client']['headers']['Content-Type'])) { - $this->connectionParams['client']['headers']['Content-Type'] = ['application/json']; - } - if (! isset($this->connectionParams['client']['headers']['Accept'])) { - $this->connectionParams['client']['headers']['Accept'] = ['application/json']; - } - - $this->connectionFactory = new ConnectionFactory($this->handler, $this->connectionParams, $this->serializer, $this->logger, $this->tracer); - } - - if (is_null($this->hosts)) { - $this->hosts = $this->getDefaultHost(); - } - - if (is_null($this->selector)) { - $this->selector = new RoundRobinSelector(); - } elseif (is_string($this->selector)) { - $this->selector = new $this->selector(); - } - - $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(); - } - }; - } - $registeredNamespaces = []; foreach ($this->registeredNamespacesBuilders as $builder) { /** @@ -696,164 +86,7 @@ public function build(): Client $registeredNamespaces[$builder->getName()] = $builder->getObject($this->transport, $this->serializer); } - return $this->instantiate($this->transport, $this->endpoint, $registeredNamespaces); - } - - protected function instantiate(Transport $transport, callable $endpoint, array $registeredNamespaces): Client - { - return new Client($transport, $endpoint, $registeredNamespaces); - } - - private function buildLoggers(): void - { - if (is_null($this->logger)) { - $this->logger = new NullLogger(); - } - - if (is_null($this->tracer)) { - $this->tracer = new NullLogger(); - } - } - - private function buildTransport(): void - { - $connections = $this->buildConnectionsFromHosts($this->hosts); - - if (is_string($this->connectionPool)) { - $this->connectionPool = new $this->connectionPool( - $connections, - $this->selector, - $this->connectionFactory, - $this->connectionPoolArgs - ); - } - - if (is_null($this->retries)) { - $this->retries = count($connections); - } - - if (is_null($this->transport)) { - $this->transport = new Transport($this->retries, $this->connectionPool, $this->logger, $this->sniffOnStart); - } - } - - private function parseStringOrObject($arg, &$destination, $interface): void - { - if (is_string($arg)) { - $destination = new $arg(); - } elseif (is_object($arg)) { - $destination = $arg; - } else { - throw new InvalidArgumentException("Serializer must be a class path or instantiated object implementing $interface"); - } - } - - private function getDefaultHost(): array - { - return ['localhost:9200']; + return new Client($this->transport, $this->getEndpointFactory(), $registeredNamespaces); } - /** - * @return ConnectionInterface[] - * @throws RuntimeException - */ - private function buildConnectionsFromHosts(array $hosts): array - { - $connections = []; - foreach ($hosts as $host) { - if (is_string($host)) { - $host = $this->prependMissingScheme($host); - $host = $this->extractURIParts($host); - } elseif (is_array($host)) { - $host = $this->normalizeExtendedHost($host); - } else { - $this->logger->error("Could not parse host: ".print_r($host, true)); - throw new RuntimeException("Could not parse host: ".print_r($host, true)); - } - - $connections[] = $this->connectionFactory->create($host); - } - - return $connections; - } - - /** - * @throws RuntimeException - */ - private function normalizeExtendedHost(array $host): array - { - if (isset($host['host']) === false) { - $this->logger->error("Required 'host' was not defined in extended format: ".print_r($host, true)); - throw new RuntimeException("Required 'host' was not defined in extended format: ".print_r($host, true)); - } - - if (isset($host['scheme']) === false) { - $host['scheme'] = 'http'; - } - if (isset($host['port']) === false) { - $host['port'] = 9200; - } - return $host; - } - - /** - * @throws InvalidArgumentException - */ - private function extractURIParts(string $host): array - { - $parts = parse_url($host); - - if ($parts === false) { - throw new InvalidArgumentException(sprintf('Could not parse URI: "%s"', $host)); - } - - if (isset($parts['port']) !== true) { - $parts['port'] = 9200; - } - - return $parts; - } - - private function prependMissingScheme(string $host): string - { - if (!preg_match("/^https?:\/\//", $host)) { - $host = 'http://' . $host; - } - - return $host; - } - - private function normalizeCredentialProvider($provider): ?callable - { - if ($provider === null || $provider === false) { - return null; - } - - if (is_callable($provider)) { - return $provider; - } - - SigV4Handler::assertDependenciesInstalled(); - - if ($provider === true) { - return CredentialProvider::defaultProvider(); - } - - if ($provider instanceof CredentialsInterface) { - return CredentialProvider::fromCredentials($provider); - } elseif (is_array($provider) && isset($provider['key']) && isset($provider['secret'])) { - return CredentialProvider::fromCredentials( - new Credentials( - $provider['key'], - $provider['secret'], - isset($provider['token']) ? $provider['token'] : null, - isset($provider['expires']) ? $provider['expires'] : null - ) - ); - } - - throw new InvalidArgumentException('Credentials must be an instance of Aws\Credentials\CredentialsInterface, an' - . ' associative array that contains "key", "secret", and an optional "token" key-value pairs, a credentials' - . ' provider function, or true.'); - } } diff --git a/src/OpenSearch/ConnectionPool/ConnectionPoolInterface.php b/src/OpenSearch/Common/Exceptions/NoAsyncClientException.php similarity index 73% rename from src/OpenSearch/ConnectionPool/ConnectionPoolInterface.php rename to src/OpenSearch/Common/Exceptions/NoAsyncClientException.php index 42917d51..b95ce053 100644 --- a/src/OpenSearch/ConnectionPool/ConnectionPoolInterface.php +++ b/src/OpenSearch/Common/Exceptions/NoAsyncClientException.php @@ -1,7 +1,5 @@ - */ - protected $connectionPoolParams; - - /** - * @var ConnectionFactoryInterface - */ - protected $connectionFactory; - - /** - * Constructor - * - * @param ConnectionInterface[] $connections The Connections to choose from - * @param SelectorInterface $selector A Selector instance to perform the selection logic for the available connections - * @param ConnectionFactoryInterface $factory ConnectionFactory instance - * @param array $connectionPoolParams - */ - public function __construct(array $connections, SelectorInterface $selector, ConnectionFactoryInterface $factory, array $connectionPoolParams) - { - $paramList = array('connections', 'selector', 'connectionPoolParams'); - foreach ($paramList as $param) { - if (isset($$param) === false) { - throw new InvalidArgumentException('`' . $param . '` parameter must not be null'); - } - } - - if (isset($connectionPoolParams['randomizeHosts']) === true - && $connectionPoolParams['randomizeHosts'] === true - ) { - shuffle($connections); - } - - $this->connections = $connections; - $this->seedConnections = $connections; - $this->selector = $selector; - $this->connectionPoolParams = $connectionPoolParams; - $this->connectionFactory = $factory; - } - - abstract public function nextConnection(bool $force = false): ConnectionInterface; - - abstract public function scheduleCheck(): void; -} diff --git a/src/OpenSearch/ConnectionPool/Selectors/RandomSelector.php b/src/OpenSearch/ConnectionPool/Selectors/RandomSelector.php deleted file mode 100644 index ecb7b380..00000000 --- a/src/OpenSearch/ConnectionPool/Selectors/RandomSelector.php +++ /dev/null @@ -1,37 +0,0 @@ -current % count($connections)]; - - $this->current += 1; - - return $returnConnection; - } -} diff --git a/src/OpenSearch/ConnectionPool/Selectors/SelectorInterface.php b/src/OpenSearch/ConnectionPool/Selectors/SelectorInterface.php deleted file mode 100644 index eeb29086..00000000 --- a/src/OpenSearch/ConnectionPool/Selectors/SelectorInterface.php +++ /dev/null @@ -1,34 +0,0 @@ -current]->isAlive()) { - return $connections[$this->current]; - } - - $this->currentCounter += 1; - $this->current = $this->currentCounter % count($connections); - - return $connections[$this->current]; - } -} diff --git a/src/OpenSearch/ConnectionPool/SimpleConnectionPool.php b/src/OpenSearch/ConnectionPool/SimpleConnectionPool.php deleted file mode 100644 index 29c14d26..00000000 --- a/src/OpenSearch/ConnectionPool/SimpleConnectionPool.php +++ /dev/null @@ -1,48 +0,0 @@ - $connectionPoolParams - */ - public function __construct($connections, SelectorInterface $selector, ConnectionFactoryInterface $factory, $connectionPoolParams) - { - parent::__construct($connections, $selector, $factory, $connectionPoolParams); - } - - public function nextConnection(bool $force = false): ConnectionInterface - { - return $this->selector->select($this->connections); - } - - public function scheduleCheck(): void - { - } -} diff --git a/src/OpenSearch/ConnectionPool/SniffingConnectionPool.php b/src/OpenSearch/ConnectionPool/SniffingConnectionPool.php deleted file mode 100644 index 2c6d6b83..00000000 --- a/src/OpenSearch/ConnectionPool/SniffingConnectionPool.php +++ /dev/null @@ -1,181 +0,0 @@ - $connectionPoolParams - */ - public function __construct( - $connections, - SelectorInterface $selector, - ConnectionFactoryInterface $factory, - $connectionPoolParams - ) { - parent::__construct($connections, $selector, $factory, $connectionPoolParams); - - $this->setConnectionPoolParams($connectionPoolParams); - $this->nextSniff = time() + $this->sniffingInterval; - } - - public function nextConnection(bool $force = false): ConnectionInterface - { - $this->sniff($force); - - $size = count($this->connections); - while ($size--) { - /** - * @var Connection $connection - */ - $connection = $this->selector->select($this->connections); - if ($connection->isAlive() === true || $connection->ping() === true) { - return $connection; - } - } - - if ($force === true) { - throw new NoNodesAvailableException("No alive nodes found in your cluster"); - } - - return $this->nextConnection(true); - } - - public function scheduleCheck(): void - { - $this->nextSniff = -1; - } - - private function sniff(bool $force = false): void - { - if ($force === false && $this->nextSniff > time()) { - return; - } - - $total = count($this->connections); - - while ($total--) { - /** - * @var Connection $connection - */ - $connection = $this->selector->select($this->connections); - - if ($connection->isAlive() xor $force) { - continue; - } - - if ($this->sniffConnection($connection) === true) { - return; - } - } - - if ($force === true) { - return; - } - - foreach ($this->seedConnections as $connection) { - /** - * @var Connection $connection - */ - if ($this->sniffConnection($connection) === true) { - return; - } - } - } - - private function sniffConnection(Connection $connection): bool - { - try { - $response = $connection->sniff(); - } catch (OperationTimeoutException $exception) { - return false; - } - - $nodes = $this->parseClusterState($response); - - if (count($nodes) === 0) { - return false; - } - - $this->connections = []; - - foreach ($nodes as $node) { - $nodeDetails = [ - 'host' => $node['host'], - 'port' => $node['port'], - ]; - $this->connections[] = $this->connectionFactory->create($nodeDetails); - } - - $this->nextSniff = time() + $this->sniffingInterval; - - return true; - } - - /** - * @return list - */ - private function parseClusterState($nodeInfo): array - { - $pattern = '/([^:]*):(\d+)/'; - $hosts = []; - - foreach ($nodeInfo['nodes'] as $node) { - if (isset($node['http']) === true && isset($node['http']['publish_address']) === true) { - if (preg_match($pattern, $node['http']['publish_address'], $match) === 1) { - $hosts[] = [ - 'host' => $match[1], - 'port' => (int)$match[2], - ]; - } - } - } - - return $hosts; - } - - /** - * @param array $connectionPoolParams - */ - private function setConnectionPoolParams(array $connectionPoolParams): void - { - $this->sniffingInterval = (int)($connectionPoolParams['sniffingInterval'] ?? 300); - } -} diff --git a/src/OpenSearch/ConnectionPool/StaticConnectionPool.php b/src/OpenSearch/ConnectionPool/StaticConnectionPool.php deleted file mode 100644 index c074e8c8..00000000 --- a/src/OpenSearch/ConnectionPool/StaticConnectionPool.php +++ /dev/null @@ -1,105 +0,0 @@ - $connectionPoolParams - */ - public function __construct($connections, SelectorInterface $selector, ConnectionFactoryInterface $factory, $connectionPoolParams) - { - parent::__construct($connections, $selector, $factory, $connectionPoolParams); - $this->scheduleCheck(); - } - - public function nextConnection(bool $force = false): ConnectionInterface - { - $skipped = []; - - $total = count($this->connections); - while ($total--) { - /** - * @var Connection $connection - */ - $connection = $this->selector->select($this->connections); - if ($connection->isAlive() === true) { - return $connection; - } - - if ($this->readyToRevive($connection) === true) { - if ($connection->ping() === true) { - return $connection; - } - } else { - $skipped[] = $connection; - } - } - - // All "alive" nodes failed, force pings on "dead" nodes - foreach ($skipped as $connection) { - if ($connection->ping() === true) { - return $connection; - } - } - - throw new NoNodesAvailableException("No alive nodes found in your cluster"); - } - - public function scheduleCheck(): void - { - foreach ($this->connections as $connection) { - $connection->markDead(); - } - } - - private function readyToRevive(Connection $connection): bool - { - $timeout = min( - $this->pingTimeout * pow(2, $connection->getPingFailures()), - $this->maxPingTimeout - ); - - if ($connection->getLastPing() + $timeout < time()) { - return true; - } else { - return false; - } - } -} diff --git a/src/OpenSearch/ConnectionPool/StaticNoPingConnectionPool.php b/src/OpenSearch/ConnectionPool/StaticNoPingConnectionPool.php deleted file mode 100644 index a4a85e32..00000000 --- a/src/OpenSearch/ConnectionPool/StaticNoPingConnectionPool.php +++ /dev/null @@ -1,88 +0,0 @@ - $connectionPoolParams - */ - public function __construct($connections, SelectorInterface $selector, ConnectionFactoryInterface $factory, $connectionPoolParams) - { - parent::__construct($connections, $selector, $factory, $connectionPoolParams); - } - - public function nextConnection(bool $force = false): ConnectionInterface - { - $total = count($this->connections); - while ($total--) { - /** - * @var Connection $connection -*/ - $connection = $this->selector->select($this->connections); - if ($connection->isAlive() === true) { - return $connection; - } - - if ($this->readyToRevive($connection) === true) { - return $connection; - } - } - - throw new NoNodesAvailableException("No alive nodes found in your cluster"); - } - - public function scheduleCheck(): void - { - } - - private function readyToRevive(Connection $connection): bool - { - $timeout = min( - $this->pingTimeout * pow(2, $connection->getPingFailures()), - $this->maxPingTimeout - ); - - if ($connection->getLastPing() + $timeout < time()) { - return true; - } else { - return false; - } - } -} diff --git a/src/OpenSearch/Connections/Connection.php b/src/OpenSearch/Connections/Connection.php deleted file mode 100644 index 7279f56c..00000000 --- a/src/OpenSearch/Connections/Connection.php +++ /dev/null @@ -1,789 +0,0 @@ -> - */ - protected $headers = []; - - /** - * @var bool - */ - protected $isAlive = false; - - /** - * @var float - */ - private $pingTimeout = 1; //TODO expose this - - /** - * @var int - */ - private $lastPing = 0; - - /** - * @var int - */ - private $failedPings = 0; - - /** - * @var mixed[] - */ - private $lastRequest = array(); - - /** - * @var string - */ - private $OSVersion = null; - - /** - * @param array{host: string, port?: int, scheme?: string, user?: string, pass?: string, path?: string} $hostDetails - * @param array{client?: array{headers?: array>, curl?: array}} $connectionParams - */ - public function __construct( - callable $handler, - array $hostDetails, - array $connectionParams, - SerializerInterface $serializer, - LoggerInterface $log, - LoggerInterface $trace - ) { - if (isset($hostDetails['port']) !== true) { - $hostDetails['port'] = 9200; - } - - if (isset($hostDetails['scheme'])) { - $this->transportSchema = $hostDetails['scheme']; - } - - // Only Set the Basic if API Key is not set and setBasicAuthentication was not called prior - if (isset($connectionParams['client']['headers']['Authorization']) === false - && isset($connectionParams['client']['curl'][CURLOPT_HTTPAUTH]) === false - && isset($hostDetails['user']) - && isset($hostDetails['pass']) - ) { - $connectionParams['client']['curl'][CURLOPT_HTTPAUTH] = CURLAUTH_BASIC; - $connectionParams['client']['curl'][CURLOPT_USERPWD] = $hostDetails['user'].':'.$hostDetails['pass']; - } - - $connectionParams['client']['curl'][CURLOPT_PORT] = $hostDetails['port']; - - if (isset($connectionParams['client']['headers'])) { - $this->headers = $connectionParams['client']['headers']; - unset($connectionParams['client']['headers']); - } - - // Add the User-Agent using the format: / (metadata-values) - $this->headers['User-Agent'] = [sprintf( - 'opensearch-php/%s (%s %s; PHP %s)', - Client::VERSION, - PHP_OS, - $this->getOSVersion(), - PHP_VERSION - )]; - - $host = $hostDetails['host']; - $path = null; - if (isset($hostDetails['path']) === true) { - $path = $hostDetails['path']; - } - $port = $hostDetails['port']; - - $this->host = $host; - $this->path = $path; - $this->port = $port; - $this->log = $log; - $this->trace = $trace; - $this->connectionParams = $connectionParams; - $this->serializer = $serializer; - - $this->handler = $this->wrapHandler($handler); - } - - /** - * @param string $method - * @param string $uri - * @param null|array $params - * @param mixed $body - * @param array $options - * @param Transport|null $transport - * @return mixed - */ - public function performRequest(string $method, string $uri, ?array $params = [], $body = null, array $options = [], ?Transport $transport = null) - { - if ($body !== null) { - $body = $this->serializer->serialize($body); - } - - $headers = $this->headers; - if (isset($options['client']['headers']) && is_array($options['client']['headers'])) { - $headers = array_merge($this->headers, $options['client']['headers']); - } - - $host = $this->host; - if (isset($this->connectionParams['client']['port_in_header']) && $this->connectionParams['client']['port_in_header']) { - $host .= ':' . $this->port; - } - - $request = [ - 'http_method' => $method, - 'scheme' => $this->transportSchema, - 'uri' => $this->getURI($uri, $params), - 'body' => $body, - 'headers' => array_merge( - [ - 'Host' => [$host] - ], - $headers - ) - ]; - - $request = array_replace_recursive($request, $this->connectionParams, $options); - - // RingPHP does not like if client is empty - if (empty($request['client'])) { - unset($request['client']); - } - - $handler = $this->handler; - $future = $handler($request, $this, $transport, $options); - - return $future; - } - - public function getTransportSchema(): string - { - return $this->transportSchema; - } - - public function getLastRequestInfo(): array - { - return $this->lastRequest; - } - - private function wrapHandler(callable $handler): callable - { - return function (array $request, Connection $connection, ?Transport $transport, $options) use ($handler) { - $this->lastRequest = []; - $this->lastRequest['request'] = $request; - - // Send the request using the wrapped handler. - $response = Core::proxy( - $handler($request), - function ($response) use ($connection, $transport, $request, $options) { - $this->lastRequest['response'] = $response; - - if (isset($response['error']) === true) { - if ($response['error'] instanceof ConnectException || $response['error'] instanceof RingException) { - $this->log->warning("Curl exception encountered."); - - $exception = $this->getCurlRetryException($request, $response); - - $this->logRequestFail($request, $response, $exception); - - $node = $connection->getHost(); - $this->log->warning("Marking node $node dead."); - $connection->markDead(); - - // If the transport has not been set, we are inside a Ping or Sniff, - // so we don't want to retrigger retries anyway. - // - // TODO this could be handled better, but we are limited because connectionpools do not - // have access to Transport. Architecturally, all of this needs to be refactored - if (isset($transport) === true) { - $transport->connectionPool->scheduleCheck(); - - $neverRetry = isset($request['client']['never_retry']) ? $request['client']['never_retry'] : false; - $shouldRetry = $transport->shouldRetry($request); - $shouldRetryText = ($shouldRetry) ? 'true' : 'false'; - - $this->log->warning("Retries left? $shouldRetryText"); - if ($shouldRetry && !$neverRetry) { - return $transport->performRequest( - $request['http_method'], - $request['uri'], - [], - $request['body'], - $options - ); - } - } - - $this->log->warning("Out of retries, throwing exception from $node"); - // Only throw if we run out of retries - throw $exception; - } else { - // Something went seriously wrong, bail - $exception = new TransportException($response['error']->getMessage()); - $this->logRequestFail($request, $response, $exception); - throw $exception; - } - } else { - $connection->markAlive(); - - if (isset($response['headers']['Warning'])) { - $this->logWarning($request, $response); - } - if (isset($response['body']) === true) { - $response['body'] = stream_get_contents($response['body']); - $this->lastRequest['response']['body'] = $response['body']; - } - - if ($response['status'] >= 400 && $response['status'] < 500) { - $ignore = $request['client']['ignore'] ?? []; - // Skip 404 if succeeded true in the body (e.g. clear_scroll) - $body = $response['body'] ?? ''; - if (strpos($body, '"succeeded":true') !== false) { - $ignore[] = 404; - } - $this->process4xxError($request, $response, $ignore); - } elseif ($response['status'] >= 500) { - $ignore = $request['client']['ignore'] ?? []; - $this->process5xxError($request, $response, $ignore); - } - - // No error, deserialize - $response['body'] = $this->serializer->deserialize($response['body'], $response['transfer_stats']); - } - $this->logRequestSuccess($request, $response); - - return isset($request['client']['verbose']) && $request['client']['verbose'] === true ? $response : $response['body']; - } - ); - - return $response; - }; - } - - /** - * @param array|null $params - */ - private function getURI(string $uri, ?array $params): string - { - if (isset($params) === true && !empty($params)) { - $params = array_map( - function ($value) { - if ($value === true) { - return 'true'; - } elseif ($value === false) { - return 'false'; - } - - return $value; - }, - $params - ); - - $uri .= '?' . http_build_query($params); - } - - if ($this->path !== null) { - $uri = $this->path . $uri; - } - - return $uri; - } - - /** - * @return array> - */ - public function getHeaders(): array - { - return $this->headers; - } - - public function logWarning(array $request, array $response): void - { - $this->log->warning('Deprecation', $response['headers']['Warning']); - } - - /** - * Log a successful request - * - * @param array $request - * @param array $response - * @return void - */ - public function logRequestSuccess(array $request, array $response): void - { - $port = $request['client']['curl'][CURLOPT_PORT] ?? $response['transfer_stats']['primary_port'] ?? ''; - $uri = $this->addPortInUrl($response['effective_url'], (int) $port); - - $this->log->debug('Request Body', array($request['body'])); - $this->log->info( - 'Request Success:', - array( - 'method' => $request['http_method'], - 'uri' => $uri, - 'port' => $port, - 'headers' => $request['headers'], - 'HTTP code' => $response['status'], - 'duration' => $response['transfer_stats']['total_time'], - ) - ); - $this->log->debug('Response', array($response['body'])); - - // Build the curl command for Trace. - $curlCommand = $this->buildCurlCommand($request['http_method'], $uri, $request['body']); - $this->trace->info($curlCommand); - $this->trace->debug( - 'Response:', - array( - 'response' => $response['body'], - 'method' => $request['http_method'], - 'uri' => $uri, - 'port' => $port, - 'HTTP code' => $response['status'], - 'duration' => $response['transfer_stats']['total_time'], - ) - ); - } - - /** - * Log a failed request - * - * @param array $request - * @param array $response - * @param \Throwable $exception - * - * @return void - */ - public function logRequestFail(array $request, array $response, \Throwable $exception): void - { - $port = $request['client']['curl'][CURLOPT_PORT] ?? $response['transfer_stats']['primary_port'] ?? ''; - $uri = $this->addPortInUrl($response['effective_url'], (int) $port); - - $this->log->debug('Request Body', array($request['body'])); - $this->log->warning( - 'Request Failure:', - array( - 'method' => $request['http_method'], - 'uri' => $uri, - 'port' => $port, - 'headers' => $request['headers'], - 'HTTP code' => $response['status'], - 'duration' => $response['transfer_stats']['total_time'], - 'error' => $exception->getMessage(), - ) - ); - $this->log->warning('Response', array($response['body'])); - - // Build the curl command for Trace. - $curlCommand = $this->buildCurlCommand($request['http_method'], $uri, $request['body']); - $this->trace->info($curlCommand); - $this->trace->debug( - 'Response:', - array( - 'response' => $response, - 'method' => $request['http_method'], - 'uri' => $uri, - 'port' => $port, - 'HTTP code' => $response['status'], - 'duration' => $response['transfer_stats']['total_time'], - ) - ); - } - - public function ping(): bool - { - $options = [ - 'client' => [ - 'timeout' => $this->pingTimeout, - 'never_retry' => true, - 'verbose' => true - ] - ]; - try { - $response = $this->performRequest('HEAD', '/', null, null, $options); - $response = $response->wait(); - } catch (TransportException $exception) { - $this->markDead(); - - return false; - } - - if ($response['status'] === 200) { - $this->markAlive(); - - return true; - } else { - $this->markDead(); - - return false; - } - } - - /** - * @return array|\GuzzleHttp\Ring\Future\FutureArray - */ - public function sniff() - { - $options = [ - 'client' => [ - 'timeout' => $this->pingTimeout, - 'never_retry' => true - ] - ]; - - return $this->performRequest('GET', '/_nodes/', null, null, $options); - } - - public function isAlive(): bool - { - return $this->isAlive; - } - - public function markAlive(): void - { - $this->failedPings = 0; - $this->isAlive = true; - $this->lastPing = time(); - } - - public function markDead(): void - { - $this->isAlive = false; - $this->failedPings += 1; - $this->lastPing = time(); - } - - public function getLastPing(): int - { - return $this->lastPing; - } - - public function getPingFailures(): int - { - return $this->failedPings; - } - - public function getHost(): string - { - return $this->host; - } - - public function getUserPass(): ?string - { - return $this->connectionParams['client']['curl'][CURLOPT_USERPWD] ?? null; - } - - public function getPath(): ?string - { - return $this->path; - } - - /** - * @return int - */ - public function getPort() - { - return $this->port; - } - - protected function getCurlRetryException(array $request, array $response): OpenSearchException - { - $exception = null; - $message = $response['error']->getMessage(); - $exception = new MaxRetriesException($message); - switch ($response['curl']['errno']) { - case 6: - $exception = new CouldNotResolveHostException($message, 0, $exception); - break; - case 7: - $exception = new CouldNotConnectToHost($message, 0, $exception); - break; - case 28: - $exception = new OperationTimeoutException($message, 0, $exception); - break; - } - - return $exception; - } - - /** - * Get the OS version using php_uname if available - * otherwise it returns an empty string - * - * @see https://github.com/elastic/elasticsearch-php/issues/922 - */ - private function getOSVersion(): string - { - if ($this->OSVersion === null) { - $this->OSVersion = strpos(strtolower(ini_get('disable_functions')), 'php_uname') !== false - ? '' - : php_uname("r"); - } - return $this->OSVersion; - } - - /** - * Add the port value in the URL if not present - */ - private function addPortInUrl(string $uri, int $port): string - { - if (strpos($uri, ':', 7) !== false) { - return $uri; - } - return preg_replace('#([^/])/([^/])#', sprintf("$1:%s/$2", $port), $uri, 1); - } - - /** - * Construct a string cURL command - */ - private function buildCurlCommand(string $method, string $url, ?string $body): string - { - if (strpos($url, '?') === false) { - $url .= '?pretty=true'; - } else { - str_replace('?', '?pretty=true', $url); - } - - $curlCommand = 'curl -X' . strtoupper($method); - $curlCommand .= " '" . $url . "'"; - - if (isset($body) === true && $body !== '') { - $curlCommand .= " -d '" . $body . "'"; - } - - return $curlCommand; - } - - /** - * @throws OpenSearchException - */ - private function process4xxError(array $request, array $response, array $ignore): void - { - $statusCode = $response['status']; - - /** - * @var \Exception $exception - */ - $exception = $this->tryDeserialize400Error($response); - - if (array_search($response['status'], $ignore) !== false) { - return; - } - - $responseBody = $this->convertBodyToString($response['body'], $statusCode, $exception); - if ($statusCode === 401) { - $exception = new Unauthorized401Exception($responseBody, $statusCode); - } elseif ($statusCode === 403) { - $exception = new Forbidden403Exception($responseBody, $statusCode); - } elseif ($statusCode === 404) { - $exception = new Missing404Exception($responseBody, $statusCode); - } elseif ($statusCode === 409) { - $exception = new Conflict409Exception($responseBody, $statusCode); - } elseif ($statusCode === 400 && strpos($responseBody, 'script_lang not supported') !== false) { - $exception = new ScriptLangNotSupportedException($responseBody. $statusCode); - } elseif ($statusCode === 408) { - $exception = new RequestTimeout408Exception($responseBody, $statusCode); - } else { - $exception = new BadRequest400Exception($responseBody, $statusCode); - } - - $this->logRequestFail($request, $response, $exception); - - throw $exception; - } - - /** - * @throws OpenSearchException - */ - private function process5xxError(array $request, array $response, array $ignore): void - { - $statusCode = (int) $response['status']; - $responseBody = $response['body']; - - /** - * @var \Exception $exception - */ - $exception = $this->tryDeserialize500Error($response); - - $exceptionText = "[$statusCode Server Exception] ".$exception->getMessage(); - $this->log->error($exceptionText); - $this->log->error($exception->getTraceAsString()); - - if (array_search($statusCode, $ignore) !== false) { - return; - } - - if ($statusCode === 500 && strpos($responseBody, "RoutingMissingException") !== false) { - $exception = new RoutingMissingException($exception->getMessage(), $statusCode, $exception); - } elseif ($statusCode === 500 && preg_match('/ActionRequestValidationException.+ no documents to get/', $responseBody) === 1) { - $exception = new NoDocumentsToGetException($exception->getMessage(), $statusCode, $exception); - } elseif ($statusCode === 500 && strpos($responseBody, 'NoShardAvailableActionException') !== false) { - $exception = new NoShardAvailableException($exception->getMessage(), $statusCode, $exception); - } else { - $exception = new ServerErrorResponseException( - $this->convertBodyToString($responseBody, $statusCode, $exception), - $statusCode - ); - } - - $this->logRequestFail($request, $response, $exception); - - throw $exception; - } - - private function convertBodyToString($body, int $statusCode, Exception $exception): string - { - if (empty($body)) { - return sprintf( - "Unknown %d error from OpenSearch %s", - $statusCode, - $exception->getMessage() - ); - } - // if body is not string, we convert it so it can be used as Exception message - if (!is_string($body)) { - return json_encode($body); - } - return $body; - } - - private function tryDeserialize400Error(array $response): OpenSearchException - { - return $this->tryDeserializeError($response, BadRequest400Exception::class); - } - - private function tryDeserialize500Error(array $response): OpenSearchException - { - return $this->tryDeserializeError($response, ServerErrorResponseException::class); - } - - private function tryDeserializeError(array $response, string $errorClass): OpenSearchException - { - $error = $this->serializer->deserialize($response['body'], $response['transfer_stats']); - if (is_array($error) === true) { - if (isset($error['error']) === false) { - // <2.0 "i just blew up" nonstructured exception - // $error is an array but we don't know the format, reuse the response body instead - // added json_encode to convert into a string - return new $errorClass(json_encode($response['body']), (int) $response['status']); - } - - // 2.0 structured exceptions - if (is_array($error['error']) && array_key_exists('reason', $error['error']) === true) { - // Try to use root cause first (only grabs the first root cause) - $info = $error['error']['root_cause'][0] ?? $error['error']; - $cause = $info['reason']; - $type = $info['type']; - // added json_encode to convert into a string - $original = new $errorClass(json_encode($response['body']), $response['status']); - - return new $errorClass("$type: $cause", (int) $response['status'], $original); - } - // <2.0 semi-structured exceptions - // added json_encode to convert into a string - $original = new $errorClass(json_encode($response['body']), $response['status']); - - $errorEncoded = $error['error']; - if (is_array($errorEncoded)) { - $errorEncoded = json_encode($errorEncoded); - } - return new $errorClass($errorEncoded, (int) $response['status'], $original); - } - - // if responseBody is not string, we convert it so it can be used as Exception message - $responseBody = $response['body']; - if (!is_string($responseBody)) { - $responseBody = json_encode($responseBody); - } - - // <2.0 "i just blew up" nonstructured exception - return new $errorClass($responseBody); - } -} diff --git a/src/OpenSearch/Connections/ConnectionFactory.php b/src/OpenSearch/Connections/ConnectionFactory.php deleted file mode 100644 index f95c2f29..00000000 --- a/src/OpenSearch/Connections/ConnectionFactory.php +++ /dev/null @@ -1,81 +0,0 @@ ->, curl?: array}} $connectionParams - */ - public function __construct(callable $handler, array $connectionParams, SerializerInterface $serializer, LoggerInterface $logger, LoggerInterface $tracer) - { - $this->handler = $handler; - $this->connectionParams = $connectionParams; - $this->logger = $logger; - $this->tracer = $tracer; - $this->serializer = $serializer; - } - - public function create(array $hostDetails): ConnectionInterface - { - if (isset($hostDetails['path'])) { - $hostDetails['path'] = rtrim($hostDetails['path'], '/'); - } - - return new Connection( - $this->handler, - $hostDetails, - $this->connectionParams, - $this->serializer, - $this->logger, - $this->tracer - ); - } -} diff --git a/src/OpenSearch/Connections/ConnectionFactoryInterface.php b/src/OpenSearch/Connections/ConnectionFactoryInterface.php deleted file mode 100644 index da209abd..00000000 --- a/src/OpenSearch/Connections/ConnectionFactoryInterface.php +++ /dev/null @@ -1,30 +0,0 @@ -|null $params - * @param mixed $body - * @return mixed - */ - public function performRequest(string $method, string $uri, ?array $params = [], $body = null, array $options = [], ?Transport $transport = null); -} diff --git a/src/OpenSearch/EndpointFactory.php b/src/OpenSearch/EndpointFactory.php new file mode 100644 index 00000000..01b2fd83 --- /dev/null +++ b/src/OpenSearch/EndpointFactory.php @@ -0,0 +1,57 @@ + + */ + private array $endpoints = []; + + public function __construct( + protected SerializerInterface $serializer, + ) { + } + + /** + * {@inheritdoc} + */ + public function getEndpoint(string $class): EndpointInterface + { + if (!isset($this->endpoints[$class])) { + $this->endpoints[$class] = $this->createEndpoint($class); + } + + return $this->endpoints[$class]; + } + + /** + * Creates an endpoint. + * + * @phpstan-template T of EndpointInterface + * @phpstan-param class-string $class + * @phpstan-return T + * @throws \ReflectionException + */ + private function createEndpoint(string $class): EndpointInterface + { + $fullPath = '\\OpenSearch\\Endpoints\\' . $class; + + $reflection = new ReflectionClass($fullPath); + $constructor = $reflection->getConstructor(); + + if ($constructor && $constructor->getParameters()) { + return new $fullPath($this->serializer); + } + return new $fullPath(); + } + +} diff --git a/src/OpenSearch/EndpointFactoryInterface.php b/src/OpenSearch/EndpointFactoryInterface.php new file mode 100644 index 00000000..f17c61b4 --- /dev/null +++ b/src/OpenSearch/EndpointFactoryInterface.php @@ -0,0 +1,19 @@ + $class + * @phpstan-return T + */ + public function getEndpoint(string $class); + +} diff --git a/src/OpenSearch/EndpointInterface.php b/src/OpenSearch/EndpointInterface.php new file mode 100644 index 00000000..b9e32e0e --- /dev/null +++ b/src/OpenSearch/EndpointInterface.php @@ -0,0 +1,77 @@ +extractOptions($params); $this->checkUserParams($params); @@ -117,7 +117,7 @@ public function getIndex(): ?string * * @return $this */ - public function setIndex($index) + public function setIndex($index): static { if ($index === null) { return $this; @@ -134,12 +134,7 @@ public function setIndex($index) return $this; } - /** - * @param int|string|null $docID - * - * @return $this - */ - public function setId($docID) + public function setId(int|string|null $docID): static { if ($docID === null) { return $this; @@ -154,16 +149,12 @@ public function setId($docID) return $this; } - /** - * @return array|string - */ - public function getBody() + public function getBody(): array|string { return $this->body; } - - public function setBody(array $body) + public function setBody(array|string $body): static { $this->body = $body; diff --git a/src/OpenSearch/Endpoints/AsynchronousSearch/Delete.php b/src/OpenSearch/Endpoints/AsynchronousSearch/Delete.php new file mode 100644 index 00000000..fe63dc31 --- /dev/null +++ b/src/OpenSearch/Endpoints/AsynchronousSearch/Delete.php @@ -0,0 +1,52 @@ +id) !== true) { + throw new RuntimeException( + 'id is required for delete' + ); + } + $id = $this->id; + return "/_plugins/_asynchronous_search/$id"; + } + + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'DELETE'; + } +} diff --git a/src/OpenSearch/Endpoints/AsynchronousSearch/Get.php b/src/OpenSearch/Endpoints/AsynchronousSearch/Get.php new file mode 100644 index 00000000..6caa77b1 --- /dev/null +++ b/src/OpenSearch/Endpoints/AsynchronousSearch/Get.php @@ -0,0 +1,52 @@ +id) !== true) { + throw new RuntimeException( + 'id is required for get' + ); + } + $id = $this->id; + return "/_plugins/_asynchronous_search/$id"; + } + + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'GET'; + } +} diff --git a/src/OpenSearch/Endpoints/AsynchronousSearch/Search.php b/src/OpenSearch/Endpoints/AsynchronousSearch/Search.php new file mode 100644 index 00000000..1d3e4372 --- /dev/null +++ b/src/OpenSearch/Endpoints/AsynchronousSearch/Search.php @@ -0,0 +1,59 @@ +body = $body; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/AsynchronousSearch/Stats.php b/src/OpenSearch/Endpoints/AsynchronousSearch/Stats.php new file mode 100644 index 00000000..8b68cb39 --- /dev/null +++ b/src/OpenSearch/Endpoints/AsynchronousSearch/Stats.php @@ -0,0 +1,45 @@ +serializer = $serializer; + } + + public function getURI(): string + { + $index = $this->index ?? null; + if (isset($index)) { + return "/$index/_bulk/stream"; + } + return "/_bulk/stream"; + } + + public function getParamWhitelist(): array + { + return [ + '_source', + '_source_excludes', + '_source_includes', + 'batch_interval', + 'batch_size', + 'pipeline', + 'refresh', + 'require_alias', + 'routing', + 'timeout', + 'wait_for_active_shards', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'PUT'; + } + + public function setBody($body): static + { + if (isset($body) !== true) { + return $this; + } + if (is_array($body) === true || $body instanceof Traversable) { + foreach ($body as $item) { + $this->body .= $this->serializer->serialize($item) . "\n"; + } + } elseif (is_string($body)) { + $this->body = $body; + if (substr($body, -1) != "\n") { + $this->body .= "\n"; + } + } else { + throw new InvalidArgumentException("Body must be an array, traversable object or string"); + } + return $this; + } + +} diff --git a/src/OpenSearch/Endpoints/Cat/Aliases.php b/src/OpenSearch/Endpoints/Cat/Aliases.php index cee786be..087899d4 100644 --- a/src/OpenSearch/Endpoints/Cat/Aliases.php +++ b/src/OpenSearch/Endpoints/Cat/Aliases.php @@ -62,7 +62,7 @@ public function getMethod(): string return 'GET'; } - public function setName($name): Aliases + public function setName($name): static { if (isset($name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Cat/Allocation.php b/src/OpenSearch/Endpoints/Cat/Allocation.php index 90947002..b84717d8 100644 --- a/src/OpenSearch/Endpoints/Cat/Allocation.php +++ b/src/OpenSearch/Endpoints/Cat/Allocation.php @@ -64,7 +64,7 @@ public function getMethod(): string return 'GET'; } - public function setNodeId($node_id): Allocation + public function setNodeId($node_id): static { if (isset($node_id) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Cat/Fielddata.php b/src/OpenSearch/Endpoints/Cat/Fielddata.php index dd48d156..3028f357 100644 --- a/src/OpenSearch/Endpoints/Cat/Fielddata.php +++ b/src/OpenSearch/Endpoints/Cat/Fielddata.php @@ -62,7 +62,7 @@ public function getMethod(): string return 'GET'; } - public function setFields($fields): Fielddata + public function setFields($fields): static { if (isset($fields) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Cat/PitSegments.php b/src/OpenSearch/Endpoints/Cat/PitSegments.php index af9981b2..f8aa23f8 100644 --- a/src/OpenSearch/Endpoints/Cat/PitSegments.php +++ b/src/OpenSearch/Endpoints/Cat/PitSegments.php @@ -49,7 +49,7 @@ public function getMethod(): string return 'GET'; } - public function setBody($body): PitSegments + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Cat/Snapshots.php b/src/OpenSearch/Endpoints/Cat/Snapshots.php index 03f0ae52..213bb0f4 100644 --- a/src/OpenSearch/Endpoints/Cat/Snapshots.php +++ b/src/OpenSearch/Endpoints/Cat/Snapshots.php @@ -64,7 +64,7 @@ public function getMethod(): string return 'GET'; } - public function setRepository($repository): Snapshots + public function setRepository($repository): static { if (isset($repository) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Cat/Templates.php b/src/OpenSearch/Endpoints/Cat/Templates.php index 8bf42aa9..116c05f6 100644 --- a/src/OpenSearch/Endpoints/Cat/Templates.php +++ b/src/OpenSearch/Endpoints/Cat/Templates.php @@ -63,7 +63,7 @@ public function getMethod(): string return 'GET'; } - public function setName($name): Templates + public function setName($name): static { if (isset($name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Cat/ThreadPool.php b/src/OpenSearch/Endpoints/Cat/ThreadPool.php index fcd168c9..1338b757 100644 --- a/src/OpenSearch/Endpoints/Cat/ThreadPool.php +++ b/src/OpenSearch/Endpoints/Cat/ThreadPool.php @@ -64,7 +64,7 @@ public function getMethod(): string return 'GET'; } - public function setThreadPoolPatterns($thread_pool_patterns): ThreadPool + public function setThreadPoolPatterns($thread_pool_patterns): static { if (isset($thread_pool_patterns) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/ClearScroll.php b/src/OpenSearch/Endpoints/ClearScroll.php index 190e9be5..e00ae70a 100644 --- a/src/OpenSearch/Endpoints/ClearScroll.php +++ b/src/OpenSearch/Endpoints/ClearScroll.php @@ -59,7 +59,7 @@ public function getMethod(): string return 'DELETE'; } - public function setBody($body): ClearScroll + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -69,7 +69,7 @@ public function setBody($body): ClearScroll return $this; } - public function setScrollId($scroll_id): ClearScroll + public function setScrollId($scroll_id): static { if (isset($scroll_id) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Cluster/AllocationExplain.php b/src/OpenSearch/Endpoints/Cluster/AllocationExplain.php index 0c0c8993..0605f258 100644 --- a/src/OpenSearch/Endpoints/Cluster/AllocationExplain.php +++ b/src/OpenSearch/Endpoints/Cluster/AllocationExplain.php @@ -51,7 +51,7 @@ public function getMethod(): string return isset($this->body) ? 'POST' : 'GET'; } - public function setBody($body): AllocationExplain + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Cluster/DeleteComponentTemplate.php b/src/OpenSearch/Endpoints/Cluster/DeleteComponentTemplate.php index e8b16bdc..09dbd056 100644 --- a/src/OpenSearch/Endpoints/Cluster/DeleteComponentTemplate.php +++ b/src/OpenSearch/Endpoints/Cluster/DeleteComponentTemplate.php @@ -59,7 +59,7 @@ public function getMethod(): string return 'DELETE'; } - public function setName($name): DeleteComponentTemplate + public function setName($name): static { if (isset($name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Cluster/DeleteWeightedRouting.php b/src/OpenSearch/Endpoints/Cluster/DeleteWeightedRouting.php index d63d9751..a91cb531 100644 --- a/src/OpenSearch/Endpoints/Cluster/DeleteWeightedRouting.php +++ b/src/OpenSearch/Endpoints/Cluster/DeleteWeightedRouting.php @@ -42,4 +42,14 @@ public function getMethod(): string { return 'DELETE'; } + + public function setBody($body): static + { + if (isset($body) !== true) { + return $this; + } + $this->body = $body; + + return $this; + } } diff --git a/src/OpenSearch/Endpoints/Cluster/ExistsComponentTemplate.php b/src/OpenSearch/Endpoints/Cluster/ExistsComponentTemplate.php index 3146fcc0..84ab4173 100644 --- a/src/OpenSearch/Endpoints/Cluster/ExistsComponentTemplate.php +++ b/src/OpenSearch/Endpoints/Cluster/ExistsComponentTemplate.php @@ -59,7 +59,7 @@ public function getMethod(): string return 'HEAD'; } - public function setName($name): ExistsComponentTemplate + public function setName($name): static { if (isset($name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Cluster/GetComponentTemplate.php b/src/OpenSearch/Endpoints/Cluster/GetComponentTemplate.php index 5d495710..0d490517 100644 --- a/src/OpenSearch/Endpoints/Cluster/GetComponentTemplate.php +++ b/src/OpenSearch/Endpoints/Cluster/GetComponentTemplate.php @@ -58,7 +58,7 @@ public function getMethod(): string return 'GET'; } - public function setName($name): GetComponentTemplate + public function setName($name): static { if (isset($name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Cluster/GetDecommissionAwareness.php b/src/OpenSearch/Endpoints/Cluster/GetDecommissionAwareness.php index 66c250c5..4b0569b2 100644 --- a/src/OpenSearch/Endpoints/Cluster/GetDecommissionAwareness.php +++ b/src/OpenSearch/Endpoints/Cluster/GetDecommissionAwareness.php @@ -50,7 +50,7 @@ public function getMethod(): string return 'GET'; } - public function setAwarenessAttributeName($awareness_attribute_name): GetDecommissionAwareness + public function setAwarenessAttributeName($awareness_attribute_name): static { if (isset($awareness_attribute_name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Cluster/GetWeightedRouting.php b/src/OpenSearch/Endpoints/Cluster/GetWeightedRouting.php index 0890735b..dd42bd43 100644 --- a/src/OpenSearch/Endpoints/Cluster/GetWeightedRouting.php +++ b/src/OpenSearch/Endpoints/Cluster/GetWeightedRouting.php @@ -50,7 +50,7 @@ public function getMethod(): string return 'GET'; } - public function setAttribute($attribute): GetWeightedRouting + public function setAttribute($attribute): static { if (isset($attribute) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Cluster/PutComponentTemplate.php b/src/OpenSearch/Endpoints/Cluster/PutComponentTemplate.php index c79a3db9..86a69816 100644 --- a/src/OpenSearch/Endpoints/Cluster/PutComponentTemplate.php +++ b/src/OpenSearch/Endpoints/Cluster/PutComponentTemplate.php @@ -60,7 +60,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): PutComponentTemplate + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -70,7 +70,7 @@ public function setBody($body): PutComponentTemplate return $this; } - public function setName($name): PutComponentTemplate + public function setName($name): static { if (isset($name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Cluster/PutDecommissionAwareness.php b/src/OpenSearch/Endpoints/Cluster/PutDecommissionAwareness.php index c80fed51..71385600 100644 --- a/src/OpenSearch/Endpoints/Cluster/PutDecommissionAwareness.php +++ b/src/OpenSearch/Endpoints/Cluster/PutDecommissionAwareness.php @@ -52,7 +52,7 @@ public function getMethod(): string return 'PUT'; } - public function setAwarenessAttributeName($awareness_attribute_name): PutDecommissionAwareness + public function setAwarenessAttributeName($awareness_attribute_name): static { if (isset($awareness_attribute_name) !== true) { return $this; @@ -62,7 +62,7 @@ public function setAwarenessAttributeName($awareness_attribute_name): PutDecommi return $this; } - public function setAwarenessAttributeValue($awareness_attribute_value): PutDecommissionAwareness + public function setAwarenessAttributeValue($awareness_attribute_value): static { if (isset($awareness_attribute_value) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Cluster/PutSettings.php b/src/OpenSearch/Endpoints/Cluster/PutSettings.php index 2a78a059..adc67a56 100644 --- a/src/OpenSearch/Endpoints/Cluster/PutSettings.php +++ b/src/OpenSearch/Endpoints/Cluster/PutSettings.php @@ -53,7 +53,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): PutSettings + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Cluster/PutWeightedRouting.php b/src/OpenSearch/Endpoints/Cluster/PutWeightedRouting.php index 3a35b555..4c707f66 100644 --- a/src/OpenSearch/Endpoints/Cluster/PutWeightedRouting.php +++ b/src/OpenSearch/Endpoints/Cluster/PutWeightedRouting.php @@ -50,7 +50,17 @@ public function getMethod(): string return 'PUT'; } - public function setAttribute($attribute): PutWeightedRouting + public function setBody($body): static + { + if (isset($body) !== true) { + return $this; + } + $this->body = $body; + + return $this; + } + + public function setAttribute($attribute): static { if (isset($attribute) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Cluster/Reroute.php b/src/OpenSearch/Endpoints/Cluster/Reroute.php index 235e5515..52246917 100644 --- a/src/OpenSearch/Endpoints/Cluster/Reroute.php +++ b/src/OpenSearch/Endpoints/Cluster/Reroute.php @@ -56,7 +56,7 @@ public function getMethod(): string return 'POST'; } - public function setBody($body): Reroute + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Cluster/State.php b/src/OpenSearch/Endpoints/Cluster/State.php index a8b7f2eb..61cf3ba6 100644 --- a/src/OpenSearch/Endpoints/Cluster/State.php +++ b/src/OpenSearch/Endpoints/Cluster/State.php @@ -68,7 +68,7 @@ public function getMethod(): string return 'GET'; } - public function setMetric($metric): State + public function setMetric($metric): static { if (isset($metric) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Cluster/Stats.php b/src/OpenSearch/Endpoints/Cluster/Stats.php index 4236808a..8967dd08 100644 --- a/src/OpenSearch/Endpoints/Cluster/Stats.php +++ b/src/OpenSearch/Endpoints/Cluster/Stats.php @@ -57,7 +57,7 @@ public function getMethod(): string return 'GET'; } - public function setNodeId($node_id): Stats + public function setNodeId($node_id): static { if (isset($node_id) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Count.php b/src/OpenSearch/Endpoints/Count.php index 43abf6b7..b83201db 100644 --- a/src/OpenSearch/Endpoints/Count.php +++ b/src/OpenSearch/Endpoints/Count.php @@ -67,7 +67,7 @@ public function getMethod(): string return isset($this->body) ? 'POST' : 'GET'; } - public function setBody($body): Count + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Create.php b/src/OpenSearch/Endpoints/Create.php index 9fd7b60b..28dac6ad 100644 --- a/src/OpenSearch/Endpoints/Create.php +++ b/src/OpenSearch/Endpoints/Create.php @@ -69,7 +69,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): Create + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/DanglingIndices/DeleteDanglingIndex.php b/src/OpenSearch/Endpoints/DanglingIndices/DeleteDanglingIndex.php index bc1e1d8a..7e9a82c7 100644 --- a/src/OpenSearch/Endpoints/DanglingIndices/DeleteDanglingIndex.php +++ b/src/OpenSearch/Endpoints/DanglingIndices/DeleteDanglingIndex.php @@ -60,7 +60,7 @@ public function getMethod(): string return 'DELETE'; } - public function setIndexUuid($index_uuid): DeleteDanglingIndex + public function setIndexUuid($index_uuid): static { if (isset($index_uuid) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/DanglingIndices/ImportDanglingIndex.php b/src/OpenSearch/Endpoints/DanglingIndices/ImportDanglingIndex.php index ca86f44d..59550796 100644 --- a/src/OpenSearch/Endpoints/DanglingIndices/ImportDanglingIndex.php +++ b/src/OpenSearch/Endpoints/DanglingIndices/ImportDanglingIndex.php @@ -60,7 +60,7 @@ public function getMethod(): string return 'POST'; } - public function setIndexUuid($index_uuid): ImportDanglingIndex + public function setIndexUuid($index_uuid): static { if (isset($index_uuid) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/DeleteByQuery.php b/src/OpenSearch/Endpoints/DeleteByQuery.php index cbcf95eb..f01f07cf 100644 --- a/src/OpenSearch/Endpoints/DeleteByQuery.php +++ b/src/OpenSearch/Endpoints/DeleteByQuery.php @@ -89,7 +89,7 @@ public function getMethod(): string return 'POST'; } - public function setBody($body): DeleteByQuery + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/DeleteByQueryRethrottle.php b/src/OpenSearch/Endpoints/DeleteByQueryRethrottle.php index a8cab68c..05a53021 100644 --- a/src/OpenSearch/Endpoints/DeleteByQueryRethrottle.php +++ b/src/OpenSearch/Endpoints/DeleteByQueryRethrottle.php @@ -59,7 +59,7 @@ public function getMethod(): string return 'POST'; } - public function setTaskId($task_id): DeleteByQueryRethrottle + public function setTaskId($task_id): static { if (isset($task_id) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/DeletePit.php b/src/OpenSearch/Endpoints/DeletePit.php index df9768d3..eca44019 100644 --- a/src/OpenSearch/Endpoints/DeletePit.php +++ b/src/OpenSearch/Endpoints/DeletePit.php @@ -43,7 +43,7 @@ public function getMethod(): string return 'DELETE'; } - public function setBody($body): DeletePit + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Explain.php b/src/OpenSearch/Endpoints/Explain.php index cf5a6f1c..9241ef83 100644 --- a/src/OpenSearch/Endpoints/Explain.php +++ b/src/OpenSearch/Endpoints/Explain.php @@ -74,7 +74,7 @@ public function getMethod(): string return isset($this->body) ? 'POST' : 'GET'; } - public function setBody($body): Explain + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/FieldCaps.php b/src/OpenSearch/Endpoints/FieldCaps.php index 93cd3749..d6f22027 100644 --- a/src/OpenSearch/Endpoints/FieldCaps.php +++ b/src/OpenSearch/Endpoints/FieldCaps.php @@ -58,7 +58,7 @@ public function getMethod(): string return isset($this->body) ? 'POST' : 'GET'; } - public function setBody($body): FieldCaps + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/FlowFramework/Create.php b/src/OpenSearch/Endpoints/FlowFramework/Create.php new file mode 100644 index 00000000..60fbac84 --- /dev/null +++ b/src/OpenSearch/Endpoints/FlowFramework/Create.php @@ -0,0 +1,60 @@ +body = $body; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/FlowFramework/Delete.php b/src/OpenSearch/Endpoints/FlowFramework/Delete.php new file mode 100644 index 00000000..c1a75384 --- /dev/null +++ b/src/OpenSearch/Endpoints/FlowFramework/Delete.php @@ -0,0 +1,63 @@ +workflow_id ?? null; + if (isset($workflow_id)) { + return "/_plugins/_flow_framework/workflow/$workflow_id"; + } + throw new RuntimeException('Missing parameter for the endpoint flow_framework.delete'); + } + + public function getParamWhitelist(): array + { + return [ + 'clear_status', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'DELETE'; + } + + public function setWorkflowId($workflow_id): static + { + if (isset($workflow_id) !== true) { + return $this; + } + $this->workflow_id = $workflow_id; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/FlowFramework/Deprovision.php b/src/OpenSearch/Endpoints/FlowFramework/Deprovision.php new file mode 100644 index 00000000..c9ef2db1 --- /dev/null +++ b/src/OpenSearch/Endpoints/FlowFramework/Deprovision.php @@ -0,0 +1,63 @@ +workflow_id ?? null; + if (isset($workflow_id)) { + return "/_plugins/_flow_framework/workflow/$workflow_id/_deprovision"; + } + throw new RuntimeException('Missing parameter for the endpoint flow_framework.deprovision'); + } + + public function getParamWhitelist(): array + { + return [ + 'allow_delete', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'POST'; + } + + public function setWorkflowId($workflow_id): static + { + if (isset($workflow_id) !== true) { + return $this; + } + $this->workflow_id = $workflow_id; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/FlowFramework/Get.php b/src/OpenSearch/Endpoints/FlowFramework/Get.php new file mode 100644 index 00000000..09226a2f --- /dev/null +++ b/src/OpenSearch/Endpoints/FlowFramework/Get.php @@ -0,0 +1,62 @@ +workflow_id ?? null; + if (isset($workflow_id)) { + return "/_plugins/_flow_framework/workflow/$workflow_id"; + } + throw new RuntimeException('Missing parameter for the endpoint flow_framework.get'); + } + + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'GET'; + } + + public function setWorkflowId($workflow_id): static + { + if (isset($workflow_id) !== true) { + return $this; + } + $this->workflow_id = $workflow_id; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/FlowFramework/GetStatus.php b/src/OpenSearch/Endpoints/FlowFramework/GetStatus.php new file mode 100644 index 00000000..9576306f --- /dev/null +++ b/src/OpenSearch/Endpoints/FlowFramework/GetStatus.php @@ -0,0 +1,63 @@ +workflow_id ?? null; + if (isset($workflow_id)) { + return "/_plugins/_flow_framework/workflow/$workflow_id/_status"; + } + throw new RuntimeException('Missing parameter for the endpoint flow_framework.get_status'); + } + + public function getParamWhitelist(): array + { + return [ + 'all', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'GET'; + } + + public function setWorkflowId($workflow_id): static + { + if (isset($workflow_id) !== true) { + return $this; + } + $this->workflow_id = $workflow_id; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/FlowFramework/GetSteps.php b/src/OpenSearch/Endpoints/FlowFramework/GetSteps.php new file mode 100644 index 00000000..ff4d4b2b --- /dev/null +++ b/src/OpenSearch/Endpoints/FlowFramework/GetSteps.php @@ -0,0 +1,46 @@ +workflow_id ?? null; + if (isset($workflow_id)) { + return "/_plugins/_flow_framework/workflow/$workflow_id/_provision"; + } + throw new RuntimeException('Missing parameter for the endpoint flow_framework.provision'); + } + + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'POST'; + } + + public function setBody($body): static + { + if (isset($body) !== true) { + return $this; + } + $this->body = $body; + + return $this; + } + + public function setWorkflowId($workflow_id): static + { + if (isset($workflow_id) !== true) { + return $this; + } + $this->workflow_id = $workflow_id; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/FlowFramework/Search.php b/src/OpenSearch/Endpoints/FlowFramework/Search.php new file mode 100644 index 00000000..353287d8 --- /dev/null +++ b/src/OpenSearch/Endpoints/FlowFramework/Search.php @@ -0,0 +1,55 @@ +body) ? 'POST' : 'GET'; + } + + public function setBody($body): static + { + if (isset($body) !== true) { + return $this; + } + $this->body = $body; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/FlowFramework/SearchState.php b/src/OpenSearch/Endpoints/FlowFramework/SearchState.php new file mode 100644 index 00000000..d1ee9c7e --- /dev/null +++ b/src/OpenSearch/Endpoints/FlowFramework/SearchState.php @@ -0,0 +1,55 @@ +body) ? 'POST' : 'GET'; + } + + public function setBody($body): static + { + if (isset($body) !== true) { + return $this; + } + $this->body = $body; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/FlowFramework/Update.php b/src/OpenSearch/Endpoints/FlowFramework/Update.php new file mode 100644 index 00000000..73fa0e12 --- /dev/null +++ b/src/OpenSearch/Endpoints/FlowFramework/Update.php @@ -0,0 +1,77 @@ +workflow_id ?? null; + if (isset($workflow_id)) { + return "/_plugins/_flow_framework/workflow/$workflow_id"; + } + throw new RuntimeException('Missing parameter for the endpoint flow_framework.update'); + } + + public function getParamWhitelist(): array + { + return [ + 'provision', + 'reprovision', + 'update_fields', + 'use_case', + 'validation', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'PUT'; + } + + public function setBody($body): static + { + if (isset($body) !== true) { + return $this; + } + $this->body = $body; + + return $this; + } + + public function setWorkflowId($workflow_id): static + { + if (isset($workflow_id) !== true) { + return $this; + } + $this->workflow_id = $workflow_id; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Index.php b/src/OpenSearch/Endpoints/Index.php index abeecc31..48ad123c 100644 --- a/src/OpenSearch/Endpoints/Index.php +++ b/src/OpenSearch/Endpoints/Index.php @@ -71,7 +71,7 @@ public function getMethod(): string return 'POST'; } - public function setBody($body): Index + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/AddBlock.php b/src/OpenSearch/Endpoints/Indices/AddBlock.php index 5c878c89..867c0788 100644 --- a/src/OpenSearch/Endpoints/Indices/AddBlock.php +++ b/src/OpenSearch/Endpoints/Indices/AddBlock.php @@ -63,7 +63,7 @@ public function getMethod(): string return 'PUT'; } - public function setBlock($block): AddBlock + public function setBlock($block): static { if (isset($block) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/Analyze.php b/src/OpenSearch/Endpoints/Indices/Analyze.php index 845502ca..63f6612a 100644 --- a/src/OpenSearch/Endpoints/Indices/Analyze.php +++ b/src/OpenSearch/Endpoints/Indices/Analyze.php @@ -54,7 +54,7 @@ public function getMethod(): string return isset($this->body) ? 'POST' : 'GET'; } - public function setBody($body): Analyze + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/CloneIndices.php b/src/OpenSearch/Endpoints/Indices/CloneIndices.php index ca94ac96..dd92e534 100644 --- a/src/OpenSearch/Endpoints/Indices/CloneIndices.php +++ b/src/OpenSearch/Endpoints/Indices/CloneIndices.php @@ -63,7 +63,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): CloneIndices + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -73,7 +73,7 @@ public function setBody($body): CloneIndices return $this; } - public function setTarget($target): CloneIndices + public function setTarget($target): static { if (isset($target) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/Create.php b/src/OpenSearch/Endpoints/Indices/Create.php index bf9e3d56..e0336b80 100644 --- a/src/OpenSearch/Endpoints/Indices/Create.php +++ b/src/OpenSearch/Endpoints/Indices/Create.php @@ -58,7 +58,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): Create + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/CreateDataStream.php b/src/OpenSearch/Endpoints/Indices/CreateDataStream.php index 0c74c24d..97a98880 100644 --- a/src/OpenSearch/Endpoints/Indices/CreateDataStream.php +++ b/src/OpenSearch/Endpoints/Indices/CreateDataStream.php @@ -56,7 +56,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): CreateDataStream + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -66,7 +66,7 @@ public function setBody($body): CreateDataStream return $this; } - public function setName($name): CreateDataStream + public function setName($name): static { if (isset($name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/DataStreamsStats.php b/src/OpenSearch/Endpoints/Indices/DataStreamsStats.php index fc3ee039..49619f24 100644 --- a/src/OpenSearch/Endpoints/Indices/DataStreamsStats.php +++ b/src/OpenSearch/Endpoints/Indices/DataStreamsStats.php @@ -55,7 +55,7 @@ public function getMethod(): string return 'GET'; } - public function setName($name): DataStreamsStats + public function setName($name): static { if (isset($name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/DeleteAlias.php b/src/OpenSearch/Endpoints/Indices/DeleteAlias.php index edce99b3..7829f215 100644 --- a/src/OpenSearch/Endpoints/Indices/DeleteAlias.php +++ b/src/OpenSearch/Endpoints/Indices/DeleteAlias.php @@ -67,7 +67,7 @@ public function getMethod(): string return 'DELETE'; } - public function setName($name): DeleteAlias + public function setName($name): static { if (isset($name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/DeleteDataStream.php b/src/OpenSearch/Endpoints/Indices/DeleteDataStream.php index f266b1d8..be9fe5f0 100644 --- a/src/OpenSearch/Endpoints/Indices/DeleteDataStream.php +++ b/src/OpenSearch/Endpoints/Indices/DeleteDataStream.php @@ -56,7 +56,7 @@ public function getMethod(): string return 'DELETE'; } - public function setName($name): DeleteDataStream + public function setName($name): static { if (isset($name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/DeleteIndexTemplate.php b/src/OpenSearch/Endpoints/Indices/DeleteIndexTemplate.php index 41f340d1..a4013a1e 100644 --- a/src/OpenSearch/Endpoints/Indices/DeleteIndexTemplate.php +++ b/src/OpenSearch/Endpoints/Indices/DeleteIndexTemplate.php @@ -59,7 +59,7 @@ public function getMethod(): string return 'DELETE'; } - public function setName($name): DeleteIndexTemplate + public function setName($name): static { if (isset($name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/DeleteTemplate.php b/src/OpenSearch/Endpoints/Indices/DeleteTemplate.php index 40f3c92e..f1137aa0 100644 --- a/src/OpenSearch/Endpoints/Indices/DeleteTemplate.php +++ b/src/OpenSearch/Endpoints/Indices/DeleteTemplate.php @@ -59,7 +59,7 @@ public function getMethod(): string return 'DELETE'; } - public function setName($name): DeleteTemplate + public function setName($name): static { if (isset($name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/ExistsAlias.php b/src/OpenSearch/Endpoints/Indices/ExistsAlias.php index 5b391dd1..e8a7fe6e 100644 --- a/src/OpenSearch/Endpoints/Indices/ExistsAlias.php +++ b/src/OpenSearch/Endpoints/Indices/ExistsAlias.php @@ -66,7 +66,7 @@ public function getMethod(): string return 'HEAD'; } - public function setName($name): ExistsAlias + public function setName($name): static { if (isset($name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/ExistsIndexTemplate.php b/src/OpenSearch/Endpoints/Indices/ExistsIndexTemplate.php index 437baf77..e2a57d27 100644 --- a/src/OpenSearch/Endpoints/Indices/ExistsIndexTemplate.php +++ b/src/OpenSearch/Endpoints/Indices/ExistsIndexTemplate.php @@ -60,7 +60,7 @@ public function getMethod(): string return 'HEAD'; } - public function setName($name): ExistsIndexTemplate + public function setName($name): static { if (isset($name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/ExistsTemplate.php b/src/OpenSearch/Endpoints/Indices/ExistsTemplate.php index 02390314..16cedd18 100644 --- a/src/OpenSearch/Endpoints/Indices/ExistsTemplate.php +++ b/src/OpenSearch/Endpoints/Indices/ExistsTemplate.php @@ -60,7 +60,7 @@ public function getMethod(): string return 'HEAD'; } - public function setName($name): ExistsTemplate + public function setName($name): static { if (isset($name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/GetAlias.php b/src/OpenSearch/Endpoints/Indices/GetAlias.php index 1a2cdc76..ef22815f 100644 --- a/src/OpenSearch/Endpoints/Indices/GetAlias.php +++ b/src/OpenSearch/Endpoints/Indices/GetAlias.php @@ -66,7 +66,7 @@ public function getMethod(): string return 'GET'; } - public function setName($name): GetAlias + public function setName($name): static { if (isset($name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/GetDataStream.php b/src/OpenSearch/Endpoints/Indices/GetDataStream.php index 0b34c657..60888c85 100644 --- a/src/OpenSearch/Endpoints/Indices/GetDataStream.php +++ b/src/OpenSearch/Endpoints/Indices/GetDataStream.php @@ -55,7 +55,7 @@ public function getMethod(): string return 'GET'; } - public function setName($name): GetDataStream + public function setName($name): static { if (isset($name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/GetFieldMapping.php b/src/OpenSearch/Endpoints/Indices/GetFieldMapping.php index aa2db2de..fe2575a8 100644 --- a/src/OpenSearch/Endpoints/Indices/GetFieldMapping.php +++ b/src/OpenSearch/Endpoints/Indices/GetFieldMapping.php @@ -67,7 +67,7 @@ public function getMethod(): string return 'GET'; } - public function setFields($fields): GetFieldMapping + public function setFields($fields): static { if (isset($fields) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/GetIndexTemplate.php b/src/OpenSearch/Endpoints/Indices/GetIndexTemplate.php index 84915edd..aad6765b 100644 --- a/src/OpenSearch/Endpoints/Indices/GetIndexTemplate.php +++ b/src/OpenSearch/Endpoints/Indices/GetIndexTemplate.php @@ -59,7 +59,7 @@ public function getMethod(): string return 'GET'; } - public function setName($name): GetIndexTemplate + public function setName($name): static { if (isset($name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/GetSettings.php b/src/OpenSearch/Endpoints/Indices/GetSettings.php index 6f0aa1b5..16b1930e 100644 --- a/src/OpenSearch/Endpoints/Indices/GetSettings.php +++ b/src/OpenSearch/Endpoints/Indices/GetSettings.php @@ -70,7 +70,7 @@ public function getMethod(): string return 'GET'; } - public function setName($name): GetSettings + public function setName($name): static { if (isset($name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/GetTemplate.php b/src/OpenSearch/Endpoints/Indices/GetTemplate.php index 83568eb6..e9876dce 100644 --- a/src/OpenSearch/Endpoints/Indices/GetTemplate.php +++ b/src/OpenSearch/Endpoints/Indices/GetTemplate.php @@ -59,7 +59,7 @@ public function getMethod(): string return 'GET'; } - public function setName($name): GetTemplate + public function setName($name): static { if (isset($name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/PutAlias.php b/src/OpenSearch/Endpoints/Indices/PutAlias.php index 62599f4c..eeb8bd5c 100644 --- a/src/OpenSearch/Endpoints/Indices/PutAlias.php +++ b/src/OpenSearch/Endpoints/Indices/PutAlias.php @@ -65,7 +65,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): PutAlias + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -75,7 +75,7 @@ public function setBody($body): PutAlias return $this; } - public function setName($name): PutAlias + public function setName($name): static { if (isset($name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/PutIndexTemplate.php b/src/OpenSearch/Endpoints/Indices/PutIndexTemplate.php index 52713029..f263c7f7 100644 --- a/src/OpenSearch/Endpoints/Indices/PutIndexTemplate.php +++ b/src/OpenSearch/Endpoints/Indices/PutIndexTemplate.php @@ -60,7 +60,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): PutIndexTemplate + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -70,7 +70,7 @@ public function setBody($body): PutIndexTemplate return $this; } - public function setName($name): PutIndexTemplate + public function setName($name): static { if (isset($name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/PutMapping.php b/src/OpenSearch/Endpoints/Indices/PutMapping.php index fd10a888..b3f63626 100644 --- a/src/OpenSearch/Endpoints/Indices/PutMapping.php +++ b/src/OpenSearch/Endpoints/Indices/PutMapping.php @@ -61,7 +61,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): PutMapping + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/PutSettings.php b/src/OpenSearch/Endpoints/Indices/PutSettings.php index 332b2286..0f66696c 100644 --- a/src/OpenSearch/Endpoints/Indices/PutSettings.php +++ b/src/OpenSearch/Endpoints/Indices/PutSettings.php @@ -61,7 +61,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): PutSettings + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/PutTemplate.php b/src/OpenSearch/Endpoints/Indices/PutTemplate.php index 90c581a3..666d67b3 100644 --- a/src/OpenSearch/Endpoints/Indices/PutTemplate.php +++ b/src/OpenSearch/Endpoints/Indices/PutTemplate.php @@ -60,7 +60,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): PutTemplate + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -70,7 +70,7 @@ public function setBody($body): PutTemplate return $this; } - public function setName($name): PutTemplate + public function setName($name): static { if (isset($name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/ResolveIndex.php b/src/OpenSearch/Endpoints/Indices/ResolveIndex.php index c6d2fec0..95604069 100644 --- a/src/OpenSearch/Endpoints/Indices/ResolveIndex.php +++ b/src/OpenSearch/Endpoints/Indices/ResolveIndex.php @@ -57,7 +57,7 @@ public function getMethod(): string return 'GET'; } - public function setName($name): ResolveIndex + public function setName($name): static { if (isset($name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/Rollover.php b/src/OpenSearch/Endpoints/Indices/Rollover.php index 0f4ec259..18c1519b 100644 --- a/src/OpenSearch/Endpoints/Indices/Rollover.php +++ b/src/OpenSearch/Endpoints/Indices/Rollover.php @@ -68,7 +68,7 @@ public function getMethod(): string return 'POST'; } - public function setBody($body): Rollover + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -78,7 +78,7 @@ public function setBody($body): Rollover return $this; } - public function setAlias($alias): Rollover + public function setAlias($alias): static { if (isset($alias) !== true) { return $this; @@ -88,7 +88,7 @@ public function setAlias($alias): Rollover return $this; } - public function setNewIndex($new_index): Rollover + public function setNewIndex($new_index): static { if (isset($new_index) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/Shrink.php b/src/OpenSearch/Endpoints/Indices/Shrink.php index 8806b7e6..c271712b 100644 --- a/src/OpenSearch/Endpoints/Indices/Shrink.php +++ b/src/OpenSearch/Endpoints/Indices/Shrink.php @@ -64,7 +64,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): Shrink + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -74,7 +74,7 @@ public function setBody($body): Shrink return $this; } - public function setTarget($target): Shrink + public function setTarget($target): static { if (isset($target) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/SimulateIndexTemplate.php b/src/OpenSearch/Endpoints/Indices/SimulateIndexTemplate.php index cc987ae2..977da385 100644 --- a/src/OpenSearch/Endpoints/Indices/SimulateIndexTemplate.php +++ b/src/OpenSearch/Endpoints/Indices/SimulateIndexTemplate.php @@ -60,7 +60,7 @@ public function getMethod(): string return 'POST'; } - public function setBody($body): SimulateIndexTemplate + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -70,7 +70,7 @@ public function setBody($body): SimulateIndexTemplate return $this; } - public function setName($name): SimulateIndexTemplate + public function setName($name): static { if (isset($name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/SimulateTemplate.php b/src/OpenSearch/Endpoints/Indices/SimulateTemplate.php index 8aa2c0ff..16ec3a9d 100644 --- a/src/OpenSearch/Endpoints/Indices/SimulateTemplate.php +++ b/src/OpenSearch/Endpoints/Indices/SimulateTemplate.php @@ -59,7 +59,7 @@ public function getMethod(): string return 'POST'; } - public function setBody($body): SimulateTemplate + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -69,7 +69,7 @@ public function setBody($body): SimulateTemplate return $this; } - public function setName($name): SimulateTemplate + public function setName($name): static { if (isset($name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/Split.php b/src/OpenSearch/Endpoints/Indices/Split.php index 6559b881..3fff81d3 100644 --- a/src/OpenSearch/Endpoints/Indices/Split.php +++ b/src/OpenSearch/Endpoints/Indices/Split.php @@ -64,7 +64,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): Split + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -74,7 +74,7 @@ public function setBody($body): Split return $this; } - public function setTarget($target): Split + public function setTarget($target): static { if (isset($target) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/Stats.php b/src/OpenSearch/Endpoints/Indices/Stats.php index 86195e16..a1f51f4d 100644 --- a/src/OpenSearch/Endpoints/Indices/Stats.php +++ b/src/OpenSearch/Endpoints/Indices/Stats.php @@ -71,7 +71,7 @@ public function getMethod(): string return 'GET'; } - public function setMetric($metric): Stats + public function setMetric($metric): static { if (isset($metric) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/UpdateAliases.php b/src/OpenSearch/Endpoints/Indices/UpdateAliases.php index fea7b223..d7dcbb9f 100644 --- a/src/OpenSearch/Endpoints/Indices/UpdateAliases.php +++ b/src/OpenSearch/Endpoints/Indices/UpdateAliases.php @@ -52,7 +52,7 @@ public function getMethod(): string return 'POST'; } - public function setBody($body): UpdateAliases + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Indices/ValidateQuery.php b/src/OpenSearch/Endpoints/Indices/ValidateQuery.php index b6d6bda7..008bebfe 100644 --- a/src/OpenSearch/Endpoints/Indices/ValidateQuery.php +++ b/src/OpenSearch/Endpoints/Indices/ValidateQuery.php @@ -65,7 +65,7 @@ public function getMethod(): string return isset($this->body) ? 'POST' : 'GET'; } - public function setBody($body): ValidateQuery + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Ingest/PutPipeline.php b/src/OpenSearch/Endpoints/Ingest/PutPipeline.php index 9205cbc4..1a4cef43 100644 --- a/src/OpenSearch/Endpoints/Ingest/PutPipeline.php +++ b/src/OpenSearch/Endpoints/Ingest/PutPipeline.php @@ -57,7 +57,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): PutPipeline + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Ingest/Simulate.php b/src/OpenSearch/Endpoints/Ingest/Simulate.php index afc87623..44e3ba9d 100644 --- a/src/OpenSearch/Endpoints/Ingest/Simulate.php +++ b/src/OpenSearch/Endpoints/Ingest/Simulate.php @@ -54,7 +54,7 @@ public function getMethod(): string return isset($this->body) ? 'POST' : 'GET'; } - public function setBody($body): Simulate + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Ism/AddPolicy.php b/src/OpenSearch/Endpoints/Ism/AddPolicy.php new file mode 100644 index 00000000..045768ab --- /dev/null +++ b/src/OpenSearch/Endpoints/Ism/AddPolicy.php @@ -0,0 +1,60 @@ +index ?? null; + if (isset($index)) { + return "/_plugins/_ism/add/$index"; + } + return "/_plugins/_ism/add"; + } + + public function getParamWhitelist(): array + { + return [ + 'index', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'POST'; + } + + public function setBody($body): static + { + if (isset($body) !== true) { + return $this; + } + $this->body = $body; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ism/ChangePolicy.php b/src/OpenSearch/Endpoints/Ism/ChangePolicy.php new file mode 100644 index 00000000..49dbb9d2 --- /dev/null +++ b/src/OpenSearch/Endpoints/Ism/ChangePolicy.php @@ -0,0 +1,60 @@ +index ?? null; + if (isset($index)) { + return "/_plugins/_ism/change_policy/$index"; + } + return "/_plugins/_ism/change_policy"; + } + + public function getParamWhitelist(): array + { + return [ + 'index', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'POST'; + } + + public function setBody($body): static + { + if (isset($body) !== true) { + return $this; + } + $this->body = $body; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ism/DeletePolicy.php b/src/OpenSearch/Endpoints/Ism/DeletePolicy.php new file mode 100644 index 00000000..a30b2a25 --- /dev/null +++ b/src/OpenSearch/Endpoints/Ism/DeletePolicy.php @@ -0,0 +1,64 @@ +policy_id) !== true) { + throw new RuntimeException( + 'policy_id is required for delete_policy' + ); + } + $policy_id = $this->policy_id; + return "/_plugins/_ism/policies/$policy_id"; + } + + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'DELETE'; + } + + public function setPolicyId($policy_id): static + { + if (isset($policy_id) !== true) { + return $this; + } + $this->policy_id = $policy_id; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ism/ExistsPolicy.php b/src/OpenSearch/Endpoints/Ism/ExistsPolicy.php new file mode 100644 index 00000000..55ea59b5 --- /dev/null +++ b/src/OpenSearch/Endpoints/Ism/ExistsPolicy.php @@ -0,0 +1,64 @@ +policy_id) !== true) { + throw new RuntimeException( + 'policy_id is required for exists_policy' + ); + } + $policy_id = $this->policy_id; + return "/_plugins/_ism/policies/$policy_id"; + } + + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'HEAD'; + } + + public function setPolicyId($policy_id): static + { + if (isset($policy_id) !== true) { + return $this; + } + $this->policy_id = $policy_id; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ism/ExplainPolicy.php b/src/OpenSearch/Endpoints/Ism/ExplainPolicy.php new file mode 100644 index 00000000..35236df6 --- /dev/null +++ b/src/OpenSearch/Endpoints/Ism/ExplainPolicy.php @@ -0,0 +1,59 @@ +index ?? null; + if (isset($index)) { + return "/_plugins/_ism/explain/$index"; + } + return "/_plugins/_ism/explain"; + } + + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return isset($this->body) ? 'POST' : 'GET'; + } + + public function setBody($body): static + { + if (isset($body) !== true) { + return $this; + } + $this->body = $body; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ism/GetPolicies.php b/src/OpenSearch/Endpoints/Ism/GetPolicies.php new file mode 100644 index 00000000..4da4ccca --- /dev/null +++ b/src/OpenSearch/Endpoints/Ism/GetPolicies.php @@ -0,0 +1,45 @@ +policy_id) !== true) { + throw new RuntimeException( + 'policy_id is required for get_policy' + ); + } + $policy_id = $this->policy_id; + return "/_plugins/_ism/policies/$policy_id"; + } + + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'GET'; + } + + public function setPolicyId($policy_id): static + { + if (isset($policy_id) !== true) { + return $this; + } + $this->policy_id = $policy_id; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ism/PutPolicies.php b/src/OpenSearch/Endpoints/Ism/PutPolicies.php new file mode 100644 index 00000000..5148d881 --- /dev/null +++ b/src/OpenSearch/Endpoints/Ism/PutPolicies.php @@ -0,0 +1,58 @@ +body = $body; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ism/PutPolicy.php b/src/OpenSearch/Endpoints/Ism/PutPolicy.php new file mode 100644 index 00000000..e93b289b --- /dev/null +++ b/src/OpenSearch/Endpoints/Ism/PutPolicy.php @@ -0,0 +1,76 @@ +policy_id) !== true) { + throw new RuntimeException( + 'policy_id is required for put_policy' + ); + } + $policy_id = $this->policy_id; + return "/_plugins/_ism/policies/$policy_id"; + } + + public function getParamWhitelist(): array + { + return [ + 'if_primary_term', + 'if_seq_no', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'PUT'; + } + + public function setBody($body): static + { + if (isset($body) !== true) { + return $this; + } + $this->body = $body; + + return $this; + } + + public function setPolicyId($policy_id): static + { + if (isset($policy_id) !== true) { + return $this; + } + $this->policy_id = $policy_id; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ism/RefreshSearchAnalyzers.php b/src/OpenSearch/Endpoints/Ism/RefreshSearchAnalyzers.php new file mode 100644 index 00000000..57ae3e51 --- /dev/null +++ b/src/OpenSearch/Endpoints/Ism/RefreshSearchAnalyzers.php @@ -0,0 +1,52 @@ +index) !== true) { + throw new RuntimeException( + 'index is required for refresh_search_analyzers' + ); + } + $index = $this->index; + return "/_plugins/_refresh_search_analyzers/$index"; + } + + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'POST'; + } +} diff --git a/src/OpenSearch/Endpoints/Ism/RemovePolicy.php b/src/OpenSearch/Endpoints/Ism/RemovePolicy.php new file mode 100644 index 00000000..b7a1eabd --- /dev/null +++ b/src/OpenSearch/Endpoints/Ism/RemovePolicy.php @@ -0,0 +1,50 @@ +index ?? null; + if (isset($index)) { + return "/_plugins/_ism/remove/$index"; + } + return "/_plugins/_ism/remove"; + } + + public function getParamWhitelist(): array + { + return [ + 'index', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'POST'; + } +} diff --git a/src/OpenSearch/Endpoints/Ism/RetryIndex.php b/src/OpenSearch/Endpoints/Ism/RetryIndex.php new file mode 100644 index 00000000..1056aab5 --- /dev/null +++ b/src/OpenSearch/Endpoints/Ism/RetryIndex.php @@ -0,0 +1,60 @@ +index ?? null; + if (isset($index)) { + return "/_plugins/_ism/retry/$index"; + } + return "/_plugins/_ism/retry"; + } + + public function getParamWhitelist(): array + { + return [ + 'index', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'POST'; + } + + public function setBody($body): static + { + if (isset($body) !== true) { + return $this; + } + $this->body = $body; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Knn/DeleteModel.php b/src/OpenSearch/Endpoints/Knn/DeleteModel.php index e4afbc05..f650a575 100644 --- a/src/OpenSearch/Endpoints/Knn/DeleteModel.php +++ b/src/OpenSearch/Endpoints/Knn/DeleteModel.php @@ -50,7 +50,7 @@ public function getMethod(): string return 'DELETE'; } - public function setModelId($model_id): DeleteModel + public function setModelId($model_id): static { if (isset($model_id) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Knn/GetModel.php b/src/OpenSearch/Endpoints/Knn/GetModel.php index c8d2e927..410d884b 100644 --- a/src/OpenSearch/Endpoints/Knn/GetModel.php +++ b/src/OpenSearch/Endpoints/Knn/GetModel.php @@ -50,7 +50,7 @@ public function getMethod(): string return 'GET'; } - public function setModelId($model_id): GetModel + public function setModelId($model_id): static { if (isset($model_id) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Knn/SearchModels.php b/src/OpenSearch/Endpoints/Knn/SearchModels.php index 23e988cd..cd25afc5 100644 --- a/src/OpenSearch/Endpoints/Knn/SearchModels.php +++ b/src/OpenSearch/Endpoints/Knn/SearchModels.php @@ -85,7 +85,7 @@ public function getMethod(): string return isset($this->body) ? 'POST' : 'GET'; } - public function setBody($body): SearchModels + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Knn/Stats.php b/src/OpenSearch/Endpoints/Knn/Stats.php index a5fac196..a8d17d78 100644 --- a/src/OpenSearch/Endpoints/Knn/Stats.php +++ b/src/OpenSearch/Endpoints/Knn/Stats.php @@ -58,7 +58,7 @@ public function getMethod(): string return 'GET'; } - public function setNodeId($node_id): Stats + public function setNodeId($node_id): static { if (isset($node_id) !== true) { return $this; @@ -71,7 +71,7 @@ public function setNodeId($node_id): Stats return $this; } - public function setStat($stat): Stats + public function setStat($stat): static { if (isset($stat) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Knn/TrainModel.php b/src/OpenSearch/Endpoints/Knn/TrainModel.php index 19b8d807..cf4cbc3b 100644 --- a/src/OpenSearch/Endpoints/Knn/TrainModel.php +++ b/src/OpenSearch/Endpoints/Knn/TrainModel.php @@ -50,7 +50,7 @@ public function getMethod(): string return 'POST'; } - public function setBody($body): TrainModel + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -60,7 +60,7 @@ public function setBody($body): TrainModel return $this; } - public function setModelId($model_id): TrainModel + public function setModelId($model_id): static { if (isset($model_id) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/MTermVectors.php b/src/OpenSearch/Endpoints/MTermVectors.php index 11afa11e..f76e0880 100644 --- a/src/OpenSearch/Endpoints/MTermVectors.php +++ b/src/OpenSearch/Endpoints/MTermVectors.php @@ -65,7 +65,7 @@ public function getMethod(): string return isset($this->body) ? 'POST' : 'GET'; } - public function setBody($body): MTermVectors + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Mget.php b/src/OpenSearch/Endpoints/Mget.php index e1a57615..edd7682f 100644 --- a/src/OpenSearch/Endpoints/Mget.php +++ b/src/OpenSearch/Endpoints/Mget.php @@ -61,7 +61,7 @@ public function getMethod(): string return isset($this->body) ? 'POST' : 'GET'; } - public function setBody($body): Mget + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Ml/CreateConnector.php b/src/OpenSearch/Endpoints/Ml/CreateConnector.php index 144debcb..887bf987 100644 --- a/src/OpenSearch/Endpoints/Ml/CreateConnector.php +++ b/src/OpenSearch/Endpoints/Ml/CreateConnector.php @@ -15,29 +15,39 @@ use OpenSearch\Endpoints\AbstractEndpoint; +/** + * NOTE: This file is autogenerated using util/GenerateEndpoints.php + */ class CreateConnector extends AbstractEndpoint { - /** - * @return string[] - */ - public function getParamWhitelist(): array + public function getURI(): string { - return []; + return "/_plugins/_ml/connectors/_create"; } - /** - * @return string - */ - public function getURI(): string + public function getParamWhitelist(): array { - return "/_plugins/_ml/connectors/_create"; + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; } - /** - * @return string - */ public function getMethod(): string { return 'POST'; } + + public function setBody($body): static + { + if (isset($body) !== true) { + return $this; + } + $this->body = $body; + + return $this; + } } diff --git a/src/OpenSearch/Endpoints/Ml/DeleteAgent.php b/src/OpenSearch/Endpoints/Ml/DeleteAgent.php new file mode 100644 index 00000000..fb8c4656 --- /dev/null +++ b/src/OpenSearch/Endpoints/Ml/DeleteAgent.php @@ -0,0 +1,62 @@ +agent_id ?? null; + if (isset($agent_id)) { + return "/_plugins/_ml/agents/$agent_id"; + } + throw new RuntimeException('Missing parameter for the endpoint ml.delete_agent'); + } + + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'DELETE'; + } + + public function setAgentId($agent_id): static + { + if (isset($agent_id) !== true) { + return $this; + } + $this->agent_id = $agent_id; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ml/DeleteConnector.php b/src/OpenSearch/Endpoints/Ml/DeleteConnector.php index 3eec653b..6c28dd27 100644 --- a/src/OpenSearch/Endpoints/Ml/DeleteConnector.php +++ b/src/OpenSearch/Endpoints/Ml/DeleteConnector.php @@ -16,36 +16,45 @@ use OpenSearch\Common\Exceptions\RuntimeException; use OpenSearch\Endpoints\AbstractEndpoint; +/** + * NOTE: This file is autogenerated using util/GenerateEndpoints.php + */ class DeleteConnector extends AbstractEndpoint { - /** - * @return string[] - */ - public function getParamWhitelist(): array - { - return []; - } + protected $connector_id; - /** - * @return string - */ public function getURI(): string { - if ($this->id) { - return "/_plugins/_ml/connectors/$this->id"; + $connector_id = $this->connector_id ?? null; + if (isset($connector_id)) { + return "/_plugins/_ml/connectors/$connector_id"; } + throw new RuntimeException('Missing parameter for the endpoint ml.delete_connector'); + } - throw new RuntimeException( - 'id is required for delete' - ); - + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; } - /** - * @return string - */ public function getMethod(): string { return 'DELETE'; } + + public function setConnectorId($connector_id): static + { + if (isset($connector_id) !== true) { + return $this; + } + $this->connector_id = $connector_id; + + return $this; + } } diff --git a/src/OpenSearch/Endpoints/Ml/DeleteTask.php b/src/OpenSearch/Endpoints/Ml/DeleteTask.php new file mode 100644 index 00000000..cbff3d87 --- /dev/null +++ b/src/OpenSearch/Endpoints/Ml/DeleteTask.php @@ -0,0 +1,62 @@ +task_id ?? null; + if (isset($task_id)) { + return "/_plugins/_ml/tasks/$task_id"; + } + throw new RuntimeException('Missing parameter for the endpoint ml.delete_task'); + } + + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'DELETE'; + } + + public function setTaskId($task_id): static + { + if (isset($task_id) !== true) { + return $this; + } + $this->task_id = $task_id; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ml/DeployModel.php b/src/OpenSearch/Endpoints/Ml/DeployModel.php index ba181822..e69da694 100644 --- a/src/OpenSearch/Endpoints/Ml/DeployModel.php +++ b/src/OpenSearch/Endpoints/Ml/DeployModel.php @@ -16,36 +16,45 @@ use OpenSearch\Common\Exceptions\RuntimeException; use OpenSearch\Endpoints\AbstractEndpoint; +/** + * NOTE: This file is autogenerated using util/GenerateEndpoints.php + */ class DeployModel extends AbstractEndpoint { - /** - * @return string[] - */ - public function getParamWhitelist(): array - { - return []; - } + protected $model_id; - /** - * @return string - */ public function getURI(): string { - if ($this->id) { - return "/_plugins/_ml/models/$this->id/_deploy"; + $model_id = $this->model_id ?? null; + if (isset($model_id)) { + return "/_plugins/_ml/models/$model_id/_deploy"; } + throw new RuntimeException('Missing parameter for the endpoint ml.deploy_model'); + } - throw new RuntimeException( - 'id is required for deploy' - ); - + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; } - /** - * @return string - */ public function getMethod(): string { return 'POST'; } + + public function setModelId($model_id): static + { + if (isset($model_id) !== true) { + return $this; + } + $this->model_id = $model_id; + + return $this; + } } diff --git a/src/OpenSearch/Endpoints/Ml/GetModelGroup.php b/src/OpenSearch/Endpoints/Ml/GetModelGroup.php index f061ea6c..989f9ae2 100644 --- a/src/OpenSearch/Endpoints/Ml/GetModelGroup.php +++ b/src/OpenSearch/Endpoints/Ml/GetModelGroup.php @@ -50,7 +50,7 @@ public function getMethod(): string return 'GET'; } - public function setModelGroupId($model_group_id): GetModelGroup + public function setModelGroupId($model_group_id): static { if (isset($model_group_id) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Ml/RegisterAgents.php b/src/OpenSearch/Endpoints/Ml/RegisterAgents.php new file mode 100644 index 00000000..11051da1 --- /dev/null +++ b/src/OpenSearch/Endpoints/Ml/RegisterAgents.php @@ -0,0 +1,55 @@ +body = $body; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ml/RegisterModel.php b/src/OpenSearch/Endpoints/Ml/RegisterModel.php index 698659c9..49824326 100644 --- a/src/OpenSearch/Endpoints/Ml/RegisterModel.php +++ b/src/OpenSearch/Endpoints/Ml/RegisterModel.php @@ -43,7 +43,7 @@ public function getMethod(): string return 'POST'; } - public function setBody($body): RegisterModel + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Ml/RegisterModelGroup.php b/src/OpenSearch/Endpoints/Ml/RegisterModelGroup.php index 046581e8..ff4943ec 100644 --- a/src/OpenSearch/Endpoints/Ml/RegisterModelGroup.php +++ b/src/OpenSearch/Endpoints/Ml/RegisterModelGroup.php @@ -43,7 +43,7 @@ public function getMethod(): string return 'POST'; } - public function setBody($body): RegisterModelGroup + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Ml/SearchModels.php b/src/OpenSearch/Endpoints/Ml/SearchModels.php index a6874ac1..84512e7c 100644 --- a/src/OpenSearch/Endpoints/Ml/SearchModels.php +++ b/src/OpenSearch/Endpoints/Ml/SearchModels.php @@ -43,7 +43,7 @@ public function getMethod(): string return 'GET'; } - public function setBody($body): SearchModels + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Ml/UndeployModel.php b/src/OpenSearch/Endpoints/Ml/UndeployModel.php index 1b9dd7fd..3aff2bad 100644 --- a/src/OpenSearch/Endpoints/Ml/UndeployModel.php +++ b/src/OpenSearch/Endpoints/Ml/UndeployModel.php @@ -16,36 +16,45 @@ use OpenSearch\Common\Exceptions\RuntimeException; use OpenSearch\Endpoints\AbstractEndpoint; +/** + * NOTE: This file is autogenerated using util/GenerateEndpoints.php + */ class UndeployModel extends AbstractEndpoint { - /** - * @return string[] - */ - public function getParamWhitelist(): array - { - return []; - } + protected $model_id; - /** - * @return string - */ public function getURI(): string { - if ($this->id) { - return "/_plugins/_ml/models/$this->id/_undeploy"; + $model_id = $this->model_id ?? null; + if (isset($model_id)) { + return "/_plugins/_ml/models/$model_id/_undeploy"; } + throw new RuntimeException('Missing parameter for the endpoint ml.undeploy_model'); + } - throw new RuntimeException( - 'id is required for undeploy' - ); - + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; } - /** - * @return string - */ public function getMethod(): string { return 'POST'; } + + public function setModelId($model_id): static + { + if (isset($model_id) !== true) { + return $this; + } + $this->model_id = $model_id; + + return $this; + } } diff --git a/src/OpenSearch/Endpoints/Msearch.php b/src/OpenSearch/Endpoints/Msearch.php index e2a5fb6e..a7e39285 100644 --- a/src/OpenSearch/Endpoints/Msearch.php +++ b/src/OpenSearch/Endpoints/Msearch.php @@ -68,7 +68,7 @@ public function getMethod(): string return isset($this->body) ? 'POST' : 'GET'; } - public function setBody($body): Msearch + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -87,4 +87,5 @@ public function setBody($body): Msearch } return $this; } + } diff --git a/src/OpenSearch/Endpoints/MsearchTemplate.php b/src/OpenSearch/Endpoints/MsearchTemplate.php index 560c62d8..247882f7 100644 --- a/src/OpenSearch/Endpoints/MsearchTemplate.php +++ b/src/OpenSearch/Endpoints/MsearchTemplate.php @@ -66,7 +66,7 @@ public function getMethod(): string return isset($this->body) ? 'POST' : 'GET'; } - public function setBody($body): MsearchTemplate + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -85,4 +85,5 @@ public function setBody($body): MsearchTemplate } return $this; } + } diff --git a/src/OpenSearch/Endpoints/Nodes/HotThreads.php b/src/OpenSearch/Endpoints/Nodes/HotThreads.php index ab4e0a97..a4854a60 100644 --- a/src/OpenSearch/Endpoints/Nodes/HotThreads.php +++ b/src/OpenSearch/Endpoints/Nodes/HotThreads.php @@ -61,7 +61,7 @@ public function getMethod(): string return 'GET'; } - public function setNodeId($node_id): HotThreads + public function setNodeId($node_id): static { if (isset($node_id) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Nodes/Info.php b/src/OpenSearch/Endpoints/Nodes/Info.php index b02a894a..da403a7c 100644 --- a/src/OpenSearch/Endpoints/Nodes/Info.php +++ b/src/OpenSearch/Endpoints/Nodes/Info.php @@ -70,7 +70,7 @@ public function getMethod(): string return 'GET'; } - public function setNodeIdOrMetric($node_id_or_metric): Info + public function setNodeIdOrMetric($node_id_or_metric): static { if (isset($node_id_or_metric) !== true) { return $this; @@ -80,7 +80,7 @@ public function setNodeIdOrMetric($node_id_or_metric): Info return $this; } - public function setMetric($metric): Info + public function setMetric($metric): static { if (isset($metric) !== true) { return $this; @@ -93,7 +93,7 @@ public function setMetric($metric): Info return $this; } - public function setNodeId($node_id): Info + public function setNodeId($node_id): static { if (isset($node_id) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Nodes/ReloadSecureSettings.php b/src/OpenSearch/Endpoints/Nodes/ReloadSecureSettings.php index f858252d..6b3a6a14 100644 --- a/src/OpenSearch/Endpoints/Nodes/ReloadSecureSettings.php +++ b/src/OpenSearch/Endpoints/Nodes/ReloadSecureSettings.php @@ -56,7 +56,7 @@ public function getMethod(): string return 'POST'; } - public function setBody($body): ReloadSecureSettings + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -66,7 +66,7 @@ public function setBody($body): ReloadSecureSettings return $this; } - public function setNodeId($node_id): ReloadSecureSettings + public function setNodeId($node_id): static { if (isset($node_id) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Nodes/Stats.php b/src/OpenSearch/Endpoints/Nodes/Stats.php index 1758d29f..b3d84d19 100644 --- a/src/OpenSearch/Endpoints/Nodes/Stats.php +++ b/src/OpenSearch/Endpoints/Nodes/Stats.php @@ -79,7 +79,7 @@ public function getMethod(): string return 'GET'; } - public function setNodeId($node_id): Stats + public function setNodeId($node_id): static { if (isset($node_id) !== true) { return $this; @@ -92,7 +92,7 @@ public function setNodeId($node_id): Stats return $this; } - public function setMetric($metric): Stats + public function setMetric($metric): static { if (isset($metric) !== true) { return $this; @@ -105,7 +105,7 @@ public function setMetric($metric): Stats return $this; } - public function setIndexMetric($index_metric): Stats + public function setIndexMetric($index_metric): static { if (isset($index_metric) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Nodes/Usage.php b/src/OpenSearch/Endpoints/Nodes/Usage.php index 3693c591..18098ada 100644 --- a/src/OpenSearch/Endpoints/Nodes/Usage.php +++ b/src/OpenSearch/Endpoints/Nodes/Usage.php @@ -64,7 +64,7 @@ public function getMethod(): string return 'GET'; } - public function setNodeId($node_id): Usage + public function setNodeId($node_id): static { if (isset($node_id) !== true) { return $this; @@ -77,7 +77,7 @@ public function setNodeId($node_id): Usage return $this; } - public function setMetric($metric): Usage + public function setMetric($metric): static { if (isset($metric) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Notifications/CreateConfig.php b/src/OpenSearch/Endpoints/Notifications/CreateConfig.php index 72ddf593..a21b3c4c 100644 --- a/src/OpenSearch/Endpoints/Notifications/CreateConfig.php +++ b/src/OpenSearch/Endpoints/Notifications/CreateConfig.php @@ -43,7 +43,7 @@ public function getMethod(): string return 'POST'; } - public function setBody($body): CreateConfig + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Notifications/DeleteConfig.php b/src/OpenSearch/Endpoints/Notifications/DeleteConfig.php index afe39ff2..6bab9ea4 100644 --- a/src/OpenSearch/Endpoints/Notifications/DeleteConfig.php +++ b/src/OpenSearch/Endpoints/Notifications/DeleteConfig.php @@ -50,7 +50,7 @@ public function getMethod(): string return 'DELETE'; } - public function setConfigId($config_id): DeleteConfig + public function setConfigId($config_id): static { if (isset($config_id) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Notifications/GetConfig.php b/src/OpenSearch/Endpoints/Notifications/GetConfig.php index ded17c03..444dfb10 100644 --- a/src/OpenSearch/Endpoints/Notifications/GetConfig.php +++ b/src/OpenSearch/Endpoints/Notifications/GetConfig.php @@ -50,7 +50,7 @@ public function getMethod(): string return 'GET'; } - public function setConfigId($config_id): GetConfig + public function setConfigId($config_id): static { if (isset($config_id) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Notifications/GetConfigs.php b/src/OpenSearch/Endpoints/Notifications/GetConfigs.php index 34ac9b41..22d250e1 100644 --- a/src/OpenSearch/Endpoints/Notifications/GetConfigs.php +++ b/src/OpenSearch/Endpoints/Notifications/GetConfigs.php @@ -32,6 +32,8 @@ public function getParamWhitelist(): array return [ 'chime.url', 'chime.url.keyword', + 'config_id', + 'config_id_list', 'config_type', 'created_time_ms', 'description', @@ -81,7 +83,7 @@ public function getMethod(): string return 'GET'; } - public function setBody($body): GetConfigs + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Notifications/SendTest.php b/src/OpenSearch/Endpoints/Notifications/SendTest.php index 2066781c..2ff69181 100644 --- a/src/OpenSearch/Endpoints/Notifications/SendTest.php +++ b/src/OpenSearch/Endpoints/Notifications/SendTest.php @@ -50,7 +50,7 @@ public function getMethod(): string return 'GET'; } - public function setConfigId($config_id): SendTest + public function setConfigId($config_id): static { if (isset($config_id) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Notifications/UpdateConfig.php b/src/OpenSearch/Endpoints/Notifications/UpdateConfig.php index d493a5c7..55fa5575 100644 --- a/src/OpenSearch/Endpoints/Notifications/UpdateConfig.php +++ b/src/OpenSearch/Endpoints/Notifications/UpdateConfig.php @@ -50,7 +50,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): UpdateConfig + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -60,7 +60,7 @@ public function setBody($body): UpdateConfig return $this; } - public function setConfigId($config_id): UpdateConfig + public function setConfigId($config_id): static { if (isset($config_id) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Observability/CreateObject.php b/src/OpenSearch/Endpoints/Observability/CreateObject.php index 47494884..a88377e5 100644 --- a/src/OpenSearch/Endpoints/Observability/CreateObject.php +++ b/src/OpenSearch/Endpoints/Observability/CreateObject.php @@ -43,7 +43,7 @@ public function getMethod(): string return 'POST'; } - public function setBody($body): CreateObject + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Observability/DeleteObject.php b/src/OpenSearch/Endpoints/Observability/DeleteObject.php index cc600211..308d4da4 100644 --- a/src/OpenSearch/Endpoints/Observability/DeleteObject.php +++ b/src/OpenSearch/Endpoints/Observability/DeleteObject.php @@ -50,7 +50,7 @@ public function getMethod(): string return 'DELETE'; } - public function setObjectId($object_id): DeleteObject + public function setObjectId($object_id): static { if (isset($object_id) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Observability/GetObject.php b/src/OpenSearch/Endpoints/Observability/GetObject.php index e2cea7a8..ed967f9b 100644 --- a/src/OpenSearch/Endpoints/Observability/GetObject.php +++ b/src/OpenSearch/Endpoints/Observability/GetObject.php @@ -50,7 +50,7 @@ public function getMethod(): string return 'GET'; } - public function setObjectId($object_id): GetObject + public function setObjectId($object_id): static { if (isset($object_id) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Observability/UpdateObject.php b/src/OpenSearch/Endpoints/Observability/UpdateObject.php index a1c07f46..69d44e46 100644 --- a/src/OpenSearch/Endpoints/Observability/UpdateObject.php +++ b/src/OpenSearch/Endpoints/Observability/UpdateObject.php @@ -50,7 +50,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): UpdateObject + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -60,7 +60,7 @@ public function setBody($body): UpdateObject return $this; } - public function setObjectId($object_id): UpdateObject + public function setObjectId($object_id): static { if (isset($object_id) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Ppl/Explain.php b/src/OpenSearch/Endpoints/Ppl/Explain.php index 708526b7..4e1c0468 100644 --- a/src/OpenSearch/Endpoints/Ppl/Explain.php +++ b/src/OpenSearch/Endpoints/Ppl/Explain.php @@ -45,7 +45,7 @@ public function getMethod(): string return 'POST'; } - public function setBody($body): Explain + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Ppl/PostStats.php b/src/OpenSearch/Endpoints/Ppl/PostStats.php index 5efac6f3..e7763bdc 100644 --- a/src/OpenSearch/Endpoints/Ppl/PostStats.php +++ b/src/OpenSearch/Endpoints/Ppl/PostStats.php @@ -45,7 +45,7 @@ public function getMethod(): string return 'POST'; } - public function setBody($body): PostStats + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Ppl/Query.php b/src/OpenSearch/Endpoints/Ppl/Query.php index bb544c86..47c31e35 100644 --- a/src/OpenSearch/Endpoints/Ppl/Query.php +++ b/src/OpenSearch/Endpoints/Ppl/Query.php @@ -45,7 +45,7 @@ public function getMethod(): string return 'POST'; } - public function setBody($body): Query + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/PutScript.php b/src/OpenSearch/Endpoints/PutScript.php index cc779271..43323828 100644 --- a/src/OpenSearch/Endpoints/PutScript.php +++ b/src/OpenSearch/Endpoints/PutScript.php @@ -50,6 +50,7 @@ public function getParamWhitelist(): array { return [ 'cluster_manager_timeout', + 'context', 'master_timeout', 'timeout', 'pretty', @@ -65,7 +66,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): PutScript + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -75,7 +76,7 @@ public function setBody($body): PutScript return $this; } - public function setContext($context): PutScript + public function setContext($context): static { if (isset($context) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Query/DatasourceDelete.php b/src/OpenSearch/Endpoints/Query/DatasourceDelete.php index fac16196..717019ba 100644 --- a/src/OpenSearch/Endpoints/Query/DatasourceDelete.php +++ b/src/OpenSearch/Endpoints/Query/DatasourceDelete.php @@ -50,7 +50,7 @@ public function getMethod(): string return 'DELETE'; } - public function setDatasourceName($datasource_name): DatasourceDelete + public function setDatasourceName($datasource_name): static { if (isset($datasource_name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Query/DatasourceRetrieve.php b/src/OpenSearch/Endpoints/Query/DatasourceRetrieve.php index f45d1adb..e0472558 100644 --- a/src/OpenSearch/Endpoints/Query/DatasourceRetrieve.php +++ b/src/OpenSearch/Endpoints/Query/DatasourceRetrieve.php @@ -50,7 +50,7 @@ public function getMethod(): string return 'GET'; } - public function setDatasourceName($datasource_name): DatasourceRetrieve + public function setDatasourceName($datasource_name): static { if (isset($datasource_name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Query/DatasourcesCreate.php b/src/OpenSearch/Endpoints/Query/DatasourcesCreate.php index b2a47881..9f1c2d4e 100644 --- a/src/OpenSearch/Endpoints/Query/DatasourcesCreate.php +++ b/src/OpenSearch/Endpoints/Query/DatasourcesCreate.php @@ -43,7 +43,7 @@ public function getMethod(): string return 'POST'; } - public function setBody($body): DatasourcesCreate + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Query/DatasourcesUpdate.php b/src/OpenSearch/Endpoints/Query/DatasourcesUpdate.php index 4da38b36..6836d726 100644 --- a/src/OpenSearch/Endpoints/Query/DatasourcesUpdate.php +++ b/src/OpenSearch/Endpoints/Query/DatasourcesUpdate.php @@ -43,7 +43,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): DatasourcesUpdate + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/RankEval.php b/src/OpenSearch/Endpoints/RankEval.php index ee92c79f..4b1b23de 100644 --- a/src/OpenSearch/Endpoints/RankEval.php +++ b/src/OpenSearch/Endpoints/RankEval.php @@ -57,7 +57,7 @@ public function getMethod(): string return isset($this->body) ? 'POST' : 'GET'; } - public function setBody($body): RankEval + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Reindex.php b/src/OpenSearch/Endpoints/Reindex.php index 8aacbcda..85b19007 100644 --- a/src/OpenSearch/Endpoints/Reindex.php +++ b/src/OpenSearch/Endpoints/Reindex.php @@ -57,7 +57,7 @@ public function getMethod(): string return 'POST'; } - public function setBody($body): Reindex + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/ReindexRethrottle.php b/src/OpenSearch/Endpoints/ReindexRethrottle.php index 50d7bc45..fbbdb529 100644 --- a/src/OpenSearch/Endpoints/ReindexRethrottle.php +++ b/src/OpenSearch/Endpoints/ReindexRethrottle.php @@ -59,7 +59,7 @@ public function getMethod(): string return 'POST'; } - public function setTaskId($task_id): ReindexRethrottle + public function setTaskId($task_id): static { if (isset($task_id) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/RemoteStore/Restore.php b/src/OpenSearch/Endpoints/RemoteStore/Restore.php index d1c4630f..fb4c6c41 100644 --- a/src/OpenSearch/Endpoints/RemoteStore/Restore.php +++ b/src/OpenSearch/Endpoints/RemoteStore/Restore.php @@ -45,7 +45,7 @@ public function getMethod(): string return 'POST'; } - public function setBody($body): Restore + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/RenderSearchTemplate.php b/src/OpenSearch/Endpoints/RenderSearchTemplate.php index 80bea800..48e32042 100644 --- a/src/OpenSearch/Endpoints/RenderSearchTemplate.php +++ b/src/OpenSearch/Endpoints/RenderSearchTemplate.php @@ -53,7 +53,7 @@ public function getMethod(): string return isset($this->body) ? 'POST' : 'GET'; } - public function setBody($body): RenderSearchTemplate + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Rollups/Put.php b/src/OpenSearch/Endpoints/Rollups/Put.php index 6aa63aaf..dc8ec845 100644 --- a/src/OpenSearch/Endpoints/Rollups/Put.php +++ b/src/OpenSearch/Endpoints/Rollups/Put.php @@ -52,7 +52,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): Put + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/ScriptsPainlessExecute.php b/src/OpenSearch/Endpoints/ScriptsPainlessExecute.php index 5a6b8b71..1e3ecef2 100644 --- a/src/OpenSearch/Endpoints/ScriptsPainlessExecute.php +++ b/src/OpenSearch/Endpoints/ScriptsPainlessExecute.php @@ -49,7 +49,7 @@ public function getMethod(): string return isset($this->body) ? 'POST' : 'GET'; } - public function setBody($body): ScriptsPainlessExecute + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Scroll.php b/src/OpenSearch/Endpoints/Scroll.php index 907a555d..f4042d83 100644 --- a/src/OpenSearch/Endpoints/Scroll.php +++ b/src/OpenSearch/Endpoints/Scroll.php @@ -62,7 +62,7 @@ public function getMethod(): string return isset($this->body) ? 'POST' : 'GET'; } - public function setBody($body): Scroll + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -72,7 +72,7 @@ public function setBody($body): Scroll return $this; } - public function setScrollId($scroll_id): Scroll + public function setScrollId($scroll_id): static { if (isset($scroll_id) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Search.php b/src/OpenSearch/Endpoints/Search.php index 0bbdf51c..8380e3f5 100644 --- a/src/OpenSearch/Endpoints/Search.php +++ b/src/OpenSearch/Endpoints/Search.php @@ -99,7 +99,7 @@ public function getMethod(): string return isset($this->body) ? 'POST' : 'GET'; } - public function setBody($body): Search + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/SearchPipeline/Put.php b/src/OpenSearch/Endpoints/SearchPipeline/Put.php index c194a59d..dc0332a5 100644 --- a/src/OpenSearch/Endpoints/SearchPipeline/Put.php +++ b/src/OpenSearch/Endpoints/SearchPipeline/Put.php @@ -50,7 +50,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): Put + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/SearchTemplate.php b/src/OpenSearch/Endpoints/SearchTemplate.php index f297b183..e5236916 100644 --- a/src/OpenSearch/Endpoints/SearchTemplate.php +++ b/src/OpenSearch/Endpoints/SearchTemplate.php @@ -66,7 +66,7 @@ public function getMethod(): string return isset($this->body) ? 'POST' : 'GET'; } - public function setBody($body): SearchTemplate + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/ChangePassword.php b/src/OpenSearch/Endpoints/Security/ChangePassword.php index 12d2f7df..494921f5 100644 --- a/src/OpenSearch/Endpoints/Security/ChangePassword.php +++ b/src/OpenSearch/Endpoints/Security/ChangePassword.php @@ -43,7 +43,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): ChangePassword + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/ConfigUpgradeCheck.php b/src/OpenSearch/Endpoints/Security/ConfigUpgradeCheck.php index 7f105c3d..217d9978 100644 --- a/src/OpenSearch/Endpoints/Security/ConfigUpgradeCheck.php +++ b/src/OpenSearch/Endpoints/Security/ConfigUpgradeCheck.php @@ -24,7 +24,7 @@ class ConfigUpgradeCheck extends AbstractEndpoint { public function getURI(): string { - return "/_plugins/_security/_upgrade_check"; + return "/_plugins/_security/api/_upgrade_check"; } public function getParamWhitelist(): array diff --git a/src/OpenSearch/Endpoints/Security/ConfigUpgradePerform.php b/src/OpenSearch/Endpoints/Security/ConfigUpgradePerform.php index 25425359..cc68e11f 100644 --- a/src/OpenSearch/Endpoints/Security/ConfigUpgradePerform.php +++ b/src/OpenSearch/Endpoints/Security/ConfigUpgradePerform.php @@ -24,7 +24,7 @@ class ConfigUpgradePerform extends AbstractEndpoint { public function getURI(): string { - return "/_plugins/_security/_upgrade_perform"; + return "/_plugins/_security/api/_upgrade_perform"; } public function getParamWhitelist(): array @@ -43,7 +43,7 @@ public function getMethod(): string return 'POST'; } - public function setBody($body): ConfigUpgradePerform + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/CreateActionGroup.php b/src/OpenSearch/Endpoints/Security/CreateActionGroup.php index 22424f36..dfb844c0 100644 --- a/src/OpenSearch/Endpoints/Security/CreateActionGroup.php +++ b/src/OpenSearch/Endpoints/Security/CreateActionGroup.php @@ -52,7 +52,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): CreateActionGroup + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -62,7 +62,7 @@ public function setBody($body): CreateActionGroup return $this; } - public function setActionGroup($action_group): CreateActionGroup + public function setActionGroup($action_group): static { if (isset($action_group) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/CreateAllowlist.php b/src/OpenSearch/Endpoints/Security/CreateAllowlist.php index 7562eb98..1cccd618 100644 --- a/src/OpenSearch/Endpoints/Security/CreateAllowlist.php +++ b/src/OpenSearch/Endpoints/Security/CreateAllowlist.php @@ -43,7 +43,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): CreateAllowlist + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/CreateRole.php b/src/OpenSearch/Endpoints/Security/CreateRole.php index 7402b3e9..5bf8a7b5 100644 --- a/src/OpenSearch/Endpoints/Security/CreateRole.php +++ b/src/OpenSearch/Endpoints/Security/CreateRole.php @@ -52,7 +52,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): CreateRole + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -62,7 +62,7 @@ public function setBody($body): CreateRole return $this; } - public function setRole($role): CreateRole + public function setRole($role): static { if (isset($role) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/CreateRoleMapping.php b/src/OpenSearch/Endpoints/Security/CreateRoleMapping.php index 6fcd61b9..7acbb792 100644 --- a/src/OpenSearch/Endpoints/Security/CreateRoleMapping.php +++ b/src/OpenSearch/Endpoints/Security/CreateRoleMapping.php @@ -52,7 +52,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): CreateRoleMapping + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -62,7 +62,7 @@ public function setBody($body): CreateRoleMapping return $this; } - public function setRole($role): CreateRoleMapping + public function setRole($role): static { if (isset($role) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/CreateTenant.php b/src/OpenSearch/Endpoints/Security/CreateTenant.php index 54ce0ee0..5463d44d 100644 --- a/src/OpenSearch/Endpoints/Security/CreateTenant.php +++ b/src/OpenSearch/Endpoints/Security/CreateTenant.php @@ -52,7 +52,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): CreateTenant + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -62,7 +62,7 @@ public function setBody($body): CreateTenant return $this; } - public function setTenant($tenant): CreateTenant + public function setTenant($tenant): static { if (isset($tenant) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/CreateUpdateTenancyConfig.php b/src/OpenSearch/Endpoints/Security/CreateUpdateTenancyConfig.php index 3d60632f..15574d10 100644 --- a/src/OpenSearch/Endpoints/Security/CreateUpdateTenancyConfig.php +++ b/src/OpenSearch/Endpoints/Security/CreateUpdateTenancyConfig.php @@ -43,7 +43,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): CreateUpdateTenancyConfig + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/CreateUser.php b/src/OpenSearch/Endpoints/Security/CreateUser.php index b6934704..a4367738 100644 --- a/src/OpenSearch/Endpoints/Security/CreateUser.php +++ b/src/OpenSearch/Endpoints/Security/CreateUser.php @@ -52,7 +52,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): CreateUser + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -62,7 +62,7 @@ public function setBody($body): CreateUser return $this; } - public function setUsername($username): CreateUser + public function setUsername($username): static { if (isset($username) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/CreateUserLegacy.php b/src/OpenSearch/Endpoints/Security/CreateUserLegacy.php index e3f5ea21..4e2bd51f 100644 --- a/src/OpenSearch/Endpoints/Security/CreateUserLegacy.php +++ b/src/OpenSearch/Endpoints/Security/CreateUserLegacy.php @@ -52,7 +52,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): CreateUserLegacy + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -62,7 +62,7 @@ public function setBody($body): CreateUserLegacy return $this; } - public function setUsername($username): CreateUserLegacy + public function setUsername($username): static { if (isset($username) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/DeleteActionGroup.php b/src/OpenSearch/Endpoints/Security/DeleteActionGroup.php index 4257f964..9645e761 100644 --- a/src/OpenSearch/Endpoints/Security/DeleteActionGroup.php +++ b/src/OpenSearch/Endpoints/Security/DeleteActionGroup.php @@ -52,7 +52,7 @@ public function getMethod(): string return 'DELETE'; } - public function setActionGroup($action_group): DeleteActionGroup + public function setActionGroup($action_group): static { if (isset($action_group) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/DeleteDistinguishedName.php b/src/OpenSearch/Endpoints/Security/DeleteDistinguishedName.php index 8e892072..f80c7e9c 100644 --- a/src/OpenSearch/Endpoints/Security/DeleteDistinguishedName.php +++ b/src/OpenSearch/Endpoints/Security/DeleteDistinguishedName.php @@ -52,7 +52,7 @@ public function getMethod(): string return 'DELETE'; } - public function setClusterName($cluster_name): DeleteDistinguishedName + public function setClusterName($cluster_name): static { if (isset($cluster_name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/DeleteRole.php b/src/OpenSearch/Endpoints/Security/DeleteRole.php index cea84504..aa906d66 100644 --- a/src/OpenSearch/Endpoints/Security/DeleteRole.php +++ b/src/OpenSearch/Endpoints/Security/DeleteRole.php @@ -52,7 +52,7 @@ public function getMethod(): string return 'DELETE'; } - public function setRole($role): DeleteRole + public function setRole($role): static { if (isset($role) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/DeleteRoleMapping.php b/src/OpenSearch/Endpoints/Security/DeleteRoleMapping.php index d1ec1f13..67b6d54a 100644 --- a/src/OpenSearch/Endpoints/Security/DeleteRoleMapping.php +++ b/src/OpenSearch/Endpoints/Security/DeleteRoleMapping.php @@ -52,7 +52,7 @@ public function getMethod(): string return 'DELETE'; } - public function setRole($role): DeleteRoleMapping + public function setRole($role): static { if (isset($role) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/DeleteTenant.php b/src/OpenSearch/Endpoints/Security/DeleteTenant.php index be3a5d84..d2e4d89e 100644 --- a/src/OpenSearch/Endpoints/Security/DeleteTenant.php +++ b/src/OpenSearch/Endpoints/Security/DeleteTenant.php @@ -52,7 +52,7 @@ public function getMethod(): string return 'DELETE'; } - public function setTenant($tenant): DeleteTenant + public function setTenant($tenant): static { if (isset($tenant) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/DeleteUser.php b/src/OpenSearch/Endpoints/Security/DeleteUser.php index 639dc4a9..10c3b593 100644 --- a/src/OpenSearch/Endpoints/Security/DeleteUser.php +++ b/src/OpenSearch/Endpoints/Security/DeleteUser.php @@ -52,7 +52,7 @@ public function getMethod(): string return 'DELETE'; } - public function setUsername($username): DeleteUser + public function setUsername($username): static { if (isset($username) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/DeleteUserLegacy.php b/src/OpenSearch/Endpoints/Security/DeleteUserLegacy.php index 590494f4..cdaf7315 100644 --- a/src/OpenSearch/Endpoints/Security/DeleteUserLegacy.php +++ b/src/OpenSearch/Endpoints/Security/DeleteUserLegacy.php @@ -52,7 +52,7 @@ public function getMethod(): string return 'DELETE'; } - public function setUsername($username): DeleteUserLegacy + public function setUsername($username): static { if (isset($username) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/GenerateOboToken.php b/src/OpenSearch/Endpoints/Security/GenerateOboToken.php index d9855ae2..503d3021 100644 --- a/src/OpenSearch/Endpoints/Security/GenerateOboToken.php +++ b/src/OpenSearch/Endpoints/Security/GenerateOboToken.php @@ -43,7 +43,7 @@ public function getMethod(): string return 'POST'; } - public function setBody($body): GenerateOboToken + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/GenerateUserToken.php b/src/OpenSearch/Endpoints/Security/GenerateUserToken.php index 476d259d..16d21456 100644 --- a/src/OpenSearch/Endpoints/Security/GenerateUserToken.php +++ b/src/OpenSearch/Endpoints/Security/GenerateUserToken.php @@ -52,7 +52,7 @@ public function getMethod(): string return 'POST'; } - public function setUsername($username): GenerateUserToken + public function setUsername($username): static { if (isset($username) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/GenerateUserTokenLegacy.php b/src/OpenSearch/Endpoints/Security/GenerateUserTokenLegacy.php index b62ecc6e..4ebdfecd 100644 --- a/src/OpenSearch/Endpoints/Security/GenerateUserTokenLegacy.php +++ b/src/OpenSearch/Endpoints/Security/GenerateUserTokenLegacy.php @@ -52,7 +52,7 @@ public function getMethod(): string return 'POST'; } - public function setUsername($username): GenerateUserTokenLegacy + public function setUsername($username): static { if (isset($username) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/GetActionGroup.php b/src/OpenSearch/Endpoints/Security/GetActionGroup.php index 2e117de7..c0c51c54 100644 --- a/src/OpenSearch/Endpoints/Security/GetActionGroup.php +++ b/src/OpenSearch/Endpoints/Security/GetActionGroup.php @@ -52,7 +52,7 @@ public function getMethod(): string return 'GET'; } - public function setActionGroup($action_group): GetActionGroup + public function setActionGroup($action_group): static { if (isset($action_group) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/GetAllCertificates.php b/src/OpenSearch/Endpoints/Security/GetAllCertificates.php new file mode 100644 index 00000000..06b5fd43 --- /dev/null +++ b/src/OpenSearch/Endpoints/Security/GetAllCertificates.php @@ -0,0 +1,47 @@ +node_id ?? null; + if (isset($node_id)) { + return "/_plugins/_security/api/certificates/$node_id"; + } + throw new RuntimeException('Missing parameter for the endpoint security.get_node_certificates'); + } + + public function getParamWhitelist(): array + { + return [ + 'cert_type', + 'timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'GET'; + } + + public function setNodeId($node_id): static + { + if (isset($node_id) !== true) { + return $this; + } + $this->node_id = $node_id; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Security/GetRole.php b/src/OpenSearch/Endpoints/Security/GetRole.php index 21db28ce..de9dfc71 100644 --- a/src/OpenSearch/Endpoints/Security/GetRole.php +++ b/src/OpenSearch/Endpoints/Security/GetRole.php @@ -52,7 +52,7 @@ public function getMethod(): string return 'GET'; } - public function setRole($role): GetRole + public function setRole($role): static { if (isset($role) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/GetRoleMapping.php b/src/OpenSearch/Endpoints/Security/GetRoleMapping.php index 34656ac7..b58d74ec 100644 --- a/src/OpenSearch/Endpoints/Security/GetRoleMapping.php +++ b/src/OpenSearch/Endpoints/Security/GetRoleMapping.php @@ -52,7 +52,7 @@ public function getMethod(): string return 'GET'; } - public function setRole($role): GetRoleMapping + public function setRole($role): static { if (isset($role) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/GetTenant.php b/src/OpenSearch/Endpoints/Security/GetTenant.php index bbb46f22..dcfd3c00 100644 --- a/src/OpenSearch/Endpoints/Security/GetTenant.php +++ b/src/OpenSearch/Endpoints/Security/GetTenant.php @@ -52,7 +52,7 @@ public function getMethod(): string return 'GET'; } - public function setTenant($tenant): GetTenant + public function setTenant($tenant): static { if (isset($tenant) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/GetUser.php b/src/OpenSearch/Endpoints/Security/GetUser.php index 71616462..ec67393a 100644 --- a/src/OpenSearch/Endpoints/Security/GetUser.php +++ b/src/OpenSearch/Endpoints/Security/GetUser.php @@ -52,7 +52,7 @@ public function getMethod(): string return 'GET'; } - public function setUsername($username): GetUser + public function setUsername($username): static { if (isset($username) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/GetUserLegacy.php b/src/OpenSearch/Endpoints/Security/GetUserLegacy.php index 285bb353..f58bdf4d 100644 --- a/src/OpenSearch/Endpoints/Security/GetUserLegacy.php +++ b/src/OpenSearch/Endpoints/Security/GetUserLegacy.php @@ -52,7 +52,7 @@ public function getMethod(): string return 'GET'; } - public function setUsername($username): GetUserLegacy + public function setUsername($username): static { if (isset($username) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/PatchActionGroup.php b/src/OpenSearch/Endpoints/Security/PatchActionGroup.php index 23a7ae15..35e737aa 100644 --- a/src/OpenSearch/Endpoints/Security/PatchActionGroup.php +++ b/src/OpenSearch/Endpoints/Security/PatchActionGroup.php @@ -52,7 +52,7 @@ public function getMethod(): string return 'PATCH'; } - public function setBody($body): PatchActionGroup + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -62,7 +62,7 @@ public function setBody($body): PatchActionGroup return $this; } - public function setActionGroup($action_group): PatchActionGroup + public function setActionGroup($action_group): static { if (isset($action_group) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/PatchActionGroups.php b/src/OpenSearch/Endpoints/Security/PatchActionGroups.php index 1934ff7b..53e84258 100644 --- a/src/OpenSearch/Endpoints/Security/PatchActionGroups.php +++ b/src/OpenSearch/Endpoints/Security/PatchActionGroups.php @@ -43,7 +43,7 @@ public function getMethod(): string return 'PATCH'; } - public function setBody($body): PatchActionGroups + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/PatchAllowlist.php b/src/OpenSearch/Endpoints/Security/PatchAllowlist.php index 1bf9c04f..bbd76c6f 100644 --- a/src/OpenSearch/Endpoints/Security/PatchAllowlist.php +++ b/src/OpenSearch/Endpoints/Security/PatchAllowlist.php @@ -43,7 +43,7 @@ public function getMethod(): string return 'PATCH'; } - public function setBody($body): PatchAllowlist + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/PatchAuditConfiguration.php b/src/OpenSearch/Endpoints/Security/PatchAuditConfiguration.php index b20b9d43..3bcd2b91 100644 --- a/src/OpenSearch/Endpoints/Security/PatchAuditConfiguration.php +++ b/src/OpenSearch/Endpoints/Security/PatchAuditConfiguration.php @@ -43,7 +43,7 @@ public function getMethod(): string return 'PATCH'; } - public function setBody($body): PatchAuditConfiguration + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/PatchConfiguration.php b/src/OpenSearch/Endpoints/Security/PatchConfiguration.php index a1ab9a69..7fb935e2 100644 --- a/src/OpenSearch/Endpoints/Security/PatchConfiguration.php +++ b/src/OpenSearch/Endpoints/Security/PatchConfiguration.php @@ -43,7 +43,7 @@ public function getMethod(): string return 'PATCH'; } - public function setBody($body): PatchConfiguration + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/PatchDistinguishedName.php b/src/OpenSearch/Endpoints/Security/PatchDistinguishedName.php index 2a25baab..419d22cb 100644 --- a/src/OpenSearch/Endpoints/Security/PatchDistinguishedName.php +++ b/src/OpenSearch/Endpoints/Security/PatchDistinguishedName.php @@ -52,7 +52,7 @@ public function getMethod(): string return 'PATCH'; } - public function setBody($body): PatchDistinguishedName + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -62,7 +62,7 @@ public function setBody($body): PatchDistinguishedName return $this; } - public function setClusterName($cluster_name): PatchDistinguishedName + public function setClusterName($cluster_name): static { if (isset($cluster_name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/PatchDistinguishedNames.php b/src/OpenSearch/Endpoints/Security/PatchDistinguishedNames.php index 26e488a3..280dd322 100644 --- a/src/OpenSearch/Endpoints/Security/PatchDistinguishedNames.php +++ b/src/OpenSearch/Endpoints/Security/PatchDistinguishedNames.php @@ -43,7 +43,7 @@ public function getMethod(): string return 'PATCH'; } - public function setBody($body): PatchDistinguishedNames + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/PatchRole.php b/src/OpenSearch/Endpoints/Security/PatchRole.php index 5d285ec3..432817e7 100644 --- a/src/OpenSearch/Endpoints/Security/PatchRole.php +++ b/src/OpenSearch/Endpoints/Security/PatchRole.php @@ -52,7 +52,7 @@ public function getMethod(): string return 'PATCH'; } - public function setBody($body): PatchRole + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -62,7 +62,7 @@ public function setBody($body): PatchRole return $this; } - public function setRole($role): PatchRole + public function setRole($role): static { if (isset($role) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/PatchRoleMapping.php b/src/OpenSearch/Endpoints/Security/PatchRoleMapping.php index f1e9bf4f..b593f2bc 100644 --- a/src/OpenSearch/Endpoints/Security/PatchRoleMapping.php +++ b/src/OpenSearch/Endpoints/Security/PatchRoleMapping.php @@ -52,7 +52,7 @@ public function getMethod(): string return 'PATCH'; } - public function setBody($body): PatchRoleMapping + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -62,7 +62,7 @@ public function setBody($body): PatchRoleMapping return $this; } - public function setRole($role): PatchRoleMapping + public function setRole($role): static { if (isset($role) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/PatchRoleMappings.php b/src/OpenSearch/Endpoints/Security/PatchRoleMappings.php index 0282e913..29ef48b5 100644 --- a/src/OpenSearch/Endpoints/Security/PatchRoleMappings.php +++ b/src/OpenSearch/Endpoints/Security/PatchRoleMappings.php @@ -43,7 +43,7 @@ public function getMethod(): string return 'PATCH'; } - public function setBody($body): PatchRoleMappings + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/PatchRoles.php b/src/OpenSearch/Endpoints/Security/PatchRoles.php index 66c12962..cb1bb3b4 100644 --- a/src/OpenSearch/Endpoints/Security/PatchRoles.php +++ b/src/OpenSearch/Endpoints/Security/PatchRoles.php @@ -43,7 +43,7 @@ public function getMethod(): string return 'PATCH'; } - public function setBody($body): PatchRoles + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/PatchTenant.php b/src/OpenSearch/Endpoints/Security/PatchTenant.php index b7efa65d..a3902d56 100644 --- a/src/OpenSearch/Endpoints/Security/PatchTenant.php +++ b/src/OpenSearch/Endpoints/Security/PatchTenant.php @@ -52,7 +52,7 @@ public function getMethod(): string return 'PATCH'; } - public function setBody($body): PatchTenant + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -62,7 +62,7 @@ public function setBody($body): PatchTenant return $this; } - public function setTenant($tenant): PatchTenant + public function setTenant($tenant): static { if (isset($tenant) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/PatchTenants.php b/src/OpenSearch/Endpoints/Security/PatchTenants.php index 41a3dbc2..1f6b71a8 100644 --- a/src/OpenSearch/Endpoints/Security/PatchTenants.php +++ b/src/OpenSearch/Endpoints/Security/PatchTenants.php @@ -43,7 +43,7 @@ public function getMethod(): string return 'PATCH'; } - public function setBody($body): PatchTenants + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/PatchUser.php b/src/OpenSearch/Endpoints/Security/PatchUser.php index 14738465..b15e8471 100644 --- a/src/OpenSearch/Endpoints/Security/PatchUser.php +++ b/src/OpenSearch/Endpoints/Security/PatchUser.php @@ -52,7 +52,7 @@ public function getMethod(): string return 'PATCH'; } - public function setBody($body): PatchUser + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -62,7 +62,7 @@ public function setBody($body): PatchUser return $this; } - public function setUsername($username): PatchUser + public function setUsername($username): static { if (isset($username) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/PatchUsers.php b/src/OpenSearch/Endpoints/Security/PatchUsers.php index dafff0a4..8b61f658 100644 --- a/src/OpenSearch/Endpoints/Security/PatchUsers.php +++ b/src/OpenSearch/Endpoints/Security/PatchUsers.php @@ -43,7 +43,7 @@ public function getMethod(): string return 'PATCH'; } - public function setBody($body): PatchUsers + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/PostDashboardsInfo.php b/src/OpenSearch/Endpoints/Security/PostDashboardsInfo.php index 75bff211..87fff406 100644 --- a/src/OpenSearch/Endpoints/Security/PostDashboardsInfo.php +++ b/src/OpenSearch/Endpoints/Security/PostDashboardsInfo.php @@ -42,14 +42,4 @@ public function getMethod(): string { return 'POST'; } - - public function setBody($body): PostDashboardsInfo - { - if (isset($body) !== true) { - return $this; - } - $this->body = $body; - - return $this; - } } diff --git a/src/OpenSearch/Endpoints/Security/UpdateAuditConfiguration.php b/src/OpenSearch/Endpoints/Security/UpdateAuditConfiguration.php index 00ff896f..c5e6824a 100644 --- a/src/OpenSearch/Endpoints/Security/UpdateAuditConfiguration.php +++ b/src/OpenSearch/Endpoints/Security/UpdateAuditConfiguration.php @@ -43,7 +43,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): UpdateAuditConfiguration + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/UpdateConfiguration.php b/src/OpenSearch/Endpoints/Security/UpdateConfiguration.php index b805d6d5..b0862fd1 100644 --- a/src/OpenSearch/Endpoints/Security/UpdateConfiguration.php +++ b/src/OpenSearch/Endpoints/Security/UpdateConfiguration.php @@ -43,7 +43,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): UpdateConfiguration + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Security/UpdateDistinguishedName.php b/src/OpenSearch/Endpoints/Security/UpdateDistinguishedName.php index b78551c6..25d8f138 100644 --- a/src/OpenSearch/Endpoints/Security/UpdateDistinguishedName.php +++ b/src/OpenSearch/Endpoints/Security/UpdateDistinguishedName.php @@ -52,7 +52,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): UpdateDistinguishedName + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -62,7 +62,7 @@ public function setBody($body): UpdateDistinguishedName return $this; } - public function setClusterName($cluster_name): UpdateDistinguishedName + public function setClusterName($cluster_name): static { if (isset($cluster_name) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Snapshot/CleanupRepository.php b/src/OpenSearch/Endpoints/Snapshot/CleanupRepository.php index 4f7b5d72..33800a06 100644 --- a/src/OpenSearch/Endpoints/Snapshot/CleanupRepository.php +++ b/src/OpenSearch/Endpoints/Snapshot/CleanupRepository.php @@ -59,7 +59,7 @@ public function getMethod(): string return 'POST'; } - public function setRepository($repository): CleanupRepository + public function setRepository($repository): static { if (isset($repository) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Snapshot/CloneSnapshot.php b/src/OpenSearch/Endpoints/Snapshot/CloneSnapshot.php index 9808f55c..2d452330 100644 --- a/src/OpenSearch/Endpoints/Snapshot/CloneSnapshot.php +++ b/src/OpenSearch/Endpoints/Snapshot/CloneSnapshot.php @@ -62,7 +62,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): CloneSnapshot + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -72,7 +72,7 @@ public function setBody($body): CloneSnapshot return $this; } - public function setRepository($repository): CloneSnapshot + public function setRepository($repository): static { if (isset($repository) !== true) { return $this; @@ -82,7 +82,7 @@ public function setRepository($repository): CloneSnapshot return $this; } - public function setSnapshot($snapshot): CloneSnapshot + public function setSnapshot($snapshot): static { if (isset($snapshot) !== true) { return $this; @@ -92,7 +92,7 @@ public function setSnapshot($snapshot): CloneSnapshot return $this; } - public function setTargetSnapshot($target_snapshot): CloneSnapshot + public function setTargetSnapshot($target_snapshot): static { if (isset($target_snapshot) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Snapshot/Create.php b/src/OpenSearch/Endpoints/Snapshot/Create.php index e46cbd48..63c5ea70 100644 --- a/src/OpenSearch/Endpoints/Snapshot/Create.php +++ b/src/OpenSearch/Endpoints/Snapshot/Create.php @@ -61,7 +61,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): Create + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -71,7 +71,7 @@ public function setBody($body): Create return $this; } - public function setRepository($repository): Create + public function setRepository($repository): static { if (isset($repository) !== true) { return $this; @@ -81,7 +81,7 @@ public function setRepository($repository): Create return $this; } - public function setSnapshot($snapshot): Create + public function setSnapshot($snapshot): static { if (isset($snapshot) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Snapshot/CreateRepository.php b/src/OpenSearch/Endpoints/Snapshot/CreateRepository.php index 1fef0bed..5d5f7ef6 100644 --- a/src/OpenSearch/Endpoints/Snapshot/CreateRepository.php +++ b/src/OpenSearch/Endpoints/Snapshot/CreateRepository.php @@ -60,7 +60,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): CreateRepository + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -70,7 +70,7 @@ public function setBody($body): CreateRepository return $this; } - public function setRepository($repository): CreateRepository + public function setRepository($repository): static { if (isset($repository) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Snapshot/Delete.php b/src/OpenSearch/Endpoints/Snapshot/Delete.php index f543d1a6..9dd2492a 100644 --- a/src/OpenSearch/Endpoints/Snapshot/Delete.php +++ b/src/OpenSearch/Endpoints/Snapshot/Delete.php @@ -60,7 +60,7 @@ public function getMethod(): string return 'DELETE'; } - public function setRepository($repository): Delete + public function setRepository($repository): static { if (isset($repository) !== true) { return $this; @@ -70,7 +70,7 @@ public function setRepository($repository): Delete return $this; } - public function setSnapshot($snapshot): Delete + public function setSnapshot($snapshot): static { if (isset($snapshot) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Snapshot/DeleteRepository.php b/src/OpenSearch/Endpoints/Snapshot/DeleteRepository.php index b4f7bd36..8e84c488 100644 --- a/src/OpenSearch/Endpoints/Snapshot/DeleteRepository.php +++ b/src/OpenSearch/Endpoints/Snapshot/DeleteRepository.php @@ -59,7 +59,7 @@ public function getMethod(): string return 'DELETE'; } - public function setRepository($repository): DeleteRepository + public function setRepository($repository): static { if (isset($repository) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Snapshot/Get.php b/src/OpenSearch/Endpoints/Snapshot/Get.php index 77facdee..6951e15f 100644 --- a/src/OpenSearch/Endpoints/Snapshot/Get.php +++ b/src/OpenSearch/Endpoints/Snapshot/Get.php @@ -62,7 +62,7 @@ public function getMethod(): string return 'GET'; } - public function setRepository($repository): Get + public function setRepository($repository): static { if (isset($repository) !== true) { return $this; @@ -72,7 +72,7 @@ public function setRepository($repository): Get return $this; } - public function setSnapshot($snapshot): Get + public function setSnapshot($snapshot): static { if (isset($snapshot) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Snapshot/GetRepository.php b/src/OpenSearch/Endpoints/Snapshot/GetRepository.php index d9b3442f..c4603a28 100644 --- a/src/OpenSearch/Endpoints/Snapshot/GetRepository.php +++ b/src/OpenSearch/Endpoints/Snapshot/GetRepository.php @@ -58,7 +58,7 @@ public function getMethod(): string return 'GET'; } - public function setRepository($repository): GetRepository + public function setRepository($repository): static { if (isset($repository) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Snapshot/Restore.php b/src/OpenSearch/Endpoints/Snapshot/Restore.php index 575cc343..9c30e67a 100644 --- a/src/OpenSearch/Endpoints/Snapshot/Restore.php +++ b/src/OpenSearch/Endpoints/Snapshot/Restore.php @@ -61,7 +61,7 @@ public function getMethod(): string return 'POST'; } - public function setBody($body): Restore + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -71,7 +71,7 @@ public function setBody($body): Restore return $this; } - public function setRepository($repository): Restore + public function setRepository($repository): static { if (isset($repository) !== true) { return $this; @@ -81,7 +81,7 @@ public function setRepository($repository): Restore return $this; } - public function setSnapshot($snapshot): Restore + public function setSnapshot($snapshot): static { if (isset($snapshot) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Snapshot/Status.php b/src/OpenSearch/Endpoints/Snapshot/Status.php index 183272cb..d894ce8c 100644 --- a/src/OpenSearch/Endpoints/Snapshot/Status.php +++ b/src/OpenSearch/Endpoints/Snapshot/Status.php @@ -63,7 +63,7 @@ public function getMethod(): string return 'GET'; } - public function setRepository($repository): Status + public function setRepository($repository): static { if (isset($repository) !== true) { return $this; @@ -73,7 +73,7 @@ public function setRepository($repository): Status return $this; } - public function setSnapshot($snapshot): Status + public function setSnapshot($snapshot): static { if (isset($snapshot) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Snapshot/VerifyRepository.php b/src/OpenSearch/Endpoints/Snapshot/VerifyRepository.php index 6203bc29..4c8b0f87 100644 --- a/src/OpenSearch/Endpoints/Snapshot/VerifyRepository.php +++ b/src/OpenSearch/Endpoints/Snapshot/VerifyRepository.php @@ -59,7 +59,7 @@ public function getMethod(): string return 'POST'; } - public function setRepository($repository): VerifyRepository + public function setRepository($repository): static { if (isset($repository) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Sql/Close.php b/src/OpenSearch/Endpoints/Sql/Close.php index 2ef15e00..dd9f8d32 100644 --- a/src/OpenSearch/Endpoints/Sql/Close.php +++ b/src/OpenSearch/Endpoints/Sql/Close.php @@ -45,7 +45,7 @@ public function getMethod(): string return 'POST'; } - public function setBody($body): Close + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Sql/Explain.php b/src/OpenSearch/Endpoints/Sql/Explain.php index 6291c3b3..c7380165 100644 --- a/src/OpenSearch/Endpoints/Sql/Explain.php +++ b/src/OpenSearch/Endpoints/Sql/Explain.php @@ -45,7 +45,7 @@ public function getMethod(): string return 'POST'; } - public function setBody($body): Explain + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Sql/PostStats.php b/src/OpenSearch/Endpoints/Sql/PostStats.php index 744ae997..4e1073dd 100644 --- a/src/OpenSearch/Endpoints/Sql/PostStats.php +++ b/src/OpenSearch/Endpoints/Sql/PostStats.php @@ -45,7 +45,7 @@ public function getMethod(): string return 'POST'; } - public function setBody($body): PostStats + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Sql/Query.php b/src/OpenSearch/Endpoints/Sql/Query.php index c92970e0..47d3699e 100644 --- a/src/OpenSearch/Endpoints/Sql/Query.php +++ b/src/OpenSearch/Endpoints/Sql/Query.php @@ -45,7 +45,7 @@ public function getMethod(): string return 'POST'; } - public function setBody($body): Query + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Sql/Settings.php b/src/OpenSearch/Endpoints/Sql/Settings.php index 78289826..5872d364 100644 --- a/src/OpenSearch/Endpoints/Sql/Settings.php +++ b/src/OpenSearch/Endpoints/Sql/Settings.php @@ -44,7 +44,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): Settings + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Tasks/Cancel.php b/src/OpenSearch/Endpoints/Tasks/Cancel.php index 83deffe9..2d578c53 100644 --- a/src/OpenSearch/Endpoints/Tasks/Cancel.php +++ b/src/OpenSearch/Endpoints/Tasks/Cancel.php @@ -59,7 +59,7 @@ public function getMethod(): string return 'POST'; } - public function setTaskId($task_id): Cancel + public function setTaskId($task_id): static { if (isset($task_id) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Tasks/Get.php b/src/OpenSearch/Endpoints/Tasks/Get.php index df8e113d..198941ab 100644 --- a/src/OpenSearch/Endpoints/Tasks/Get.php +++ b/src/OpenSearch/Endpoints/Tasks/Get.php @@ -58,7 +58,7 @@ public function getMethod(): string return 'GET'; } - public function setTaskId($task_id): Get + public function setTaskId($task_id): static { if (isset($task_id) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/TermVectors.php b/src/OpenSearch/Endpoints/TermVectors.php index c06aefdb..7a35caf1 100644 --- a/src/OpenSearch/Endpoints/TermVectors.php +++ b/src/OpenSearch/Endpoints/TermVectors.php @@ -71,7 +71,7 @@ public function getMethod(): string return isset($this->body) ? 'POST' : 'GET'; } - public function setBody($body): TermVectors + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Transforms/Preview.php b/src/OpenSearch/Endpoints/Transforms/Preview.php index 7600a1c8..167422e5 100644 --- a/src/OpenSearch/Endpoints/Transforms/Preview.php +++ b/src/OpenSearch/Endpoints/Transforms/Preview.php @@ -40,6 +40,16 @@ public function getParamWhitelist(): array public function getMethod(): string { - return 'GET'; + return 'POST'; + } + + public function setBody($body): static + { + if (isset($body) !== true) { + return $this; + } + $this->body = $body; + + return $this; } } diff --git a/src/OpenSearch/Endpoints/Transforms/Put.php b/src/OpenSearch/Endpoints/Transforms/Put.php index 68c37191..5230fc88 100644 --- a/src/OpenSearch/Endpoints/Transforms/Put.php +++ b/src/OpenSearch/Endpoints/Transforms/Put.php @@ -50,7 +50,7 @@ public function getMethod(): string return 'PUT'; } - public function setBody($body): Put + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/Update.php b/src/OpenSearch/Endpoints/Update.php index eedb3019..a45d4ee2 100644 --- a/src/OpenSearch/Endpoints/Update.php +++ b/src/OpenSearch/Endpoints/Update.php @@ -74,7 +74,7 @@ public function getMethod(): string return 'POST'; } - public function setBody($body): Update + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/UpdateByQuery.php b/src/OpenSearch/Endpoints/UpdateByQuery.php index f08a450e..627176dd 100644 --- a/src/OpenSearch/Endpoints/UpdateByQuery.php +++ b/src/OpenSearch/Endpoints/UpdateByQuery.php @@ -90,7 +90,7 @@ public function getMethod(): string return 'POST'; } - public function setBody($body): UpdateByQuery + public function setBody($body): static { if (isset($body) !== true) { return $this; diff --git a/src/OpenSearch/Endpoints/UpdateByQueryRethrottle.php b/src/OpenSearch/Endpoints/UpdateByQueryRethrottle.php index 37d8f7ff..1281a1ab 100644 --- a/src/OpenSearch/Endpoints/UpdateByQueryRethrottle.php +++ b/src/OpenSearch/Endpoints/UpdateByQueryRethrottle.php @@ -59,7 +59,7 @@ public function getMethod(): string return 'POST'; } - public function setTaskId($task_id): UpdateByQueryRethrottle + public function setTaskId($task_id): static { if (isset($task_id) !== true) { return $this; diff --git a/src/OpenSearch/Handlers/SigV4Handler.php b/src/OpenSearch/Handlers/SigV4Handler.php deleted file mode 100644 index e45639c7..00000000 --- a/src/OpenSearch/Handlers/SigV4Handler.php +++ /dev/null @@ -1,151 +0,0 @@ ->, body: string|resource|null, client?: array} - */ -class SigV4Handler -{ - /** - * @var SignatureV4 - */ - private $signer; - /** - * @var callable - */ - private $credentialProvider; - /** - * @var callable - */ - private $wrappedHandler; - - /** - * A handler that applies an AWS V4 signature before dispatching requests. - * - * @param string $region The region of your Amazon - * OpenSearch Service domain - * @param string $service The Service of your Amazon - * OpenSearch Service domain - * @param callable|null $credentialProvider A callable that returns a - * promise that is fulfilled - * with an instance of - * Aws\Credentials\Credentials - * @param callable|null $wrappedHandler A RingPHP handler - */ - public function __construct( - string $region, - string $service, - ?callable $credentialProvider = null, - ?callable $wrappedHandler = null - ) { - self::assertDependenciesInstalled(); - $this->signer = new SignatureV4($service, $region); - $this->wrappedHandler = $wrappedHandler - ?: ClientBuilder::defaultHandler(); - $this->credentialProvider = $credentialProvider - ?: CredentialProvider::defaultProvider(); - } - - /** - * @phpstan-param RingPhpRequest $request - */ - public function __invoke(array $request) - { - $creds = call_user_func($this->credentialProvider)->wait(); - - $psr7Request = $this->createPsr7Request($request); - $psr7Request = $psr7Request->withHeader('x-amz-content-sha256', Utils::hash($psr7Request->getBody(), 'sha256')); - $signedRequest = $this->signer - ->signRequest($psr7Request, $creds); - return call_user_func($this->wrappedHandler, $this->createRingRequest($signedRequest, $request)); - } - - public static function assertDependenciesInstalled(): void - { - if (!class_exists(SignatureV4::class)) { - throw new RuntimeException( - 'The AWS SDK for PHP must be installed in order to use the SigV4 signing handler' - ); - } - } - - /** - * @phpstan-param RingPhpRequest $ringPhpRequest - */ - private function createPsr7Request(array $ringPhpRequest): Request - { - // fix for uppercase 'Host' array key in elasticsearch-php 5.3.1 and backward compatible - // https://github.com/aws/aws-sdk-php/issues/1225 - $hostKey = isset($ringPhpRequest['headers']['Host']) ? 'Host' : 'host'; - - // Amazon ES/OS listens on standard ports (443 for HTTPS, 80 for HTTP). - // Consequently, the port should be stripped from the host header. - $parsedUrl = parse_url($ringPhpRequest['headers'][$hostKey][0]); - if (isset($parsedUrl['host'])) { - $ringPhpRequest['headers'][$hostKey][0] = $parsedUrl['host']; - } - - // Create a PSR-7 URI from the array passed to the handler - $uri = (new Uri($ringPhpRequest['uri'])) - ->withScheme($ringPhpRequest['scheme']) - ->withHost($ringPhpRequest['headers'][$hostKey][0]); - if (isset($ringPhpRequest['query_string'])) { - $uri = $uri->withQuery($ringPhpRequest['query_string']); - } - - // Create a PSR-7 request from the array passed to the handler - return new Request( - $ringPhpRequest['http_method'], - $uri, - $ringPhpRequest['headers'], - $ringPhpRequest['body'] - ); - } - - /** - * @phpstan-param RingPhpRequest $originalRequest - * - * @phpstan-return RingPhpRequest - */ - private function createRingRequest(RequestInterface $request, array $originalRequest): array - { - $uri = $request->getUri(); - $body = (string) $request->getBody(); - - // RingPHP currently expects empty message bodies to be null: - // https://github.com/guzzle/RingPHP/blob/4c8fe4c48a0fb7cc5e41ef529e43fecd6da4d539/src/Client/CurlFactory.php#L202 - if (empty($body)) { - $body = null; - } - - // Reset the explicit port in the URL - $client = $originalRequest['client']; - unset($client['curl'][CURLOPT_PORT]); - - $ringRequest = [ - 'http_method' => $request->getMethod(), - 'scheme' => $uri->getScheme(), - 'uri' => $uri->getPath(), - 'body' => $body, - 'headers' => $request->getHeaders(), - 'client' => $client - ]; - if ($uri->getQuery()) { - $ringRequest['query_string'] = $uri->getQuery(); - } - - return $ringRequest; - } -} diff --git a/src/OpenSearch/Namespaces/AbstractNamespace.php b/src/OpenSearch/Namespaces/AbstractNamespace.php index 0b5a7a32..f48278d5 100644 --- a/src/OpenSearch/Namespaces/AbstractNamespace.php +++ b/src/OpenSearch/Namespaces/AbstractNamespace.php @@ -21,25 +21,37 @@ namespace OpenSearch\Namespaces; -use OpenSearch\Endpoints\AbstractEndpoint; +use Http\Promise\Promise; +use OpenSearch\EndpointFactoryInterface; +use OpenSearch\EndpointInterface; use OpenSearch\Transport; +use Psr\Http\Message\ResponseInterface; abstract class AbstractNamespace { + public function __construct( + protected readonly Transport $transport, + protected readonly EndpointFactoryInterface $endpointFactory, + ) { + } + + protected bool $isAsync = false; + /** - * @var \OpenSearch\Transport + * Check if the client is running in async mode. */ - protected $transport; + public function isAsync(): bool + { + return $this->isAsync; + } /** - * @var callable + * Set the client to run in async mode. */ - protected $endpoints; - - public function __construct(Transport $transport, callable $endpoints) + public function setAsync(bool $isAsync): static { - $this->transport = $transport; - $this->endpoints = $endpoints; + $this->isAsync = $isAsync; + return $this; } /** @@ -56,16 +68,23 @@ public function extractArgument(array &$params, string $arg) } } - protected function performRequest(AbstractEndpoint $endpoint) + /** + * Perform the request. + * + * @throws \Psr\Http\Client\ClientExceptionInterface|\Exception + */ + protected function performRequest(EndpointInterface $endpoint): Promise|ResponseInterface { - $response = $this->transport->performRequest( + $request = $this->transport->createRequest( $endpoint->getMethod(), $endpoint->getURI(), $endpoint->getParams(), $endpoint->getBody(), - $endpoint->getOptions() ); - - return $this->transport->resultOrFuture($response, $endpoint->getOptions()); + if ($this->isAsync()) { + return $this->transport->sendAsyncRequest($request); + } + return $this->transport->sendRequest($request); } + } diff --git a/src/OpenSearch/Namespaces/AsynchronousSearchNamespace.php b/src/OpenSearch/Namespaces/AsynchronousSearchNamespace.php new file mode 100644 index 00000000..8400201f --- /dev/null +++ b/src/OpenSearch/Namespaces/AsynchronousSearchNamespace.php @@ -0,0 +1,120 @@ +extractArgument($params, 'id'); + + $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. + * + * $params['id'] = (string) (Required) + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. + * $params['human'] = (boolean) Whether to return human readable values for statistics. + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. + * $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 "-". + * + * @param array $params Associative array of parameters + * @return array + */ + public function get(array $params = []) + { + $id = $this->extractArgument($params, 'id'); + + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\AsynchronousSearch\Get::class); + $endpoint->setParams($params); + $endpoint->setId($id); + + return $this->performRequest($endpoint); + } + + /** + * Perform an asynchronous search. + * + * $params['index'] = (string) The name of the index to be searched. + * $params['keep_alive'] = (string) The amount of time that the result is saved in the cluster. + * $params['keep_on_completion'] = (boolean) Whether you want to save the results in the cluster after the search is complete. + * $params['wait_for_completion_timeout'] = (string) The amount of time that you plan to wait for the results. + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. + * $params['human'] = (boolean) Whether to return human readable values for statistics. + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. + * $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 "-". + * + * @param array $params Associative array of parameters + * @return array + */ + public function search(array $params = []) + { + $body = $this->extractArgument($params, 'body'); + + $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. + * + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. + * $params['human'] = (boolean) Whether to return human readable values for statistics. + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. + * $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 "-". + * + * @param array $params Associative array of parameters + * @return array + */ + public function stats(array $params = []) + { + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\AsynchronousSearch\Stats::class); + $endpoint->setParams($params); + + return $this->performRequest($endpoint); + } + +} diff --git a/src/OpenSearch/Namespaces/BooleanRequestWrapper.php b/src/OpenSearch/Namespaces/BooleanRequestWrapper.php index 9c29f656..50138316 100644 --- a/src/OpenSearch/Namespaces/BooleanRequestWrapper.php +++ b/src/OpenSearch/Namespaces/BooleanRequestWrapper.php @@ -24,6 +24,7 @@ use OpenSearch\Common\Exceptions\Missing404Exception; use OpenSearch\Common\Exceptions\RoutingMissingException; use OpenSearch\Endpoints\AbstractEndpoint; +use OpenSearch\Endpoints\EndpointInterface; use OpenSearch\Transport; use GuzzleHttp\Ring\Future\FutureArrayInterface; @@ -35,7 +36,7 @@ abstract class BooleanRequestWrapper * @throws Missing404Exception * @throws RoutingMissingException */ - public static function performRequest(AbstractEndpoint $endpoint, Transport $transport) + public static function performRequest(EndpointInterface $endpoint, Transport $transport) { try { $response = $transport->performRequest( diff --git a/src/OpenSearch/Namespaces/CatNamespace.php b/src/OpenSearch/Namespaces/CatNamespace.php index d51d8223..957b5eb2 100644 --- a/src/OpenSearch/Namespaces/CatNamespace.php +++ b/src/OpenSearch/Namespaces/CatNamespace.php @@ -21,8 +21,6 @@ namespace OpenSearch\Namespaces; -use OpenSearch\Namespaces\AbstractNamespace; - /** * Class CatNamespace * @@ -45,7 +43,7 @@ class CatNamespace extends AbstractNamespace * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -54,13 +52,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. * @@ -74,19 +72,19 @@ public function aliases(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -104,7 +102,7 @@ public function allPitSegments(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -113,13 +111,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. * @@ -135,19 +133,19 @@ public function allocation(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -161,7 +159,7 @@ public function clusterManager(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -170,13 +168,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. * @@ -191,7 +189,7 @@ public function count(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -200,13 +198,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. * @@ -221,19 +219,19 @@ public function fielddata(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -241,19 +239,19 @@ public function health(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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, ... * @@ -276,7 +274,7 @@ public function help(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -285,13 +283,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. * @@ -307,19 +305,19 @@ public function indices(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -335,19 +333,19 @@ public function master(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -366,19 +364,19 @@ public function nodeattrs(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -395,19 +393,19 @@ public function nodes(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -421,7 +419,7 @@ public function pendingTasks(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -430,13 +428,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. * @@ -452,19 +450,19 @@ public function pitSegments(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -482,7 +480,7 @@ public function plugins(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -491,13 +489,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. * @@ -513,19 +511,19 @@ public function recovery(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -550,7 +548,7 @@ public function repositories(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -559,13 +557,13 @@ 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. * @@ -582,7 +580,7 @@ public function segmentReplication(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -591,13 +589,13 @@ 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. * @@ -616,7 +614,7 @@ public function segments(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -625,13 +623,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. * @@ -649,7 +647,7 @@ public function shards(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -658,13 +656,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. * @@ -680,7 +678,7 @@ public function snapshots(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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['node_id'] = (array) Comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes. * $params['parent_task'] = (string) The parent task identifier, which is used to limit the response. * @@ -689,12 +687,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. * @@ -711,7 +709,7 @@ public function tasks(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -720,13 +718,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. * @@ -744,7 +742,7 @@ public function templates(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -753,11 +751,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 dbe85126..c218d231 100644 --- a/src/OpenSearch/Namespaces/ClusterNamespace.php +++ b/src/OpenSearch/Namespaces/ClusterNamespace.php @@ -21,8 +21,6 @@ namespace OpenSearch\Namespaces; -use OpenSearch\Namespaces\AbstractNamespace; - /** * Class ClusterNamespace * @@ -39,7 +37,7 @@ class ClusterNamespace extends AbstractNamespace * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The index, shard, and primary flag to explain. Empty means 'explain the first unassigned shard' * * @param array $params Associative array of parameters @@ -49,13 +47,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. * @@ -67,7 +65,7 @@ public function allocationExplain(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -76,13 +74,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. * @@ -90,19 +88,19 @@ public function deleteComponentTemplate(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -111,19 +109,19 @@ public function deleteDecommissionAwareness(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -131,19 +129,22 @@ public function deleteVotingConfigExclusions(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ public function deleteWeightedRouting(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Cluster\DeleteWeightedRouting'); + $body = $this->extractArgument($params, 'body'); + + $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. * @@ -155,7 +156,7 @@ public function deleteWeightedRouting(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return bool @@ -167,13 +168,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. * @@ -185,7 +186,7 @@ public function existsComponentTemplate(array $params = []): bool * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -194,13 +195,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. * @@ -209,7 +210,7 @@ public function getComponentTemplate(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -218,13 +219,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. * @@ -237,19 +238,19 @@ public function getDecommissionAwareness(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -258,7 +259,7 @@ public function getSettings(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -267,13 +268,13 @@ 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. * @@ -295,7 +296,7 @@ public function getWeightedRouting(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -304,13 +305,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. * @@ -321,19 +322,19 @@ public function health(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -344,19 +345,19 @@ public function pendingTasks(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -369,7 +370,7 @@ public function postVotingConfigExclusions(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The template definition (Required) * * @param array $params Associative array of parameters @@ -380,14 +381,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. * @@ -397,7 +398,7 @@ public function putComponentTemplate(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -407,14 +408,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. * @@ -426,7 +427,7 @@ public function putDecommissionAwareness(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The settings to be updated. Can be either `transient` or `persistent` (survives cluster restart). (Required) * * @param array $params Associative array of parameters @@ -436,13 +437,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. * @@ -451,7 +452,7 @@ public function putSettings(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -459,14 +460,16 @@ public function putSettings(array $params = []) 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. * @@ -474,19 +477,19 @@ public function putWeightedRouting(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -501,7 +504,7 @@ public function remoteInfo(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The definition of `commands` to perform (`move`, `cancel`, `allocate`) * * @param array $params Associative array of parameters @@ -511,13 +514,13 @@ 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. * @@ -530,13 +533,13 @@ public function reroute(array $params = []) * $params['ignore_unavailable'] = (boolean) Whether specified concrete indices 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'] = (number) Wait for the metadata version to be equal or greater than the specified metadata version + * $params['wait_for_metadata_version'] = (integer) Wait for the metadata version to be equal or greater than the specified metadata version * $params['wait_for_timeout'] = (string) The maximum time to wait for wait_for_metadata_version before timing out * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -546,14 +549,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. * @@ -564,7 +567,7 @@ public function state(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -573,11 +576,11 @@ public function stats(array $params = []) { $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->setNodeId($node_id); return $this->performRequest($endpoint); } + } diff --git a/src/OpenSearch/Namespaces/DanglingIndicesNamespace.php b/src/OpenSearch/Namespaces/DanglingIndicesNamespace.php index ff17095b..206fa661 100644 --- a/src/OpenSearch/Namespaces/DanglingIndicesNamespace.php +++ b/src/OpenSearch/Namespaces/DanglingIndicesNamespace.php @@ -21,8 +21,6 @@ namespace OpenSearch\Namespaces; -use OpenSearch\Namespaces\AbstractNamespace; - /** * Class DanglingIndicesNamespace * @@ -42,7 +40,7 @@ class DanglingIndicesNamespace extends AbstractNamespace * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -51,13 +49,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. * @@ -70,7 +68,7 @@ public function deleteDanglingIndex(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -79,13 +77,13 @@ 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. * @@ -93,17 +91,17 @@ public function importDanglingIndex(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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 new file mode 100644 index 00000000..3b71ef5f --- /dev/null +++ b/src/OpenSearch/Namespaces/FlowFrameworkNamespace.php @@ -0,0 +1,276 @@ +extractArgument($params, 'body'); + + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\FlowFramework\Create::class); + $endpoint->setParams($params); + $endpoint->setBody($body); + + return $this->performRequest($endpoint); + } + + /** + * Delete a workflow. + * + * $params['workflow_id'] = (string) + * $params['clear_status'] = (boolean) (Default = false) + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. + * $params['human'] = (boolean) Whether to return human readable values for statistics. + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. + * $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 "-". + * + * @param array $params Associative array of parameters + * @return array + */ + public function delete(array $params = []) + { + $workflow_id = $this->extractArgument($params, 'workflow_id'); + + $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. + * + * $params['workflow_id'] = (string) + * $params['allow_delete'] = (string) + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. + * $params['human'] = (boolean) Whether to return human readable values for statistics. + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. + * $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 "-". + * + * @param array $params Associative array of parameters + * @return array + */ + public function deprovision(array $params = []) + { + $workflow_id = $this->extractArgument($params, 'workflow_id'); + + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\FlowFramework\Deprovision::class); + $endpoint->setParams($params); + $endpoint->setWorkflowId($workflow_id); + + return $this->performRequest($endpoint); + } + + /** + * Get a workflow. + * + * $params['workflow_id'] = (string) + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. + * $params['human'] = (boolean) Whether to return human readable values for statistics. + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. + * $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 "-". + * + * @param array $params Associative array of parameters + * @return array + */ + public function get(array $params = []) + { + $workflow_id = $this->extractArgument($params, 'workflow_id'); + + $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. + * + * $params['workflow_id'] = (string) + * $params['all'] = (boolean) The all parameter specifies whether the response should return all fields. (Default = false) + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. + * $params['human'] = (boolean) Whether to return human readable values for statistics. + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. + * $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 "-". + * + * @param array $params Associative array of parameters + * @return array + */ + public function getStatus(array $params = []) + { + $workflow_id = $this->extractArgument($params, 'workflow_id'); + + $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. + * + * $params['workflow_step'] = (string) + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. + * $params['human'] = (boolean) Whether to return human readable values for statistics. + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. + * $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 "-". + * + * @param array $params Associative array of parameters + * @return array + */ + public function getSteps(array $params = []) + { + $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. + * + * $params['workflow_id'] = (string) + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. + * $params['human'] = (boolean) Whether to return human readable values for statistics. + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. + * $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 "-". + * + * @param array $params Associative array of parameters + * @return array + */ + public function provision(array $params = []) + { + $workflow_id = $this->extractArgument($params, 'workflow_id'); + $body = $this->extractArgument($params, 'body'); + + $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. + * + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. + * $params['human'] = (boolean) Whether to return human readable values for statistics. + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. + * $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 "-". + * + * @param array $params Associative array of parameters + * @return array + */ + public function search(array $params = []) + { + $body = $this->extractArgument($params, 'body'); + + $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. + * + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. + * $params['human'] = (boolean) Whether to return human readable values for statistics. + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. + * $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 "-". + * + * @param array $params Associative array of parameters + * @return array + */ + public function searchState(array $params = []) + { + $body = $this->extractArgument($params, 'body'); + + $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. + * + * $params['workflow_id'] = (string) + * $params['provision'] = (boolean) (Default = false) + * $params['reprovision'] = (boolean) (Default = false) + * $params['update_fields'] = (boolean) (Default = false) + * $params['use_case'] = (string) To use a workflow template, specify it in the use_case query parameter when creating a workflow. + * $params['validation'] = (string) (Default = all) + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. + * $params['human'] = (boolean) Whether to return human readable values for statistics. + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. + * $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 "-". + * + * @param array $params Associative array of parameters + * @return array + */ + public function update(array $params = []) + { + $workflow_id = $this->extractArgument($params, 'workflow_id'); + $body = $this->extractArgument($params, 'body'); + + $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 7d6b5ca5..43d95e87 100644 --- a/src/OpenSearch/Namespaces/IndicesNamespace.php +++ b/src/OpenSearch/Namespaces/IndicesNamespace.php @@ -21,8 +21,6 @@ namespace OpenSearch\Namespaces; -use OpenSearch\Namespaces\AbstractNamespace; - /** * Class IndicesNamespace * @@ -45,7 +43,7 @@ class IndicesNamespace extends AbstractNamespace * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -55,14 +53,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. * @@ -71,7 +69,7 @@ public function addBlock(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) Define analyzer/tokenizer parameters and the text on which the analysis should be performed * * @param array $params Associative array of parameters @@ -82,14 +80,14 @@ 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. * @@ -106,7 +104,7 @@ public function analyze(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -115,13 +113,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. * @@ -137,7 +135,7 @@ public function clearCache(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The configuration for the target index (`settings` and `aliases`) * * @param array $params Associative array of parameters @@ -149,8 +147,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,6 +155,7 @@ public function clone(array $params = []) return $this->performRequest($endpoint); } + /** * Closes an index. * @@ -173,7 +171,7 @@ public function clone(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -182,13 +180,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. * @@ -201,7 +199,7 @@ public function close(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The configuration for the index (`settings` and `mappings`) * * @param array $params Associative array of parameters @@ -212,14 +210,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. * @@ -228,7 +226,7 @@ public function create(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The data stream definition * * @param array $params Associative array of parameters @@ -239,14 +237,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. * @@ -255,7 +253,7 @@ public function createDataStream(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -264,13 +262,13 @@ 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. * @@ -285,7 +283,7 @@ public function dataStreamsStats(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -294,13 +292,13 @@ 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. * @@ -313,7 +311,7 @@ public function delete(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -323,14 +321,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. * @@ -339,7 +337,7 @@ public function deleteAlias(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -348,13 +346,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. * @@ -366,7 +364,7 @@ public function deleteDataStream(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -375,13 +373,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. * @@ -393,7 +391,7 @@ public function deleteIndexTemplate(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -402,13 +400,13 @@ 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. * @@ -424,7 +422,7 @@ public function deleteTemplate(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return bool @@ -436,13 +434,13 @@ 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. * @@ -456,7 +454,7 @@ public function exists(array $params = []): bool * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return bool @@ -469,14 +467,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. * @@ -489,7 +487,7 @@ public function existsAlias(array $params = []): bool * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return bool @@ -501,13 +499,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. * @@ -520,7 +518,7 @@ public function existsIndexTemplate(array $params = []): bool * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return bool @@ -532,13 +530,13 @@ 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. * @@ -552,7 +550,7 @@ public function existsTemplate(array $params = []): bool * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -561,13 +559,13 @@ 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. * @@ -584,7 +582,7 @@ public function flush(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -593,13 +591,13 @@ 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. * @@ -616,7 +614,7 @@ public function forcemerge(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -625,13 +623,13 @@ 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. * @@ -645,7 +643,7 @@ public function get(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -655,14 +653,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. * @@ -671,7 +669,7 @@ public function getAlias(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -680,13 +678,13 @@ 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. * @@ -701,7 +699,7 @@ public function getDataStream(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -711,14 +709,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. * @@ -731,7 +729,7 @@ public function getFieldMapping(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -740,13 +738,13 @@ 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. * @@ -761,7 +759,7 @@ public function getIndexTemplate(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -770,13 +768,13 @@ 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. * @@ -794,7 +792,7 @@ public function getMapping(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -804,14 +802,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. * @@ -824,7 +822,7 @@ public function getSettings(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -833,13 +831,13 @@ 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. * @@ -851,7 +849,7 @@ public function getTemplate(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -860,13 +858,13 @@ 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. * @@ -884,7 +882,7 @@ public function getUpgrade(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -893,13 +891,13 @@ 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. * @@ -912,7 +910,7 @@ public function open(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The settings for the alias, such as `routing` or `filter` * * @param array $params Associative array of parameters @@ -924,8 +922,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 +930,7 @@ public function putAlias(array $params = []) return $this->performRequest($endpoint); } + /** * Creates or updates an index template. * @@ -945,7 +943,7 @@ public function putAlias(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The template definition (Required) * * @param array $params Associative array of parameters @@ -956,14 +954,14 @@ 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. * @@ -979,7 +977,7 @@ public function putIndexTemplate(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The mapping definition (Required) * * @param array $params Associative array of parameters @@ -990,14 +988,14 @@ 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. * @@ -1014,7 +1012,7 @@ public function putMapping(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -1024,14 +1022,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. * @@ -1044,7 +1042,7 @@ public function putSettings(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The template definition (Required) * * @param array $params Associative array of parameters @@ -1055,14 +1053,14 @@ 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. * @@ -1073,7 +1071,7 @@ public function putTemplate(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -1082,13 +1080,13 @@ 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. * @@ -1100,7 +1098,7 @@ public function recovery(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -1109,13 +1107,13 @@ 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. * @@ -1125,7 +1123,7 @@ public function refresh(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -1134,13 +1132,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. * @@ -1155,7 +1153,7 @@ public function resolveIndex(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The conditions that needs to be met for executing rollover * * @param array $params Associative array of parameters @@ -1167,8 +1165,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,6 +1173,7 @@ public function rollover(array $params = []) return $this->performRequest($endpoint); } + /** * Provides low-level information about segments in a Lucene index. * @@ -1188,7 +1186,7 @@ public function rollover(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -1197,13 +1195,13 @@ 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. * @@ -1216,7 +1214,7 @@ public function segments(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -1225,13 +1223,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. * @@ -1248,7 +1246,7 @@ public function shardStores(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The configuration for the target index (`settings` and `aliases`) * * @param array $params Associative array of parameters @@ -1260,8 +1258,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 +1266,7 @@ public function shrink(array $params = []) return $this->performRequest($endpoint); } + /** * Simulate matching the given index name against the index templates in the system. * @@ -1281,7 +1279,7 @@ public function shrink(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) New index template definition, which will be included in the simulation, as if it already exists in the system * * @param array $params Associative array of parameters @@ -1292,14 +1290,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. * @@ -1312,7 +1310,7 @@ public function simulateIndexTemplate(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -1322,14 +1320,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. * @@ -1346,7 +1344,7 @@ public function simulateTemplate(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The configuration for the target index (`settings` and `aliases`) * * @param array $params Associative array of parameters @@ -1358,8 +1356,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,6 +1364,7 @@ public function split(array $params = []) return $this->performRequest($endpoint); } + /** * Provides statistics on operations happening in an index. * @@ -1385,7 +1383,7 @@ public function split(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -1395,14 +1393,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. * @@ -1413,7 +1411,7 @@ public function stats(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The definition of `actions` to perform (Required) * * @param array $params Associative array of parameters @@ -1423,13 +1421,13 @@ 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. * @@ -1443,7 +1441,7 @@ public function updateAliases(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -1452,13 +1450,13 @@ 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. * @@ -1479,7 +1477,7 @@ public function upgrade(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The query definition specified with the Query DSL * * @param array $params Associative array of parameters @@ -1490,14 +1488,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() * diff --git a/src/OpenSearch/Namespaces/IngestNamespace.php b/src/OpenSearch/Namespaces/IngestNamespace.php index d217dc47..8e195d8c 100644 --- a/src/OpenSearch/Namespaces/IngestNamespace.php +++ b/src/OpenSearch/Namespaces/IngestNamespace.php @@ -21,8 +21,6 @@ namespace OpenSearch\Namespaces; -use OpenSearch\Namespaces\AbstractNamespace; - /** * Class IngestNamespace * @@ -41,7 +39,7 @@ class IngestNamespace extends AbstractNamespace * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -50,13 +48,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. * @@ -67,7 +65,7 @@ public function deletePipeline(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -76,13 +74,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. * @@ -90,19 +88,19 @@ public function getPipeline(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -114,7 +112,7 @@ public function processorGrok(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The ingest definition (Required) * * @param array $params Associative array of parameters @@ -125,14 +123,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. * @@ -142,7 +140,7 @@ public function putPipeline(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The simulate definition (Required) * * @param array $params Associative array of parameters @@ -153,12 +151,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/IsmNamespace.php b/src/OpenSearch/Namespaces/IsmNamespace.php new file mode 100644 index 00000000..c3a3dc3f --- /dev/null +++ b/src/OpenSearch/Namespaces/IsmNamespace.php @@ -0,0 +1,326 @@ +extractArgument($params, 'index'); + $body = $this->extractArgument($params, 'body'); + + $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['pretty'] = (boolean) Whether to pretty format the returned JSON response. + * $params['human'] = (boolean) Whether to return human readable values for statistics. + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. + * $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 "-". + * + * @param array $params Associative array of parameters + * @return array + */ + public function changePolicy(array $params = []) + { + $index = $this->extractArgument($params, 'index'); + $body = $this->extractArgument($params, 'body'); + + $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. + * + * $params['policy_id'] = (string) (Required) + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. + * $params['human'] = (boolean) Whether to return human readable values for statistics. + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. + * $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 "-". + * + * @param array $params Associative array of parameters + * @return array + */ + public function deletePolicy(array $params = []) + { + $policy_id = $this->extractArgument($params, 'policy_id'); + + $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. + * + * $params['policy_id'] = (string) (Required) + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. + * $params['human'] = (boolean) Whether to return human readable values for statistics. + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. + * $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 "-". + * + * @param array $params Associative array of parameters + * @return bool + */ + public function existsPolicy(array $params = []): bool + { + $policy_id = $this->extractArgument($params, 'policy_id'); + + // manually make this verbose so we can check status code + $params['client']['verbose'] = true; + + $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['pretty'] = (boolean) Whether to pretty format the returned JSON response. + * $params['human'] = (boolean) Whether to return human readable values for statistics. + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. + * $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 "-". + * + * @param array $params Associative array of parameters + * @return array + */ + public function explainPolicy(array $params = []) + { + $index = $this->extractArgument($params, 'index'); + $body = $this->extractArgument($params, 'body'); + + $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. + * + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. + * $params['human'] = (boolean) Whether to return human readable values for statistics. + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. + * $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 "-". + * + * @param array $params Associative array of parameters + * @return array + */ + public function getPolicies(array $params = []) + { + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ism\GetPolicies::class); + $endpoint->setParams($params); + + return $this->performRequest($endpoint); + } + + /** + * Gets a policy. + * + * $params['policy_id'] = (string) (Required) + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. + * $params['human'] = (boolean) Whether to return human readable values for statistics. + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. + * $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 "-". + * + * @param array $params Associative array of parameters + * @return array + */ + public function getPolicy(array $params = []) + { + $policy_id = $this->extractArgument($params, 'policy_id'); + + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ism\GetPolicy::class); + $endpoint->setParams($params); + $endpoint->setPolicyId($policy_id); + + return $this->performRequest($endpoint); + } + + /** + * Gets the policies. + * + * $params['if_primary_term'] = (number) Only perform the operation if the document has this primary term. + * $params['if_seq_no'] = (integer) Only perform the operation if the document has this sequence number. + * $params['policyID'] = (string) + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. + * $params['human'] = (boolean) Whether to return human readable values for statistics. + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. + * $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 "-". + * + * @param array $params Associative array of parameters + * @return array + */ + public function putPolicies(array $params = []) + { + $body = $this->extractArgument($params, 'body'); + + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ism\PutPolicies::class); + $endpoint->setParams($params); + $endpoint->setBody($body); + + return $this->performRequest($endpoint); + } + + /** + * Creates or updates a policy. + * + * $params['policy_id'] = (string) (Required) + * $params['if_primary_term'] = (number) Only perform the operation if the document has this primary term. + * $params['if_seq_no'] = (integer) Only perform the operation if the document has this sequence number. + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. + * $params['human'] = (boolean) Whether to return human readable values for statistics. + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. + * $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 "-". + * + * @param array $params Associative array of parameters + * @return array + */ + public function putPolicy(array $params = []) + { + $policy_id = $this->extractArgument($params, 'policy_id'); + $body = $this->extractArgument($params, 'body'); + + $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['pretty'] = (boolean) Whether to pretty format the returned JSON response. + * $params['human'] = (boolean) Whether to return human readable values for statistics. + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. + * $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 "-". + * + * @param array $params Associative array of parameters + * @return array + */ + public function refreshSearchAnalyzers(array $params = []) + { + $index = $this->extractArgument($params, 'index'); + + $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['pretty'] = (boolean) Whether to pretty format the returned JSON response. + * $params['human'] = (boolean) Whether to return human readable values for statistics. + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. + * $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 "-". + * + * @param array $params Associative array of parameters + * @return array + */ + public function removePolicy(array $params = []) + { + $index = $this->extractArgument($params, 'index'); + + $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['pretty'] = (boolean) Whether to pretty format the returned JSON response. + * $params['human'] = (boolean) Whether to return human readable values for statistics. + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. + * $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 "-". + * + * @param array $params Associative array of parameters + * @return array + */ + public function retryIndex(array $params = []) + { + $index = $this->extractArgument($params, 'index'); + $body = $this->extractArgument($params, 'body'); + + $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 9406836f..9575a2c5 100644 --- a/src/OpenSearch/Namespaces/KnnNamespace.php +++ b/src/OpenSearch/Namespaces/KnnNamespace.php @@ -15,8 +15,6 @@ namespace OpenSearch\Namespaces; -use OpenSearch\Namespaces\AbstractNamespace; - /** * Class KnnNamespace * @@ -32,7 +30,7 @@ class KnnNamespace extends AbstractNamespace * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -41,13 +39,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. * @@ -56,7 +54,7 @@ public function deleteModel(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -65,13 +63,13 @@ 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. * @@ -99,7 +97,7 @@ public function getModel(array $params = []) * $params['q'] = (string) Query in the Lucene query string syntax. * $params['request_cache'] = (boolean) Specify if request cache should be used for this request or not, defaults to index level setting. * $params['rest_total_hits_as_int'] = (boolean) Indicates whether hits.total should be rendered as an integer or an object in the rest search response. (Default = false) - * $params['routing'] = (array) Comma-separated list of specific routing values. + * $params['routing'] = (any) Comma-separated list of specific routing values. * $params['scroll'] = (string) Specify how long a consistent view of the index should be maintained for scrolled search. * $params['search_type'] = (enum) Search operation type. (Options = dfs_query_then_fetch,query_then_fetch) * $params['seq_no_primary_term'] = (boolean) Specify whether to return sequence number and primary term of the last modification of each hit. @@ -121,7 +119,7 @@ public function getModel(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -130,13 +128,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. * @@ -147,7 +145,7 @@ public function searchModels(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -157,14 +155,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. * @@ -174,7 +172,7 @@ public function stats(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -184,14 +182,14 @@ 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. * @@ -200,7 +198,7 @@ public function trainModel(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -209,11 +207,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/MlNamespace.php b/src/OpenSearch/Namespaces/MlNamespace.php index c89c35e8..c15048d2 100644 --- a/src/OpenSearch/Namespaces/MlNamespace.php +++ b/src/OpenSearch/Namespaces/MlNamespace.php @@ -15,8 +15,6 @@ namespace OpenSearch\Namespaces; -use OpenSearch\Namespaces\AbstractNamespace; - /** * Class MlNamespace * @@ -24,6 +22,30 @@ */ class MlNamespace extends AbstractNamespace { + /** + * Delete an agent. + * + * $params['agent_id'] = (string) + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. + * $params['human'] = (boolean) Whether to return human readable values for statistics. + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. + * $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 "-". + * + * @param array $params Associative array of parameters + * @return array + */ + public function deleteAgent(array $params = []) + { + $agent_id = $this->extractArgument($params, 'agent_id'); + + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\DeleteAgent::class); + $endpoint->setParams($params); + $endpoint->setAgentId($agent_id); + + return $this->performRequest($endpoint); + } + /** * Deletes a model. * @@ -32,7 +54,7 @@ class MlNamespace extends AbstractNamespace * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -41,13 +63,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. * @@ -56,7 +78,7 @@ public function deleteModel(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -65,13 +87,37 @@ 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. + * + * $params['task_id'] = (string) + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. + * $params['human'] = (boolean) Whether to return human readable values for statistics. + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. + * $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 "-". + * + * @param array $params Associative array of parameters + * @return array + */ + public function deleteTask(array $params = []) + { + $task_id = $this->extractArgument($params, 'task_id'); + + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\DeleteTask::class); + $endpoint->setParams($params); + $endpoint->setTaskId($task_id); + + return $this->performRequest($endpoint); + } + /** * Retrieves a model group. * @@ -80,7 +126,7 @@ public function deleteModelGroup(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -89,13 +135,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. * @@ -104,7 +150,7 @@ public function getModelGroup(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -113,13 +159,36 @@ 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. + * + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. + * $params['human'] = (boolean) Whether to return human readable values for statistics. + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. + * $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 "-". + * + * @param array $params Associative array of parameters + * @return array + */ + public function registerAgents(array $params = []) + { + $body = $this->extractArgument($params, 'body'); + + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\RegisterAgents::class); + $endpoint->setParams($params); + $endpoint->setBody($body); + + return $this->performRequest($endpoint); + } + /** * Registers a model. * @@ -127,7 +196,7 @@ public function getTask(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -136,13 +205,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. * @@ -150,7 +219,7 @@ public function registerModel(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -159,13 +228,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. * @@ -173,7 +242,7 @@ public function registerModelGroup(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -182,13 +251,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) * diff --git a/src/OpenSearch/Namespaces/MonitoringNamespace.php b/src/OpenSearch/Namespaces/MonitoringNamespace.php index 02dec449..e6baaa8d 100644 --- a/src/OpenSearch/Namespaces/MonitoringNamespace.php +++ b/src/OpenSearch/Namespaces/MonitoringNamespace.php @@ -21,6 +21,7 @@ namespace OpenSearch\Namespaces; +use OpenSearch\Endpoints\Monitoring\Bulk; use OpenSearch\Namespaces\AbstractNamespace; /** diff --git a/src/OpenSearch/Namespaces/NodesNamespace.php b/src/OpenSearch/Namespaces/NodesNamespace.php index e9baf762..64f3e409 100644 --- a/src/OpenSearch/Namespaces/NodesNamespace.php +++ b/src/OpenSearch/Namespaces/NodesNamespace.php @@ -21,8 +21,6 @@ namespace OpenSearch\Namespaces; -use OpenSearch\Namespaces\AbstractNamespace; - /** * Class NodesNamespace * @@ -44,7 +42,7 @@ class NodesNamespace extends AbstractNamespace * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -53,13 +51,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. * @@ -72,7 +70,7 @@ public function hotThreads(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -83,8 +81,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 +89,7 @@ public function info(array $params = []) return $this->performRequest($endpoint); } + /** * Reloads secure settings. * @@ -101,7 +99,7 @@ public function info(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) An object containing the password for the opensearch keystore * * @param array $params Associative array of parameters @@ -112,14 +110,14 @@ 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. * @@ -138,7 +136,7 @@ public function reloadSecureSettings(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -149,8 +147,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 +155,7 @@ public function stats(array $params = []) return $this->performRequest($endpoint); } + /** * Returns low-level information about REST actions usage on nodes. * @@ -168,7 +166,7 @@ public function stats(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -178,12 +176,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 2022c024..37b78908 100644 --- a/src/OpenSearch/Namespaces/NotificationsNamespace.php +++ b/src/OpenSearch/Namespaces/NotificationsNamespace.php @@ -15,8 +15,6 @@ namespace OpenSearch\Namespaces; -use OpenSearch\Namespaces\AbstractNamespace; - /** * Class NotificationsNamespace * @@ -31,7 +29,7 @@ class NotificationsNamespace extends AbstractNamespace * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -40,13 +38,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. * @@ -55,7 +53,7 @@ public function createConfig(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -64,13 +62,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. * @@ -80,19 +78,19 @@ public function deleteConfig(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -101,7 +99,7 @@ public function deleteConfigs(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -110,18 +108,20 @@ 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. * * $params['chime.url'] = (string) * $params['chime.url.keyword'] = (string) + * $params['config_id'] = (string) Notification configuration ID. + * $params['config_id_list'] = (array) Notification configuration IDs. * $params['config_type'] = (enum) Type of notification configuration. (Options = chime,email,email_group,microsoft_teams,ses_account,slack,smtp_account,sns,webhook) * $params['created_time_ms'] = (integer) * $params['description'] = (string) @@ -162,7 +162,7 @@ public function getConfig(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -171,13 +171,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. * @@ -185,19 +185,19 @@ public function getConfigs(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -205,19 +205,19 @@ public function listChannels(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -226,7 +226,7 @@ public function listFeatures(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -235,13 +235,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. * @@ -250,7 +250,7 @@ public function sendTest(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -260,12 +260,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 3c8132ae..0c438e45 100644 --- a/src/OpenSearch/Namespaces/ObservabilityNamespace.php +++ b/src/OpenSearch/Namespaces/ObservabilityNamespace.php @@ -15,8 +15,6 @@ namespace OpenSearch\Namespaces; -use OpenSearch\Namespaces\AbstractNamespace; - /** * Class ObservabilityNamespace * @@ -31,7 +29,7 @@ class ObservabilityNamespace extends AbstractNamespace * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -40,13 +38,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. * @@ -55,7 +53,7 @@ public function createObject(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -64,13 +62,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. * @@ -80,19 +78,19 @@ public function deleteObject(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -100,19 +98,19 @@ public function deleteObjects(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -121,7 +119,7 @@ public function getLocalstats(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -130,13 +128,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. * @@ -144,19 +142,19 @@ public function getObject(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -165,7 +163,7 @@ public function listObjects(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -175,12 +173,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 e6220a4d..38c8eeb5 100644 --- a/src/OpenSearch/Namespaces/PplNamespace.php +++ b/src/OpenSearch/Namespaces/PplNamespace.php @@ -15,8 +15,6 @@ namespace OpenSearch\Namespaces; -use OpenSearch\Namespaces\AbstractNamespace; - /** * Class PplNamespace * @@ -33,7 +31,7 @@ class PplNamespace extends AbstractNamespace * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -42,13 +40,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. * @@ -58,19 +56,19 @@ public function explain(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -80,7 +78,7 @@ public function getStats(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -89,13 +87,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. * @@ -105,7 +103,7 @@ public function postStats(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -114,11 +112,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 0ee9a004..1b7a9e18 100644 --- a/src/OpenSearch/Namespaces/QueryNamespace.php +++ b/src/OpenSearch/Namespaces/QueryNamespace.php @@ -15,8 +15,6 @@ namespace OpenSearch\Namespaces; -use OpenSearch\Namespaces\AbstractNamespace; - /** * Class QueryNamespace * @@ -32,7 +30,7 @@ class QueryNamespace extends AbstractNamespace * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -41,13 +39,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. * @@ -56,7 +54,7 @@ public function datasourceDelete(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -65,13 +63,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. * @@ -79,7 +77,7 @@ public function datasourceRetrieve(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -88,13 +86,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. * @@ -102,19 +100,19 @@ public function datasourcesCreate(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -122,7 +120,7 @@ public function datasourcesList(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -131,11 +129,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 bd1b9080..69bea03f 100644 --- a/src/OpenSearch/Namespaces/RemoteStoreNamespace.php +++ b/src/OpenSearch/Namespaces/RemoteStoreNamespace.php @@ -15,8 +15,6 @@ namespace OpenSearch\Namespaces; -use OpenSearch\Namespaces\AbstractNamespace; - /** * Class RemoteStoreNamespace * @@ -33,7 +31,7 @@ class RemoteStoreNamespace extends AbstractNamespace * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 index IDs (Required) * * @param array $params Associative array of parameters @@ -43,11 +41,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 d0deb602..3a40e0f2 100644 --- a/src/OpenSearch/Namespaces/RollupsNamespace.php +++ b/src/OpenSearch/Namespaces/RollupsNamespace.php @@ -15,8 +15,6 @@ namespace OpenSearch\Namespaces; -use OpenSearch\Namespaces\AbstractNamespace; - /** * Class RollupsNamespace * @@ -32,7 +30,7 @@ class RollupsNamespace extends AbstractNamespace * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -41,13 +39,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. * @@ -56,7 +54,7 @@ public function delete(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -65,13 +63,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. * @@ -80,7 +78,7 @@ public function explain(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -89,24 +87,24 @@ 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. * * $params['id'] = (string) Rollup to access (Required) * $params['if_primary_term'] = (number) Only perform the operation if the document has this primary term. - * $params['if_seq_no'] = (number) Only perform the operation if the document has this sequence number. + * $params['if_seq_no'] = (integer) Only perform the operation if the document has this sequence number. * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -116,14 +114,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. * @@ -132,7 +130,7 @@ public function put(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -141,13 +139,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. * @@ -156,7 +154,7 @@ public function start(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -165,11 +163,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 0066519d..486ecb4a 100644 --- a/src/OpenSearch/Namespaces/SearchPipelineNamespace.php +++ b/src/OpenSearch/Namespaces/SearchPipelineNamespace.php @@ -15,8 +15,6 @@ namespace OpenSearch\Namespaces; -use OpenSearch\Namespaces\AbstractNamespace; - /** * Class SearchPipelineNamespace * @@ -34,7 +32,7 @@ class SearchPipelineNamespace extends AbstractNamespace * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -43,13 +41,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. * @@ -59,7 +57,7 @@ public function delete(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -68,13 +66,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. * @@ -85,7 +83,7 @@ public function get(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -95,12 +93,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 bf7a5937..9fe2bc59 100644 --- a/src/OpenSearch/Namespaces/SecurityNamespace.php +++ b/src/OpenSearch/Namespaces/SecurityNamespace.php @@ -15,8 +15,6 @@ namespace OpenSearch\Namespaces; -use OpenSearch\Namespaces\AbstractNamespace; - /** * Class SecurityNamespace * @@ -33,19 +31,19 @@ class SecurityNamespace extends AbstractNamespace * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -53,19 +51,19 @@ public function authinfo(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -73,19 +71,19 @@ public function authtoken(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -93,19 +91,19 @@ public function cache(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -113,7 +111,7 @@ public function configUpgradeCheck(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -122,13 +120,13 @@ 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. * @@ -136,7 +134,7 @@ public function configUpgradePerform(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -145,13 +143,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. * @@ -159,7 +157,7 @@ public function createAllowlist(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -168,22 +166,22 @@ 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. * - * $params['username'] = (string) (Required) + * $params['username'] = (string) The name of the user to be created. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -193,23 +191,23 @@ 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. * - * $params['action_group'] = (string) Action group to delete. (Required) + * $params['action_group'] = (string) The name of the action group to delete. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -218,22 +216,22 @@ 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. * - * $params['cluster_name'] = (string) (Required) + * $params['cluster_name'] = (string) The cluster-name to delete from list of distinguished names. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -242,22 +240,22 @@ 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. * - * $params['role'] = (string) (Required) + * $params['role'] = (string) The name of the role to delete. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -266,22 +264,22 @@ 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. * - * $params['role'] = (string) (Required) + * $params['role'] = (string) The name of the role whose mapping needs to delete. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -290,22 +288,22 @@ 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. * - * $params['tenant'] = (string) (Required) + * $params['tenant'] = (string) The name of the tenant to delete. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -314,22 +312,22 @@ 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. * - * $params['username'] = (string) (Required) + * $params['username'] = (string) The name of the user to delete. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -338,22 +336,22 @@ 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. * - * $params['username'] = (string) (Required) + * $params['username'] = (string) The name of the user to delete. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -362,13 +360,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. * @@ -376,19 +374,19 @@ public function deleteUserLegacy(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -396,7 +394,7 @@ public function flushCache(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -405,22 +403,22 @@ 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. * - * $params['username'] = (string) (Required) + * $params['username'] = (string) The name of the user for whom an auth token is to be vended. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -429,22 +427,22 @@ 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. + * Generates authorization token for the given user. Legacy API. Not Implemented. * - * $params['username'] = (string) (Required) + * $params['username'] = (string) The name of the user for whom an auth token is to be vended. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -453,13 +451,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. * @@ -467,28 +465,28 @@ public function generateUserTokenLegacy(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * - * $params['action_group'] = (string) Action group to retrieve. (Required) + * $params['action_group'] = (string) The name of the action group to retrieve. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -497,13 +495,35 @@ 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. + * + * $params['cert_type'] = (string) The type of certificates (HTTP, TRANSPORT, ALL) to retrieve from all nodes. + * $params['timeout'] = (string) The maximum duration, in seconds, to be spent to retrieve certificates from all nodes. + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. + * $params['human'] = (boolean) Whether to return human readable values for statistics. + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. + * $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 "-". + * + * @param array $params Associative array of parameters + * @return array + */ + public function getAllCertificates(array $params = []) + { + $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. * @@ -511,19 +531,19 @@ public function getActionGroup(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -531,19 +551,19 @@ public function getAllowlist(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -551,19 +571,19 @@ public function getAuditConfiguration(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -571,19 +591,19 @@ public function getCertificates(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -591,29 +611,29 @@ public function getConfiguration(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * - * $params['cluster_name'] = (string) (Required) - * $params['show_all'] = (boolean) + * $params['cluster_name'] = (string) The cluster-name to retrieve nodes DN setting for. (Required) + * $params['show_all'] = (boolean) A boolean flag to include/exclude static nodes DN from final result. * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -622,13 +642,39 @@ 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. + * + * $params['node_id'] = (string) The full-id of the node to retrieve certificates. + * $params['cert_type'] = (string) The type of certificates (HTTP, TRANSPORT, ALL) to retrieve for a node. + * $params['timeout'] = (string) The maximum duration, in seconds, to be spent to retrieve a node's certificates. + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. + * $params['human'] = (boolean) Whether to return human readable values for statistics. + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. + * $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 "-". + * + * @param array $params Associative array of parameters + * @return array + */ + public function getNodeCertificates(array $params = []) + { + $node_id = $this->extractArgument($params, 'node_id'); + + $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. * @@ -636,19 +682,19 @@ public function getDistinguishedName(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -657,7 +703,7 @@ public function getPermissionsInfo(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -666,13 +712,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. * @@ -681,7 +727,7 @@ public function getRole(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -690,34 +736,34 @@ 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. * - * $params['show_dn'] = (string) The domain names from all certificates. + * $params['show_dn'] = (Array) A boolean flag to indicate whether all domain names should be returned. * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -725,28 +771,28 @@ public function getSslinfo(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * - * $params['tenant'] = (string) (Required) + * $params['tenant'] = (string) The name of the tenant to retrieve. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -755,22 +801,22 @@ 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. * - * $params['username'] = (string) (Required) + * $params['username'] = (string) The name of the user to retrieve. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -779,22 +825,22 @@ 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. * - * $params['username'] = (string) (Required) + * $params['username'] = (string) The name of the user to retrieve. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -803,13 +849,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. * @@ -817,40 +863,40 @@ public function getUserLegacy(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * - * $params['mode'] = (string) + * $params['mode'] = (string) A flag to indicate whether service should consider security-plugin's status before returning health response. `strict` mode indicates service should check security plugin status. * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -858,28 +904,28 @@ public function health(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * - * $params['action_group'] = (string) (Required) + * $params['action_group'] = (string) The name of the action group to update. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -889,14 +935,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. * @@ -904,7 +950,7 @@ public function patchActionGroup(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -913,13 +959,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. * @@ -927,7 +973,7 @@ public function patchAllowlist(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -936,13 +982,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. * @@ -950,7 +996,7 @@ public function patchAuditConfiguration(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -959,22 +1005,22 @@ 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. * - * $params['cluster_name'] = (string) (Required) + * $params['cluster_name'] = (string) The cluster-name to update nodesDn value. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -984,14 +1030,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. * @@ -999,7 +1045,7 @@ public function patchDistinguishedName(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -1008,22 +1054,22 @@ 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. * - * $params['role'] = (string) (Required) + * $params['role'] = (string) The name of the role to update. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -1033,23 +1079,23 @@ 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. * - * $params['role'] = (string) (Required) + * $params['role'] = (string) The name of the role to update role-mapping for. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -1059,23 +1105,23 @@ 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. * - * $params['tenant'] = (string) (Required) + * $params['tenant'] = (string) The name of the tenant to update. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -1085,23 +1131,23 @@ 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. * - * $params['username'] = (string) (Required) + * $params['username'] = (string) The name of the user to update. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -1111,14 +1157,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. * @@ -1126,22 +1172,19 @@ public function patchUser(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ public function postDashboardsInfo(array $params = []) { - $body = $this->extractArgument($params, 'body'); - - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Security\PostDashboardsInfo'); + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Security\PostDashboardsInfo::class); $endpoint->setParams($params); - $endpoint->setBody($body); return $this->performRequest($endpoint); } + /** * Reload HTTP layer communication certificates. * @@ -1149,19 +1192,19 @@ public function postDashboardsInfo(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -1169,19 +1212,19 @@ public function reloadHttpCertificates(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -1189,19 +1232,19 @@ public function reloadTransportCertificates(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -1209,7 +1252,7 @@ public function tenantInfo(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -1218,13 +1261,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. * @@ -1232,7 +1275,7 @@ public function updateAuditConfiguration(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -1241,22 +1284,22 @@ 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. * - * $params['cluster_name'] = (string) (Required) + * $params['cluster_name'] = (string) The cluster-name to create/update nodesDn value for. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -1266,35 +1309,35 @@ 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. * - * $params['accept_invalid'] = (boolean) + * $params['accept_invalid'] = (boolean) A boolean flag to indicate whether invalid v6 configuration should be allowed. * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -1302,19 +1345,19 @@ public function validate(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -1322,19 +1365,19 @@ public function whoAmI(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * diff --git a/src/OpenSearch/Namespaces/SnapshotNamespace.php b/src/OpenSearch/Namespaces/SnapshotNamespace.php index db1dc978..0418dd2a 100644 --- a/src/OpenSearch/Namespaces/SnapshotNamespace.php +++ b/src/OpenSearch/Namespaces/SnapshotNamespace.php @@ -21,8 +21,6 @@ namespace OpenSearch\Namespaces; -use OpenSearch\Namespaces\AbstractNamespace; - /** * Class SnapshotNamespace * @@ -41,7 +39,7 @@ class SnapshotNamespace extends AbstractNamespace * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -50,13 +48,13 @@ 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. * @@ -69,7 +67,7 @@ public function cleanupRepository(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The snapshot clone definition (Required) * * @param array $params Associative array of parameters @@ -82,8 +80,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 +89,7 @@ public function clone(array $params = []) return $this->performRequest($endpoint); } + /** * Creates a snapshot in a repository. * @@ -104,7 +102,7 @@ public function clone(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The snapshot definition * * @param array $params Associative array of parameters @@ -116,8 +114,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 +122,7 @@ public function create(array $params = []) return $this->performRequest($endpoint); } + /** * Creates a repository. * @@ -137,7 +135,7 @@ public function create(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) The repository definition (Required) * * @param array $params Associative array of parameters @@ -148,14 +146,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. * @@ -167,7 +165,7 @@ public function createRepository(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -177,14 +175,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. * @@ -196,7 +194,7 @@ public function delete(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -205,13 +203,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. * @@ -225,7 +223,7 @@ public function deleteRepository(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -235,14 +233,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. * @@ -254,7 +252,7 @@ public function get(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -263,13 +261,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. * @@ -282,7 +280,7 @@ public function getRepository(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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) Details of what to restore * * @param array $params Associative array of parameters @@ -294,8 +292,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 +300,7 @@ public function restore(array $params = []) return $this->performRequest($endpoint); } + /** * Returns information about the status of a snapshot. * @@ -315,7 +313,7 @@ public function restore(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -325,14 +323,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. * @@ -344,7 +342,7 @@ public function status(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -353,11 +351,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 83340f78..a00d0c99 100644 --- a/src/OpenSearch/Namespaces/SqlNamespace.php +++ b/src/OpenSearch/Namespaces/SqlNamespace.php @@ -15,8 +15,6 @@ namespace OpenSearch\Namespaces; -use OpenSearch\Namespaces\AbstractNamespace; - /** * Class SqlNamespace * @@ -33,7 +31,7 @@ class SqlNamespace extends AbstractNamespace * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -42,13 +40,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. * @@ -58,19 +56,19 @@ public function close(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -80,7 +78,7 @@ public function getStats(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -89,13 +87,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. * @@ -104,7 +102,7 @@ public function postStats(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -113,13 +111,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 diff --git a/src/OpenSearch/Namespaces/TasksNamespace.php b/src/OpenSearch/Namespaces/TasksNamespace.php index 6bdb239b..4cf51e80 100644 --- a/src/OpenSearch/Namespaces/TasksNamespace.php +++ b/src/OpenSearch/Namespaces/TasksNamespace.php @@ -21,8 +21,6 @@ namespace OpenSearch\Namespaces; -use OpenSearch\Namespaces\AbstractNamespace; - /** * Class TasksNamespace * @@ -42,7 +40,7 @@ class TasksNamespace extends AbstractNamespace * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -51,13 +49,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. * @@ -68,7 +66,7 @@ public function cancel(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -77,13 +75,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. * @@ -98,19 +96,19 @@ public function get(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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 55f744df..9accbd3a 100644 --- a/src/OpenSearch/Namespaces/TransformsNamespace.php +++ b/src/OpenSearch/Namespaces/TransformsNamespace.php @@ -15,8 +15,6 @@ namespace OpenSearch\Namespaces; -use OpenSearch\Namespaces\AbstractNamespace; - /** * Class TransformsNamespace * @@ -32,7 +30,7 @@ class TransformsNamespace extends AbstractNamespace * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -41,13 +39,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. * @@ -56,7 +54,7 @@ public function delete(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -65,13 +63,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. * @@ -80,7 +78,7 @@ public function explain(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -89,13 +87,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. * @@ -103,30 +101,33 @@ public function get(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ public function preview(array $params = []) { - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('Transforms\Preview'); + $body = $this->extractArgument($params, 'body'); + + $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. * * $params['id'] = (string) Transform to create/update * $params['if_primary_term'] = (number) Only perform the operation if the document has this primary term. - * $params['if_seq_no'] = (number) Only perform the operation if the document has this sequence number. + * $params['if_seq_no'] = (integer) Only perform the operation if the document has this sequence number. * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -136,14 +137,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. * @@ -156,19 +157,19 @@ public function put(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array */ 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. * @@ -177,7 +178,7 @@ public function search(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -186,13 +187,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. * @@ -201,7 +202,7 @@ public function start(array $params = []) * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. * $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) Comma-separated list of filters used to reduce the response. + * $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 "-". * * @param array $params Associative array of parameters * @return array @@ -210,11 +211,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/RequestFactory.php b/src/OpenSearch/RequestFactory.php new file mode 100644 index 00000000..c5a1561c --- /dev/null +++ b/src/OpenSearch/RequestFactory.php @@ -0,0 +1,141 @@ +getUriFactory()->createUri($uri); + $uri = $uri->withQuery(http_build_query($params)); + $request = $this->getRequestFactory()->createRequest($method, $uri); + if ($body !== null) { + $bodyJson = $this->getSerializer()->serialize($body); + $bodyStream = $this->getStreamFactory()->createStream($bodyJson); + $request = $request->withBody($bodyStream); + } + foreach ($headers as $name => $value) { + $request = $request->withHeader($name, $value); + } + return $request; + } + + /** + * Get the serializer to use for serializing request and response bodies. + */ + public function getSerializer(): ?SerializerInterface + { + if ($this->serializer) { + return $this->serializer; + } + return new SmartSerializer(); + } + + /** + * Set the serializer to use for serializing request and response bodies. + */ + public function setSerializer(?SerializerInterface $serializer): self + { + $this->serializer = $serializer; + return $this; + } + + /** + * Get the request factory to use for creating requests. + * + * If no request factory is set, the discovery mechanism will be used to find + * a request factory. + * + * @throws \Http\Discovery\Exception\NotFoundException + */ + private function getRequestFactory(): RequestFactoryInterface + { + if ($this->requestFactory) { + return $this->requestFactory; + } + + return $this->requestFactory = Psr17FactoryDiscovery::findRequestFactory(); + } + + /** + * Set the request factory to use for creating requests. + */ + public function setRequestFactory(RequestFactoryInterface $requestFactory): self + { + $this->requestFactory = $requestFactory; + return $this; + } + + /** + * Get the stream factory to use for creating streams. + * + * If no stream factory is set, the discovery mechanism will be used to find + * a stream factory. + * + * @throws \Http\Discovery\Exception\NotFoundException + */ + private function getStreamFactory(): StreamFactoryInterface + { + if ($this->streamFactory) { + return $this->streamFactory; + } + return $this->streamFactory = Psr17FactoryDiscovery::findStreamFactory(); + } + + /** + * Set the stream factory to use for creating streams. + */ + public function setStreamFactory(?StreamFactoryInterface $streamFactory): self + { + $this->streamFactory = $streamFactory; + return $this; + } + + /** + * Get the URI factory to use for creating URIs. + * + * If no URI factory is set, the discovery mechanism will be used to find + * a URI factory. + * + * @throws \Http\Discovery\Exception\NotFoundException + */ + private function getUriFactory(): UriFactoryInterface + { + if ($this->uriFactory) { + return $this->uriFactory; + } + return $this->uriFactory = Psr17FactoryDiscovery::findUriFactory(); + } + + /** + * Set the URI factory to use for creating URIs. + */ + public function setUriFactory(?UriFactoryInterface $uriFactory): self + { + $this->uriFactory = $uriFactory; + return $this; + } + +} diff --git a/src/OpenSearch/Transport.php b/src/OpenSearch/Transport.php index df6b5b98..7c1b03cb 100644 --- a/src/OpenSearch/Transport.php +++ b/src/OpenSearch/Transport.php @@ -21,158 +21,85 @@ namespace OpenSearch; -use OpenSearch\Common\Exceptions; -use OpenSearch\ConnectionPool\AbstractConnectionPool; -use OpenSearch\Connections\Connection; -use OpenSearch\Connections\ConnectionInterface; -use GuzzleHttp\Ring\Future\FutureArrayInterface; -use Psr\Log\LoggerInterface; - -class Transport +use Http\Client\HttpAsyncClient; +use Http\Discovery\HttpAsyncClientDiscovery; +use Http\Promise\Promise; +use OpenSearch\Common\Exceptions\NoAsyncClientException; +use Psr\Http\Client\ClientInterface; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; + +final class Transport implements ClientInterface, HttpAsyncClient { - /** - * @var AbstractConnectionPool - */ - public $connectionPool; - - /** - * @var LoggerInterface - */ - private $log; + private ?HttpAsyncClient $asyncClient = null; /** - * @var int - */ - public $retryAttempts = 0; - - /** - * @var ConnectionInterface + * Transport class is responsible for dispatching requests to the + * underlying cluster connections */ - public $lastConnection; + public function __construct( + protected readonly ClientInterface $client, + protected readonly RequestFactory $requestFactory, + ) { + } /** - * @var int + * Create a new request. */ - public $retries; + public function createRequest(string $method, string $uri, array $params = [], mixed $body = null): RequestInterface + { + return $this->requestFactory->createRequest($method, $uri, $params, $body); + } /** - * Transport class is responsible for dispatching requests to the - * underlying cluster connections - * - * @param int $retries - * @param bool $sniffOnStart - * @param ConnectionPool\AbstractConnectionPool $connectionPool - * @param \Psr\Log\LoggerInterface $log Monolog logger object + * {@inheritdoc} */ - public function __construct(int $retries, AbstractConnectionPool $connectionPool, LoggerInterface $log, bool $sniffOnStart = false) + public function sendAsyncRequest(RequestInterface $request): Promise { - $this->log = $log; - $this->connectionPool = $connectionPool; - $this->retries = $retries; - - if ($sniffOnStart === true) { - $this->log->notice('Sniff on Start.'); - $this->connectionPool->scheduleCheck(); - } + $httpAsyncClient = $this->getAsyncClient(); + return $httpAsyncClient->sendAsyncRequest($request); } /** - * Returns a single connection from the connection pool - * Potentially performs a sniffing step before returning + * {@inheritdoc} */ - public function getConnection(): ConnectionInterface + public function sendRequest(RequestInterface $request): ResponseInterface { - return $this->connectionPool->nextConnection(); + return $this->client->sendRequest($request); } /** - * Perform a request to the Cluster - * - * @param string $method HTTP method to use - * @param string $uri HTTP URI to send request to - * @param array $params Optional query parameters - * @param mixed|null $body Optional query body - * @param array $options - * - * @throws Common\Exceptions\NoNodesAvailableException|\Exception + * Set the async client to use for async requests. */ - public function performRequest(string $method, string $uri, array $params = [], $body = null, array $options = []): FutureArrayInterface + public function setAsyncClient(HttpAsyncClient $asyncClient): self { - try { - $connection = $this->getConnection(); - } catch (Exceptions\NoNodesAvailableException $exception) { - $this->log->critical('No alive nodes found in cluster'); - throw $exception; - } - - $response = []; - $caughtException = null; - $this->lastConnection = $connection; - - $future = $connection->performRequest( - $method, - $uri, - $params, - $body, - $options, - $this - ); - - $future->promise()->then( - //onSuccess - function ($response) { - $this->retryAttempts = 0; - // Note, this could be a 4xx or 5xx error - }, - //onFailure - function ($response) { - $code = $response->getCode(); - // Ignore 400 level errors, as that means the server responded just fine - if ($code < 400 || $code >= 500) { - // Otherwise schedule a check - $this->connectionPool->scheduleCheck(); - } - } - ); - - return $future; + $this->asyncClient = $asyncClient; + return $this; } /** - * @param FutureArrayInterface $result Response of a request (promise) - * @param array $options Options for transport + * Get the async client to use for async requests. + * + * If no async client is set, the discovery mechanism will be used to find + * an async client. * - * @return callable|array + * @throws NoAsyncClientException */ - public function resultOrFuture(FutureArrayInterface $result, array $options = []) + private function getAsyncClient(): HttpAsyncClient { - $response = null; - $async = isset($options['client']['future']) ? $options['client']['future'] : null; - if (is_null($async) || $async === false) { - do { - $result = $result->wait(); - } while ($result instanceof FutureArrayInterface); + if ($this->asyncClient) { + return $this->asyncClient; } - return $result; - } - - public function shouldRetry(array $request): bool - { - if ($this->retryAttempts < $this->retries) { - $this->retryAttempts += 1; - return true; + if ($this->client instanceof HttpAsyncClient) { + return $this->asyncClient = $this->client; } - return false; + try { + return $this->asyncClient = HttpAsyncClientDiscovery::find(); + } catch (\Exception $e) { + throw new NoAsyncClientException('No async HTTP client found. Install a package providing "php-http/async-client-implementation"', 0, $e); + } } - /** - * Returns the last used connection so that it may be inspected. Mainly - * for debugging/testing purposes. - */ - public function getLastConnection(): ConnectionInterface - { - return $this->lastConnection; - } } diff --git a/tests/Endpoints/AbstractEndpointTest.php b/tests/Endpoints/AbstractEndpointTest.php index 7a3e7b87..fd5b7c20 100644 --- a/tests/Endpoints/AbstractEndpointTest.php +++ b/tests/Endpoints/AbstractEndpointTest.php @@ -22,6 +22,7 @@ namespace OpenSearch\Tests\Endpoints; use OpenSearch\Endpoints\AbstractEndpoint; +use OpenSearch\Endpoints\EndpointInterface; use PHPUnit\Framework\MockObject\MockObject; /** @@ -30,7 +31,7 @@ class AbstractEndpointTest extends \PHPUnit\Framework\TestCase { /** - * @var AbstractEndpoint&MockObject + * @var EndpointInterface&MockObject */ private $endpoint; diff --git a/util/EndpointProxies/createProxy.php b/util/EndpointProxies/createProxy.php index 56a75bf6..c854176b 100644 --- a/util/EndpointProxies/createProxy.php +++ b/util/EndpointProxies/createProxy.php @@ -22,7 +22,7 @@ * $params['body'] = (array) The document (Required) * * @param array $params Associative array of parameters - * @return array + * @return \Http\Promise\Promise|\Psr\Http\Message\ResponseInterface */ public function create(array $params = []) { diff --git a/util/NamespaceEndpoint.php b/util/NamespaceEndpoint.php index b8c7dfb4..5c748fee 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 e3ed316f..684cc219 100644 --- a/util/template/client-class +++ b/util/template/client-class @@ -21,12 +21,15 @@ declare(strict_types=1); namespace OpenSearch; +use Http\Promise\Promise; use OpenSearch\Common\Exceptions\BadMethodCallException; use OpenSearch\Common\Exceptions\NoNodesAvailableException; use OpenSearch\Endpoints\AbstractEndpoint; use OpenSearch\Namespaces\NamespaceBuilderInterface; use OpenSearch\Namespaces\BooleanRequestWrapper; :use-namespaces +use Psr\Http\Message\ResponseInterface; + /** * Class Client * @@ -36,40 +39,22 @@ class Client { const VERSION = '2.3.1'; - /** - * @var Transport - */ - public $transport; - - /** - * @var array - */ - protected $params; - - /** - * @var callable - */ - protected $endpoints; - - /** - * @var NamespaceBuilderInterface[] - */ - protected $registeredNamespaces = []; + protected bool $isAsync; :namespace_properties /** * Client constructor * * @param Transport $transport - * @param callable $endpoint + * @param EndpointFactoryInterface $endpointFactory * @param NamespaceBuilderInterface[] $registeredNamespaces */ - public function __construct(Transport $transport, callable $endpoint, array $registeredNamespaces) - { - $this->transport = $transport; - $this->endpoints = $endpoint; + public function __construct( + protected Transport $transport, + protected EndpointFactoryInterface $endpointFactory, + protected array $registeredNamespaces, + ) { :new-namespaces - $this->registeredNamespaces = $registeredNamespaces; } :endpoints :functions @@ -107,34 +92,57 @@ class Client } /** - * Sends a raw request to the cluster - * @return callable|array - * @throws NoNodesAvailableException + * Check if the client is running in async mode. */ - public function request(string $method, string $uri, array $attributes = []) + public function isAsync(): bool + { + return $this->isAsync; + } + + /** + * Set the client to run in async mode. + */ + public function setAsync(bool $isAsync): static + { + $this->isAsync = $isAsync; + return $this; + } + + /** + * Sends a raw request to the cluster. + * + * @throws \Psr\Http\Client\ClientExceptionInterface|\Exception + */ + public function request(string $method, string $uri, array $attributes = []): Promise|ResponseInterface { $params = $attributes['params'] ?? []; $body = $attributes['body'] ?? null; - $options = $attributes['options'] ?? []; - $promise = $this->transport->performRequest($method, $uri, $params, $body, $options); + $request = $this->transport->createRequest($method, $uri, $params, $body); - return $this->transport->resultOrFuture($promise, $options); + if ($this->isAsync()) { + return $this->transport->sendAsyncRequest($request); + } + return $this->transport->sendRequest($request); } /** - * @return callable|array + * Perform the request. + * + * @throws \Psr\Http\Client\ClientExceptionInterface|\Exception */ - private function performRequest(AbstractEndpoint $endpoint) + private function performRequest(EndpointInterface $endpoint): Promise|ResponseInterface { - $promise = $this->transport->performRequest( + $request = $this->transport->createRequest( $endpoint->getMethod(), $endpoint->getURI(), $endpoint->getParams(), $endpoint->getBody(), - $endpoint->getOptions() ); - - return $this->transport->resultOrFuture($promise, $endpoint->getOptions()); + if ($this->isAsync()) { + return $this->transport->sendAsyncRequest($request); + } + return $this->transport->sendRequest($request); } + } diff --git a/util/template/endpoint-function b/util/template/endpoint-function index d5d0a054..a96c37c5 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 d4e6945d..d4c90d6d 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/namespace-class b/util/template/namespace-class index 7ea1ddd8..6a1c0d23 100644 --- a/util/template/namespace-class +++ b/util/template/namespace-class @@ -4,8 +4,6 @@ declare(strict_types=1); namespace OpenSearch\Namespaces; -use OpenSearch\Namespaces\AbstractNamespace; - /** * Class :namespace * diff --git a/util/template/namespace-property b/util/template/namespace-property index 7b88dd7f..96fce500 100644 --- a/util/template/namespace-property +++ b/util/template/namespace-property @@ -1,5 +1 @@ - /** - * @var :namespaceNamespace - */ - protected $:var_namespace; - \ No newline at end of file + protected :namespaceNamespace $:var_namespace; diff --git a/util/template/new-namespace b/util/template/new-namespace index 3c4b354c..cbf51bca 100644 --- a/util/template/new-namespace +++ b/util/template/new-namespace @@ -1 +1 @@ - $this->:name = new :namespace($transport, $endpoint); + $this->:name = new :namespace($this->transport, $this->endpointFactory); diff --git a/util/template/set-bulk-body b/util/template/set-bulk-body index bebb6700..ece8963f 100644 --- a/util/template/set-bulk-body +++ b/util/template/set-bulk-body @@ -1,5 +1,5 @@ - public function setBody($body): :endpoint + public function setBody($body): static { if (isset($body) !== true) { return $this; @@ -17,4 +17,4 @@ throw new InvalidArgumentException("Body must be an array, traversable object or string"); } return $this; - } \ No newline at end of file + } diff --git a/util/template/set-part b/util/template/set-part index 5397fed5..e84cc82e 100644 --- a/util/template/set-part +++ b/util/template/set-part @@ -1,5 +1,5 @@ - public function set:Part($:part): :endpoint + public function set:Part($:part): static { if (isset($:part) !== true) { return $this; diff --git a/util/template/set-part-list b/util/template/set-part-list index 21fa1361..6f786de9 100644 --- a/util/template/set-part-list +++ b/util/template/set-part-list @@ -1,5 +1,5 @@ - public function set:Part($:part): :endpoint + public function set:Part($:part): static { if (isset($:part) !== true) { return $this;