1<?php 2 3declare(strict_types = 1); 4 5namespace Elasticsearch\Endpoints\Tasks; 6 7use Elasticsearch\Common\Exceptions; 8use Elasticsearch\Endpoints\AbstractEndpoint; 9 10/** 11 * Class Cancel 12 * 13 * @category Elasticsearch 14 * @package Elasticsearch\Endpoints\Tasks 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 Cancel extends AbstractEndpoint 20{ 21 private $taskId; 22 23 /** 24 * @throws \Elasticsearch\Common\Exceptions\InvalidArgumentException 25 */ 26 public function setTaskId(?string $taskId): Cancel 27 { 28 if (isset($taskId) !== true) { 29 return $this; 30 } 31 32 $this->taskId = $taskId; 33 34 return $this; 35 } 36 37 /** 38 * @throws \Elasticsearch\Common\Exceptions\RuntimeException 39 */ 40 public function getURI(): string 41 { 42 $taskId = $this->taskId ?? null; 43 44 if (isset($taskId)) { 45 return "/_tasks/$taskId/_cancel"; 46 } 47 return "/_tasks/_cancel"; 48 } 49 50 public function getParamWhitelist(): array 51 { 52 return [ 53 'nodes', 54 'actions', 55 'parent_task_id' 56 ]; 57 } 58 59 public function getMethod(): string 60 { 61 return 'POST'; 62 } 63} 64