diff --git a/CHANGELOG.md b/CHANGELOG.md index f1d458c6b..e2d00fea8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Fixed PHP 8.4 deprecations - Fixed outdated tests ### Updated APIs +- Updated opensearch-php APIs to reflect [opensearch-api-specification@1681adc](https://github.com/opensearch-project/opensearch-api-specification/commit/1681adc7a638187fb3042e639c61bd1b1ab4c4f9) - Updated opensearch-php APIs to reflect [opensearch-api-specification@2395cb4](https://github.com/opensearch-project/opensearch-api-specification/commit/2395cb472ec5581656aac184f7b20548cd5b06ac) - Updated opensearch-php APIs to reflect [opensearch-api-specification@ebe0f8a](https://github.com/opensearch-project/opensearch-api-specification/commit/ebe0f8a885f7db7e882d160c101055a5aa70a707) - Updated opensearch-php APIs to reflect [opensearch-api-specification@398481e](https://github.com/opensearch-project/opensearch-api-specification/commit/398481e5bd1cc590d947c35379c47096f2114f00) diff --git a/src/OpenSearch/Client.php b/src/OpenSearch/Client.php index 8c107f20d..5aeabafb1 100644 --- a/src/OpenSearch/Client.php +++ b/src/OpenSearch/Client.php @@ -21,17 +21,6 @@ namespace OpenSearch; -use OpenSearch\Common\Exceptions\BadRequest400Exception; -use OpenSearch\Common\Exceptions\Conflict409Exception; -use OpenSearch\Common\Exceptions\Forbidden403Exception; -use OpenSearch\Common\Exceptions\Missing404Exception; -use OpenSearch\Common\Exceptions\NoDocumentsToGetException; -use OpenSearch\Common\Exceptions\NoShardAvailableException; -use OpenSearch\Common\Exceptions\RequestTimeout408Exception; -use OpenSearch\Common\Exceptions\RoutingMissingException; -use OpenSearch\Common\Exceptions\ScriptLangNotSupportedException; -use OpenSearch\Common\Exceptions\ServerErrorResponseException; -use OpenSearch\Common\Exceptions\Unauthorized401Exception; use OpenSearch\Endpoints\AbstractEndpoint; use OpenSearch\Namespaces\BooleanRequestWrapper; use OpenSearch\Namespaces\NamespaceBuilderInterface; @@ -284,13 +273,11 @@ class Client * @param TransportInterface|Transport $transport * @param callable|EndpointFactoryInterface $endpointFactory * @param NamespaceBuilderInterface[] $registeredNamespaces - * @param bool $throwExceptions */ public function __construct( TransportInterface|Transport $transport, callable|EndpointFactoryInterface $endpointFactory, array $registeredNamespaces, - bool $throwExceptions = false, ) { if (!$transport instanceof TransportInterface) { @trigger_error('Passing an instance of \OpenSearch\Transport to ' . __METHOD__ . '() is deprecated in 2.3.2 and will be removed in 3.0.0. Pass an instance of \OpenSearch\TransportInterface instead.', E_USER_DEPRECATED); @@ -311,13 +298,6 @@ public function __construct( } $this->endpoints = $endpoints; $this->endpointFactory = $endpointFactory; - if ($throwExceptions === true) { - @trigger_error( - 'The $throwExceptions parameter is deprecated in 2.4.0 and will be removed in 3.0.0. Check the response \'status_code\' instead', - E_USER_DEPRECATED - ); - $this->throwExceptions = true; - } $this->asyncSearch = new AsyncSearchNamespace($transport, $this->endpointFactory); $this->asynchronousSearch = new AsynchronousSearchNamespace($transport, $this->endpointFactory); $this->cat = new CatNamespace($transport, $this->endpointFactory); @@ -465,7 +445,7 @@ public function clearScroll(array $params = []) * $params['analyzer'] = (string) Analyzer to use for the query string.This parameter can only be used when the `q` query string parameter is specified. * $params['default_operator'] = (enum) The default operator for query string query: `AND` or `OR`.This parameter can only be used when the `q` query string parameter is specified. (Options = and,AND,or,OR) * $params['df'] = (string) Field to use as default where no field prefix is given in the query string.This parameter can only be used when the `q` query string parameter is specified. - * $params['expand_wildcards'] = (any) Type of index that wildcard patterns can match.If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.Supports comma-separated values, such as `open,hidden`. + * $params['expand_wildcards'] = (any) * $params['ignore_throttled'] = (boolean) If `true`, concrete, expanded or aliased indexes are ignored when frozen. * $params['ignore_unavailable'] = (boolean) If `false`, the request returns an error if it targets a missing or closed index. * $params['lenient'] = (boolean) If `true`, format-based query failures (such as providing text to a numeric field) in the query string will be ignored. @@ -585,7 +565,7 @@ public function deleteAllPits(array $params = []) * Deletes documents matching the provided query. * * $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases to search. Supports wildcards (`*`). To search all data streams or indexes, omit this parameter or use `*` or `_all`. (Required) - * $params['_source'] = (array) Set to `true` or `false` to return the `_source` field or not, or a list of fields to return. + * $params['_source'] = (any) Set to `true` or `false` to return the `_source` field or not, or a list of fields to return. * $params['_source_excludes'] = (array) List of fields to exclude from the returned `_source` field. * $params['_source_includes'] = (array) List of fields to extract and return from the `_source` field. * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes.This behavior applies even if the request targets other open indexes.For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`. @@ -608,7 +588,7 @@ public function deleteAllPits(array $params = []) * $params['scroll'] = (string) Period to retain the search context for scrolling. * $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['search_type'] = (any) The type of the search operation.Available options: `query_then_fetch`, `dfs_query_then_fetch`. * $params['size'] = (integer) Deprecated, 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. @@ -1134,7 +1114,7 @@ public function mget(array $params = []) * $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['search_type'] = (any) Indicates whether global term and document frequencies should be used when scoring returned documents. * $params['typed_keys'] = (boolean) Specifies whether aggregation and suggester names should be prefixed by their respective types in the response. * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) @@ -1166,7 +1146,7 @@ public function msearch(array $params = []) * $params['ccs_minimize_roundtrips'] = (boolean) If `true`, network round-trips are minimized for cross-cluster search requests. (Default = true) * $params['max_concurrent_searches'] = (integer) Maximum number of concurrent searches the API can run. * $params['rest_total_hits_as_int'] = (boolean) If `true`, the response returns `hits.total` as an integer.If `false`, it returns `hits.total` as an object. (Default = false) - * $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['search_type'] = (any) The type of the search operation.Available options: `query_then_fetch`, `dfs_query_then_fetch`. * $params['typed_keys'] = (boolean) If `true`, the response prefixes aggregation and suggester names with their respective types. * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) @@ -1293,7 +1273,7 @@ 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 indexes. This behavior applies even if the request targets other open indexes. For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`. * $params['expand_wildcards'] = (any) Whether to expand wildcard expression to concrete indexes that are open, closed or both. * $params['ignore_unavailable'] = (boolean) If `true`, missing or closed indexes are not included in the response. - * $params['search_type'] = (enum) Search operation type (Options = dfs_query_then_fetch,query_then_fetch) + * $params['search_type'] = (any) Search operation type * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) @@ -1323,6 +1303,7 @@ public function rankEval(array $params = []) * $params['max_docs'] = (integer) Maximum number of documents to process. By default, all documents. * $params['refresh'] = (any) If `true`, the request refreshes affected shards to make this operation visible to search. * $params['requests_per_second'] = (number) The throttle for this request in sub-requests per second.Defaults to no throttle. (Default = 0) + * $params['require_alias'] = (boolean) * $params['scroll'] = (string) Specifies how long a consistent view of the index should be maintained for scrolled search. * $params['slices'] = (any) The number of slices this task should be divided into.Defaults to 1 slice, meaning the task isn't sliced into subtasks. * $params['timeout'] = (string) Period each indexing waits for automatic index creation, dynamic mapping updates, and waiting for active shards. @@ -1487,7 +1468,7 @@ public function scroll(array $params = []) * $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['search_type'] = (any) How distributed term frequencies are calculated for relevance scoring. * $params['seq_no_primary_term'] = (boolean) If `true`, returns sequence number and primary term of the last modification of each hit. * $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. @@ -1541,7 +1522,6 @@ public function search(array $params = []) * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-". - * $params['body'] = (array) Defines the parameters that can be used in the `search_shards` endpoint request. See documentation for supported query syntax. * * @param array $params Associative array of parameters * @return array @@ -1549,12 +1529,10 @@ public function search(array $params = []) public function searchShards(array $params = []) { $index = $this->extractArgument($params, 'index'); - $body = $this->extractArgument($params, 'body'); $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\SearchShards::class); $endpoint->setParams($params); $endpoint->setIndex($index); - $endpoint->setBody($body); return $this->performRequest($endpoint); } @@ -1574,7 +1552,7 @@ public function searchShards(array $params = []) * $params['rest_total_hits_as_int'] = (boolean) If `true`, `hits.total` are rendered as an integer in the response. (Default = false) * $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['search_type'] = (any) The type of the search operation. * $params['typed_keys'] = (boolean) If `true`, the response prefixes aggregation and suggester names with their respective types. * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) @@ -1686,7 +1664,7 @@ public function update(array $params = []) * Performs an update on every document in the index without changing the source,for example to pick up a mapping change. * * $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases to search. Supports wildcards (`*`). To search all data streams or indexes, omit this parameter or use `*` or `_all`. (Required) - * $params['_source'] = (array) Set to `true` or `false` to return the `_source` field or not, or a list of fields to return. + * $params['_source'] = (any) Set to `true` or `false` to return the `_source` field or not, or a list of fields to return. * $params['_source_excludes'] = (array) List of fields to exclude from the returned `_source` field. * $params['_source_includes'] = (array) List of fields to extract and return from the `_source` field. * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes.This behavior applies even if the request targets other open indexes.For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`. @@ -1710,7 +1688,7 @@ public function update(array $params = []) * $params['scroll'] = (string) Period to retain the search context for scrolling. * $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['search_type'] = (any) The type of the search operation. Available options: `query_then_fetch`, `dfs_query_then_fetch`. * $params['size'] = (integer) Deprecated, 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. @@ -2100,7 +2078,7 @@ public function extractArgument(array &$params, string $arg) * Send a raw request to the cluster. * * @throws \Psr\Http\Client\ClientExceptionInterface - * @throws \OpenSearch\Common\Exceptions\OpenSearchException + * @throws \OpenSearch\Exception\HttpExceptionInterface */ public function request( string $method, @@ -2111,117 +2089,24 @@ public function request( $body = $attributes['body'] ?? null; $options = $attributes['options'] ?? []; - $response = $this->httpTransport->sendRequest($method, $uri, $params, $body, $options['headers'] ?? []); - - // @todo: Remove this in the next major release. - // Throw legacy exceptions. - if ($this->throwExceptions) { - if (isset($response['status']) && $response['status'] >= 400) { - $this->throwLegacyException($response); - } - } - - return $response; + return $this->httpTransport->sendRequest($method, $uri, $params, $body, $options['headers'] ?? []); } /** * Send a request for an endpoint. * * @throws \Psr\Http\Client\ClientExceptionInterface - * @throws \OpenSearch\Common\Exceptions\OpenSearchException + * @throws \OpenSearch\Exception\HttpExceptionInterface */ private function performRequest(AbstractEndpoint $endpoint): array|string|null { - $response = $this->httpTransport->sendRequest( + return $this->httpTransport->sendRequest( $endpoint->getMethod(), $endpoint->getURI(), $endpoint->getParams(), $endpoint->getBody(), $endpoint->getOptions() ); - - // @todo: Remove this in the next major release. - // Throw legacy exceptions. - if ($this->throwExceptions) { - if (isset($response['status']) && $response['status'] >= 400) { - $this->throwLegacyException($response); - } - } - - return $response; - } - - /** - * Throw legacy exceptions. - * - * @param array $response - * - * @throws \OpenSearch\Common\Exceptions\OpenSearchException - */ - private function throwLegacyException(array $response): void - { - if ($response['status'] >= 400 && $response['status'] < 500) { - $this->throwLegacyClientException($response); - } - if ($response['status'] >= 500) { - $this->throwLegacyServerException($response); - } - } - - /** - * Throw legacy client exceptions based on status code. - * - * @throws \OpenSearch\Common\Exceptions\OpenSearchException - */ - private function throwLegacyClientException($response): void - { - $statusCode = $response['status_code']; - $responseBody = $this->convertBodyToString($response['body'], $statusCode); - throw match ($statusCode) { - 401 => new Unauthorized401Exception($responseBody, $statusCode), - 403 => new Forbidden403Exception($responseBody, $statusCode), - 404 => new Missing404Exception($responseBody, $statusCode), - 409 => new Conflict409Exception($responseBody, $statusCode), - 400 => (str_contains($responseBody, 'script_lang not supported')) - ? new ScriptLangNotSupportedException($responseBody . $statusCode) - : new BadRequest400Exception($responseBody, $statusCode), - 408 => new RequestTimeout408Exception($responseBody, $statusCode), - default => new BadRequest400Exception($responseBody, $statusCode), - }; - } - - /** - * Throw legacy server exceptions based on status code. - * - * @throws \OpenSearch\Common\Exceptions\OpenSearchException - */ - private function throwLegacyServerException($response): void - { - $statusCode = $response['status_code']; - $error = $response['body']['error'] ?? []; - $reason = $error['reason'] ?? 'undefined reason'; - $type = $error['type'] ?? 'undefined type'; - $errorMessage = "$type: $reason"; - $responseBody = $this->convertBodyToString($response['body'], $statusCode); - - $exception = new ServerErrorResponseException($responseBody, $statusCode); - if ($statusCode === 500) { - if (str_contains($responseBody, "RoutingMissingException")) { - $exception = new RoutingMissingException($errorMessage, $statusCode); - } elseif (preg_match('/ActionRequestValidationException.+ no documents to get/', $responseBody) === 1) { - $exception = new NoDocumentsToGetException($errorMessage, $statusCode); - } elseif (str_contains($responseBody, 'NoShardAvailableActionException')) { - $exception = new NoShardAvailableException($errorMessage, $statusCode); - } - } - throw $exception; - } - - private function convertBodyToString(mixed $body, int $statusCode): string - { - return empty($body) - ? "Unknown $statusCode error from OpenSearch" - : (is_string($body) ? $body : json_encode($body)); } } diff --git a/src/OpenSearch/Endpoints/Ml/ChunkModel.php b/src/OpenSearch/Endpoints/Ml/ChunkModel.php new file mode 100644 index 000000000..afc9f49ee --- /dev/null +++ b/src/OpenSearch/Endpoints/Ml/ChunkModel.php @@ -0,0 +1,87 @@ +chunk_number ?? null; + $model_id = $this->model_id ?? null; + if (isset($model_id) && isset($chunk_number)) { + return "/_plugins/_ml/models/$model_id/chunk/$chunk_number"; + } + throw new RuntimeException('Missing parameter for the endpoint ml.chunk_model'); + } + + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'POST'; + } + + public function setBody($body): static + { + if (is_null($body)) { + return $this; + } + $this->body = $body; + + return $this; + } + + public function setChunkNumber($chunk_number): static + { + if (is_null($chunk_number)) { + return $this; + } + $this->chunk_number = $chunk_number; + + return $this; + } + + public function setModelId($model_id): static + { + if (is_null($model_id)) { + return $this; + } + $this->model_id = $model_id; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ml/CreateController.php b/src/OpenSearch/Endpoints/Ml/CreateController.php new file mode 100644 index 000000000..c8cb5f394 --- /dev/null +++ b/src/OpenSearch/Endpoints/Ml/CreateController.php @@ -0,0 +1,72 @@ +model_id ?? null; + if (isset($model_id)) { + return "/_plugins/_ml/controllers/$model_id"; + } + throw new RuntimeException('Missing parameter for the endpoint ml.create_controller'); + } + + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'POST'; + } + + public function setBody($body): static + { + if (is_null($body)) { + return $this; + } + $this->body = $body; + + return $this; + } + + public function setModelId($model_id): static + { + if (is_null($model_id)) { + return $this; + } + $this->model_id = $model_id; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ml/CreateModelMeta.php b/src/OpenSearch/Endpoints/Ml/CreateModelMeta.php new file mode 100644 index 000000000..8d2c22cef --- /dev/null +++ b/src/OpenSearch/Endpoints/Ml/CreateModelMeta.php @@ -0,0 +1,58 @@ +body = $body; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ml/DeleteController.php b/src/OpenSearch/Endpoints/Ml/DeleteController.php new file mode 100644 index 000000000..031888632 --- /dev/null +++ b/src/OpenSearch/Endpoints/Ml/DeleteController.php @@ -0,0 +1,62 @@ +model_id ?? null; + if (isset($model_id)) { + return "/_plugins/_ml/controllers/$model_id"; + } + throw new RuntimeException('Missing parameter for the endpoint ml.delete_controller'); + } + + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'DELETE'; + } + + public function setModelId($model_id): static + { + if (is_null($model_id)) { + return $this; + } + $this->model_id = $model_id; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ml/GetController.php b/src/OpenSearch/Endpoints/Ml/GetController.php new file mode 100644 index 000000000..b8557d78b --- /dev/null +++ b/src/OpenSearch/Endpoints/Ml/GetController.php @@ -0,0 +1,62 @@ +model_id ?? null; + if (isset($model_id)) { + return "/_plugins/_ml/controllers/$model_id"; + } + throw new RuntimeException('Missing parameter for the endpoint ml.get_controller'); + } + + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'GET'; + } + + public function setModelId($model_id): static + { + if (is_null($model_id)) { + return $this; + } + $this->model_id = $model_id; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ml/GetModel.php b/src/OpenSearch/Endpoints/Ml/GetModel.php index eb284d7a4..e0550ce4b 100644 --- a/src/OpenSearch/Endpoints/Ml/GetModel.php +++ b/src/OpenSearch/Endpoints/Ml/GetModel.php @@ -16,36 +16,45 @@ use OpenSearch\Common\Exceptions\RuntimeException; use OpenSearch\Endpoints\AbstractEndpoint; +/** + * NOTE: This file is autogenerated using util/GenerateEndpoints.php + */ class GetModel 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"; + $model_id = $this->model_id ?? null; + if (isset($model_id)) { + return "/_plugins/_ml/models/$model_id"; } + throw new RuntimeException('Missing parameter for the endpoint ml.get_model'); + } - throw new RuntimeException( - 'id is required for get' - ); - + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; } - /** - * @return string - */ public function getMethod(): string { return 'GET'; } + + public function setModelId($model_id): static + { + if (is_null($model_id)) { + return $this; + } + $this->model_id = $model_id; + + return $this; + } } diff --git a/src/OpenSearch/Endpoints/Ml/GetProfile.php b/src/OpenSearch/Endpoints/Ml/GetProfile.php new file mode 100644 index 000000000..064382935 --- /dev/null +++ b/src/OpenSearch/Endpoints/Ml/GetProfile.php @@ -0,0 +1,55 @@ +body = $body; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ml/GetProfileModels.php b/src/OpenSearch/Endpoints/Ml/GetProfileModels.php new file mode 100644 index 000000000..987d5c8fd --- /dev/null +++ b/src/OpenSearch/Endpoints/Ml/GetProfileModels.php @@ -0,0 +1,71 @@ +model_id ?? null; + if (isset($model_id)) { + return "/_plugins/_ml/profile/models/$model_id"; + } + return "/_plugins/_ml/profile/models"; + } + + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'GET'; + } + + public function setBody($body): static + { + if (is_null($body)) { + return $this; + } + $this->body = $body; + + return $this; + } + + public function setModelId($model_id): static + { + if (is_null($model_id)) { + return $this; + } + $this->model_id = $model_id; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ml/GetProfileTasks.php b/src/OpenSearch/Endpoints/Ml/GetProfileTasks.php new file mode 100644 index 000000000..03321c09e --- /dev/null +++ b/src/OpenSearch/Endpoints/Ml/GetProfileTasks.php @@ -0,0 +1,71 @@ +task_id ?? null; + if (isset($task_id)) { + return "/_plugins/_ml/profile/tasks/$task_id"; + } + return "/_plugins/_ml/profile/tasks"; + } + + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'GET'; + } + + public function setBody($body): static + { + if (is_null($body)) { + return $this; + } + $this->body = $body; + + return $this; + } + + public function setTaskId($task_id): static + { + if (is_null($task_id)) { + return $this; + } + $this->task_id = $task_id; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ml/GetStats.php b/src/OpenSearch/Endpoints/Ml/GetStats.php new file mode 100644 index 000000000..284cd9715 --- /dev/null +++ b/src/OpenSearch/Endpoints/Ml/GetStats.php @@ -0,0 +1,79 @@ +node_id ?? null; + $stat = $this->stat ?? null; + if (isset($node_id) && isset($stat)) { + return "/_plugins/_ml/$node_id/stats/$stat"; + } + if (isset($node_id)) { + return "/_plugins/_ml/$node_id/stats/"; + } + if (isset($stat)) { + return "/_plugins/_ml/stats/$stat"; + } + return "/_plugins/_ml/stats"; + } + + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'GET'; + } + + public function setNodeId($node_id): static + { + if (is_null($node_id)) { + return $this; + } + $this->node_id = $node_id; + + return $this; + } + + public function setStat($stat): static + { + if (is_null($stat)) { + return $this; + } + $this->stat = $stat; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ml/LoadModel.php b/src/OpenSearch/Endpoints/Ml/LoadModel.php new file mode 100644 index 000000000..c88667fb5 --- /dev/null +++ b/src/OpenSearch/Endpoints/Ml/LoadModel.php @@ -0,0 +1,65 @@ +model_id ?? null; + if (isset($model_id)) { + return "/_plugins/_ml/models/$model_id/_load"; + } + throw new RuntimeException('Missing parameter for the endpoint ml.load_model'); + } + + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'POST'; + } + + public function setModelId($model_id): static + { + if (is_null($model_id)) { + return $this; + } + $this->model_id = $model_id; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ml/PredictModel.php b/src/OpenSearch/Endpoints/Ml/PredictModel.php new file mode 100644 index 000000000..62c8014b5 --- /dev/null +++ b/src/OpenSearch/Endpoints/Ml/PredictModel.php @@ -0,0 +1,72 @@ +model_id ?? null; + if (isset($model_id)) { + return "/_plugins/_ml/models/$model_id/_predict"; + } + throw new RuntimeException('Missing parameter for the endpoint ml.predict_model'); + } + + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'POST'; + } + + public function setBody($body): static + { + if (is_null($body)) { + return $this; + } + $this->body = $body; + + return $this; + } + + public function setModelId($model_id): static + { + if (is_null($model_id)) { + return $this; + } + $this->model_id = $model_id; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ml/RegisterModelMeta.php b/src/OpenSearch/Endpoints/Ml/RegisterModelMeta.php new file mode 100644 index 000000000..dd4902ffc --- /dev/null +++ b/src/OpenSearch/Endpoints/Ml/RegisterModelMeta.php @@ -0,0 +1,55 @@ +body = $body; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ml/SearchModels.php b/src/OpenSearch/Endpoints/Ml/SearchModels.php index 25d7e06b4..868d295c2 100644 --- a/src/OpenSearch/Endpoints/Ml/SearchModels.php +++ b/src/OpenSearch/Endpoints/Ml/SearchModels.php @@ -40,7 +40,7 @@ public function getParamWhitelist(): array public function getMethod(): string { - return 'GET'; + return isset($this->body) ? 'POST' : 'GET'; } public function setBody($body): static diff --git a/src/OpenSearch/Endpoints/Ml/UndeployModel.php b/src/OpenSearch/Endpoints/Ml/UndeployModel.php index 313dba614..76eade2ca 100644 --- a/src/OpenSearch/Endpoints/Ml/UndeployModel.php +++ b/src/OpenSearch/Endpoints/Ml/UndeployModel.php @@ -13,7 +13,6 @@ namespace OpenSearch\Endpoints\Ml; -use OpenSearch\Common\Exceptions\RuntimeException; use OpenSearch\Endpoints\AbstractEndpoint; /** @@ -29,7 +28,7 @@ public function getURI(): string if (isset($model_id)) { return "/_plugins/_ml/models/$model_id/_undeploy"; } - throw new RuntimeException('Missing parameter for the endpoint ml.undeploy_model'); + return "/_plugins/_ml/models/_undeploy"; } public function getParamWhitelist(): array @@ -48,6 +47,16 @@ public function getMethod(): string return 'POST'; } + public function setBody($body): static + { + if (is_null($body)) { + return $this; + } + $this->body = $body; + + return $this; + } + public function setModelId($model_id): static { if (is_null($model_id)) { diff --git a/src/OpenSearch/Endpoints/Ml/UnloadModel.php b/src/OpenSearch/Endpoints/Ml/UnloadModel.php new file mode 100644 index 000000000..40f40aa4e --- /dev/null +++ b/src/OpenSearch/Endpoints/Ml/UnloadModel.php @@ -0,0 +1,74 @@ +model_id ?? null; + if (isset($model_id)) { + return "/_plugins/_ml/models/$model_id/_unload"; + } + return "/_plugins/_ml/models/_unload"; + } + + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'POST'; + } + + public function setBody($body): static + { + if (is_null($body)) { + return $this; + } + $this->body = $body; + + return $this; + } + + public function setModelId($model_id): static + { + if (is_null($model_id)) { + return $this; + } + $this->model_id = $model_id; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ml/UpdateController.php b/src/OpenSearch/Endpoints/Ml/UpdateController.php new file mode 100644 index 000000000..ed956577a --- /dev/null +++ b/src/OpenSearch/Endpoints/Ml/UpdateController.php @@ -0,0 +1,72 @@ +model_id ?? null; + if (isset($model_id)) { + return "/_plugins/_ml/controllers/$model_id"; + } + throw new RuntimeException('Missing parameter for the endpoint ml.update_controller'); + } + + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'PUT'; + } + + public function setBody($body): static + { + if (is_null($body)) { + return $this; + } + $this->body = $body; + + return $this; + } + + public function setModelId($model_id): static + { + if (is_null($model_id)) { + return $this; + } + $this->model_id = $model_id; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ml/UpdateModel.php b/src/OpenSearch/Endpoints/Ml/UpdateModel.php new file mode 100644 index 000000000..7cb9ba5a8 --- /dev/null +++ b/src/OpenSearch/Endpoints/Ml/UpdateModel.php @@ -0,0 +1,72 @@ +model_id ?? null; + if (isset($model_id)) { + return "/_plugins/_ml/models/$model_id"; + } + throw new RuntimeException('Missing parameter for the endpoint ml.update_model'); + } + + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'PUT'; + } + + public function setBody($body): static + { + if (is_null($body)) { + return $this; + } + $this->body = $body; + + return $this; + } + + public function setModelId($model_id): static + { + if (is_null($model_id)) { + return $this; + } + $this->model_id = $model_id; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ml/UploadChunk.php b/src/OpenSearch/Endpoints/Ml/UploadChunk.php new file mode 100644 index 000000000..5831292f6 --- /dev/null +++ b/src/OpenSearch/Endpoints/Ml/UploadChunk.php @@ -0,0 +1,84 @@ +chunk_number ?? null; + $model_id = $this->model_id ?? null; + if (isset($model_id) && isset($chunk_number)) { + return "/_plugins/_ml/models/$model_id/upload_chunk/$chunk_number"; + } + throw new RuntimeException('Missing parameter for the endpoint ml.upload_chunk'); + } + + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'POST'; + } + + public function setBody($body): static + { + if (is_null($body)) { + return $this; + } + $this->body = $body; + + return $this; + } + + public function setChunkNumber($chunk_number): static + { + if (is_null($chunk_number)) { + return $this; + } + $this->chunk_number = $chunk_number; + + return $this; + } + + public function setModelId($model_id): static + { + if (is_null($model_id)) { + return $this; + } + $this->model_id = $model_id; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ml/UploadModel.php b/src/OpenSearch/Endpoints/Ml/UploadModel.php new file mode 100644 index 000000000..e4ac9913b --- /dev/null +++ b/src/OpenSearch/Endpoints/Ml/UploadModel.php @@ -0,0 +1,58 @@ +body = $body; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Reindex.php b/src/OpenSearch/Endpoints/Reindex.php index c65560a65..b6c7cefa3 100644 --- a/src/OpenSearch/Endpoints/Reindex.php +++ b/src/OpenSearch/Endpoints/Reindex.php @@ -39,6 +39,7 @@ public function getParamWhitelist(): array 'max_docs', 'refresh', 'requests_per_second', + 'require_alias', 'scroll', 'slices', 'timeout', diff --git a/src/OpenSearch/Endpoints/SearchShards.php b/src/OpenSearch/Endpoints/SearchShards.php index f777c44cc..4d7d3161b 100644 --- a/src/OpenSearch/Endpoints/SearchShards.php +++ b/src/OpenSearch/Endpoints/SearchShards.php @@ -56,16 +56,6 @@ public function getParamWhitelist(): array public function getMethod(): string { - return isset($this->body) ? 'POST' : 'GET'; - } - - public function setBody($body): static - { - if (is_null($body)) { - return $this; - } - $this->body = $body; - - return $this; + return 'GET'; } } diff --git a/src/OpenSearch/Namespaces/AsynchronousSearchNamespace.php b/src/OpenSearch/Namespaces/AsynchronousSearchNamespace.php index 9922a808c..be64b2b38 100644 --- a/src/OpenSearch/Namespaces/AsynchronousSearchNamespace.php +++ b/src/OpenSearch/Namespaces/AsynchronousSearchNamespace.php @@ -23,7 +23,7 @@ class AsynchronousSearchNamespace extends AbstractNamespace { /** - * Delete asynchronous search. + * Deletes any responses from an asynchronous search. * * $params['id'] = (string) (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) @@ -47,7 +47,7 @@ public function delete(array $params = []) } /** - * Get partial responses from asynchronous search. + * Gets partial responses from an asynchronous search. * * $params['id'] = (string) (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) @@ -71,12 +71,12 @@ public function get(array $params = []) } /** - * Perform an asynchronous search. + * Performs an asynchronous search. * * $params['index'] = (string) The name of the index to be searched. Can be an individual name, a comma-separated list of indexes, or a wildcard expression of index names. * $params['keep_alive'] = (string) The amount of time that the result is saved in the cluster. For example, `2d` means that the results are stored in the cluster for 48 hours. The saved search results are deleted after this period or if the search is canceled. Note that this includes the query execution time. If the query overruns this time, the process cancels this query automatically. - * $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. You can poll the remaining results based on an ID. The maximum value is `300s`. Default is `1s`. + * $params['keep_on_completion'] = (boolean) Whether you want to save the results in the cluster after the search is complete. You can examine the stored results at a later time. + * $params['wait_for_completion_timeout'] = (string) The amount of time that you plan to wait for the results. You can poll the remaining results based on an ID. The maximum value is 300 seconds. Default is `1s`. * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) @@ -98,7 +98,7 @@ public function search(array $params = []) } /** - * Monitoring of asynchronous searches that are running, completed, and/or persisted. + * Monitors any asynchronous searches that are `running`, `completed`, `persisted`. * * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) diff --git a/src/OpenSearch/Namespaces/CatNamespace.php b/src/OpenSearch/Namespaces/CatNamespace.php index f1503a8f7..3c7d1534e 100644 --- a/src/OpenSearch/Namespaces/CatNamespace.php +++ b/src/OpenSearch/Namespaces/CatNamespace.php @@ -65,7 +65,7 @@ public function aliases(array $params = []) * $params['bytes'] = (any) The units used to display byte values. * $params['format'] = (string) A short version of the `Accept` header, such as `json` or `yaml`. * $params['h'] = (array) A comma-separated list of column names to display. - * $params['help'] = (boolean) Return help information. (Default = false) + * $params['help'] = (boolean) Returns help information. (Default = false) * $params['s'] = (array) A comma-separated list of column names or column aliases to sort by. * $params['v'] = (boolean) Enables verbose mode, which displays column headers. (Default = false) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) @@ -124,7 +124,7 @@ public function allocation(array $params = []) * $params['cluster_manager_timeout'] = (string) A timeout for connection to the cluster manager node. * $params['format'] = (string) A short version of the HTTP `Accept` header, such as `json` or `yaml`. * $params['h'] = (array) A comma-separated list of column names to display. - * $params['help'] = (boolean) Return help information. (Default = false) + * $params['help'] = (boolean) Returns help information. (Default = false) * $params['local'] = (boolean) Returns local information but does not retrieve the state from the cluster manager node. (Default = false) * $params['master_timeout'] = (string) A timeout for connection to the cluster manager node. * $params['s'] = (array) A comma-separated list of column names or column aliases to sort by. @@ -152,7 +152,7 @@ public function clusterManager(array $params = []) * $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. * $params['format'] = (string) A short version of the `Accept` header, such as `json` or `yaml`. * $params['h'] = (array) A comma-separated list of column names to display. - * $params['help'] = (boolean) Return help information. (Default = false) + * $params['help'] = (boolean) Returns help information. (Default = false) * $params['s'] = (array) A comma-separated list of column names or column aliases to sort by. * $params['v'] = (boolean) Enables verbose mode, which displays column headers. (Default = false) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) @@ -182,7 +182,7 @@ public function count(array $params = []) * $params['bytes'] = (any) The units used to display byte values. * $params['format'] = (string) A short version of the `Accept` header, such as `json` or `yaml`. * $params['h'] = (array) A comma-separated list of column names to display. - * $params['help'] = (boolean) Return help information. (Default = false) + * $params['help'] = (boolean) Returns help information. (Default = false) * $params['s'] = (array) A comma-separated list of column names or column aliases to sort by. * $params['v'] = (boolean) Enables verbose mode, which displays column headers. (Default = false) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) @@ -210,7 +210,7 @@ public function fielddata(array $params = []) * * $params['format'] = (string) A short version of the `Accept` header, such as `json` or `yaml`. * $params['h'] = (array) A comma-separated list of column names to display. - * $params['help'] = (boolean) Return help information. (Default = false) + * $params['help'] = (boolean) Returns help information. (Default = false) * $params['s'] = (array) A comma-separated list of column names or column aliases to sort by. * $params['time'] = (any) The unit used to display time values. * $params['ts'] = (boolean) When `true`, returns `HH:MM:SS` and Unix epoch timestamps. (Default = true) @@ -258,11 +258,11 @@ public function help(array $params = []) * $params['index'] = (array) A comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. * $params['bytes'] = (any) The units used to display byte values. * $params['cluster_manager_timeout'] = (string) The amount of time allowed to establish a connection to the cluster manager node. - * $params['expand_wildcards'] = (any) The type of index that wildcard patterns can match. + * $params['expand_wildcards'] = (any) The type of index that wildcard patterns can match. Supported values are `all`, `open`, `closed`, `hidden`, and `none`. * $params['format'] = (string) A short version of the `Accept` header, such as `json` or `yaml`. * $params['h'] = (array) A comma-separated list of column names to display. * $params['health'] = (any) Limits indexes based on their health status. Supported values are `green`, `yellow`, and `red`. - * $params['help'] = (boolean) Return help information. (Default = false) + * $params['help'] = (boolean) Returns help information. (Default = false) * $params['include_unloaded_segments'] = (boolean) Whether to include information from segments not loaded into memory. (Default = false) * $params['local'] = (boolean) Returns local information but does not retrieve the state from the cluster manager node. (Default = false) * $params['master_timeout'] = (string) The amount of time allowed to establish a connection to the cluster manager node. @@ -296,7 +296,7 @@ public function indices(array $params = []) * $params['cluster_manager_timeout'] = (string) The amount of time allowed to establish a connection to the cluster manager node. * $params['format'] = (string) A short version of the `Accept` header, such as `json` or `yaml`. * $params['h'] = (array) A comma-separated list of column names to display. - * $params['help'] = (boolean) Return help information. (Default = false) + * $params['help'] = (boolean) Returns help information. (Default = false) * $params['local'] = (boolean) Returns local information but does not retrieve the state from the cluster manager node. (Default = false) * $params['master_timeout'] = (string) The amount of time allowed to establish a connection to the cluster manager node. * $params['s'] = (array) A comma-separated list of column names or column aliases to sort by. @@ -324,7 +324,7 @@ public function master(array $params = []) * $params['cluster_manager_timeout'] = (string) The amount of time allowed to establish a connection to the cluster manager node. * $params['format'] = (string) A short version of the `Accept` header, such as `json` or `yaml`. * $params['h'] = (array) A comma-separated list of column names to display. - * $params['help'] = (boolean) Return help information. (Default = false) + * $params['help'] = (boolean) Returns help information. (Default = false) * $params['local'] = (boolean) Returns local information but does not retrieve the state from the cluster manager node. (Default = false) * $params['master_timeout'] = (string) The amount of time allowed to establish a connection to the cluster manager node. * $params['s'] = (array) A comma-separated list of column names or column aliases to sort by. @@ -354,7 +354,7 @@ public function nodeattrs(array $params = []) * $params['format'] = (string) A short version of the `Accept` header, such as `json` or `yaml`. * $params['full_id'] = (any) When `true`, returns the full node ID. When `false`, returns the shortened node ID. * $params['h'] = (array) A comma-separated list of column names to display. - * $params['help'] = (boolean) Return help information. (Default = false) + * $params['help'] = (boolean) Returns help information. (Default = false) * $params['local'] = (boolean) Returns local information but does not retrieve the state from the cluster manager node. (Default = false) * $params['master_timeout'] = (string) The amount of time allowed to establish a connection to the cluster manager node. * $params['s'] = (array) A comma-separated list of column names or column aliases to sort by. @@ -383,7 +383,7 @@ public function nodes(array $params = []) * $params['cluster_manager_timeout'] = (string) The amount of time allowed to establish a connection to the cluster manager node. * $params['format'] = (string) A short version of the `Accept` header, such as `json` or `yaml`. * $params['h'] = (array) A comma-separated list of column names to display. - * $params['help'] = (boolean) Return help information. (Default = false) + * $params['help'] = (boolean) Returns help information. (Default = false) * $params['local'] = (boolean) Returns local information but does not retrieve the state from the cluster manager node. (Default = false) * $params['master_timeout'] = (string) The amount of time allowed to establish a connection to the cluster manager node. * $params['s'] = (array) A comma-separated list of column names or column aliases to sort by. @@ -412,7 +412,7 @@ public function pendingTasks(array $params = []) * $params['bytes'] = (any) The units used to display byte values. * $params['format'] = (string) A short version of the `Accept` header, such as `json` or `yaml`. * $params['h'] = (array) A comma-separated list of column names to display. - * $params['help'] = (boolean) Return help information. (Default = false) + * $params['help'] = (boolean) Returns help information. (Default = false) * $params['s'] = (array) A comma-separated list of column names or column aliases to sort by. * $params['v'] = (boolean) Enables verbose mode, which displays column headers. (Default = false) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) @@ -441,7 +441,7 @@ public function pitSegments(array $params = []) * $params['cluster_manager_timeout'] = (string) The amount of time allowed to establish a connection to the cluster manager node. * $params['format'] = (string) A short version of the `Accept` header, such as `json` or `yaml`. * $params['h'] = (array) A comma-separated list of column names to display. - * $params['help'] = (boolean) Return help information. (Default = false) + * $params['help'] = (boolean) Returns help information. (Default = false) * $params['local'] = (boolean) Returns local information but does not retrieve the state from the cluster manager node. (Default = false) * $params['master_timeout'] = (string) The amount of time allowed to establish a connection to the cluster manager node. * $params['s'] = (array) A comma-separated list of column names or column aliases to sort by. @@ -472,7 +472,7 @@ public function plugins(array $params = []) * $params['detailed'] = (boolean) When `true`, includes detailed information about shard recoveries. (Default = false) * $params['format'] = (string) A short version of the `Accept` header, such as `json` or `yaml`. * $params['h'] = (array) A comma-separated list of column names to display. - * $params['help'] = (boolean) Return help information. (Default = false) + * $params['help'] = (boolean) Returns help information. (Default = false) * $params['s'] = (array) A comma-separated list of column names or column aliases to sort by. * $params['time'] = (any) Specifies the time units, for example, `5d` or `7h`. For more information, see [Supported units](https://opensearch.org/docs/latest/api-reference/units/). * $params['v'] = (boolean) Enables verbose mode, which displays column headers. (Default = false) @@ -502,7 +502,7 @@ public function recovery(array $params = []) * $params['cluster_manager_timeout'] = (string) The amount of time allowed to establish a connection to the cluster manager node. * $params['format'] = (string) A short version of the `Accept` header, such as `json` or `yaml`. * $params['h'] = (array) A comma-separated list of column names to display. - * $params['help'] = (boolean) Return help information. (Default = false) + * $params['help'] = (boolean) Returns help information. (Default = false) * $params['local'] = (boolean) Returns local information but does not retrieve the state from the cluster manager node. (Default = false) * $params['master_timeout'] = (string) The amount of time allowed to establish a connection to the cluster manager node. * $params['s'] = (array) A comma-separated list of column names or column aliases to sort by. @@ -533,10 +533,10 @@ public function repositories(array $params = []) * $params['bytes'] = (any) The units used to display byte values. * $params['completed_only'] = (boolean) When `true`, the response only includes the last-completed segment replication events. (Default = false) * $params['detailed'] = (boolean) When `true`, the response includes additional metrics for each stage of a segment replication event. (Default = false) - * $params['expand_wildcards'] = (any) Whether to expand the wildcard expression to include concrete indexes that are open, closed, or both. + * $params['expand_wildcards'] = (any) The type of index that wildcard patterns can match. Supported values are `all`, `open`, `closed`, `hidden`, and `none`. * $params['format'] = (string) A short version of the `Accept` header, such as `json` or `yaml`. * $params['h'] = (array) A comma-separated list of column names to display. - * $params['help'] = (boolean) Return help information. (Default = false) + * $params['help'] = (boolean) Returns help information. (Default = false) * $params['ignore_throttled'] = (boolean) Whether specified concrete, expanded, or aliased indexes should be ignored when throttled. * $params['ignore_unavailable'] = (boolean) Whether the specified concrete indexes should be ignored when missing or closed. * $params['s'] = (array) A comma-separated list of column names or column aliases to sort by. @@ -604,7 +604,7 @@ public function segments(array $params = []) * $params['cluster_manager_timeout'] = (string) The amount of time allowed to establish a connection to the cluster manager node. * $params['format'] = (string) A short version of the `Accept` header, such as `json` or `yaml`. * $params['h'] = (array) A comma-separated list of column names to display. - * $params['help'] = (boolean) Return help information. (Default = false) + * $params['help'] = (boolean) Returns help information. (Default = false) * $params['local'] = (boolean) Returns local information but does not retrieve the state from the cluster manager node. (Default = false) * $params['master_timeout'] = (string) The amount of time allowed to establish a connection to the cluster manager node. * $params['s'] = (array) A comma-separated list of column names or column aliases to sort by. @@ -637,7 +637,7 @@ public function shards(array $params = []) * $params['cluster_manager_timeout'] = (string) The amount of time allowed to establish a connection to the cluster manager node. * $params['format'] = (string) A short version of the `Accept` header, such as `json` or `yaml`. * $params['h'] = (array) A comma-separated list of column names to display. - * $params['help'] = (boolean) Return help information. (Default = false) + * $params['help'] = (boolean) Returns help information. (Default = false) * $params['ignore_unavailable'] = (boolean) When `true`, the response does not include information from unavailable snapshots. (Default = false) * $params['master_timeout'] = (string) The amount of time allowed to establish a connection to the cluster manager node. * $params['s'] = (array) A comma-separated list of column names or column aliases to sort by. @@ -670,7 +670,7 @@ public function snapshots(array $params = []) * $params['detailed'] = (boolean) If `true`, the response includes detailed information about shard recoveries. (Default = false) * $params['format'] = (string) A short version of the `Accept` header, such as `json` or `yaml`. * $params['h'] = (array) A comma-separated list of column names to display. - * $params['help'] = (boolean) Return help information. (Default = false) + * $params['help'] = (boolean) Returns help information. (Default = false) * $params['s'] = (array) A comma-separated list of column names or column aliases to sort by. * $params['time'] = (any) Specifies the time units, for example, `5d` or `7h`. For more information, see [Supported units](https://opensearch.org/docs/latest/api-reference/units/). * $params['v'] = (boolean) Enables verbose mode, which displays column headers. (Default = false) @@ -700,7 +700,7 @@ public function tasks(array $params = []) * $params['cluster_manager_timeout'] = (string) The amount of time allowed to establish a connection to the cluster manager node. * $params['format'] = (string) A short version of the `Accept` header, such as `json` or `yaml`. * $params['h'] = (array) A comma-separated list of column names to display. - * $params['help'] = (boolean) Return help information. (Default = false) + * $params['help'] = (boolean) Returns help information. (Default = false) * $params['local'] = (boolean) Returns local information but does not retrieve the state from the cluster manager node. (Default = false) * $params['master_timeout'] = (string) The amount of time allowed to establish a connection to the cluster manager node. * $params['s'] = (array) A comma-separated list of column names or column aliases to sort by. @@ -732,7 +732,7 @@ public function templates(array $params = []) * $params['cluster_manager_timeout'] = (string) A timeout for connection to the cluster manager node. * $params['format'] = (string) A short version of the `Accept` header, such as `json` or `yaml`. * $params['h'] = (array) A comma-separated list of column names to display. - * $params['help'] = (boolean) Return help information. (Default = false) + * $params['help'] = (boolean) Returns help information. (Default = false) * $params['local'] = (boolean) Returns local information but does not retrieve the state from the cluster manager node. (Default = false) * $params['master_timeout'] = (string) The amount of time allowed to establish a connection to the cluster manager node. * $params['s'] = (array) A comma-separated list of column names or column aliases to sort by. diff --git a/src/OpenSearch/Namespaces/MlNamespace.php b/src/OpenSearch/Namespaces/MlNamespace.php index 52f284464..62b722329 100644 --- a/src/OpenSearch/Namespaces/MlNamespace.php +++ b/src/OpenSearch/Namespaces/MlNamespace.php @@ -22,6 +22,61 @@ */ class MlNamespace extends AbstractNamespace { + /** + * Uploads model chunk. + * + * $params['chunk_number'] = (integer) + * $params['model_id'] = (string) + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) + * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) + * $params['source'] = (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 chunkModel(array $params = []) + { + $chunk_number = $this->extractArgument($params, 'chunk_number'); + $model_id = $this->extractArgument($params, 'model_id'); + $body = $this->extractArgument($params, 'body'); + + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\ChunkModel::class); + $endpoint->setParams($params); + $endpoint->setChunkNumber($chunk_number); + $endpoint->setModelId($model_id); + $endpoint->setBody($body); + + return $this->performRequest($endpoint); + } + + /** + * Creates a controller. + * + * $params['model_id'] = (string) + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) + * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) + * $params['source'] = (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 createController(array $params = []) + { + $model_id = $this->extractArgument($params, 'model_id'); + $body = $this->extractArgument($params, 'body'); + + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\CreateController::class); + $endpoint->setParams($params); + $endpoint->setModelId($model_id); + $endpoint->setBody($body); + + return $this->performRequest($endpoint); + } + /** * Create a memory. * @@ -71,6 +126,29 @@ public function createMessage(array $params = []) return $this->performRequest($endpoint); } + /** + * Registers model metadata. + * + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) + * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) + * $params['source'] = (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 createModelMeta(array $params = []) + { + $body = $this->extractArgument($params, 'body'); + + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\CreateModelMeta::class); + $endpoint->setParams($params); + $endpoint->setBody($body); + + return $this->performRequest($endpoint); + } + /** * Delete an agent. * @@ -95,6 +173,30 @@ public function deleteAgent(array $params = []) return $this->performRequest($endpoint); } + /** + * Deletes a controller. + * + * $params['model_id'] = (string) + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) + * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) + * $params['source'] = (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 deleteController(array $params = []) + { + $model_id = $this->extractArgument($params, 'model_id'); + + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\DeleteController::class); + $endpoint->setParams($params); + $endpoint->setModelId($model_id); + + return $this->performRequest($endpoint); + } + /** * Delete a memory. * @@ -191,6 +293,30 @@ public function deleteTask(array $params = []) return $this->performRequest($endpoint); } + /** + * Retrieves a controller. + * + * $params['model_id'] = (string) + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) + * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) + * $params['source'] = (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 getController(array $params = []) + { + $model_id = $this->extractArgument($params, 'model_id'); + + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\GetController::class); + $endpoint->setParams($params); + $endpoint->setModelId($model_id); + + return $this->performRequest($endpoint); + } + /** * Get a memory. * @@ -292,6 +418,108 @@ public function getModelGroup(array $params = []) return $this->performRequest($endpoint); } + /** + * Get a profile. + * + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) + * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) + * $params['source'] = (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 getProfile(array $params = []) + { + $body = $this->extractArgument($params, 'body'); + + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\GetProfile::class); + $endpoint->setParams($params); + $endpoint->setBody($body); + + return $this->performRequest($endpoint); + } + + /** + * Get a profile models. + * + * $params['model_id'] = (string) + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) + * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) + * $params['source'] = (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 getProfileModels(array $params = []) + { + $model_id = $this->extractArgument($params, 'model_id'); + $body = $this->extractArgument($params, 'body'); + + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\GetProfileModels::class); + $endpoint->setParams($params); + $endpoint->setModelId($model_id); + $endpoint->setBody($body); + + return $this->performRequest($endpoint); + } + + /** + * Get a profile tasks. + * + * $params['task_id'] = (string) + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) + * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) + * $params['source'] = (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 getProfileTasks(array $params = []) + { + $task_id = $this->extractArgument($params, 'task_id'); + $body = $this->extractArgument($params, 'body'); + + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\GetProfileTasks::class); + $endpoint->setParams($params); + $endpoint->setTaskId($task_id); + $endpoint->setBody($body); + + return $this->performRequest($endpoint); + } + + /** + * Get stats. + * + * $params['node_id'] = (string) + * $params['stat'] = (string) + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) + * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) + * $params['source'] = (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 getStats(array $params = []) + { + $node_id = $this->extractArgument($params, 'node_id'); + $stat = $this->extractArgument($params, 'stat'); + + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\GetStats::class); + $endpoint->setParams($params); + $endpoint->setNodeId($node_id); + $endpoint->setStat($stat); + + return $this->performRequest($endpoint); + } + /** * Retrieves a task. * @@ -316,6 +544,56 @@ public function getTask(array $params = []) return $this->performRequest($endpoint); } + /** + * Deploys a model. + * + * $params['model_id'] = (string) + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) + * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) + * $params['source'] = (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 loadModel(array $params = []) + { + $model_id = $this->extractArgument($params, 'model_id'); + + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\LoadModel::class); + $endpoint->setParams($params); + $endpoint->setModelId($model_id); + + return $this->performRequest($endpoint); + } + + /** + * Predicts a model. + * + * $params['model_id'] = (string) + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) + * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) + * $params['source'] = (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 predictModel(array $params = []) + { + $model_id = $this->extractArgument($params, 'model_id'); + $body = $this->extractArgument($params, 'body'); + + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\PredictModel::class); + $endpoint->setParams($params); + $endpoint->setModelId($model_id); + $endpoint->setBody($body); + + return $this->performRequest($endpoint); + } + /** * Register an agent. * @@ -385,6 +663,29 @@ public function registerModelGroup(array $params = []) return $this->performRequest($endpoint); } + /** + * Registers model metadata. + * + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) + * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) + * $params['source'] = (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 registerModelMeta(array $params = []) + { + $body = $this->extractArgument($params, 'body'); + + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\RegisterModelMeta::class); + $endpoint->setParams($params); + $endpoint->setBody($body); + + return $this->performRequest($endpoint); + } + /** * Searches for standalone connectors. * @@ -555,6 +856,32 @@ public function trainPredict(array $params = []) return $this->performRequest($endpoint); } + /** + * Unloads a model. + * + * $params['model_id'] = (string) + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) + * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) + * $params['source'] = (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 unloadModel(array $params = []) + { + $model_id = $this->extractArgument($params, 'model_id'); + $body = $this->extractArgument($params, 'body'); + + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\UnloadModel::class); + $endpoint->setParams($params); + $endpoint->setModelId($model_id); + $endpoint->setBody($body); + + return $this->performRequest($endpoint); + } + /** * Updates a standalone connector. * @@ -581,6 +908,32 @@ public function updateConnector(array $params = []) return $this->performRequest($endpoint); } + /** + * Updates a controller. + * + * $params['model_id'] = (string) + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) + * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) + * $params['source'] = (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 updateController(array $params = []) + { + $model_id = $this->extractArgument($params, 'model_id'); + $body = $this->extractArgument($params, 'body'); + + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\UpdateController::class); + $endpoint->setParams($params); + $endpoint->setModelId($model_id); + $endpoint->setBody($body); + + return $this->performRequest($endpoint); + } + /** * Update a memory. * @@ -633,6 +986,84 @@ public function updateMessage(array $params = []) return $this->performRequest($endpoint); } + /** + * Updates a model. + * + * $params['model_id'] = (string) + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) + * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) + * $params['source'] = (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 updateModel(array $params = []) + { + $model_id = $this->extractArgument($params, 'model_id'); + $body = $this->extractArgument($params, 'body'); + + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\UpdateModel::class); + $endpoint->setParams($params); + $endpoint->setModelId($model_id); + $endpoint->setBody($body); + + return $this->performRequest($endpoint); + } + + /** + * Uploads model chunk. + * + * $params['chunk_number'] = (integer) + * $params['model_id'] = (string) + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) + * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) + * $params['source'] = (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 uploadChunk(array $params = []) + { + $chunk_number = $this->extractArgument($params, 'chunk_number'); + $model_id = $this->extractArgument($params, 'model_id'); + $body = $this->extractArgument($params, 'body'); + + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\UploadChunk::class); + $endpoint->setParams($params); + $endpoint->setChunkNumber($chunk_number); + $endpoint->setModelId($model_id); + $endpoint->setBody($body); + + return $this->performRequest($endpoint); + } + + /** + * Registers a model. + * + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) + * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) + * $params['source'] = (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 uploadModel(array $params = []) + { + $body = $this->extractArgument($params, 'body'); + + $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Ml\UploadModel::class); + $endpoint->setParams($params); + $endpoint->setBody($body); + + return $this->performRequest($endpoint); + } + /** * $params['body'] = (string) The body of the request (Required) *