1<?php
2
3declare(strict_types = 1);
4
5namespace Elasticsearch\Endpoints\Indices\Alias;
6
7use Elasticsearch\Endpoints\AbstractEndpoint;
8
9/**
10 * Class Get
11 *
12 * @category Elasticsearch
13 * @package  Elasticsearch\Endpoints\Indices\Alias
14 * @author   Zachary Tong <zach@elastic.co>
15 * @license  http://www.apache.org/licenses/LICENSE-2.0 Apache2
16 * @link     http://elastic.co
17 */
18class Get extends AbstractEndpoint
19{
20    /**
21     * A comma-separated list of alias names to return
22     *
23     * @var string
24     */
25    private $name;
26
27    public function setName(?string $name): Get
28    {
29        if (isset($name) !== true) {
30            return $this;
31        }
32
33        $this->name = $name;
34
35        return $this;
36    }
37
38    public function getURI(): string
39    {
40        $index = $this->index ?? null;
41        $name = $this->name ?? null;
42        if (isset($index) && isset($name)) {
43            return "/$index/_alias/$name";
44        }
45        if (isset($name)) {
46            return "/_alias/$name";
47        }
48        if (isset($index)) {
49            return "/$index/_alias";
50        }
51        return "/_alias";
52    }
53
54    public function getParamWhitelist(): array
55    {
56        return [
57            'ignore_unavailable',
58            'allow_no_indices',
59            'expand_wildcards',
60            'local',
61        ];
62    }
63
64    public function getMethod(): string
65    {
66        return 'GET';
67    }
68}
69