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 ReindexRethrottle extends AbstractEndpoint
19{
20    protected $taskId;
21
22    public function setTaskId(?string $taskId): ReindexRethrottle
23    {
24        if ($taskId !== null) {
25            $this->taskId = $taskId;
26        }
27        return $this;
28    }
29
30    public function getParamWhitelist(): array
31    {
32        return [
33            'requests_per_second'
34        ];
35    }
36
37    public function getURI(): string
38    {
39        if (!isset($this->taskId)) {
40            throw new RuntimeException(
41                'task_id is required for ReindexRethrottle'
42            );
43        }
44        return "/_reindex/{$this->taskId}/_rethrottle";
45    }
46
47    public function getMethod(): string
48    {
49        return 'POST';
50    }
51}
52