1<?php 2 3declare(strict_types = 1); 4 5namespace Elasticsearch\Endpoints\Indices\Alias; 6 7use Elasticsearch\Endpoints\AbstractEndpoint; 8use Elasticsearch\Common\Exceptions; 9 10/** 11 * Class Delete 12 * 13 * @category Elasticsearch 14 * @package Elasticsearch\Endpoints\Indices\Alias 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 Delete extends AbstractEndpoint 20{ 21 /** 22 * A comma-separated list of aliases to delete (supports wildcards); use `_all` to delete all aliases for the specified indices. 23 * 24 * @var string 25 */ 26 private $name; 27 28 public function setName(?string $name): Delete 29 { 30 if (isset($name) !== true) { 31 return $this; 32 } 33 34 $this->name = $name; 35 36 return $this; 37 } 38 39 /** 40 * @throws \Elasticsearch\Common\Exceptions\RuntimeException 41 */ 42 public function getURI(): string 43 { 44 if (isset($this->index) !== true) { 45 throw new Exceptions\RuntimeException( 46 'index is required for Delete' 47 ); 48 } 49 if (isset($this->name) !== true) { 50 throw new Exceptions\RuntimeException( 51 'name is required for Delete' 52 ); 53 } 54 return "/{$this->index}/_alias/{$this->name}"; 55 } 56 57 public function getParamWhitelist(): array 58 { 59 return [ 60 'timeout', 61 'master_timeout' 62 ]; 63 } 64 65 public function getMethod(): string 66 { 67 return 'DELETE'; 68 } 69} 70