1: | <?php |
2: | |
3: | declare(strict_types=1); |
4: | |
5: | /** |
6: | * Copyright OpenSearch Contributors |
7: | * SPDX-License-Identifier: Apache-2.0 |
8: | * |
9: | * OpenSearch PHP client |
10: | * |
11: | * @link https://github.com/opensearch-project/opensearch-php/ |
12: | * @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co) |
13: | * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 |
14: | * @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1 |
15: | * |
16: | * Licensed to Elasticsearch B.V under one or more agreements. |
17: | * Elasticsearch B.V licenses this file to you under the Apache 2.0 License or |
18: | * the GNU Lesser General Public License, Version 2.1, at your option. |
19: | * See the LICENSE file in the project root for more information. |
20: | */ |
21: | |
22: | namespace OpenSearch\Namespaces; |
23: | |
24: | use OpenSearch\Endpoints\Tasks\Cancel; |
25: | use OpenSearch\Endpoints\Tasks\Get; |
26: | use OpenSearch\Endpoints\Tasks\ListTasks; |
27: | |
28: | /** |
29: | * Class TasksNamespace |
30: | * |
31: | * NOTE: This file is autogenerated using util/GenerateEndpoints.php |
32: | */ |
33: | class TasksNamespace extends AbstractNamespace |
34: | { |
35: | /** |
36: | * Cancels a task, if it can be cancelled through an API. |
37: | * |
38: | * $params['task_id'] = (string) The task ID. |
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 used 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 a specific node, 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) |
43: | * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) |
44: | * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) |
45: | * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) |
46: | * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. |
47: | * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-". |
48: | * |
49: | * @param array $params Associative array of parameters |
50: | * @return array |
51: | */ |
52: | public function cancel(array $params = []) |
53: | { |
54: | $task_id = $this->extractArgument($params, 'task_id'); |
55: | |
56: | $endpoint = $this->endpointFactory->getEndpoint(Cancel::class); |
57: | $endpoint->setParams($params); |
58: | $endpoint->setTaskId($task_id); |
59: | |
60: | return $this->performRequest($endpoint); |
61: | } |
62: | |
63: | /** |
64: | * Returns information about a task. |
65: | * |
66: | * $params['task_id'] = (string) The task ID. |
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) |
69: | * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) |
70: | * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) |
71: | * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) |
72: | * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. |
73: | * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-". |
74: | * |
75: | * @param array $params Associative array of parameters |
76: | * @return array |
77: | */ |
78: | public function get(array $params = []) |
79: | { |
80: | $task_id = $this->extractArgument($params, 'task_id'); |
81: | |
82: | $endpoint = $this->endpointFactory->getEndpoint(Get::class); |
83: | $endpoint->setParams($params); |
84: | $endpoint->setTaskId($task_id); |
85: | |
86: | return $this->performRequest($endpoint); |
87: | } |
88: | |
89: | /** |
90: | * Returns a list of tasks. |
91: | * |
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 used 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 a specific node, 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) |
99: | * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) |
100: | * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) |
101: | * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) |
102: | * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. |
103: | * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-". |
104: | * |
105: | * @param array $params Associative array of parameters |
106: | * @return array |
107: | */ |
108: | public function list(array $params = []) |
109: | { |
110: | $endpoint = $this->endpointFactory->getEndpoint(ListTasks::class); |
111: | $endpoint->setParams($params); |
112: | |
113: | return $this->performRequest($endpoint); |
114: | } |
115: | |
116: | /** |
117: | * Proxy function to list() to prevent BC break since 7.4.0 |
118: | */ |
119: | public function tasksList(array $params = []) |
120: | { |
121: | return $this->list($params); |
122: | } |
123: | } |
124: |