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\Namespaces\AbstractNamespace;
25:
26: /**
27: * Class TasksNamespace
28: *
29: * NOTE: This file is autogenerated using util/GenerateEndpoints.php
30: */
31: class TasksNamespace extends AbstractNamespace
32: {
33: /**
34: * Cancels a task, if it can be cancelled through an API.
35: *
36: * $params['task_id'] = (number) ID of the task.
37: * $params['actions'] = (any) Comma-separated list or wildcard expression of actions used to limit the request.
38: * $params['nodes'] = (array) Comma-separated list of node IDs or names used to limit the request.
39: * $params['parent_task_id'] = (string) Parent task ID used to limit the tasks.
40: * $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)
41: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
42: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
43: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
44: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
45: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
46: *
47: * @param array $params Associative array of parameters
48: * @return array
49: */
50: public function cancel(array $params = [])
51: {
52: $task_id = $this->extractArgument($params, 'task_id');
53:
54: $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Tasks\Cancel::class);
55: $endpoint->setParams($params);
56: $endpoint->setTaskId($task_id);
57:
58: return $this->performRequest($endpoint);
59: }
60:
61: /**
62: * Returns information about a task.
63: *
64: * $params['task_id'] = (string) ID of the task.
65: * $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.
66: * $params['wait_for_completion'] = (boolean) If `true`, the request blocks until the task has completed. (Default = false)
67: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
68: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
69: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
70: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
71: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
72: *
73: * @param array $params Associative array of parameters
74: * @return array
75: */
76: public function get(array $params = [])
77: {
78: $task_id = $this->extractArgument($params, 'task_id');
79:
80: $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Tasks\Get::class);
81: $endpoint->setParams($params);
82: $endpoint->setTaskId($task_id);
83:
84: return $this->performRequest($endpoint);
85: }
86:
87: /**
88: * Returns a list of tasks.
89: *
90: * $params['actions'] = (any) Comma-separated list or wildcard expression of actions used to limit the request.
91: * $params['detailed'] = (boolean) If `true`, the response includes detailed information about shard recoveries. (Default = false)
92: * $params['group_by'] = (enum) Key used to group tasks in the response. (Options = nodes,none,parents)
93: * $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.
94: * $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`.
95: * $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.
96: * $params['wait_for_completion'] = (boolean) If `true`, the request blocks until the operation is complete. (Default = false)
97: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
98: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
99: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
100: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
101: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
102: *
103: * @param array $params Associative array of parameters
104: * @return array
105: */
106: public function list(array $params = [])
107: {
108: $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Tasks\ListTasks::class);
109: $endpoint->setParams($params);
110:
111: return $this->performRequest($endpoint);
112: }
113:
114: /**
115: * Proxy function to list() to prevent BC break since 7.4.0
116: */
117: public function tasksList(array $params = [])
118: {
119: return $this->list($params);
120: }
121: }
122: