1<?php
2
3declare(strict_types = 1);
4
5namespace Elasticsearch\Endpoints\Indices\Aliases;
6
7use Elasticsearch\Endpoints\AbstractEndpoint;
8use Elasticsearch\Common\Exceptions;
9
10/**
11 * Class Update
12 *
13 * @category Elasticsearch
14 * @package  Elasticsearch\Endpoints\Indices\Aliases
15 * @author   Zachary Tong <zach@elastic.co>
16 * @license  http://www.apache.org/licenses/LICENSE-2.0 Apache2
17 * @link     http://elastic.co
18 */
19class Update extends AbstractEndpoint
20{
21    /**
22     * @throws \Elasticsearch\Common\Exceptions\InvalidArgumentException
23     */
24    public function setBody($body): Update
25    {
26        if (isset($body) !== true) {
27            return $this;
28        }
29
30        $this->body = $body;
31
32        return $this;
33    }
34
35    public function getURI(): string
36    {
37        return "/_aliases";
38    }
39
40    public function getParamWhitelist(): array
41    {
42        return [
43            'timeout',
44            'master_timeout',
45        ];
46    }
47
48    /**
49     * @throws \Elasticsearch\Common\Exceptions\RuntimeException
50     */
51    public function getBody()
52    {
53        if (isset($this->body) !== true) {
54            throw new Exceptions\RuntimeException('Body is required for Update Aliases');
55        }
56
57        return $this->body;
58    }
59
60    public function getMethod(): string
61    {
62        return 'POST';
63    }
64}
65