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 Get 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 Get extends AbstractEndpoint 20{ 21 private $taskId; 22 23 public function setTaskId(?string $taskId): Get 24 { 25 if (isset($taskId) !== true) { 26 return $this; 27 } 28 29 $this->taskId = $taskId; 30 31 return $this; 32 } 33 34 /** 35 * @throws \Elasticsearch\Common\Exceptions\RuntimeException 36 */ 37 public function getURI(): string 38 { 39 if (isset($this->taskId) !== true) { 40 throw new Exceptions\RuntimeException( 41 'task_id is required for Get' 42 ); 43 } 44 45 return "/_tasks/{$this->taskId}"; 46 } 47 48 public function getParamWhitelist(): array 49 { 50 return [ 51 'wait_for_completion', 52 'timeout' 53 ]; 54 } 55 56 public function getMethod(): string 57 { 58 return 'GET'; 59 } 60} 61