1<?php
2/**
3 * Elasticsearch PHP client
4 *
5 * @link      https://github.com/elastic/elasticsearch-php/
6 * @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
7 * @license   http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
8 * @license   https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
9 *
10 * Licensed to Elasticsearch B.V under one or more agreements.
11 * Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
12 * the GNU Lesser General Public License, Version 2.1, at your option.
13 * See the LICENSE file in the project root for more information.
14 */
15declare(strict_types = 1);
16
17namespace Elasticsearch\Endpoints;
18
19use Elasticsearch\Common\Exceptions\RuntimeException;
20use Elasticsearch\Endpoints\AbstractEndpoint;
21
22/**
23 * Class SearchMvt
24 * Elasticsearch API name search_mvt
25 *
26 * NOTE: this file is autogenerated using util/GenerateEndpoints.php
27 * and Elasticsearch 7.16.0-SNAPSHOT (dfc9a8e7563ed5f24b5210ed21ed92ae182cd0ee)
28 */
29class SearchMvt extends AbstractEndpoint
30{
31    protected $field;
32    protected $zoom;
33    protected $x;
34    protected $y;
35
36    public function getURI(): string
37    {
38        $index = $this->index ?? null;
39        $field = $this->field ?? null;
40        $zoom = $this->zoom ?? null;
41        $x = $this->x ?? null;
42        $y = $this->y ?? null;
43
44        if (isset($index) && isset($field) && isset($zoom) && isset($x) && isset($y)) {
45            return "/$index/_mvt/$field/$zoom/$x/$y";
46        }
47        throw new RuntimeException('Missing parameter for the endpoint search_mvt');
48    }
49
50    public function getParamWhitelist(): array
51    {
52        return [
53            'exact_bounds',
54            'extent',
55            'grid_precision',
56            'grid_type',
57            'size'
58        ];
59    }
60
61    public function getMethod(): string
62    {
63        return isset($this->body) ? 'POST' : 'GET';
64    }
65
66    public function setBody($body): SearchMvt
67    {
68        if (isset($body) !== true) {
69            return $this;
70        }
71        $this->body = $body;
72
73        return $this;
74    }
75
76    public function setField($field): SearchMvt
77    {
78        if (isset($field) !== true) {
79            return $this;
80        }
81        $this->field = $field;
82
83        return $this;
84    }
85
86    public function setZoom($zoom): SearchMvt
87    {
88        if (isset($zoom) !== true) {
89            return $this;
90        }
91        $this->zoom = $zoom;
92
93        return $this;
94    }
95
96    public function setX($x): SearchMvt
97    {
98        if (isset($x) !== true) {
99            return $this;
100        }
101        $this->x = $x;
102
103        return $this;
104    }
105
106    public function setY($y): SearchMvt
107    {
108        if (isset($y) !== true) {
109            return $this;
110        }
111        $this->y = $y;
112
113        return $this;
114    }
115}
116