1<?php
2
3declare(strict_types = 1);
4
5namespace Elasticsearch\Endpoints\Indices\Template;
6
7use Elasticsearch\Endpoints\AbstractEndpoint;
8use Elasticsearch\Common\Exceptions;
9
10/**
11 * Class Get
12 *
13 * @category Elasticsearch
14 * @package  Elasticsearch\Endpoints\Indices\Template
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    /**
22     * The name of the template
23     *
24     * @var string
25     */
26    private $name;
27
28    public function setName(?string $name): Get
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        $name = $this->name ?? null;
45
46        if (isset($name)) {
47            return "/_template/$name";
48        }
49        return "/_template";
50    }
51
52    /**
53     * @return string[]
54     */
55    public function getParamWhitelist(): array
56    {
57        return [
58            'include_type_name',
59            'flat_settings',
60            'master_timeout',
61            'local'
62        ];
63    }
64
65    public function getMethod(): string
66    {
67        return 'GET';
68    }
69}
70