Skip to content

Commit b5a06a9

Browse files
authored
Updated opensearch-php to reflect the latest OpenSearch API spec (2025-03-14)
Signed-off-by: GitHub <[email protected]>
1 parent e97fc63 commit b5a06a9

File tree

6 files changed

+172
-16
lines changed

6 files changed

+172
-16
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
1010
### Fixed
1111
### Security
1212
### Updated APIs
13+
- Updated opensearch-php APIs to reflect [opensearch-api-specification@c070795](https://github.com/opensearch-project/opensearch-api-specification/commit/c0707952df2846e8e04a533ec5453883771e885a)
1314

1415
## [2.4.3]
1516
### Added

src/OpenSearch/Client.php

+14
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
use OpenSearch\Namespaces\IsmNamespace;
3838
use OpenSearch\Namespaces\KnnNamespace;
3939
use OpenSearch\Namespaces\ListNamespace;
40+
use OpenSearch\Namespaces\LtrNamespace;
4041
use OpenSearch\Namespaces\MlNamespace;
4142
use OpenSearch\Namespaces\MonitoringNamespace;
4243
use OpenSearch\Namespaces\NodesNamespace;
@@ -207,6 +208,11 @@ class Client
207208
*/
208209
protected $list;
209210

211+
/**
212+
* @var LtrNamespace
213+
*/
214+
protected $ltr;
215+
210216
/**
211217
* @var MlNamespace
212218
*/
@@ -370,6 +376,7 @@ public function __construct(
370376
$this->ism = new IsmNamespace($transport, $this->endpointFactory);
371377
$this->knn = new KnnNamespace($transport, $this->endpointFactory);
372378
$this->list = new ListNamespace($transport, $this->endpointFactory);
379+
$this->ltr = new LtrNamespace($transport, $this->endpointFactory);
373380
$this->ml = new MlNamespace($transport, $this->endpointFactory);
374381
// @phpstan-ignore new.deprecated, property.deprecated
375382
$this->monitoring = new MonitoringNamespace($transport, $this->endpointFactory);
@@ -1962,6 +1969,13 @@ public function list(): ListNamespace
19621969
{
19631970
return $this->list;
19641971
}
1972+
/**
1973+
* Returns the ltr namespace
1974+
*/
1975+
public function ltr(): LtrNamespace
1976+
{
1977+
return $this->ltr;
1978+
}
19651979
/**
19661980
* Returns the ml namespace
19671981
*/
+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-License-Identifier: Apache-2.0
7+
*
8+
* The OpenSearch Contributors require contributions made to
9+
* this file be licensed under the Apache-2.0 license or a
10+
* compatible open source license.
11+
*
12+
* Modifications Copyright OpenSearch Contributors. See
13+
* GitHub history for details.
14+
*/
15+
16+
namespace OpenSearch\Endpoints\Ltr;
17+
18+
use OpenSearch\Endpoints\AbstractEndpoint;
19+
20+
/**
21+
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
22+
*/
23+
class Stats extends AbstractEndpoint
24+
{
25+
protected $node_id;
26+
protected $stat;
27+
28+
public function getURI(): string
29+
{
30+
$node_id = $this->node_id ?? null;
31+
$stat = $this->stat ?? null;
32+
if (isset($node_id) && isset($stat)) {
33+
return "/_plugins/_ltr/$node_id/stats/$stat";
34+
}
35+
if (isset($node_id)) {
36+
return "/_plugins/_ltr/$node_id/stats";
37+
}
38+
if (isset($stat)) {
39+
return "/_plugins/_ltr/stats/$stat";
40+
}
41+
return "/_plugins/_ltr/stats";
42+
}
43+
44+
public function getParamWhitelist(): array
45+
{
46+
return [
47+
'timeout',
48+
'pretty',
49+
'human',
50+
'error_trace',
51+
'source',
52+
'filter_path'
53+
];
54+
}
55+
56+
public function getMethod(): string
57+
{
58+
return 'GET';
59+
}
60+
61+
public function setNodeId($node_id): static
62+
{
63+
if (isset($node_id) !== true) {
64+
return $this;
65+
}
66+
if (is_array($node_id) === true) {
67+
$node_id = implode(",", $node_id);
68+
}
69+
$this->node_id = $node_id;
70+
71+
return $this;
72+
}
73+
74+
public function setStat($stat): static
75+
{
76+
if (isset($stat) !== true) {
77+
return $this;
78+
}
79+
if (is_array($stat) === true) {
80+
$stat = implode(",", $stat);
81+
}
82+
$this->stat = $stat;
83+
84+
return $this;
85+
}
86+
}

src/OpenSearch/Namespaces/ClusterNamespace.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ public function reroute(array $params = [])
551551
* $params['metric'] = (array) Limits the information returned to only the specified metrics.
552552
* $params['index'] = (array)
553553
* $params['allow_no_indices'] = (boolean) Whether to ignore a wildcard index expression that resolves into no concrete indexes. This includes the `_all` string or when no indexes have been specified.
554-
* $params['cluster_manager_timeout'] = (string) The amount of time to wait for a response from the cluster manager node. For more information about supported time units, see [Common parameters]({https://opensearch.org/docs/latest/api-reference/common-parameters/#time-units).
554+
* $params['cluster_manager_timeout'] = (string) The amount of time to wait for a response from the cluster manager node. For more information about supported time units, see [Common parameters](https://opensearch.org/docs/latest/api-reference/common-parameters/#time-units).
555555
* $params['expand_wildcards'] = (any)
556556
* $params['flat_settings'] = (boolean) Returns settings in a flat format. (Default = false)
557557
* $params['ignore_unavailable'] = (boolean) Whether the specified concrete indexes should be ignored when unavailable (missing or closed).
+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-License-Identifier: Apache-2.0
7+
*
8+
* The OpenSearch Contributors require contributions made to
9+
* this file be licensed under the Apache-2.0 license or a
10+
* compatible open source license.
11+
*
12+
* Modifications Copyright OpenSearch Contributors. See
13+
* GitHub history for details.
14+
*/
15+
16+
namespace OpenSearch\Namespaces;
17+
18+
use OpenSearch\Endpoints\Ltr\Stats;
19+
20+
/**
21+
* Class LtrNamespace
22+
*
23+
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
24+
*/
25+
class LtrNamespace extends AbstractNamespace
26+
{
27+
/**
28+
* Provides information about the current status of the LTR plugin.
29+
*
30+
* $params['node_id'] = (array) Comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes.
31+
* $params['stat'] = (array) Comma-separated list of stats to retrieve; use `_all` or empty string to retrieve all stats.
32+
* $params['timeout'] = (string) The time in milliseconds to wait for a response.
33+
* $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
34+
* $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
35+
* $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
36+
* $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
37+
* $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
38+
*
39+
* @param array $params Associative array of parameters
40+
* @return array
41+
*/
42+
public function stats(array $params = [])
43+
{
44+
$node_id = $this->extractArgument($params, 'node_id');
45+
$stat = $this->extractArgument($params, 'stat');
46+
47+
$endpoint = $this->endpointFactory->getEndpoint(Stats::class);
48+
$endpoint->setParams($params);
49+
$endpoint->setNodeId($node_id);
50+
$endpoint->setStat($stat);
51+
52+
return $this->performRequest($endpoint);
53+
}
54+
55+
}

src/OpenSearch/Namespaces/TasksNamespace.php

+15-15
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ class TasksNamespace extends AbstractNamespace
3535
/**
3636
* Cancels a task, if it can be cancelled through an API.
3737
*
38-
* $params['task_id'] = (string) ID of the task.
39-
* $params['actions'] = (any) Comma-separated list or wildcard expression of actions used to limit the request.
40-
* $params['nodes'] = (array) Comma-separated list of node IDs or names used to limit the request.
41-
* $params['parent_task_id'] = (string) Parent task ID used to limit the tasks.
42-
* $params['wait_for_completion'] = (boolean) Should the request block until the cancellation of the task and its descendant tasks is completed. Defaults to false (Default = false)
38+
* $params['task_id'] = (string) The ID of the task.
39+
* $params['actions'] = (any) A comma-separated list of actions that should be returned. Keep empty to return all.
40+
* $params['nodes'] = (array) A comma-separated list of node IDs or names to limit the returned information. Use `_local` to return information from the node you're connecting to, specify the node name to get information from specific nodes, or keep the parameter empty to get information from all nodes.
41+
* $params['parent_task_id'] = (string) Returns tasks with a specified parent task ID (node_id:task_number). Keep empty or set to -1 to return all.
42+
* $params['wait_for_completion'] = (boolean) Waits for the matching task to complete. When `true`, the request is blocked until the task has completed. (Default = false)
4343
* $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
4444
* $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
4545
* $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
@@ -63,9 +63,9 @@ public function cancel(array $params = [])
6363
/**
6464
* Returns information about a task.
6565
*
66-
* $params['task_id'] = (string) ID of the task.
67-
* $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.
68-
* $params['wait_for_completion'] = (boolean) If `true`, the request blocks until the task has completed. (Default = false)
66+
* $params['task_id'] = (string) The ID of the task.
67+
* $params['timeout'] = (string) The amount of time to wait for a response.
68+
* $params['wait_for_completion'] = (boolean) Waits for the matching task to complete. When `true`, the request is blocked until the task has completed. (Default = false)
6969
* $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
7070
* $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
7171
* $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
@@ -89,13 +89,13 @@ public function get(array $params = [])
8989
/**
9090
* Returns a list of tasks.
9191
*
92-
* $params['actions'] = (any) Comma-separated list or wildcard expression of actions used to limit the request.
93-
* $params['detailed'] = (boolean) If `true`, the response includes detailed information about shard recoveries. (Default = false)
94-
* $params['group_by'] = (enum) Key used to group tasks in the response. (Options = nodes,none,parents)
95-
* $params['nodes'] = (array) Comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes.
96-
* $params['parent_task_id'] = (string) Parent task ID used to limit returned information. To return all tasks, omit this parameter or use a value of `-1`.
97-
* $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.
98-
* $params['wait_for_completion'] = (boolean) If `true`, the request blocks until the operation is complete. (Default = false)
92+
* $params['actions'] = (any) A comma-separated list of actions that should be returned. Keep empty to return all.
93+
* $params['detailed'] = (boolean) When `true`, the response includes detailed information about shard recoveries. (Default = false)
94+
* $params['group_by'] = (enum) Groups tasks by parent/child relationships or nodes. (Options = nodes,none,parents)
95+
* $params['nodes'] = (array) A comma-separated list of node IDs or names to limit the returned information. Use `_local` to return information from the node you're connecting to, specify the node name to get information from specific nodes, or keep the parameter empty to get information from all nodes.
96+
* $params['parent_task_id'] = (string) Returns tasks with a specified parent task ID (node_id:task_number). Keep empty or set to -1 to return all.
97+
* $params['timeout'] = (string) The amount of time to wait for a response.
98+
* $params['wait_for_completion'] = (boolean) Waits for the matching task to complete. When `true`, the request is blocked until the task has completed. (Default = false)
9999
* $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
100100
* $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
101101
* $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)

0 commit comments

Comments
 (0)