1<?php
2
3declare(strict_types = 1);
4
5namespace Elasticsearch\Endpoints;
6
7use Elasticsearch\Common\Exceptions;
8
9/**
10 * Class Count
11 *
12 * @category Elasticsearch
13 * @package  Elasticsearch\Endpoints
14 * @author   Zachary Tong <zach@elastic.co>
15 * @license  http://www.apache.org/licenses/LICENSE-2.0 Apache2
16 * @link     http://elastic.co
17 */
18class Count extends AbstractEndpoint
19{
20    public function setBody($body): Count
21    {
22        if (isset($body) !== true) {
23            return $this;
24        }
25
26        $this->body = $body;
27
28        return $this;
29    }
30
31    public function getURI(): string
32    {
33        $index = $this->index ?? null;
34        $type = $this->type ?? null;
35
36        if (isset($index) && isset($type)) {
37            return "/$index/$type/_count";
38        }
39        if (isset($index)) {
40            return "/$index/_count";
41        }
42        return "/_count";
43    }
44
45    public function getParamWhitelist(): array
46    {
47        return [
48            'ignore_unavailable',
49            'ignore_throttled',
50            'allow_no_indices',
51            'expand_wildcards',
52            'min_score',
53            'preference',
54            'routing',
55            'q',
56            'analyzer',
57            'analyze_wildcard',
58            'default_operator',
59            'df',
60            'lenient',
61            'terminate_after'
62        ];
63    }
64
65    public function getMethod(): string
66    {
67        return 'GET';
68    }
69}
70