1<?php
2
3declare(strict_types = 1);
4
5namespace Elasticsearch\Endpoints;
6
7use Elasticsearch\Common\Exceptions\RuntimeException;
8
9/**
10 * Class Get
11 *
12 * @category Elasticsearch
13 * @package  Elasticsearch\Endpoints
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     * @throws RuntimeException
22     */
23    public function getURI(): string
24    {
25        if (isset($this->id) !== true) {
26            throw new RuntimeException(
27                'id is required for Get'
28            );
29        }
30        if (isset($this->index) !== true) {
31            throw new RuntimeException(
32                'index is required for Get'
33            );
34        }
35        $id = $this->id;
36        $index = $this->index;
37        $type = $this->type ?? '_doc';
38
39        return "/$index/$type/$id";
40    }
41
42    public function getParamWhitelist(): array
43    {
44        return [
45            'stored_fields',
46            'parent',
47            'preference',
48            'realtime',
49            'refresh',
50            'routing',
51            '_source',
52            '_source_excludes',
53            '_source_exclude',
54            '_source_includes',
55            '_source_include',
56            'version',
57            'version_type'
58        ];
59    }
60
61    public function getMethod(): string
62    {
63        return 'GET';
64    }
65}
66