1<?php 2 3declare(strict_types = 1); 4 5namespace Elasticsearch\Endpoints\Indices; 6 7use Elasticsearch\Endpoints\AbstractEndpoint; 8use Elasticsearch\Common\Exceptions; 9 10/** 11 * Class Create 12 * 13 * @category Elasticsearch 14 * @package Elasticsearch\Endpoints\Indices 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 Create extends AbstractEndpoint 20{ 21 /** 22 * @param array|object $body 23 * @throws \Elasticsearch\Common\Exceptions\InvalidArgumentException 24 */ 25 public function setBody($body): Create 26 { 27 if (isset($body) !== true) { 28 return $this; 29 } 30 31 $this->body = $body; 32 33 return $this; 34 } 35 36 /** 37 * @throws \Elasticsearch\Common\Exceptions\RuntimeException 38 */ 39 public function getURI(): string 40 { 41 if (isset($this->index) !== true) { 42 throw new Exceptions\RuntimeException( 43 'index is required for Create' 44 ); 45 } 46 return "/{$this->index}"; 47 } 48 49 public function getParamWhitelist(): array 50 { 51 return [ 52 'include_type_name', 53 'wait_for_active_shards', 54 'timeout', 55 'master_timeout' 56 ]; 57 } 58 59 public function getMethod(): string 60 { 61 return 'PUT'; 62 } 63} 64