1<?php
2
3declare(strict_types = 1);
4
5namespace Elasticsearch\Endpoints;
6
7use Elasticsearch\Common\Exceptions\RuntimeException;
8
9/**
10 * Class Reindex
11 *
12 * @category Elasticsearch
13 * @package  Elasticsearch\Endpoints
14 * @author   Enrico Zimuel <enrico.zimuel@elastic.co>
15 * @license  http://www.apache.org/licenses/LICENSE-2.0 Apache2
16 * @link     http://elastic.co
17 */
18class ScriptsPainlessExecute extends AbstractEndpoint
19{
20    public function getParamWhitelist(): array
21    {
22        return [
23            'requests_per_second'
24        ];
25    }
26
27    public function getURI(): string
28    {
29        return "/_scripts/painless/_execute";
30    }
31
32    public function getMethod(): string
33    {
34        return isset($this->body) ? 'POST' : 'GET';
35    }
36
37    public function setBody($body): ScriptsPainlessExecute
38    {
39        if (isset($body) !== true) {
40            return $this;
41        }
42
43        $this->body = $body;
44
45        return $this;
46    }
47}
48