From f56e9b9e76565b23a25c22cd14a2710af9051fe9 Mon Sep 17 00:00:00 2001 From: dblock Date: Sat, 13 Jul 2024 03:34:31 +0000 Subject: [PATCH] Updated opensearch-php to reflect the latest OpenSearch API spec (2024-07-13) Signed-off-by: GitHub --- CHANGELOG.md | 1 + src/OpenSearch/Client.php | 30 +- .../Endpoints/Indices/ClearCache.php | 1 + .../Endpoints/Indices/GetMapping.php | 1 + .../Connectors/CreateConnector.php | 43 -- .../Connectors/DeleteConnector.php | 51 --- .../Connectors/GetConnector.php | 51 --- .../Connectors/GetConnectors.php | 43 -- .../ModelGroups/DeleteModelGroup.php | 51 --- .../ModelGroups/GetModelGroups.php | 43 -- .../ModelGroups/RegisterModelGroup.php | 43 -- .../ModelGroups/UpdateModelGroup.php | 50 --- .../MachineLearning/Models/DeleteModel.php | 51 --- .../MachineLearning/Models/DeployModel.php | 51 --- .../MachineLearning/Models/GetModel.php | 51 --- .../MachineLearning/Models/GetModels.php | 43 -- .../MachineLearning/Models/Predict.php | 51 --- .../MachineLearning/Models/RegisterModel.php | 43 -- .../MachineLearning/Models/UndeployModel.php | 51 --- .../MachineLearning/Tasks/GetTask.php | 51 --- src/OpenSearch/Endpoints/Ml/DeleteModel.php | 62 +++ .../Endpoints/Ml/DeleteModelGroup.php | 62 +++ src/OpenSearch/Endpoints/Ml/GetModelGroup.php | 62 +++ src/OpenSearch/Endpoints/Ml/GetTask.php | 62 +++ src/OpenSearch/Endpoints/Ml/RegisterModel.php | 55 +++ .../Endpoints/Ml/RegisterModelGroup.php | 55 +++ src/OpenSearch/Endpoints/Ml/SearchModels.php | 55 +++ .../Namespaces/ClusterNamespace.php | 4 +- .../Namespaces/IndicesNamespace.php | 3 +- src/OpenSearch/Namespaces/IngestNamespace.php | 2 +- .../Namespaces/MachineLearningNamespace.php | 371 ------------------ src/OpenSearch/Namespaces/MlNamespace.php | 192 +++++++++ .../Namespaces/TransformsNamespace.php | 6 +- 33 files changed, 633 insertions(+), 1158 deletions(-) delete mode 100644 src/OpenSearch/Endpoints/MachineLearning/Connectors/CreateConnector.php delete mode 100644 src/OpenSearch/Endpoints/MachineLearning/Connectors/DeleteConnector.php delete mode 100644 src/OpenSearch/Endpoints/MachineLearning/Connectors/GetConnector.php delete mode 100644 src/OpenSearch/Endpoints/MachineLearning/Connectors/GetConnectors.php delete mode 100644 src/OpenSearch/Endpoints/MachineLearning/ModelGroups/DeleteModelGroup.php delete mode 100644 src/OpenSearch/Endpoints/MachineLearning/ModelGroups/GetModelGroups.php delete mode 100644 src/OpenSearch/Endpoints/MachineLearning/ModelGroups/RegisterModelGroup.php delete mode 100644 src/OpenSearch/Endpoints/MachineLearning/ModelGroups/UpdateModelGroup.php delete mode 100644 src/OpenSearch/Endpoints/MachineLearning/Models/DeleteModel.php delete mode 100644 src/OpenSearch/Endpoints/MachineLearning/Models/DeployModel.php delete mode 100644 src/OpenSearch/Endpoints/MachineLearning/Models/GetModel.php delete mode 100644 src/OpenSearch/Endpoints/MachineLearning/Models/GetModels.php delete mode 100644 src/OpenSearch/Endpoints/MachineLearning/Models/Predict.php delete mode 100644 src/OpenSearch/Endpoints/MachineLearning/Models/RegisterModel.php delete mode 100644 src/OpenSearch/Endpoints/MachineLearning/Models/UndeployModel.php delete mode 100644 src/OpenSearch/Endpoints/MachineLearning/Tasks/GetTask.php create mode 100644 src/OpenSearch/Endpoints/Ml/DeleteModel.php create mode 100644 src/OpenSearch/Endpoints/Ml/DeleteModelGroup.php create mode 100644 src/OpenSearch/Endpoints/Ml/GetModelGroup.php create mode 100644 src/OpenSearch/Endpoints/Ml/GetTask.php create mode 100644 src/OpenSearch/Endpoints/Ml/RegisterModel.php create mode 100644 src/OpenSearch/Endpoints/Ml/RegisterModelGroup.php create mode 100644 src/OpenSearch/Endpoints/Ml/SearchModels.php delete mode 100644 src/OpenSearch/Namespaces/MachineLearningNamespace.php create mode 100644 src/OpenSearch/Namespaces/MlNamespace.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 3cb14f22..1a56e8a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Removed ### Fixed ### Updated APIs +- Updated opensearch-php APIs to reflect [opensearch-api-specification@188413c](https://github.com/opensearch-project/opensearch-api-specification/commit/188413c86aad9958680bc7953514b277177e147a) ### Security ### Dependencies diff --git a/src/OpenSearch/Client.php b/src/OpenSearch/Client.php index 1db3a7f1..dce79dc3 100644 --- a/src/OpenSearch/Client.php +++ b/src/OpenSearch/Client.php @@ -34,7 +34,7 @@ use OpenSearch\Namespaces\IndicesNamespace; use OpenSearch\Namespaces\IngestNamespace; use OpenSearch\Namespaces\KnnNamespace; -use OpenSearch\Namespaces\MachineLearningNamespace; +use OpenSearch\Namespaces\MlNamespace; use OpenSearch\Namespaces\MonitoringNamespace; use OpenSearch\Namespaces\NodesNamespace; use OpenSearch\Namespaces\NotificationsNamespace; @@ -118,6 +118,11 @@ class Client */ protected $knn; + /** + * @var MlNamespace + */ + protected $ml; + /** * @var MonitoringNamespace */ @@ -183,10 +188,6 @@ class Client */ protected $transforms; - /** - * @var MachineLearningNamespace - */ - protected $ml; /** * Client constructor @@ -207,6 +208,7 @@ public function __construct(Transport $transport, callable $endpoint, array $reg $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); @@ -218,7 +220,6 @@ public function __construct(Transport $transport, callable $endpoint, array $reg $this->snapshot = new SnapshotNamespace($transport, $endpoint); $this->sql = new SqlNamespace($transport, $endpoint); $this->ssl = new SslNamespace($transport, $endpoint); - $this->ml = new MachineLearningNamespace($transport, $endpoint); $this->tasks = new TasksNamespace($transport, $endpoint); $this->transforms = new TransformsNamespace($transport, $endpoint); @@ -234,7 +235,7 @@ public function __construct(Transport $transport, callable $endpoint, array $reg * $params['_source_includes'] = (any) A comma-separated list of source fields to include in the response. * $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 = true,false,wait_for) - * $params['require_alias'] = (boolean) If `true`, the request’s actions must target an index alias. (Default = false) + * $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['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`). @@ -1156,7 +1157,7 @@ public function rankEval(array $params = []) * $params['refresh'] = (boolean) 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['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['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. * $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['wait_for_completion'] = (boolean) If `true`, the request blocks until the operation is complete. (Default = true) @@ -1261,7 +1262,7 @@ public function scriptsPainlessExecute(array $params = []) * Allows to retrieve a large numbers of results from a single search request. * * $params['scroll_id'] = DEPRECATED (string) The scroll ID - * $params['rest_total_hits_as_int'] = (boolean) If true, the API response’s hit.total property is returned as an integer. If false, the API response’s hit.total property is returned as an object. (Default = false) + * $params['rest_total_hits_as_int'] = (boolean) If true, the API response's hit.total property is returned as an integer. If false, the API response's hit.total property is returned as an object. (Default = false) * $params['scroll'] = (string) Period to retain the search context for scrolling. * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. @@ -1707,6 +1708,13 @@ public function knn(): KnnNamespace { return $this->knn; } + /** + * Returns the ml namespace + */ + public function ml(): MlNamespace + { + return $this->ml; + } /** * Returns the monitoring namespace */ @@ -1798,10 +1806,6 @@ public function transforms(): TransformsNamespace { return $this->transforms; } - public function ml(): MachineLearningNamespace - { - return $this->ml; - } /** * Catchall for registered namespaces diff --git a/src/OpenSearch/Endpoints/Indices/ClearCache.php b/src/OpenSearch/Endpoints/Indices/ClearCache.php index deafb1eb..dfc086a0 100644 --- a/src/OpenSearch/Endpoints/Indices/ClearCache.php +++ b/src/OpenSearch/Endpoints/Indices/ClearCache.php @@ -44,6 +44,7 @@ public function getParamWhitelist(): array 'expand_wildcards', 'fielddata', 'fields', + 'file', 'ignore_unavailable', 'index', 'query', diff --git a/src/OpenSearch/Endpoints/Indices/GetMapping.php b/src/OpenSearch/Endpoints/Indices/GetMapping.php index 0641e8ed..d80a8332 100644 --- a/src/OpenSearch/Endpoints/Indices/GetMapping.php +++ b/src/OpenSearch/Endpoints/Indices/GetMapping.php @@ -44,6 +44,7 @@ public function getParamWhitelist(): array 'cluster_manager_timeout', 'expand_wildcards', 'ignore_unavailable', + 'index', 'local', 'master_timeout', 'pretty', diff --git a/src/OpenSearch/Endpoints/MachineLearning/Connectors/CreateConnector.php b/src/OpenSearch/Endpoints/MachineLearning/Connectors/CreateConnector.php deleted file mode 100644 index 4bd4d6ad..00000000 --- a/src/OpenSearch/Endpoints/MachineLearning/Connectors/CreateConnector.php +++ /dev/null @@ -1,43 +0,0 @@ -id) { - return "/_plugins/_ml/connectors/$this->id"; - } - - throw new RuntimeException( - 'id is required for delete' - ); - - } - - /** - * @return string - */ - public function getMethod(): string - { - return 'DELETE'; - } -} diff --git a/src/OpenSearch/Endpoints/MachineLearning/Connectors/GetConnector.php b/src/OpenSearch/Endpoints/MachineLearning/Connectors/GetConnector.php deleted file mode 100644 index fef1aa17..00000000 --- a/src/OpenSearch/Endpoints/MachineLearning/Connectors/GetConnector.php +++ /dev/null @@ -1,51 +0,0 @@ -id) { - return "/_plugins/_ml/connectors/$this->id"; - } - - throw new RuntimeException( - 'id is required for get' - ); - - } - - /** - * @return string - */ - public function getMethod(): string - { - return 'GET'; - } -} diff --git a/src/OpenSearch/Endpoints/MachineLearning/Connectors/GetConnectors.php b/src/OpenSearch/Endpoints/MachineLearning/Connectors/GetConnectors.php deleted file mode 100644 index e5e5d698..00000000 --- a/src/OpenSearch/Endpoints/MachineLearning/Connectors/GetConnectors.php +++ /dev/null @@ -1,43 +0,0 @@ -id) { - return "/_plugins/_ml/model_groups/$this->id"; - } - - throw new RuntimeException( - 'id is required for delete' - ); - - } - - /** - * @return string - */ - public function getMethod(): string - { - return 'DELETE'; - } -} diff --git a/src/OpenSearch/Endpoints/MachineLearning/ModelGroups/GetModelGroups.php b/src/OpenSearch/Endpoints/MachineLearning/ModelGroups/GetModelGroups.php deleted file mode 100644 index 0dd03bbc..00000000 --- a/src/OpenSearch/Endpoints/MachineLearning/ModelGroups/GetModelGroups.php +++ /dev/null @@ -1,43 +0,0 @@ -id) { - return "/_plugins/_ml/model_groups/$this->id"; - } - - throw new RuntimeException( - 'id is required for update' - ); - } - - /** - * @return string - */ - public function getMethod(): string - { - return 'PUT'; - } -} diff --git a/src/OpenSearch/Endpoints/MachineLearning/Models/DeleteModel.php b/src/OpenSearch/Endpoints/MachineLearning/Models/DeleteModel.php deleted file mode 100644 index d4810d7a..00000000 --- a/src/OpenSearch/Endpoints/MachineLearning/Models/DeleteModel.php +++ /dev/null @@ -1,51 +0,0 @@ -id) { - return "/_plugins/_ml/models/$this->id"; - } - - throw new RuntimeException( - 'id is required for delete' - ); - - } - - /** - * @return string - */ - public function getMethod(): string - { - return 'DELETE'; - } -} diff --git a/src/OpenSearch/Endpoints/MachineLearning/Models/DeployModel.php b/src/OpenSearch/Endpoints/MachineLearning/Models/DeployModel.php deleted file mode 100644 index 48bfede1..00000000 --- a/src/OpenSearch/Endpoints/MachineLearning/Models/DeployModel.php +++ /dev/null @@ -1,51 +0,0 @@ -id) { - return "/_plugins/_ml/models/$this->id/_deploy"; - } - - throw new RuntimeException( - 'id is required for deploy' - ); - - } - - /** - * @return string - */ - public function getMethod(): string - { - return 'POST'; - } -} diff --git a/src/OpenSearch/Endpoints/MachineLearning/Models/GetModel.php b/src/OpenSearch/Endpoints/MachineLearning/Models/GetModel.php deleted file mode 100644 index f2c333d9..00000000 --- a/src/OpenSearch/Endpoints/MachineLearning/Models/GetModel.php +++ /dev/null @@ -1,51 +0,0 @@ -id) { - return "/_plugins/_ml/models/$this->id"; - } - - throw new RuntimeException( - 'id is required for get' - ); - - } - - /** - * @return string - */ - public function getMethod(): string - { - return 'GET'; - } -} diff --git a/src/OpenSearch/Endpoints/MachineLearning/Models/GetModels.php b/src/OpenSearch/Endpoints/MachineLearning/Models/GetModels.php deleted file mode 100644 index 7f714ec4..00000000 --- a/src/OpenSearch/Endpoints/MachineLearning/Models/GetModels.php +++ /dev/null @@ -1,43 +0,0 @@ -id) { - return "/_plugins/_ml/models/$this->id/_predict"; - } - - throw new RuntimeException( - 'id is required for predict' - ); - - } - - /** - * @return string - */ - public function getMethod(): string - { - return 'POST'; - } -} diff --git a/src/OpenSearch/Endpoints/MachineLearning/Models/RegisterModel.php b/src/OpenSearch/Endpoints/MachineLearning/Models/RegisterModel.php deleted file mode 100644 index aa9c1105..00000000 --- a/src/OpenSearch/Endpoints/MachineLearning/Models/RegisterModel.php +++ /dev/null @@ -1,43 +0,0 @@ -id) { - return "/_plugins/_ml/models/$this->id/_undeploy"; - } - - throw new RuntimeException( - 'id is required for undeploy' - ); - - } - - /** - * @return string - */ - public function getMethod(): string - { - return 'POST'; - } -} diff --git a/src/OpenSearch/Endpoints/MachineLearning/Tasks/GetTask.php b/src/OpenSearch/Endpoints/MachineLearning/Tasks/GetTask.php deleted file mode 100644 index 833d88ef..00000000 --- a/src/OpenSearch/Endpoints/MachineLearning/Tasks/GetTask.php +++ /dev/null @@ -1,51 +0,0 @@ -id) { - return "/_plugins/_ml/tasks/$this->id"; - } - - throw new RuntimeException( - 'id is required for get' - ); - - } - - /** - * @return string - */ - public function getMethod(): string - { - return 'GET'; - } -} diff --git a/src/OpenSearch/Endpoints/Ml/DeleteModel.php b/src/OpenSearch/Endpoints/Ml/DeleteModel.php new file mode 100644 index 00000000..065a3bc2 --- /dev/null +++ b/src/OpenSearch/Endpoints/Ml/DeleteModel.php @@ -0,0 +1,62 @@ +model_id ?? null; + if (isset($model_id)) { + return "/_plugins/_ml/models/$model_id"; + } + throw new RuntimeException('Missing parameter for the endpoint ml.delete_model'); + } + + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'DELETE'; + } + + public function setModelId($model_id): DeleteModel + { + if (isset($model_id) !== true) { + return $this; + } + $this->model_id = $model_id; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ml/DeleteModelGroup.php b/src/OpenSearch/Endpoints/Ml/DeleteModelGroup.php new file mode 100644 index 00000000..da6af1c7 --- /dev/null +++ b/src/OpenSearch/Endpoints/Ml/DeleteModelGroup.php @@ -0,0 +1,62 @@ +model_group_id ?? null; + if (isset($model_group_id)) { + return "/_plugins/_ml/model_groups/$model_group_id"; + } + throw new RuntimeException('Missing parameter for the endpoint ml.delete_model_group'); + } + + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'DELETE'; + } + + public function setModelGroupId($model_group_id): DeleteModelGroup + { + if (isset($model_group_id) !== true) { + return $this; + } + $this->model_group_id = $model_group_id; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ml/GetModelGroup.php b/src/OpenSearch/Endpoints/Ml/GetModelGroup.php new file mode 100644 index 00000000..f061ea6c --- /dev/null +++ b/src/OpenSearch/Endpoints/Ml/GetModelGroup.php @@ -0,0 +1,62 @@ +model_group_id ?? null; + if (isset($model_group_id)) { + return "/_plugins/_ml/model_groups/$model_group_id"; + } + throw new RuntimeException('Missing parameter for the endpoint ml.get_model_group'); + } + + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'GET'; + } + + public function setModelGroupId($model_group_id): GetModelGroup + { + if (isset($model_group_id) !== true) { + return $this; + } + $this->model_group_id = $model_group_id; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ml/GetTask.php b/src/OpenSearch/Endpoints/Ml/GetTask.php new file mode 100644 index 00000000..43ed4c70 --- /dev/null +++ b/src/OpenSearch/Endpoints/Ml/GetTask.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.get_task'); + } + + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'GET'; + } + + public function setTaskId($task_id): GetTask + { + if (isset($task_id) !== true) { + return $this; + } + $this->task_id = $task_id; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ml/RegisterModel.php b/src/OpenSearch/Endpoints/Ml/RegisterModel.php new file mode 100644 index 00000000..698659c9 --- /dev/null +++ b/src/OpenSearch/Endpoints/Ml/RegisterModel.php @@ -0,0 +1,55 @@ +body = $body; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Ml/RegisterModelGroup.php b/src/OpenSearch/Endpoints/Ml/RegisterModelGroup.php new file mode 100644 index 00000000..046581e8 --- /dev/null +++ b/src/OpenSearch/Endpoints/Ml/RegisterModelGroup.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 new file mode 100644 index 00000000..a6874ac1 --- /dev/null +++ b/src/OpenSearch/Endpoints/Ml/SearchModels.php @@ -0,0 +1,55 @@ +body = $body; + + return $this; + } +} diff --git a/src/OpenSearch/Namespaces/ClusterNamespace.php b/src/OpenSearch/Namespaces/ClusterNamespace.php index c0e3c9fc..c34073f7 100644 --- a/src/OpenSearch/Namespaces/ClusterNamespace.php +++ b/src/OpenSearch/Namespaces/ClusterNamespace.php @@ -360,7 +360,7 @@ public function postVotingConfigExclusions(array $params = []) /** * Creates or updates a component template. * - * $params['name'] = (string) Name of the component template to create. OpenSearch includes the following built-in component templates: `logs-mappings`; 'logs-settings`; `metrics-mappings`; `metrics-settings`;`synthetics-mapping`; `synthetics-settings`. OpenSearch Agent uses these templates to configure backing indices for its data streams. If you use OpenSearch Agent and want to overwrite one of these templates, set the `version` for your replacement template higher than the current version. If you don’t use OpenSearch Agent and want to disable all built-in component and index templates, set `stack.templates.enabled` to `false` using the cluster update settings API. + * $params['name'] = (string) Name of the component template to create. OpenSearch includes the following built-in component templates: `logs-mappings`; 'logs-settings`; `metrics-mappings`; `metrics-settings`;`synthetics-mapping`; `synthetics-settings`. OpenSearch Agent uses these templates to configure backing indices for its data streams. If you use OpenSearch Agent and want to overwrite one of these templates, set the `version` for your replacement template higher than the current version. If you don't use OpenSearch Agent and want to disable all built-in component and index templates, set `stack.templates.enabled` to `false` using the cluster update settings API. * $params['cluster_manager_timeout'] = (string) Operation timeout for connection to cluster-manager node. * $params['create'] = (boolean) If `true`, this request cannot replace or update existing component templates. (Default = false) * $params['master_timeout'] = (string) Period to wait for a connection to the master node.If no response is received before the timeout expires, the request fails and returns an error. @@ -559,7 +559,7 @@ public function state(array $params = []) * * $params['node_id'] = (array) Comma-separated list of node filters used to limit returned information. Defaults to all nodes in the cluster. * $params['flat_settings'] = (boolean) If `true`, returns settings in flat format. (Default = false) - * $params['timeout'] = (string) Period to wait for each node to respond.If a node does not respond before its timeout expires, the response does not include its stats.However, timed out nodes are included in the response’s `_nodes.failed` property. Defaults to no timeout. + * $params['timeout'] = (string) Period to wait for each node to respond.If a node does not respond before its timeout expires, the response does not include its stats.However, timed out nodes are included in the response's `_nodes.failed` property. Defaults to no timeout. * $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. diff --git a/src/OpenSearch/Namespaces/IndicesNamespace.php b/src/OpenSearch/Namespaces/IndicesNamespace.php index 47396725..65d41c1b 100644 --- a/src/OpenSearch/Namespaces/IndicesNamespace.php +++ b/src/OpenSearch/Namespaces/IndicesNamespace.php @@ -98,6 +98,7 @@ public function analyze(array $params = []) * $params['expand_wildcards'] = (any) Type of index that wildcard patterns can match.If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.Supports comma-separated values, such as `open,hidden`.Valid values are: `all`, `open`, `closed`, `hidden`, `none`. * $params['fielddata'] = (boolean) If `true`, clears the fields cache.Use the `fields` parameter to clear the cache of specific fields only. * $params['fields'] = (any) Comma-separated list of field names used to limit the `fielddata` parameter. + * $params['file'] = (boolean) If true, clears the unused entries from the file cache on nodes with the Search role. (Default = false) * $params['ignore_unavailable'] = (boolean) If `false`, the request returns an error if it targets a missing or closed index. * $params['query'] = (boolean) If `true`, clears the query cache. * $params['request'] = (boolean) If `true`, clears the request cache. @@ -902,7 +903,7 @@ public function open(array $params = []) * Creates or updates an alias. * * $params['index'] = (array) Comma-separated list of data streams or indices to add. Supports wildcards (`*`). Wildcard patterns that match both data streams and indices return an error. (Required) - * $params['name'] = (string) Alias to update. If the alias doesn’t exist, the request creates it. Index alias names support date math. (Required) + * $params['name'] = (string) Alias to update. If the alias doesn't exist, the request creates it. Index alias names support date math. (Required) * $params['cluster_manager_timeout'] = (string) Operation timeout for connection to cluster-manager node. * $params['master_timeout'] = (string) Period to wait for a connection to the master node.If no response is received before the timeout expires, the request fails and returns an error. * $params['timeout'] = (string) Period to wait for a response.If no response is received before the timeout expires, the request fails and returns an error. diff --git a/src/OpenSearch/Namespaces/IngestNamespace.php b/src/OpenSearch/Namespaces/IngestNamespace.php index 927158c5..d217dc47 100644 --- a/src/OpenSearch/Namespaces/IngestNamespace.php +++ b/src/OpenSearch/Namespaces/IngestNamespace.php @@ -136,7 +136,7 @@ public function putPipeline(array $params = []) /** * Allows to simulate a pipeline with example documents. * - * $params['id'] = (string) Pipeline to test. If you don’t specify a `pipeline` in the request body, this parameter is required. + * $params['id'] = (string) Pipeline to test. If you don't specify a `pipeline` in the request body, this parameter is required. * $params['verbose'] = (boolean) If `true`, the response includes output data for each processor in the executed pipeline. (Default = false) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. diff --git a/src/OpenSearch/Namespaces/MachineLearningNamespace.php b/src/OpenSearch/Namespaces/MachineLearningNamespace.php deleted file mode 100644 index d4989b6a..00000000 --- a/src/OpenSearch/Namespaces/MachineLearningNamespace.php +++ /dev/null @@ -1,371 +0,0 @@ -extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('MachineLearning\Connectors\CreateConnector'); - $endpoint->setParams($params); - $endpoint->setBody($body); - - return $this->performRequest($endpoint); - } - - /** - * $params['id'] = (string) The id of the connector (Required) - * - * @param array $params Associative array of parameters - * - * @return array - * The response. - */ - public function getConnector(array $params = []): array - { - $id = $this->extractArgument($params, 'id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('MachineLearning\Connectors\GetConnector'); - $endpoint->setParams($params); - $endpoint->setId($id); - - return $this->performRequest($endpoint); - } - - /** - * $params['body'] = (string) The body of the request - * - * @param array $params Associative array of parameters - * - * @return array - * The response. - */ - public function getConnectors(array $params = []): array - { - if (!isset($params['body'])) { - $params['body'] = [ - 'query' => [ - 'match_all' => new \StdClass(), - ], - 'size' => 1000, - ]; - } - $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('MachineLearning\Connectors\GetConnectors'); - $endpoint->setBody($body); - - return $this->performRequest($endpoint); - } - - /** - * $params['id'] = (string) The id of the connector (Required) - * - * @param array $params Associative array of parameters - * - * @return array - * The response. - */ - public function deleteConnector(array $params = []): array - { - $id = $this->extractArgument($params, 'id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('MachineLearning\Connectors\DeleteConnector'); - $endpoint->setParams($params); - $endpoint->setId($id); - - return $this->performRequest($endpoint); - } - - /** - * $params['body'] = (string) The body of the request (Required) - * - * @param array $params Associative array of parameters - * - * @return array - * The response. - */ - public function registerModelGroup(array $params = []): array - { - $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('MachineLearning\ModelGroups\RegisterModelGroup'); - $endpoint->setParams($params); - $endpoint->setBody($body); - - return $this->performRequest($endpoint); - } - - /** - * $params['body'] = (string) The body of the request - * - * @param array $params Associative array of parameters - * - * @return array - * The response. - */ - public function getModelGroups(array $params = []): array - { - if (!isset($params['body'])) { - $params['body'] = [ - 'query' => [ - 'match_all' => new \StdClass(), - ], - 'size' => 1000, - ]; - } - $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('MachineLearning\ModelGroups\GetModelGroups'); - $endpoint->setBody($body); - - return $this->performRequest($endpoint); - } - - /** - * $params['id'] = (string) The id of the model group (Required) - * $params['body'] = (array) The body of the request (Required) - * - * @param array $params Associative array of parameters - * - * @return array - * The response. - */ - public function updateModelGroup(array $params = []): array - { - $id = $this->extractArgument($params, 'id'); - $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('MachineLearning\ModelGroups\UpdateModelGroup'); - $endpoint->setParams($params); - $endpoint->setBody($body); - $endpoint->setId($id); - - return $this->performRequest($endpoint); - } - - /** - * $params['id'] = (string) The id of the model group (Required) - * - * @param array $params Associative array of parameters - * - * @return array - * The response. - */ - public function deleteModelGroup(array $params = []): array - { - $id = $this->extractArgument($params, 'id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('MachineLearning\ModelGroups\DeleteModelGroup'); - $endpoint->setParams($params); - $endpoint->setId($id); - - return $this->performRequest($endpoint); - } - - /** - * $params['body'] = (string) The body of the request (Required) - * - * @param array $params Associative array of parameters - * - * @return array - * The response. - */ - public function registerModel(array $params = []): array - { - $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('MachineLearning\Models\RegisterModel'); - $endpoint->setParams($params); - $endpoint->setBody($body); - - return $this->performRequest($endpoint); - } - - /** - * $params['id'] = (string) The id of the model (Required) - * - * @param array $params Associative array of parameters - * - * @return array - * The response. - */ - public function getModel(array $params = []): array - { - $id = $this->extractArgument($params, 'id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('MachineLearning\Models\GetModel'); - $endpoint->setParams($params); - $endpoint->setId($id); - - return $this->performRequest($endpoint); - } - - /** - * $params['body'] = (array) The body of the request - * - * @param array $params Associative array of parameters - * - * @return array - * The response. - */ - public function getModels(array $params = []): array - { - if (!isset($params['body'])) { - $params['body'] = [ - 'query' => [ - 'match_all' => new \StdClass(), - ], - 'size' => 1000, - ]; - } - $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('MachineLearning\Models\GetModels'); - $endpoint->setParams($params); - $endpoint->setBody($body); - - return $this->performRequest($endpoint); - } - - /** - * $params['id'] = (string) The id of the model (Required) - * $params['body'] = (string) The body of the request - * - * @param array $params Associative array of parameters - * - * @return array - * The response. - */ - public function deployModel(array $params = []): array - { - $id = $this->extractArgument($params, 'id'); - $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('MachineLearning\Models\DeployModel'); - $endpoint->setParams($params); - $endpoint->setId($id); - if ($body) { - $endpoint->setBody($body); - } - - return $this->performRequest($endpoint); - } - - /** - * $params['id'] = (string) The id of the model (Required) - * $params['body'] = (string) The body of the request - * - * @param array $params Associative array of parameters - * - * @return array - * The response. - */ - public function undeployModel(array $params = []): array - { - $id = $this->extractArgument($params, 'id'); - $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('MachineLearning\Models\UndeployModel'); - $endpoint->setParams($params); - $endpoint->setId($id); - if ($body) { - $endpoint->setBody($body); - } - - return $this->performRequest($endpoint); - } - - /** - * $params['id'] = (string) The id of the model (Required) - * - * @param array $params Associative array of parameters - * - * @return array - * The response. - */ - public function deleteModel(array $params = []): array - { - $id = $this->extractArgument($params, 'id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('MachineLearning\Models\DeleteModel'); - $endpoint->setParams($params); - $endpoint->setId($id); - - return $this->performRequest($endpoint); - } - - /** - * $params['id'] = (string) The id of the model (Required) - * $params['body'] = (string) The body of the request - * - * @param array $params Associative array of parameters - * - * @return array - * The response. - */ - public function predict(array $params = []): array - { - $id = $this->extractArgument($params, 'id'); - $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('MachineLearning\Models\Predict'); - $endpoint->setParams($params); - $endpoint->setId($id); - $endpoint->setBody($body); - - return $this->performRequest($endpoint); - } - - /** - * $params['id'] = (string) The id of the task (Required) - * - * @param array $params Associative array of parameters - * - * @return array - * The response. - */ - public function getTask(array $params = []): array - { - $id = $this->extractArgument($params, 'id'); - $endpointBuilder = $this->endpoints; - $endpoint = $endpointBuilder('MachineLearning\Tasks\GetTask'); - $endpoint->setParams($params); - $endpoint->setId($id); - - return $this->performRequest($endpoint); - } - -} diff --git a/src/OpenSearch/Namespaces/MlNamespace.php b/src/OpenSearch/Namespaces/MlNamespace.php new file mode 100644 index 00000000..c0b615f4 --- /dev/null +++ b/src/OpenSearch/Namespaces/MlNamespace.php @@ -0,0 +1,192 @@ +extractArgument($params, 'model_id'); + + $endpointBuilder = $this->endpoints; + $endpoint = $endpointBuilder('Ml\DeleteModel'); + $endpoint->setParams($params); + $endpoint->setModelId($model_id); + + return $this->performRequest($endpoint); + } + /** + * Deletes a model group. + * + * $params['model_group_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) Comma-separated list of filters used to reduce the response. + * + * @param array $params Associative array of parameters + * @return array + */ + public function deleteModelGroup(array $params = []) + { + $model_group_id = $this->extractArgument($params, 'model_group_id'); + + $endpointBuilder = $this->endpoints; + $endpoint = $endpointBuilder('Ml\DeleteModelGroup'); + $endpoint->setParams($params); + $endpoint->setModelGroupId($model_group_id); + + return $this->performRequest($endpoint); + } + /** + * Retrieves a model group. + * + * $params['model_group_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) Comma-separated list of filters used to reduce the response. + * + * @param array $params Associative array of parameters + * @return array + */ + public function getModelGroup(array $params = []) + { + $model_group_id = $this->extractArgument($params, 'model_group_id'); + + $endpointBuilder = $this->endpoints; + $endpoint = $endpointBuilder('Ml\GetModelGroup'); + $endpoint->setParams($params); + $endpoint->setModelGroupId($model_group_id); + + return $this->performRequest($endpoint); + } + /** + * Retrieves 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) Comma-separated list of filters used to reduce the response. + * + * @param array $params Associative array of parameters + * @return array + */ + public function getTask(array $params = []) + { + $task_id = $this->extractArgument($params, 'task_id'); + + $endpointBuilder = $this->endpoints; + $endpoint = $endpointBuilder('Ml\GetTask'); + $endpoint->setParams($params); + $endpoint->setTaskId($task_id); + + return $this->performRequest($endpoint); + } + /** + * Registers a model. + * + * $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. + * + * @param array $params Associative array of parameters + * @return array + */ + public function registerModel(array $params = []) + { + $body = $this->extractArgument($params, 'body'); + + $endpointBuilder = $this->endpoints; + $endpoint = $endpointBuilder('Ml\RegisterModel'); + $endpoint->setParams($params); + $endpoint->setBody($body); + + return $this->performRequest($endpoint); + } + /** + * Registers a model group. + * + * $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. + * + * @param array $params Associative array of parameters + * @return array + */ + public function registerModelGroup(array $params = []) + { + $body = $this->extractArgument($params, 'body'); + + $endpointBuilder = $this->endpoints; + $endpoint = $endpointBuilder('Ml\RegisterModelGroup'); + $endpoint->setParams($params); + $endpoint->setBody($body); + + return $this->performRequest($endpoint); + } + /** + * Searches for models. + * + * $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. + * + * @param array $params Associative array of parameters + * @return array + */ + public function searchModels(array $params = []) + { + $body = $this->extractArgument($params, 'body'); + + $endpointBuilder = $this->endpoints; + $endpoint = $endpointBuilder('Ml\SearchModels'); + $endpoint->setParams($params); + $endpoint->setBody($body); + + return $this->performRequest($endpoint); + } +} diff --git a/src/OpenSearch/Namespaces/TransformsNamespace.php b/src/OpenSearch/Namespaces/TransformsNamespace.php index fa124ad5..8612685d 100644 --- a/src/OpenSearch/Namespaces/TransformsNamespace.php +++ b/src/OpenSearch/Namespaces/TransformsNamespace.php @@ -147,10 +147,10 @@ public function put(array $params = []) /** * Returns the details of all transform jobs. * - * $params['from'] = (number) The starting transform to return. Default is 0. + * $params['from'] = (number) The starting transform to return. Default is `0`. * $params['search'] = (string) The search term to use to filter results. - * $params['size'] = (number) Specifies the number of transforms to return. Default is 10. - * $params['sortDirection'] = (string) Specifies the direction to sort results in. Can be ASC or DESC. Default is ASC. + * $params['size'] = (number) Specifies the number of transforms to return. Default is `10`. + * $params['sortDirection'] = (string) Specifies the direction to sort results in. Can be `ASC` or `DESC`. Default is `ASC`. * $params['sortField'] = (string) The field to sort results with. * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics.