1<?php
2
3declare(strict_types = 1);
4
5namespace Elasticsearch\Endpoints\Indices\Mapping;
6
7use Elasticsearch\Endpoints\AbstractEndpoint;
8
9/**
10 * Class Get
11 *
12 * @category Elasticsearch
13 * @package  Elasticsearch\Endpoints\Indices\Mapping
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    public function getURI(): string
21    {
22        $index = $this->index ?? null;
23        $type = $this->type ?? null;
24        if (isset($index) && isset($type)) {
25            return "/$index/_mapping/$type";
26        }
27        if (isset($index)) {
28            return "/$index/_mapping";
29        }
30        if (isset($type)) {
31            return "/_mapping/$type";
32        }
33        return "/_mapping";
34    }
35
36    public function getParamWhitelist(): array
37    {
38        return [
39            'include_type_name',
40            'ignore_unavailable',
41            'allow_no_indices',
42            'expand_wildcards',
43            'master_timeout',
44            'local'
45        ];
46    }
47
48    public function getMethod(): string
49    {
50        return 'GET';
51    }
52}
53