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