1<?php 2 3declare(strict_types = 1); 4 5namespace Elasticsearch\Namespaces; 6 7use Elasticsearch\Endpoints\Tasks\Cancel; 8use Elasticsearch\Endpoints\Tasks\Get; 9 10/** 11 * Class TasksNamespace 12 * 13 * @category Elasticsearch 14 * @package Elasticsearch\Namespaces\TasksNamespace 15 * @author Zachary Tong <zach@elastic.co> 16 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache2 17 * @link http://elastic.co 18 */ 19class TasksNamespace extends AbstractNamespace 20{ 21 /** 22 * $params['wait_for_completion'] = (bool) Wait for the matching tasks to complete (default: false) 23 * 24 * @return callable|array 25 */ 26 public function get(array $params = []) 27 { 28 $id = $this->extractArgument($params, 'task_id'); 29 30 /** 31 * @var callable $endpointBuilder 32*/ 33 $endpointBuilder = $this->endpoints; 34 35 /** 36 * @var Get $endpoint 37*/ 38 $endpoint = $endpointBuilder('Tasks\Get'); 39 $endpoint->setTaskId($id) 40 ->setParams($params); 41 42 return $this->performRequest($endpoint); 43 } 44 45 /** 46 * $params['node_id'] = (list) 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, leave empty to get information from all nodes 47 * ['actions'] = (list) A comma-separated list of actions that should be cancelled. Leave empty to cancel all. 48 * ['parent_node'] = (string) Cancel tasks with specified parent node 49 * ['parent_task'] = (string) Cancel tasks with specified parent task id (node_id:task_number). Set to -1 to cancel all. 50 * ['detailed'] = (bool) Return detailed task information (default: false) 51 * ['wait_for_completion'] = (bool) Wait for the matching tasks to complete (default: false) 52 * ['group_by'] = (enum) Group tasks by nodes or parent/child relationships 53 * 54 * @return callable|array 55 */ 56 public function tasksList(array $params = []) 57 { 58 59 /** 60 * @var callable $endpointBuilder 61*/ 62 $endpointBuilder = $this->endpoints; 63 64 /** 65 * @var Get $endpoint 66*/ 67 $endpoint = $endpointBuilder('Tasks\TasksList'); 68 $endpoint->setParams($params); 69 70 return $this->performRequest($endpoint); 71 } 72 73 /** 74 * $params['node_id'] = (list) 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, leave empty to get information from all nodes 75 * ['actions'] = (list) A comma-separated list of actions that should be cancelled. Leave empty to cancel all. 76 * ['parent_node'] = (string) Cancel tasks with specified parent node 77 * ['parent_task'] = (string) Cancel tasks with specified parent task id (node_id:task_number). Set to -1 to cancel all. 78 * 79 * @return callable|array 80 */ 81 public function cancel(array $params = []) 82 { 83 $id = $this->extractArgument($params, 'id'); 84 85 /** 86 * @var callable $endpointBuilder 87*/ 88 $endpointBuilder = $this->endpoints; 89 90 /** 91 * @var Cancel $endpoint 92*/ 93 $endpoint = $endpointBuilder('Tasks\Cancel'); 94 $endpoint->setTaskId($id) 95 ->setParams($params); 96 97 return $this->performRequest($endpoint); 98 } 99} 100