1<?php
2
3declare(strict_types = 1);
4
5namespace Elasticsearch\Endpoints;
6
7use Elasticsearch\Common\Exceptions;
8
9/**
10 * Class UpdateByQueryRethrottle
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://elasticsearch.org
17 */
18class UpdateByQueryRethrottle extends AbstractEndpoint
19{
20    protected $taskId;
21
22    public function setTaskId(?string $taskId): UpdateByQueryRethrottle
23    {
24        if ($taskId !== null) {
25            $this->taskId = $taskId;
26        }
27        return $this;
28    }
29
30    /**
31     * @throws Exceptions\RuntimeException
32     * @return string
33     */
34    public function getURI(): string
35    {
36        if (!isset($this->taskId)) {
37            throw new Exceptions\RuntimeException(
38                'task_id is required for UpdateByQueryRethrottle'
39            );
40        }
41        return "/_update_by_query/{$this->taskId}/_rethrottle";
42    }
43
44
45    public function getParamWhitelist(): array
46    {
47        return [
48            'requests_per_second'
49        ];
50    }
51
52    public function getMethod(): string
53    {
54        return 'POST';
55    }
56}
57