1<?php
2
3declare(strict_types = 1);
4
5namespace Elasticsearch\Namespaces;
6
7/**
8 * Class IndicesNamespace
9 *
10 * @category Elasticsearch
11 * @package  Elasticsearch\Namespaces\IndicesNamespace
12 * @author   Zachary Tong <zach@elastic.co>
13 * @license  http://www.apache.org/licenses/LICENSE-2.0 Apache2
14 * @link     http://elastic.co
15 */
16class IndicesNamespace extends AbstractNamespace
17{
18    /**
19     * $params['index'] = (list) A comma-separated list of indices to check (Required)
20     *        ['local'] = (bool) Return local information, do not retrieve the state
21     *        from master node (default: false)
22     *        ['ignore_unavailable'] = (bool) Ignore unavailable indexes (default: false)
23     *        ['allow_no_indices'] = (bool) Ignore if a wildcard expression resolves to no
24     *        concrete indices (default: false)
25     *        ['expand_wildcards'] = (enum) Whether wildcard expressions should get
26     *        expanded to open or closed indices (default: open)
27     *        ['flat_settings'] = (bool) Return settings in flat format (default: false)
28     *        ['include_defaults'] = (bool) Whether to return all default setting for each
29     *        of the indices
30     */
31    public function exists(array $params): bool
32    {
33        $index = $this->extractArgument($params, 'index');
34
35        // manually make this verbose so we can check status code
36        $params['client']['verbose'] = true;
37
38        /**
39 * @var callable $endpointBuilder
40*/
41        $endpointBuilder = $this->endpoints;
42
43        /**
44 * @var \Elasticsearch\Endpoints\Indices\Exists $endpoint
45*/
46        $endpoint = $endpointBuilder('Indices\Exists');
47        $endpoint->setIndex($index);
48        $endpoint->setParams($params);
49
50        return BooleanRequestWrapper::performRequest($endpoint, $this->transport);
51    }
52
53    /**
54     * $params['index'] = (list) A comma-separated list of indices to check (Required)
55     *        ['include_type_name'] = (bool) Whether to add the type name to the response (default: false)
56     *        ['local'] = (bool) Return local information, do not retrieve the state from master node (default: false)
57     *        ['ignore_unavailable'] = (bool) Whether specified concrete indices should be ignored when unavailable (missing or closed)
58     *        ['allow_no_indices']   = (bool) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
59     *        ['expand_wildcards']   = (enum) Whether to expand wildcard expression to concrete indices that are open, closed or both.
60     *        ['flat_settings'] = (bool) Return settings in flat format (default: false)
61     *        ['include_defaults'] = (bool) Whether to return all default setting for each of the indices
62     *        ['master_timeout'] = (time) Specify timeout for connection to master
63     *
64     * @return callable|array
65     */
66    public function get(array $params)
67    {
68        $index = $this->extractArgument($params, 'index');
69
70        /**
71 * @var callable $endpointBuilder
72*/
73        $endpointBuilder = $this->endpoints;
74
75        /**
76 * @var \Elasticsearch\Endpoints\Indices\Get $endpoint
77*/
78        $endpoint = $endpointBuilder('Indices\Get');
79        $endpoint->setIndex($index)
80            ->setParams($params);
81
82        return $this->performRequest($endpoint);
83    }
84
85    /**
86     * $params['index']               = (list) A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
87     *        ['ignore_unavailable'] = (bool) Whether specified concrete indices should be ignored when unavailable (missing or closed)
88     *        ['allow_no_indices']   = (bool) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
89     *        ['expand_wildcards']   = (enum) Whether to expand wildcard expression to concrete indices that are open, closed or both.
90     *        ['verbose'] = (bool) Includes detailed memory usage by Lucene
91     *
92     * @return callable|array
93     */
94    public function segments(array $params = [])
95    {
96        $index = $this->extractArgument($params, 'index');
97
98        /**
99 * @var callable $endpointBuilder
100*/
101        $endpointBuilder = $this->endpoints;
102
103        /**
104 * @var \Elasticsearch\Endpoints\Indices\Segments $endpoint
105*/
106        $endpoint = $endpointBuilder('Indices\Segments');
107        $endpoint->setIndex($index);
108        $endpoint->setParams($params);
109
110        return $this->performRequest($endpoint);
111    }
112
113    /**
114     * $params['name']    = (string) The name of the template (Required)
115     *        ['timeout'] = (time) Explicit operation timeout
116     *        ['master_timeout'] = (time) Specify timeout for connection to master
117     *
118     * @return callable|array
119     */
120    public function deleteTemplate(array $params)
121    {
122        $name = $this->extractArgument($params, 'name');
123
124        /**
125 * @var callable $endpointBuilder
126*/
127        $endpointBuilder = $this->endpoints;
128
129        /**
130 * @var \Elasticsearch\Endpoints\Indices\Template\Delete $endpoint
131*/
132        $endpoint = $endpointBuilder('Indices\Template\Delete');
133        $endpoint->setName($name);
134        $endpoint->setParams($params);
135
136        return $this->performRequest($endpoint);
137    }
138
139    /**
140     * $params['index']   = (list) A comma-separated list of indices to delete; use `_all` or empty string to delete all indices
141     *        ['timeout'] = (time) Explicit operation timeout
142     *        ['master_timeout'] = (time) Specify timeout for connection to master
143     *        ['ignore_unavailable'] = (bool) Ignore unavailable indexes (default: false)
144     *        ['allow_no_indices'] = (bool) Ignore if a wildcard expression resolves to no concrete indices (default: false)
145     *        ['expand_wildcards'] = (enum) Whether wildcard expressions should get expanded to open or closed indices (default: open)
146     *
147     * @return callable|array
148     */
149    public function delete(array $params = [])
150    {
151        $index = $this->extractArgument($params, 'index');
152
153        /**
154 * @var callable $endpointBuilder
155*/
156        $endpointBuilder = $this->endpoints;
157
158        /**
159 * @var \Elasticsearch\Endpoints\Indices\Delete $endpoint
160*/
161        $endpoint = $endpointBuilder('Indices\Delete');
162        $endpoint->setIndex($index);
163        $endpoint->setParams($params);
164
165        return $this->performRequest($endpoint);
166    }
167
168    /**
169     * $params['fields']         = (boolean) A comma-separated list of fields for `fielddata` metric (supports wildcards)
170     *        ['index']          = (list) A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
171     *        ['indexing_types'] = (list) A comma-separated list of document types to include in the `indexing` statistics
172     *        ['metric_family']  = (enum) Limit the information returned to a specific metric
173     *        ['search_groups']  = (list) A comma-separated list of search groups to include in the `search` statistics
174     *        ['all']            = (boolean) Return all available information
175     *        ['clear']          = (boolean) Reset the default level of detail
176     *        ['docs']           = (boolean) Return information about indexed and deleted documents
177     *        ['fielddata']      = (boolean) Return information about field data
178     *        ['filter_cache']   = (boolean) Return information about filter cache
179     *        ['flush']          = (boolean) Return information about flush operations
180     *        ['get']            = (boolean) Return information about get operations
181     *        ['groups']         = (boolean) A comma-separated list of search groups for `search` statistics
182     *        ['id_cache']       = (boolean) Return information about ID cache
183     *        ['ignore_indices'] = (enum) When performed on multiple indices, allows to ignore `missing` ones
184     *        ['indexing']       = (boolean) Return information about indexing operations
185     *        ['merge']          = (boolean) Return information about merge operations
186     *        ['refresh']        = (boolean) Return information about refresh operations
187     *        ['search']         = (boolean) Return information about search operations; use the `groups` parameter to include information for specific search groups
188     *        ['store']          = (boolean) Return information about the size of the index
189     *
190     * @return callable|array
191     */
192    public function stats(array $params = [])
193    {
194        $metric = $this->extractArgument($params, 'metric');
195
196        $index = $this->extractArgument($params, 'index');
197
198        /**
199 * @var callable $endpointBuilder
200*/
201        $endpointBuilder = $this->endpoints;
202
203        /**
204 * @var \Elasticsearch\Endpoints\Indices\Stats $endpoint
205*/
206        $endpoint = $endpointBuilder('Indices\Stats');
207        $endpoint->setIndex($index)
208            ->setMetric($metric);
209        $endpoint->setParams($params);
210
211        return $this->performRequest($endpoint);
212    }
213
214    /**
215     * $params['index'] = (list) A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
216     *        ['body']  = (list) A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
217     *
218     * @return callable|array
219     */
220    public function putSettings(array $params = [])
221    {
222        $index = $this->extractArgument($params, 'index');
223
224        $body = $this->extractArgument($params, 'body');
225
226        /**
227 * @var callable $endpointBuilder
228*/
229        $endpointBuilder = $this->endpoints;
230
231        /**
232 * @var \Elasticsearch\Endpoints\Indices\Settings\Put $endpoint
233*/
234        $endpoint = $endpointBuilder('Indices\Settings\Put');
235        $endpoint->setIndex($index)
236            ->setBody($body);
237        $endpoint->setParams($params);
238
239        return $this->performRequest($endpoint);
240    }
241
242    /**
243     * $params['index']          = (string) The name of the source index to shrink
244     *        ['target']         = (string) The name of the target index to shrink into
245     *        ['timeout']        = (time) Explicit operation timeout
246     *        ['master_timeout'] = (time) Specify timeout for connection to master
247     *
248     * @return callable|array
249     */
250    public function shrink(array $params = [])
251    {
252        $index = $this->extractArgument($params, 'index');
253        $target = $this->extractArgument($params, 'target');
254        $body = $this->extractArgument($params, 'body');
255
256        /**
257 * @var callable $endpointBuilder
258*/
259        $endpointBuilder = $this->endpoints;
260
261        /**
262 * @var \Elasticsearch\Endpoints\Indices\Shrink $endpoint
263*/
264        $endpoint = $endpointBuilder('Indices\Shrink');
265        $endpoint->setIndex($index)
266            ->setTarget($target)
267            ->setBody($body);
268
269        return $this->performRequest($endpoint);
270    }
271
272    /**
273     * $params['index'] = (list) A comma-separated list of index names; use `_all` or empty string for all indices
274     *        ['type']  = (list) A comma-separated list of document types
275     *
276     * @return callable|array
277     */
278    public function getMapping(array $params = [])
279    {
280        $index = $this->extractArgument($params, 'index');
281
282        $type = $this->extractArgument($params, 'type');
283
284        /**
285 * @var callable $endpointBuilder
286*/
287        $endpointBuilder = $this->endpoints;
288
289        /**
290 * @var \Elasticsearch\Endpoints\Indices\Mapping\Get $endpoint
291*/
292        $endpoint = $endpointBuilder('Indices\Mapping\Get');
293        $endpoint->setIndex($index)
294            ->setType($type);
295        $endpoint->setParams($params);
296
297        return $this->performRequest($endpoint);
298    }
299
300    /**
301     * $params['index']            = (list) A comma-separated list of index names; use `_all` or empty string for all indices
302     *        ['type']             = (list) A comma-separated list of document types
303     *        ['field']            = (list) A comma-separated list of document fields
304     *        ['include_defaults'] = (bool) specifies default mapping values should be returned
305     *
306     * @return callable|array
307     */
308    public function getFieldMapping(array $params = [])
309    {
310        $index = $this->extractArgument($params, 'index');
311        $type = $this->extractArgument($params, 'type');
312        $fields = $this->extractArgument($params, 'fields');
313
314        if (!isset($fields)) {
315            $fields = $this->extractArgument($params, 'field');
316        }
317
318
319        /**
320 * @var callable $endpointBuilder
321*/
322        $endpointBuilder = $this->endpoints;
323
324        /**
325 * @var \Elasticsearch\Endpoints\Indices\Mapping\GetField $endpoint
326*/
327        $endpoint = $endpointBuilder('Indices\Mapping\GetField');
328        $endpoint->setIndex($index)
329            ->setType($type)
330            ->setFields($fields);
331
332        $endpoint->setParams($params);
333
334        return $this->performRequest($endpoint);
335    }
336
337    /**
338     * $params['index']              = (list) A comma-separated list of index names; use `_all` or empty string for all indices
339     *        ['force']              = (boolean) Whether a flush should be forced even if it is not necessarily needed ie.
340     *        if no changes will be committed to the index. This is useful if transaction log IDs should be incremented even if
341     *        no uncommitted changes are present. (This setting can be considered as internal)
342     *        ['wait_if_ongoing']    = (boolean) If set to true the flush operation will block until the flush can be executed
343     *        if another flush operation is already executing. The default is true. If set to false the flush will be skipped iff if another flush operation is already running
344     *        ['ignore_unavailable'] = (bool) Whether specified concrete indices should be ignored when unavailable (missing or closed)
345     *        ['allow_no_indices']   = (bool) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
346     *        ['expand_wildcards']   = (enum) Whether to expand wildcard expression to concrete indices that are open, closed or both.
347     *
348     * @return callable|array
349     */
350    public function flush(array $params = [])
351    {
352        $index = $this->extractArgument($params, 'index');
353
354        /**
355 * @var callable $endpointBuilder
356*/
357        $endpointBuilder = $this->endpoints;
358
359        /**
360 * @var \Elasticsearch\Endpoints\Indices\Flush $endpoint
361*/
362        $endpoint = $endpointBuilder('Indices\Flush');
363        $endpoint->setIndex($index);
364        $endpoint->setParams($params);
365
366        return $this->performRequest($endpoint);
367    }
368
369    /**
370     * $params['index']              = (list) A comma-separated list of index names; use `_all` or empty string for all indices
371     *        ['ignore_unavailable'] = (bool) Whether specified concrete indices should be ignored when unavailable (missing or closed)
372     *        ['allow_no_indices']   = (bool) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
373     *        ['expand_wildcards']   = (enum) Whether to expand wildcard expression to concrete indices that are open, closed or both.
374     *
375     * @return callable|array
376     */
377    public function flushSynced(array $params = [])
378    {
379        $index = $this->extractArgument($params, 'index');
380
381        /**
382 * @var callable $endpointBuilder
383*/
384        $endpointBuilder = $this->endpoints;
385
386        /**
387 * @var \Elasticsearch\Endpoints\Indices\Flush $endpoint
388*/
389        $endpoint = $endpointBuilder('Indices\FlushSynced');
390        $endpoint->setIndex($index);
391        $endpoint->setParams($params);
392
393        return $this->performRequest($endpoint);
394    }
395
396
397    /**
398     * $params['index']               = (list) A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
399     *        ['operation_threading'] = () TODO: ?
400     *        ['ignore_unavailable'] = (bool) Whether specified concrete indices should be ignored when unavailable (missing or closed)
401     *        ['allow_no_indices']   = (bool) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
402     *        ['expand_wildcards']   = (enum) Whether to expand wildcard expression to concrete indices that are open, closed or both.
403     *
404     * @return callable|array
405     */
406    public function refresh(array $params = [])
407    {
408        $index = $this->extractArgument($params, 'index');
409
410        /**
411 * @var callable $endpointBuilder
412*/
413        $endpointBuilder = $this->endpoints;
414
415        /**
416 * @var \Elasticsearch\Endpoints\Indices\Refresh $endpoint
417*/
418        $endpoint = $endpointBuilder('Indices\Refresh');
419        $endpoint->setIndex($index);
420        $endpoint->setParams($params);
421
422        return $this->performRequest($endpoint);
423    }
424
425    /**
426     * $params['index']       = (list) A comma-separated list of index names; use `_all` or empty string for all indices
427     *        ['detailed']    = (bool) Whether to display detailed information about shard recovery
428     *        ['active_only'] = (bool) Display only those recoveries that are currently on-going
429     *        ['human']       = (bool) Whether to return time and byte values in human-readable format.
430     *
431     * @return callable|array
432     */
433    public function recovery(array $params = [])
434    {
435        $index = $this->extractArgument($params, 'index');
436
437        /**
438 * @var callable $endpointBuilder
439*/
440        $endpointBuilder = $this->endpoints;
441
442        /**
443 * @var \Elasticsearch\Endpoints\Indices\Flush $endpoint
444*/
445        $endpoint = $endpointBuilder('Indices\Recovery');
446        $endpoint->setIndex($index);
447        $endpoint->setParams($params);
448
449        return $this->performRequest($endpoint);
450    }
451
452    /**
453     * $params['index']              = (list) A comma-separated list of index names; use `_all` to check the types across all indices (Required)
454     *        ['type']               = (list) A comma-separated list of document types to check (Required)
455     *        ['ignore_unavailable'] = (bool) Whether specified concrete indices should be ignored when unavailable (missing or closed)
456     *        ['allow_no_indices']   = (bool) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
457     *        ['expand_wildcards']   = (enum) Whether to expand wildcard expression to concrete indices that are open, closed or both.
458     */
459    public function existsType(array $params): bool
460    {
461        $index = $this->extractArgument($params, 'index');
462        $type = $this->extractArgument($params, 'type');
463
464        // manually make this verbose so we can check status code
465        $params['client']['verbose'] = true;
466
467        /**
468 * @var callable $endpointBuilder
469*/
470        $endpointBuilder = $this->endpoints;
471
472        /**
473 * @var \Elasticsearch\Endpoints\Indices\Type\Exists $endpoint
474*/
475        $endpoint = $endpointBuilder('Indices\Type\Exists');
476        $endpoint->setIndex($index)
477            ->setType($type);
478        $endpoint->setParams($params);
479
480        return BooleanRequestWrapper::performRequest($endpoint, $this->transport);
481    }
482
483    /**
484     * $params['index']   = (string) The name of the index with an alias
485     *        ['name']    = (string) The name of the alias to be created or updated
486     *        ['timeout'] = (time) Explicit timestamp for the document
487     *        ['body']    = (time) Explicit timestamp for the document
488     *
489     * @return callable|array
490     */
491    public function putAlias(array $params = [])
492    {
493        $index = $this->extractArgument($params, 'index');
494        $name = $this->extractArgument($params, 'name');
495        $body = $this->extractArgument($params, 'body');
496
497        /**
498 * @var callable $endpointBuilder
499*/
500        $endpointBuilder = $this->endpoints;
501
502        /**
503 * @var \Elasticsearch\Endpoints\Indices\Alias\Put $endpoint
504*/
505        $endpoint = $endpointBuilder('Indices\Alias\Put');
506        $endpoint->setIndex($index)
507            ->setName($name)
508            ->setBody($body);
509        $endpoint->setParams($params);
510
511        return $this->performRequest($endpoint);
512    }
513
514    /**
515     * $params['name']    = (string) The name of the template (Required)
516     *        ['order']   = (number) The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers)
517     *        ['timeout'] = (time) Explicit operation timeout
518     *        ['body']    = (time) Explicit operation timeout
519     *        ['create']  = (bool) Whether the index template should only be added if new or can also replace an existing one
520     *
521     * @return callable|array
522     */
523    public function putTemplate(array $params)
524    {
525        $name = $this->extractArgument($params, 'name');
526        $body = $this->extractArgument($params, 'body');
527
528        /**
529 * @var callable $endpointBuilder
530*/
531        $endpointBuilder = $this->endpoints;
532
533        /**
534 * @var \Elasticsearch\Endpoints\Indices\Template\Put $endpoint
535*/
536        $endpoint = $endpointBuilder('Indices\Template\Put');
537        $endpoint->setName($name)
538            ->setBody($body);
539        $endpoint->setParams($params);
540
541        return $this->performRequest($endpoint);
542    }
543
544    /**
545     * $params['index']               = (list) A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices
546     *        ['type']                = (list) A comma-separated list of document types to restrict the operation; leave empty to perform the operation on all types
547     *        ['explain']             = (boolean) Return detailed information about the error
548     *        ['ignore_indices']      = (enum) When performed on multiple indices, allows to ignore `missing` ones
549     *        ['operation_threading'] = () TODO: ?
550     *        ['source']              = (string) The URL-encoded query definition (instead of using the request body)
551     *        ['body']                = (string) The URL-encoded query definition (instead of using the request body)
552     *
553     * @return callable|array
554     */
555    public function validateQuery(array $params = [])
556    {
557        $index = $this->extractArgument($params, 'index');
558        $type = $this->extractArgument($params, 'type');
559        $body = $this->extractArgument($params, 'body');
560
561        /**
562 * @var callable $endpointBuilder
563*/
564        $endpointBuilder = $this->endpoints;
565
566        /**
567 * @var \Elasticsearch\Endpoints\Indices\Validate\Query $endpoint
568*/
569        $endpoint = $endpointBuilder('Indices\Validate\Query');
570        $endpoint->setIndex($index)
571            ->setType($type)
572            ->setBody($body);
573        $endpoint->setParams($params);
574
575        return $this->performRequest($endpoint);
576    }
577
578    /**
579     * $params['name']           = (list) A comma-separated list of alias names to return (Required)
580     *        ['index']          = (list) A comma-separated list of index names to filter aliases
581     *        ['ignore_indices'] = (enum) When performed on multiple indices, allows to ignore `missing` ones
582     *        ['name']           = (list) A comma-separated list of alias names to return
583     *
584     * @return callable|array
585     */
586    public function getAlias(array $params)
587    {
588        $index = $this->extractArgument($params, 'index');
589        $name = $this->extractArgument($params, 'name');
590
591        /**
592 * @var callable $endpointBuilder
593*/
594        $endpointBuilder = $this->endpoints;
595
596        /**
597 * @var \Elasticsearch\Endpoints\Indices\Alias\Get $endpoint
598*/
599        $endpoint = $endpointBuilder('Indices\Alias\Get');
600        $endpoint->setIndex($index)
601            ->setName($name);
602        $endpoint->setParams($params);
603
604        return $this->performRequest($endpoint);
605    }
606
607    /**
608     * $params['index']            = (list) A comma-separated list of index names; use `_all` to perform the operation on all indices (Required)
609     *        ['type']             = (string) The name of the document type
610     *        ['ignore_conflicts'] = (boolean) Specify whether to ignore conflicts while updating the mapping (default: false)
611     *        ['timeout']          = (time) Explicit operation timeout
612     *        ['body']             = (time) Explicit operation timeout
613     *
614     * @return callable|array
615     */
616    public function putMapping(array $params)
617    {
618        $index = $this->extractArgument($params, 'index');
619        $type = $this->extractArgument($params, 'type');
620        $body = $this->extractArgument($params, 'body');
621
622        /**
623 * @var callable $endpointBuilder
624*/
625        $endpointBuilder = $this->endpoints;
626
627        /**
628 * @var \Elasticsearch\Endpoints\Indices\Mapping\Put $endpoint
629*/
630        $endpoint = $endpointBuilder('Indices\Mapping\Put');
631        $endpoint->setIndex($index)
632            ->setType($type)
633            ->setBody($body);
634        $endpoint->setParams($params);
635
636        return $this->performRequest($endpoint);
637    }
638
639    /**
640     * $params['name'] = (string) The name of the template (Required)
641     *
642     * @return callable|array
643     */
644    public function getTemplate(array $params)
645    {
646        $name = $this->extractArgument($params, 'name');
647
648        /**
649 * @var callable $endpointBuilder
650*/
651        $endpointBuilder = $this->endpoints;
652
653        /**
654 * @var \Elasticsearch\Endpoints\Indices\Template\Get $endpoint
655*/
656        $endpoint = $endpointBuilder('Indices\Template\Get');
657        $endpoint->setName($name);
658        $endpoint->setParams($params);
659
660        return $this->performRequest($endpoint);
661    }
662
663    /**
664     * $params['name'] = (string) The name of the template (Required)
665     */
666    public function existsTemplate(array $params): bool
667    {
668        $name = $this->extractArgument($params, 'name');
669
670        // manually make this verbose so we can check status code
671        $params['client']['verbose'] = true;
672
673        /**
674 * @var callable $endpointBuilder
675*/
676        $endpointBuilder = $this->endpoints;
677
678        /**
679 * @var \Elasticsearch\Endpoints\Indices\Template\Exists $endpoint
680*/
681        $endpoint = $endpointBuilder('Indices\Template\Exists');
682        $endpoint->setName($name);
683        $endpoint->setParams($params);
684
685        return BooleanRequestWrapper::performRequest($endpoint, $this->transport);
686    }
687
688    /**
689     * $params['index']   = (string) The name of the index (Required)
690     *        ['timeout'] = (time) Explicit operation timeout
691     *        ['body']    = (time) Explicit operation timeout
692     *
693     * @return callable|array
694     */
695    public function create(array $params)
696    {
697        $index = $this->extractArgument($params, 'index');
698        $body = $this->extractArgument($params, 'body');
699
700        /**
701 * @var callable $endpointBuilder
702*/
703        $endpointBuilder = $this->endpoints;
704
705        /**
706 * @var \Elasticsearch\Endpoints\Indices\Create $endpoint
707*/
708        $endpoint = $endpointBuilder('Indices\Create');
709        $endpoint->setIndex($index)
710            ->setBody($body);
711        $endpoint->setParams($params);
712
713        return $this->performRequest($endpoint);
714    }
715
716    /**
717     * $params['index']                = (list) A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
718     *        ['flush']                = (boolean) Specify whether the index should be flushed after performing the operation (default: true)
719     *        ['max_num_segments']     = (number) The number of segments the index should be merged into (default: dynamic)
720     *        ['only_expunge_deletes'] = (boolean) Specify whether the operation should only expunge deleted documents
721     *        ['operation_threading']  = () TODO: ?
722     *        ['refresh']              = (boolean) Specify whether the index should be refreshed after performing the operation (default: true)
723     *        ['wait_for_merge']       = (boolean) Specify whether the request should block until the merge process is finished (default: true)
724     *        ['ignore_unavailable']   = (bool) Whether specified concrete indices should be ignored when unavailable (missing or closed)
725     *        ['allow_no_indices']     = (bool) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
726     *        ['expand_wildcards']     = (enum) Whether to expand wildcard expression to concrete indices that are open, closed or both.
727     *
728     * @return callable|array
729     */
730    public function forceMerge(array $params = [])
731    {
732        $index = $this->extractArgument($params, 'index');
733
734        /**
735 * @var callable $endpointBuilder
736*/
737        $endpointBuilder = $this->endpoints;
738
739        /**
740 * @var \Elasticsearch\Endpoints\Indices\ForceMerge $endpoint
741*/
742        $endpoint = $endpointBuilder('Indices\ForceMerge');
743        $endpoint->setIndex($index);
744        $endpoint->setParams($params);
745
746        return $this->performRequest($endpoint);
747    }
748
749    /**
750     * $params['index']   = (string) The name of the index with an alias (Required)
751     *        ['name']    = (string) The name of the alias to be deleted (Required)
752     *        ['timeout'] = (time) Explicit timestamp for the document
753     *
754     * @return callable|array
755     */
756    public function deleteAlias(array $params)
757    {
758        $index = $this->extractArgument($params, 'index');
759        $name = $this->extractArgument($params, 'name');
760
761        /**
762 * @var callable $endpointBuilder
763*/
764        $endpointBuilder = $this->endpoints;
765
766        /**
767 * @var \Elasticsearch\Endpoints\Indices\Alias\Delete $endpoint
768*/
769        $endpoint = $endpointBuilder('Indices\Alias\Delete');
770        $endpoint->setIndex($index)
771            ->setName($name);
772        $endpoint->setParams($params);
773
774        return $this->performRequest($endpoint);
775    }
776
777    /**
778     * $params['index']   = (string) The name of the index (Required)
779     *        ['timeout'] = (time) Explicit operation timeout
780     *
781     * @return callable|array
782     */
783    public function open(array $params)
784    {
785        $index = $this->extractArgument($params, 'index');
786
787        /**
788 * @var callable $endpointBuilder
789*/
790        $endpointBuilder = $this->endpoints;
791
792        /**
793 * @var \Elasticsearch\Endpoints\Indices\Open $endpoint
794*/
795        $endpoint = $endpointBuilder('Indices\Open');
796        $endpoint->setIndex($index);
797        $endpoint->setParams($params);
798
799        return $this->performRequest($endpoint);
800    }
801
802    /**
803     * $params['index']        = (string) The name of the index to scope the operation
804     *        ['analyzer']     = (string) The name of the analyzer to use
805     *        ['field']        = (string) Use the analyzer configured for this field (instead of passing the analyzer name)
806     *        ['filter']       = (list) A comma-separated list of filters to use for the analysis
807     *        ['prefer_local'] = (boolean) With `true`, specify that a local shard should be used if available, with `false`, use a random shard (default: true)
808     *        ['text']         = (string) The text on which the analysis should be performed (when request body is not used)
809     *        ['tokenizer']    = (string) The name of the tokenizer to use for the analysis
810     *        ['format']       = (enum) Format of the output
811     *        ['body']         = (enum) Format of the output
812     *        ['char_filter']  = (list) A comma-separated list of character filters to use for the analysis
813     *        ['explain']      = (bool) With `true`, outputs more advanced details. (default: false)
814     *        ['attributes']   = (list) A comma-separated list of token attributes to output, this parameter works only with `explain=true`
815     *        ['format']       = (enum) Format of the output (["detailed", "text"])
816     *
817     * @return callable|array
818     */
819    public function analyze(array $params = [])
820    {
821        $index = $this->extractArgument($params, 'index');
822
823        $body = $this->extractArgument($params, 'body');
824
825        /**
826 * @var callable $endpointBuilder
827*/
828        $endpointBuilder = $this->endpoints;
829
830        /**
831 * @var \Elasticsearch\Endpoints\Indices\Analyze $endpoint
832*/
833        $endpoint = $endpointBuilder('Indices\Analyze');
834        $endpoint->setIndex($index)
835            ->setBody($body);
836        $endpoint->setParams($params);
837
838        return $this->performRequest($endpoint);
839    }
840
841    /**
842     * $params['index']              = (list) A comma-separated list of index name to limit the operation
843     *        ['field_data']         = (boolean) Clear field data
844     *        ['fielddata']          = (boolean) Clear field data
845     *        ['fields']             = (list) A comma-separated list of fields to clear when using the `field_data` parameter (default: all)
846     *        ['filter']             = (boolean) Clear filter caches
847     *        ['filter_cache']       = (boolean) Clear filter caches
848     *        ['filter_keys']        = (boolean) A comma-separated list of keys to clear when using the `filter_cache` parameter (default: all)
849     *        ['id']                 = (boolean) Clear ID caches for parent/child
850     *        ['id_cache']           = (boolean) Clear ID caches for parent/child
851     *        ['recycler']           = (boolean) Clear the recycler cache
852     *        ['ignore_unavailable'] = (bool) Whether specified concrete indices should be ignored when unavailable (missing or closed)
853     *        ['allow_no_indices']   = (bool) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
854     *        ['expand_wildcards']   = (enum) Whether to expand wildcard expression to concrete indices that are open, closed or both.
855     *
856     * @return callable|array
857     */
858    public function clearCache(array $params = [])
859    {
860        $index = $this->extractArgument($params, 'index');
861
862        /**
863 * @var callable $endpointBuilder
864*/
865        $endpointBuilder = $this->endpoints;
866
867        /**
868 * @var \Elasticsearch\Endpoints\Indices\Cache\Clear $endpoint
869*/
870        $endpoint = $endpointBuilder('Indices\Cache\Clear');
871        $endpoint->setIndex($index);
872        $endpoint->setParams($params);
873
874        return $this->performRequest($endpoint);
875    }
876
877    /**
878     * $params['index']   = (list) A comma-separated list of index names to filter aliases
879     *        ['timeout'] = (time) Explicit timestamp for the document
880     *        ['body']    = (time) Explicit timestamp for the document
881     *
882     * @return callable|array
883     */
884    public function updateAliases(array $params = [])
885    {
886        $index = $this->extractArgument($params, 'index');
887        $body = $this->extractArgument($params, 'body');
888
889        /**
890 * @var callable $endpointBuilder
891*/
892        $endpointBuilder = $this->endpoints;
893
894        /**
895 * @var \Elasticsearch\Endpoints\Indices\Aliases\Update $endpoint
896*/
897        $endpoint = $endpointBuilder('Indices\Aliases\Update');
898        $endpoint->setIndex($index)
899            ->setBody($body);
900        $endpoint->setParams($params);
901
902        return $this->performRequest($endpoint);
903    }
904
905    /**
906     * $params['local']   = (bool) Return local information, do not retrieve the state from master node (default: false)
907     *        ['timeout'] = (time) Explicit timestamp for the document
908     *
909     * @return callable|array
910     */
911    public function getAliases(array $params = [])
912    {
913        $index = $this->extractArgument($params, 'index');
914        $name = $this->extractArgument($params, 'name');
915
916        /**
917 * @var callable $endpointBuilder
918*/
919        $endpointBuilder = $this->endpoints;
920
921        /**
922 * @var \Elasticsearch\Endpoints\Indices\Alias\Get $endpoint
923*/
924        $endpoint = $endpointBuilder('Indices\Alias\Get');
925        $endpoint->setIndex($index)
926            ->setName($name);
927        $endpoint->setParams($params);
928
929        return $this->performRequest($endpoint);
930    }
931
932    /**
933     * $params['name']               = (list) A comma-separated list of alias names to return (Required)
934     *        ['index']              = (list) A comma-separated list of index names to filter aliases
935     *        ['ignore_unavailable'] = (bool) Whether specified concrete indices should be ignored when unavailable (missing or closed)
936     *        ['allow_no_indices']   = (bool) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
937     *        ['expand_wildcards']   = (enum) Whether to expand wildcard expression to concrete indices that are open, closed or both.
938     */
939    public function existsAlias(array $params): bool
940    {
941        $index = $this->extractArgument($params, 'index');
942        $name = $this->extractArgument($params, 'name');
943
944        // manually make this verbose so we can check status code
945        $params['client']['verbose'] = true;
946
947        /**
948 * @var callable $endpointBuilder
949*/
950        $endpointBuilder = $this->endpoints;
951
952        /**
953 * @var \Elasticsearch\Endpoints\Indices\Alias\Exists $endpoint
954*/
955        $endpoint = $endpointBuilder('Indices\Alias\Exists');
956        $endpoint->setIndex($index)
957            ->setName($name);
958        $endpoint->setParams($params);
959
960        return BooleanRequestWrapper::performRequest($endpoint, $this->transport);
961    }
962
963    /**
964     * $params['index'] = (list) A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
965     *
966     * @return callable|array
967     */
968    public function getSettings(array $params = [])
969    {
970        $index = $this->extractArgument($params, 'index');
971
972        $name = $this->extractArgument($params, 'name');
973
974        /**
975 * @var callable $endpointBuilder
976*/
977        $endpointBuilder = $this->endpoints;
978
979        /**
980 * @var \Elasticsearch\Endpoints\Indices\Settings\Get $endpoint
981*/
982        $endpoint = $endpointBuilder('Indices\Settings\Get');
983        $endpoint->setIndex($index)
984            ->setName($name);
985        $endpoint->setParams($params);
986
987        return $this->performRequest($endpoint);
988    }
989
990    /**
991     * $params['index']   = (string) The name of the index (Required)
992     *        ['timeout'] = (time) Explicit operation timeout
993     *
994     * @return callable|array
995     */
996    public function close(array $params)
997    {
998        $index = $this->extractArgument($params, 'index');
999
1000        /**
1001 * @var callable $endpointBuilder
1002*/
1003        $endpointBuilder = $this->endpoints;
1004
1005        /**
1006 * @var \Elasticsearch\Endpoints\Indices\Close $endpoint
1007*/
1008        $endpoint = $endpointBuilder('Indices\Close');
1009        $endpoint->setIndex($index);
1010        $endpoint->setParams($params);
1011
1012        return $this->performRequest($endpoint);
1013    }
1014
1015    /**
1016     * $params['index']              = (list) A comma-separated list of index names; use `_all` or empty string for all indices
1017     *        ['wait_for_completion']= (boolean) Specify whether the request should block until the all segments are upgraded (default: false)
1018     *        ['only_ancient_segments'] = (boolean) If true, only ancient (an older Lucene major release) segments will be upgraded
1019     *        ['refresh']            = (boolean) Refresh the index after performing the operation
1020     *        ['ignore_unavailable'] = (bool) Whether specified concrete indices should be ignored when unavailable (missing or closed)
1021     *        ['allow_no_indices']   = (bool) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
1022     *        ['expand_wildcards']   = (enum) Whether to expand wildcard expression to concrete indices that are open, closed or both.
1023     *
1024     * @return callable|array
1025     */
1026    public function upgrade(array $params = [])
1027    {
1028        $index = $this->extractArgument($params, 'index');
1029
1030        /**
1031 * @var callable $endpointBuilder
1032*/
1033        $endpointBuilder = $this->endpoints;
1034
1035        /**
1036 * @var \Elasticsearch\Endpoints\Indices\Upgrade\Post $endpoint
1037*/
1038        $endpoint = $endpointBuilder('Indices\Upgrade\Post');
1039        $endpoint->setIndex($index);
1040        $endpoint->setParams($params);
1041
1042        return $this->performRequest($endpoint);
1043    }
1044
1045    /**
1046     * $params['index']              = (list) A comma-separated list of index names; use `_all` or empty string for all indices
1047     *        ['wait_for_completion']= (boolean) Specify whether the request should block until the all segments are upgraded (default: false)
1048     *        ['only_ancient_segments'] = (boolean) If true, only ancient (an older Lucene major release) segments will be upgraded
1049     *        ['refresh']            = (boolean) Refresh the index after performing the operation
1050     *        ['ignore_unavailable'] = (bool) Whether specified concrete indices should be ignored when unavailable (missing or closed)
1051     *        ['allow_no_indices']   = (bool) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
1052     *        ['expand_wildcards']   = (enum) Whether to expand wildcard expression to concrete indices that are open, closed or both.
1053     *
1054     * @return callable|array
1055     */
1056    public function getUpgrade(array $params = [])
1057    {
1058        $index = $this->extractArgument($params, 'index');
1059
1060        /**
1061 * @var callable $endpointBuilder
1062*/
1063        $endpointBuilder = $this->endpoints;
1064
1065        /**
1066 * @var \Elasticsearch\Endpoints\Indices\Upgrade\Get $endpoint
1067*/
1068        $endpoint = $endpointBuilder('Indices\Upgrade\Get');
1069        $endpoint->setIndex($index);
1070        $endpoint->setParams($params);
1071
1072        return $this->performRequest($endpoint);
1073    }
1074
1075    /**
1076     * $params['index']   = (string) A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
1077     *        ['status']   = (list) A comma-separated list of statuses used to filter on shards to get store information for
1078     *        ['ignore_unavailable'] = (boolean) Whether specified concrete indices should be ignored when unavailable (missing or closed)
1079     *        ['allow_no_indices'] = (boolean) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
1080     *        ['expand_wildcards'] = (boolean) Whether to expand wildcard expression to concrete indices that are open, closed or both.
1081     *        ['operation_threading']
1082     *
1083     * @return callable|array
1084     */
1085    public function shardStores(array $params)
1086    {
1087        $index = $this->extractArgument($params, 'index');
1088
1089        /**
1090 * @var callable $endpointBuilder
1091*/
1092        $endpointBuilder = $this->endpoints;
1093
1094        /**
1095 * @var \Elasticsearch\Endpoints\Indices\ShardStores $endpoint
1096*/
1097        $endpoint = $endpointBuilder('Indices\ShardStores');
1098        $endpoint->setIndex($index);
1099        $endpoint->setParams($params);
1100
1101        return $this->performRequest($endpoint);
1102    }
1103
1104    /**
1105     * $params['newIndex']       = (string) The name of the rollover index
1106     *        ['alias']          = (string) The name of the alias to rollover
1107     *        ['timeout']        = (time) Explicit operation timeout
1108     *        ['master_timeout'] = (time) Specify timeout for connection to master
1109     *
1110     * @return callable|array
1111     */
1112    public function rollover(array $params)
1113    {
1114        $newIndex = $this->extractArgument($params, 'newIndex');
1115        $alias = $this->extractArgument($params, 'alias');
1116        $body = $this->extractArgument($params, 'body');
1117
1118        /**
1119 * @var callable $endpointBuilder
1120*/
1121        $endpointBuilder = $this->endpoints;
1122
1123        /**
1124 * @var \Elasticsearch\Endpoints\Indices\Rollover $endpoint
1125*/
1126        $endpoint = $endpointBuilder('Indices\Rollover');
1127        $endpoint->setNewIndex($newIndex)
1128            ->setAlias($alias)
1129            ->setParams($params)
1130            ->setBody($body);
1131
1132        return $this->performRequest($endpoint);
1133    }
1134
1135    /**
1136     * $params['index'] = (string) The name of the source index to split
1137     *        ['target']  = (string) The name of the target index to split into
1138     *        ['copy_settings']  = (boolean) whether or not to copy settings from the source index (defaults to false)
1139     *        ['timeout']  = (time) Explicit operation timeout
1140     *        ['master_timeout']  = (time) Specify timeout for connection to master
1141     *        ['wait_for_active_shards']  = (string) Set the number of active shards to wait for on the shrunken index before the operation returns.
1142     *
1143     * @return callable|array
1144     */
1145    public function split(array $params = [])
1146    {
1147        $index = $this->extractArgument($params, 'index');
1148        $body = $this->extractArgument($params, 'body');
1149        $target = $this->extractArgument($params, 'target');
1150
1151        /**
1152 * @var callable $endpointBuilder
1153*/
1154        $endpointBuilder = $this->endpoints;
1155
1156        /**
1157 * @var \Elasticsearch\Endpoints\Indices\Split $endpoint
1158*/
1159        $endpoint = $endpointBuilder('Indices\Split');
1160        $endpoint->setIndex($index)
1161            ->setBody($body)
1162            ->setTarget($target);
1163        $endpoint->setParams($params);
1164
1165        return $this->performRequest($endpoint);
1166    }
1167}
1168