<?php

declare(strict_types=1);

/**
 * Copyright OpenSearch Contributors
 * SPDX-License-Identifier: Apache-2.0
 *
 * OpenSearch PHP client
 *
 * @link      https://github.com/opensearch-project/opensearch-php/
 * @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
 * @license   http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
 * @license   https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
 *
 * Licensed to Elasticsearch B.V under one or more agreements.
 * Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
 * the GNU Lesser General Public License, Version 2.1, at your option.
 * See the LICENSE file in the project root for more information.
 */

namespace OpenSearch\Namespaces;

use OpenSearch\Endpoints\Indices\AddBlock;
use OpenSearch\Endpoints\Indices\Analyze;
use OpenSearch\Endpoints\Indices\ClearCache;
use OpenSearch\Endpoints\Indices\CloneIndices;
use OpenSearch\Endpoints\Indices\Close;
use OpenSearch\Endpoints\Indices\Create;
use OpenSearch\Endpoints\Indices\CreateDataStream;
use OpenSearch\Endpoints\Indices\DataStreamsStats;
use OpenSearch\Endpoints\Indices\Delete;
use OpenSearch\Endpoints\Indices\DeleteAlias;
use OpenSearch\Endpoints\Indices\DeleteDataStream;
use OpenSearch\Endpoints\Indices\DeleteIndexTemplate;
use OpenSearch\Endpoints\Indices\DeleteTemplate;
use OpenSearch\Endpoints\Indices\Exists;
use OpenSearch\Endpoints\Indices\ExistsAlias;
use OpenSearch\Endpoints\Indices\ExistsIndexTemplate;
use OpenSearch\Endpoints\Indices\ExistsTemplate;
use OpenSearch\Endpoints\Indices\Flush;
use OpenSearch\Endpoints\Indices\ForceMerge;
use OpenSearch\Endpoints\Indices\Get;
use OpenSearch\Endpoints\Indices\GetAlias;
use OpenSearch\Endpoints\Indices\GetDataStream;
use OpenSearch\Endpoints\Indices\GetFieldMapping;
use OpenSearch\Endpoints\Indices\GetIndexTemplate;
use OpenSearch\Endpoints\Indices\GetMapping;
use OpenSearch\Endpoints\Indices\GetSettings;
use OpenSearch\Endpoints\Indices\GetTemplate;
use OpenSearch\Endpoints\Indices\GetUpgrade;
use OpenSearch\Endpoints\Indices\Open;
use OpenSearch\Endpoints\Indices\PutAlias;
use OpenSearch\Endpoints\Indices\PutIndexTemplate;
use OpenSearch\Endpoints\Indices\PutMapping;
use OpenSearch\Endpoints\Indices\PutSettings;
use OpenSearch\Endpoints\Indices\PutTemplate;
use OpenSearch\Endpoints\Indices\Recovery;
use OpenSearch\Endpoints\Indices\Refresh;
use OpenSearch\Endpoints\Indices\RefreshSearchAnalyzers;
use OpenSearch\Endpoints\Indices\ResolveIndex;
use OpenSearch\Endpoints\Indices\Rollover;
use OpenSearch\Endpoints\Indices\Segments;
use OpenSearch\Endpoints\Indices\ShardStores;
use OpenSearch\Endpoints\Indices\Shrink;
use OpenSearch\Endpoints\Indices\SimulateIndexTemplate;
use OpenSearch\Endpoints\Indices\SimulateTemplate;
use OpenSearch\Endpoints\Indices\Split;
use OpenSearch\Endpoints\Indices\Stats;
use OpenSearch\Endpoints\Indices\UpdateAliases;
use OpenSearch\Endpoints\Indices\Upgrade;
use OpenSearch\Endpoints\Indices\ValidateQuery;

/**
 * Class IndicesNamespace
 *
 * NOTE: This file is autogenerated using util/GenerateEndpoints.php
 */
class IndicesNamespace extends AbstractNamespace
{
    /**
     * Adds a block to an index.
     *
     * @param array{block?: string, index?: mixed, allow_no_indices?: bool, cluster_manager_timeout?: string, expand_wildcards?: mixed, ignore_unavailable?: bool, master_timeout?: string, timeout?: string, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - block: The block to add (one of `read`, `write`, `read_only` or `metadata`).
     * - index: A comma separated list of indexes to add a block to.
     * - allow_no_indices: Whether to ignore if a wildcard indexes expression resolves into no concrete indexes. (This includes `_all` string or when no indexes have been specified).
     * - cluster_manager_timeout: Operation timeout for connection to cluster-manager node.
     * - expand_wildcards: Whether to expand wildcard expression to concrete indexes that are open, closed or both.
     * - ignore_unavailable: Whether specified concrete indexes should be ignored when unavailable (missing or closed).
     * - master_timeout: Specify timeout for connection to cluster manager.
     * - timeout: Explicit operation timeout
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return array
     */
    public function addBlock(array $params = [])
    {
        $block = $this->extractArgument($params, 'block');
        $index = $this->extractArgument($params, 'index');

        $endpoint = $this->endpointFactory->getEndpoint(AddBlock::class);
        $endpoint->setParams($params);
        $endpoint->setBlock($block);
        $endpoint->setIndex($index);

        return $this->performRequest($endpoint);
    }

    /**
     * Performs the analysis process on a text and return the tokens breakdown of the text.
     *
     * @param array{index?: string, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed, body?: mixed} $params
     * - index: The name of the index to scope the operation.
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * - body: Define analyzer/tokenizer parameters and the text on which the analysis should be performed
     * @return array
     */
    public function analyze(array $params = [])
    {
        $index = $this->extractArgument($params, 'index');
        $body = $this->extractArgument($params, 'body');

        $endpoint = $this->endpointFactory->getEndpoint(Analyze::class);
        $endpoint->setParams($params);
        $endpoint->setIndex($index);
        $endpoint->setBody($body);

        return $this->performRequest($endpoint);
    }

    /**
     * Clears all or specific caches for one or more indexes.
     *
     * @param array{index?: mixed, allow_no_indices?: bool, expand_wildcards?: mixed, fielddata?: bool, fields?: mixed, file?: bool, ignore_unavailable?: bool, query?: bool, request?: bool, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - index: A comma-separated list of indexes; use `_all` or empty string to perform the operation on all indexes.
     * - allow_no_indices: If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes.
     * - expand_wildcards: Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`.
     * - fielddata: If `true`, clears the fields cache. Use the `fields` parameter to clear the cache of specific fields only.
     * - fields: A comma-separated list of field names used to limit the `fielddata` parameter.
     * - file: If `true`, clears the unused entries from the file cache on nodes with the Search role. (Default: false)
     * - ignore_unavailable: If `false`, the request returns an error if it targets a missing or closed index.
     * - query: If `true`, clears the query cache.
     * - request: If `true`, clears the request cache.
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return array
     */
    public function clearCache(array $params = [])
    {
        $index = $this->extractArgument($params, 'index');

        $endpoint = $this->endpointFactory->getEndpoint(ClearCache::class);
        $endpoint->setParams($params);
        $endpoint->setIndex($index);

        return $this->performRequest($endpoint);
    }

    /**
     * Clones an index.
     *
     * @param array{index?: string, target?: string, cluster_manager_timeout?: string, master_timeout?: string, task_execution_timeout?: string, timeout?: string, wait_for_active_shards?: mixed, wait_for_completion?: bool, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed, body?: mixed} $params
     * - index: Name of the source index to clone.
     * - target: Name of the target index to create.
     * - cluster_manager_timeout: Operation timeout for connection to cluster-manager node.
     * - master_timeout: Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error.
     * - task_execution_timeout: Explicit task execution timeout, only useful when `wait_for_completion` is false, defaults to `1h`.
     * - timeout: Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.
     * - wait_for_active_shards: The number of shard copies that must be active before proceeding with the operation. Set to `all` or any positive integer up to the total number of shards in the index (`number_of_replicas+1`).
     * - wait_for_completion: Should this request wait until the operation has completed before returning. (Default: true)
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * - body: The configuration for the target index (`settings` and `aliases`)
     * @return array
     */
    public function clone(array $params = [])
    {
        $index = $this->extractArgument($params, 'index');
        $target = $this->extractArgument($params, 'target');
        $body = $this->extractArgument($params, 'body');

        $endpoint = $this->endpointFactory->getEndpoint(CloneIndices::class);
        $endpoint->setParams($params);
        $endpoint->setIndex($index);
        $endpoint->setTarget($target);
        $endpoint->setBody($body);

        return $this->performRequest($endpoint);
    }

    /**
     * Closes an index.
     *
     * @param array{index?: mixed, allow_no_indices?: bool, cluster_manager_timeout?: string, expand_wildcards?: mixed, ignore_unavailable?: bool, master_timeout?: string, timeout?: string, wait_for_active_shards?: mixed, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - index: A comma-separated list or wildcard expression of index names used to limit the request.
     * - allow_no_indices: If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes.
     * - cluster_manager_timeout: Operation timeout for connection to cluster-manager node.
     * - expand_wildcards: Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`.
     * - ignore_unavailable: If `false`, the request returns an error if it targets a missing or closed index.
     * - master_timeout: Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error.
     * - timeout: Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.
     * - wait_for_active_shards: The number of shard copies that must be active before proceeding with the operation. Set to `all` or any positive integer up to the total number of shards in the index (`number_of_replicas+1`).
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return array
     */
    public function close(array $params = [])
    {
        $index = $this->extractArgument($params, 'index');

        $endpoint = $this->endpointFactory->getEndpoint(Close::class);
        $endpoint->setParams($params);
        $endpoint->setIndex($index);

        return $this->performRequest($endpoint);
    }

    /**
     * Creates an index with optional settings and mappings.
     *
     * @param array{index?: string, cluster_manager_timeout?: string, master_timeout?: string, timeout?: string, wait_for_active_shards?: mixed, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed, body?: mixed} $params
     * - index: The name of the index you wish to create.
     * - cluster_manager_timeout: Operation timeout for connection to cluster-manager node.
     * - master_timeout: Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error.
     * - timeout: Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.
     * - wait_for_active_shards: The number of shard copies that must be active before proceeding with the operation. Set to `all` or any positive integer up to the total number of shards in the index (`number_of_replicas+1`).
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * - body: The configuration for the index (`settings` and `mappings`)
     * @return array
     */
    public function create(array $params = [])
    {
        $index = $this->extractArgument($params, 'index');
        $body = $this->extractArgument($params, 'body');

        $endpoint = $this->endpointFactory->getEndpoint(Create::class);
        $endpoint->setParams($params);
        $endpoint->setIndex($index);
        $endpoint->setBody($body);

        return $this->performRequest($endpoint);
    }

    /**
     * Creates or updates a data stream.
     *
     * @param array{name?: string, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed, body?: mixed} $params
     * - name: Name of the data stream, which must meet the following criteria: Lowercase only; Cannot include `\`, `/`, `*`, `?`, `"`, `<`, `>`, `|`, `,`, `#`, `:`, or a space character; Cannot start with `-`, `_`, `+`, or `.ds-`; Cannot be `.` or `..`; Cannot be longer than 255 bytes. Multi-byte characters count towards this limit faster.
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * - body: The data stream definition
     * @return array
     */
    public function createDataStream(array $params = [])
    {
        $name = $this->extractArgument($params, 'name');
        $body = $this->extractArgument($params, 'body');

        $endpoint = $this->endpointFactory->getEndpoint(CreateDataStream::class);
        $endpoint->setParams($params);
        $endpoint->setName($name);
        $endpoint->setBody($body);

        return $this->performRequest($endpoint);
    }

    /**
     * Provides statistics on operations happening in a data stream.
     *
     * @param array{name?: mixed, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - name: A comma-separated list of data streams used to limit the request. Wildcard expressions (`*`) are supported. To target all data streams in a cluster, omit this parameter or use `*`.
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return array
     */
    public function dataStreamsStats(array $params = [])
    {
        $name = $this->extractArgument($params, 'name');

        $endpoint = $this->endpointFactory->getEndpoint(DataStreamsStats::class);
        $endpoint->setParams($params);
        $endpoint->setName($name);

        return $this->performRequest($endpoint);
    }

    /**
     * Deletes an index.
     *
     * @param array{index?: mixed, allow_no_indices?: bool, cluster_manager_timeout?: string, expand_wildcards?: mixed, ignore_unavailable?: bool, master_timeout?: string, timeout?: string, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - index: A comma-separated list of indexes to delete. You cannot specify index aliases. By default, this parameter does not support wildcards (`*`) or `_all`. To use wildcards or `_all`, set the `action.destructive_requires_name` cluster setting to `false`.
     * - allow_no_indices: If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. (Default: false)
     * - cluster_manager_timeout: Operation timeout for connection to cluster-manager node.
     * - expand_wildcards: Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`.
     * - ignore_unavailable: If `false`, the request returns an error if it targets a missing or closed index. (Default: false)
     * - master_timeout: Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error.
     * - timeout: Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return array
     */
    public function delete(array $params = [])
    {
        $index = $this->extractArgument($params, 'index');

        $endpoint = $this->endpointFactory->getEndpoint(Delete::class);
        $endpoint->setParams($params);
        $endpoint->setIndex($index);

        return $this->performRequest($endpoint);
    }

    /**
     * Deletes an alias.
     *
     * @param array{index?: mixed, name?: mixed, cluster_manager_timeout?: string, master_timeout?: string, timeout?: string, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - index: A comma-separated list of data streams or indexes used to limit the request. Supports wildcards (`*`).
     * - name: A comma-separated list of aliases to remove. Supports wildcards (`*`). To remove all aliases, use `*` or `_all`.
     * - cluster_manager_timeout: Operation timeout for connection to cluster-manager node.
     * - master_timeout: Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error.
     * - timeout: Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return array
     */
    public function deleteAlias(array $params = [])
    {
        $index = $this->extractArgument($params, 'index');
        $name = $this->extractArgument($params, 'name');

        $endpoint = $this->endpointFactory->getEndpoint(DeleteAlias::class);
        $endpoint->setParams($params);
        $endpoint->setIndex($index);
        $endpoint->setName($name);

        return $this->performRequest($endpoint);
    }

    /**
     * Deletes a data stream.
     *
     * @param array{name?: mixed, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - name: A comma-separated list of data streams to delete. Wildcard (`*`) expressions are supported.
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return array
     */
    public function deleteDataStream(array $params = [])
    {
        $name = $this->extractArgument($params, 'name');

        $endpoint = $this->endpointFactory->getEndpoint(DeleteDataStream::class);
        $endpoint->setParams($params);
        $endpoint->setName($name);

        return $this->performRequest($endpoint);
    }

    /**
     * Deletes an index template.
     *
     * @param array{name?: string, cluster_manager_timeout?: string, master_timeout?: string, timeout?: string, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - name: The name of the index template to delete. Wildcard (*) expressions are supported.
     * - cluster_manager_timeout: Operation timeout for connection to cluster-manager node.
     * - master_timeout: Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error.
     * - timeout: Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return array
     */
    public function deleteIndexTemplate(array $params = [])
    {
        $name = $this->extractArgument($params, 'name');

        $endpoint = $this->endpointFactory->getEndpoint(DeleteIndexTemplate::class);
        $endpoint->setParams($params);
        $endpoint->setName($name);

        return $this->performRequest($endpoint);
    }

    /**
     * Deletes an index template.
     *
     * @param array{name?: string, cluster_manager_timeout?: string, master_timeout?: string, timeout?: string, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - name: The name of the legacy index template to delete. Wildcard (`*`) expressions are supported.
     * - cluster_manager_timeout: Operation timeout for connection to cluster-manager node.
     * - master_timeout: Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error.
     * - timeout: Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return array
     */
    public function deleteTemplate(array $params = [])
    {
        $name = $this->extractArgument($params, 'name');

        $endpoint = $this->endpointFactory->getEndpoint(DeleteTemplate::class);
        $endpoint->setParams($params);
        $endpoint->setName($name);

        return $this->performRequest($endpoint);
    }

    /**
     * Returns information about whether a particular index exists.
     *
     * @param array{index?: mixed, allow_no_indices?: bool, cluster_manager_timeout?: string, expand_wildcards?: mixed, flat_settings?: bool, ignore_unavailable?: bool, include_defaults?: bool, local?: bool, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - index: A comma-separated list of data streams, indexes, and aliases. Supports wildcards (`*`).
     * - allow_no_indices: If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. (Default: false)
     * - cluster_manager_timeout: Operation timeout for connection to cluster-manager node.
     * - expand_wildcards: Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`.
     * - flat_settings: If `true`, returns settings in flat format. (Default: false)
     * - ignore_unavailable: If `false`, the request returns an error if it targets a missing or closed index. (Default: false)
     * - include_defaults: If `true`, return all default settings in the response. (Default: false)
     * - local: If `true`, the request retrieves information from the local node only. (Default: false)
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return bool
     */
    public function exists(array $params = []): bool
    {
        $index = $this->extractArgument($params, 'index');
        // Legacy option to manually make this verbose so we can check status code.
        // @todo remove in 3.0.0
        $params['client']['verbose'] = true;

        $endpoint = $this->endpointFactory->getEndpoint(Exists::class);
        $endpoint->setParams($params);
        $endpoint->setIndex($index);

        return BooleanRequestWrapper::sendRequest($endpoint, $this->httpTransport);
    }

    /**
     * Returns information about whether a particular alias exists.
     *
     * @param array{name?: mixed, index?: mixed, allow_no_indices?: bool, expand_wildcards?: mixed, ignore_unavailable?: bool, local?: bool, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - name: A comma-separated list of aliases to check. Supports wildcards (`*`).
     * - index: A comma-separated list of data streams or indexes used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`.
     * - allow_no_indices: If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes.
     * - expand_wildcards: Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`.
     * - ignore_unavailable: If `false`, requests that include a missing data stream or index in the target indexes or data streams return an error.
     * - local: If `true`, the request retrieves information from the local node only. (Default: false)
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return bool
     */
    public function existsAlias(array $params = []): bool
    {
        $name = $this->extractArgument($params, 'name');
        $index = $this->extractArgument($params, 'index');
        // Legacy option to manually make this verbose so we can check status code.
        // @todo remove in 3.0.0
        $params['client']['verbose'] = true;

        $endpoint = $this->endpointFactory->getEndpoint(ExistsAlias::class);
        $endpoint->setParams($params);
        $endpoint->setName($name);
        $endpoint->setIndex($index);

        return BooleanRequestWrapper::sendRequest($endpoint, $this->httpTransport);
    }

    /**
     * Returns information about whether a particular index template exists.
     *
     * @param array{name?: string, cluster_manager_timeout?: string, flat_settings?: bool, local?: bool, master_timeout?: string, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - name: The name of the index template to check existence of. Wildcard (*) expressions are supported.
     * - cluster_manager_timeout: Operation timeout for connection to cluster-manager node.
     * - flat_settings: Return settings in flat format. (Default: false)
     * - local: Return local information, do not retrieve the state from cluster-manager node. (Default: false)
     * - master_timeout: Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error.
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return bool
     */
    public function existsIndexTemplate(array $params = []): bool
    {
        $name = $this->extractArgument($params, 'name');
        // Legacy option to manually make this verbose so we can check status code.
        // @todo remove in 3.0.0
        $params['client']['verbose'] = true;

        $endpoint = $this->endpointFactory->getEndpoint(ExistsIndexTemplate::class);
        $endpoint->setParams($params);
        $endpoint->setName($name);

        return BooleanRequestWrapper::sendRequest($endpoint, $this->httpTransport);
    }

    /**
     * Returns information about whether a particular index template exists.
     *
     * @param array{name?: mixed, cluster_manager_timeout?: string, flat_settings?: bool, local?: bool, master_timeout?: string, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - name: The comma separated names of the index templates
     * - cluster_manager_timeout: Operation timeout for connection to cluster-manager node.
     * - flat_settings: Return settings in flat format. (Default: false)
     * - local: Return local information, do not retrieve the state from cluster-manager node. (Default: false)
     * - master_timeout: Explicit operation timeout for connection to cluster-manager node
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return bool
     */
    public function existsTemplate(array $params = []): bool
    {
        $name = $this->extractArgument($params, 'name');
        // Legacy option to manually make this verbose so we can check status code.
        // @todo remove in 3.0.0
        $params['client']['verbose'] = true;

        $endpoint = $this->endpointFactory->getEndpoint(ExistsTemplate::class);
        $endpoint->setParams($params);
        $endpoint->setName($name);

        return BooleanRequestWrapper::sendRequest($endpoint, $this->httpTransport);
    }

    /**
     * Performs the flush operation on one or more indexes.
     *
     * @param array{index?: mixed, allow_no_indices?: bool, expand_wildcards?: mixed, force?: bool, ignore_unavailable?: bool, wait_if_ongoing?: bool, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - index: A comma-separated list of data streams, indexes, and aliases to flush. Supports wildcards (`*`). To flush all data streams and indexes, omit this parameter or use `*` or `_all`.
     * - allow_no_indices: If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes.
     * - expand_wildcards: Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`.
     * - force: If `true`, the request forces a flush even if there are no changes to commit to the index.
     * - ignore_unavailable: If `false`, the request returns an error if it targets a missing or closed index.
     * - wait_if_ongoing: If `true`, the flush operation blocks until execution when another flush operation is running. If `false`, OpenSearch returns an error if you request a flush when another flush operation is running. (Default: true)
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return array
     */
    public function flush(array $params = [])
    {
        $index = $this->extractArgument($params, 'index');

        $endpoint = $this->endpointFactory->getEndpoint(Flush::class);
        $endpoint->setParams($params);
        $endpoint->setIndex($index);

        return $this->performRequest($endpoint);
    }

    /**
     * Performs the force merge operation on one or more indexes.
     *
     * @param array{index?: mixed, allow_no_indices?: bool, expand_wildcards?: mixed, flush?: bool, ignore_unavailable?: bool, max_num_segments?: int, only_expunge_deletes?: bool, primary_only?: bool, wait_for_completion?: bool, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - index: A comma-separated list of index names; use `_all` or empty string to perform the operation on all indexes
     * - allow_no_indices: Whether to ignore if a wildcard indexes expression resolves into no concrete indexes. (This includes `_all` string or when no indexes have been specified)
     * - expand_wildcards: Whether to expand wildcard expression to concrete indexes that are open, closed or both.
     * - flush: Specify whether the index should be flushed after performing the operation. (Default: true)
     * - ignore_unavailable: Whether specified concrete indexes should be ignored when unavailable (missing or closed)
     * - max_num_segments: The number of larger segments into which smaller segments are merged. Set this parameter to 1 to merge all segments into one segment. The default behavior is to perform the merge as necessary.
     * - only_expunge_deletes: Specify whether the operation should only expunge deleted documents
     * - primary_only: Specify whether the operation should only perform on primary shards. Defaults to false. (Default: false)
     * - wait_for_completion: Should the request wait until the force merge is completed. (Default: true)
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return array
     */
    public function forcemerge(array $params = [])
    {
        $index = $this->extractArgument($params, 'index');

        $endpoint = $this->endpointFactory->getEndpoint(ForceMerge::class);
        $endpoint->setParams($params);
        $endpoint->setIndex($index);

        return $this->performRequest($endpoint);
    }

    /**
     * Returns information about one or more indexes.
     *
     * @param array{index?: mixed, allow_no_indices?: bool, cluster_manager_timeout?: string, expand_wildcards?: mixed, flat_settings?: bool, ignore_unavailable?: bool, include_defaults?: bool, local?: bool, master_timeout?: string, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - index: A comma-separated list of data streams, indexes, and index aliases used to limit the request. Wildcard expressions (*) are supported.
     * - allow_no_indices: If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. For example, a request targeting foo*,bar* returns an error if an index starts with foo but no index starts with bar. (Default: false)
     * - cluster_manager_timeout: Operation timeout for connection to cluster-manager node.
     * - expand_wildcards: Type of index that wildcard expressions can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`.
     * - flat_settings: If `true`, returns settings in flat format. (Default: false)
     * - ignore_unavailable: If `false`, requests that target a missing index return an error. (Default: false)
     * - include_defaults: If `true`, return all default settings in the response. (Default: false)
     * - local: If `true`, the request retrieves information from the local node only. Defaults to false, which means information is retrieved from the cluster-manager node. (Default: false)
     * - master_timeout: Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error.
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return array
     */
    public function get(array $params = [])
    {
        $index = $this->extractArgument($params, 'index');

        $endpoint = $this->endpointFactory->getEndpoint(Get::class);
        $endpoint->setParams($params);
        $endpoint->setIndex($index);

        return $this->performRequest($endpoint);
    }

    /**
     * Returns an alias.
     *
     * @param array{name?: mixed, index?: mixed, allow_no_indices?: bool, expand_wildcards?: mixed, ignore_unavailable?: bool, local?: bool, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - name: A comma-separated list of aliases to retrieve. Supports wildcards (`*`). To retrieve all aliases, omit this parameter or use `*` or `_all`.
     * - index: A comma-separated list of data streams or indexes used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`.
     * - allow_no_indices: If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes.
     * - expand_wildcards: Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`.
     * - ignore_unavailable: If `false`, the request returns an error if it targets a missing or closed index.
     * - local: If `true`, the request retrieves information from the local node only. (Default: false)
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return array
     */
    public function getAlias(array $params = [])
    {
        $name = $this->extractArgument($params, 'name');
        $index = $this->extractArgument($params, 'index');

        $endpoint = $this->endpointFactory->getEndpoint(GetAlias::class);
        $endpoint->setParams($params);
        $endpoint->setName($name);
        $endpoint->setIndex($index);

        return $this->performRequest($endpoint);
    }

    /**
     * Returns data streams.
     *
     * @param array{name?: mixed, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - name: A comma-separated list of data stream names used to limit the request. Wildcard (`*`) expressions are supported. If omitted, all data streams are returned.
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return array
     */
    public function getDataStream(array $params = [])
    {
        $name = $this->extractArgument($params, 'name');

        $endpoint = $this->endpointFactory->getEndpoint(GetDataStream::class);
        $endpoint->setParams($params);
        $endpoint->setName($name);

        return $this->performRequest($endpoint);
    }

    /**
     * Returns mapping for one or more fields.
     *
     * @param array{fields?: mixed, index?: mixed, allow_no_indices?: bool, expand_wildcards?: mixed, ignore_unavailable?: bool, include_defaults?: bool, local?: bool, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - fields: A comma-separated list or wildcard expression of fields used to limit returned information.
     * - index: A comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`.
     * - allow_no_indices: If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes.
     * - expand_wildcards: Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`.
     * - ignore_unavailable: If `false`, the request returns an error if it targets a missing or closed index.
     * - include_defaults: If `true`, return all default settings in the response.
     * - local: If `true`, the request retrieves information from the local node only. (Default: false)
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return array
     */
    public function getFieldMapping(array $params = [])
    {
        $fields = $this->extractArgument($params, 'fields');
        $index = $this->extractArgument($params, 'index');

        $endpoint = $this->endpointFactory->getEndpoint(GetFieldMapping::class);
        $endpoint->setParams($params);
        $endpoint->setFields($fields);
        $endpoint->setIndex($index);

        return $this->performRequest($endpoint);
    }

    /**
     * Returns an index template.
     *
     * @param array{name?: mixed, cluster_manager_timeout?: string, flat_settings?: bool, local?: bool, master_timeout?: string, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - name: The name of the index template to retrieve. Wildcard (*) expressions are supported.
     * - cluster_manager_timeout: Operation timeout for connection to cluster-manager node.
     * - flat_settings: If `true`, returns settings in flat format. (Default: false)
     * - local: If `true`, the request retrieves information from the local node only. Defaults to false, which means information is retrieved from the cluster-manager node. (Default: false)
     * - master_timeout: Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error.
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return array
     */
    public function getIndexTemplate(array $params = [])
    {
        $name = $this->extractArgument($params, 'name');

        $endpoint = $this->endpointFactory->getEndpoint(GetIndexTemplate::class);
        $endpoint->setParams($params);
        $endpoint->setName($name);

        return $this->performRequest($endpoint);
    }

    /**
     * Returns mappings for one or more indexes.
     *
     * @param array{index?: mixed, allow_no_indices?: bool, cluster_manager_timeout?: string, expand_wildcards?: mixed, ignore_unavailable?: bool, local?: bool, master_timeout?: string, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - index: A comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`.
     * - allow_no_indices: If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes.
     * - cluster_manager_timeout: Operation timeout for connection to cluster-manager node.
     * - expand_wildcards: Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`.
     * - ignore_unavailable: If `false`, the request returns an error if it targets a missing or closed index.
     * - local: If `true`, the request retrieves information from the local node only. (Default: false)
     * - master_timeout: Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error.
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return array
     */
    public function getMapping(array $params = [])
    {
        $index = $this->extractArgument($params, 'index');

        $endpoint = $this->endpointFactory->getEndpoint(GetMapping::class);
        $endpoint->setParams($params);
        $endpoint->setIndex($index);

        return $this->performRequest($endpoint);
    }

    /**
     * Returns settings for one or more indexes.
     *
     * @param array{name?: mixed, index?: mixed, allow_no_indices?: bool, cluster_manager_timeout?: string, expand_wildcards?: mixed, flat_settings?: bool, ignore_unavailable?: bool, include_defaults?: bool, local?: bool, master_timeout?: string, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - name: A comma-separated list or wildcard expression of settings to retrieve.
     * - index: A comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`.
     * - allow_no_indices: If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. For example, a request targeting `foo*,bar*` returns an error if an index starts with foo but no index starts with `bar`.
     * - cluster_manager_timeout: Operation timeout for connection to cluster-manager node.
     * - expand_wildcards: Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`.
     * - flat_settings: If `true`, returns settings in flat format. (Default: false)
     * - ignore_unavailable: If `false`, the request returns an error if it targets a missing or closed index.
     * - include_defaults: If `true`, return all default settings in the response. (Default: false)
     * - local: If `true`, the request retrieves information from the local node only. If `false`, information is retrieved from the cluster-manager node. (Default: false)
     * - master_timeout: Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error.
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return array
     */
    public function getSettings(array $params = [])
    {
        $name = $this->extractArgument($params, 'name');
        $index = $this->extractArgument($params, 'index');

        $endpoint = $this->endpointFactory->getEndpoint(GetSettings::class);
        $endpoint->setParams($params);
        $endpoint->setName($name);
        $endpoint->setIndex($index);

        return $this->performRequest($endpoint);
    }

    /**
     * Returns an index template.
     *
     * @param array{name?: mixed, cluster_manager_timeout?: string, flat_settings?: bool, local?: bool, master_timeout?: string, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - name: A comma-separated list of index template names used to limit the request. Wildcard (`*`) expressions are supported. To return all index templates, omit this parameter or use a value of `_all` or `*`.
     * - cluster_manager_timeout: Operation timeout for connection to cluster-manager node.
     * - flat_settings: If `true`, returns settings in flat format. (Default: false)
     * - local: If `true`, the request retrieves information from the local node only. (Default: false)
     * - master_timeout: Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error.
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return array
     */
    public function getTemplate(array $params = [])
    {
        $name = $this->extractArgument($params, 'name');

        $endpoint = $this->endpointFactory->getEndpoint(GetTemplate::class);
        $endpoint->setParams($params);
        $endpoint->setName($name);

        return $this->performRequest($endpoint);
    }

    /**
     * The `_upgrade` API is no longer useful and will be removed.
     *
     * @param array{index?: mixed, allow_no_indices?: bool, expand_wildcards?: mixed, ignore_unavailable?: bool, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - index: A comma-separated list of indexes; use `_all` or empty string to perform the operation on all indexes.
     * - allow_no_indices: Whether to ignore if a wildcard indexes expression resolves into no concrete indexes. (This includes `_all` string or when no indexes have been specified).
     * - expand_wildcards: Whether to expand wildcard expression to concrete indexes that are open, closed or both.
     * - ignore_unavailable: Whether specified concrete indexes should be ignored when unavailable (missing or closed).
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return array
     */
    public function getUpgrade(array $params = [])
    {
        $index = $this->extractArgument($params, 'index');

        $endpoint = $this->endpointFactory->getEndpoint(GetUpgrade::class);
        $endpoint->setParams($params);
        $endpoint->setIndex($index);

        return $this->performRequest($endpoint);
    }

    /**
     * Opens an index.
     *
     * @param array{index?: mixed, allow_no_indices?: bool, cluster_manager_timeout?: string, expand_wildcards?: mixed, ignore_unavailable?: bool, master_timeout?: string, task_execution_timeout?: string, timeout?: string, wait_for_active_shards?: mixed, wait_for_completion?: bool, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - index: A comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). By default, you must explicitly name the indexes you using to limit the request. To limit a request using `_all`, `*`, or other wildcard expressions, change the `action.destructive_requires_name` setting to false. You can update this setting in the `opensearch.yml` file or using the cluster update settings API.
     * - allow_no_indices: If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes.
     * - cluster_manager_timeout: Operation timeout for connection to cluster-manager node.
     * - expand_wildcards: Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`.
     * - ignore_unavailable: If `false`, the request returns an error if it targets a missing or closed index.
     * - master_timeout: Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error.
     * - task_execution_timeout: Explicit task execution timeout, only useful when `wait_for_completion` is false, defaults to `1h`.
     * - timeout: Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.
     * - wait_for_active_shards: The number of shard copies that must be active before proceeding with the operation. Set to `all` or any positive integer up to the total number of shards in the index (`number_of_replicas+1`).
     * - wait_for_completion: Should this request wait until the operation has completed before returning. (Default: true)
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return array
     */
    public function open(array $params = [])
    {
        $index = $this->extractArgument($params, 'index');

        $endpoint = $this->endpointFactory->getEndpoint(Open::class);
        $endpoint->setParams($params);
        $endpoint->setIndex($index);

        return $this->performRequest($endpoint);
    }

    /**
     * Creates or updates an alias.
     *
     * @param array{name?: string, index?: mixed, cluster_manager_timeout?: string, master_timeout?: string, timeout?: string, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed, body?: mixed} $params
     * - name: Alias to update. If the alias doesn't exist, the request creates it. Index alias names support date math.
     * - index: A comma-separated list of data streams or indexes to add. Supports wildcards (`*`). Wildcard patterns that match both data streams and indexes return an error.
     * - cluster_manager_timeout: Operation timeout for connection to cluster-manager node.
     * - master_timeout: Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error.
     * - timeout: Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * - body: The settings for the alias, such as `routing` or `filter`
     * @return array
     */
    public function putAlias(array $params = [])
    {
        $name = $this->extractArgument($params, 'name');
        $index = $this->extractArgument($params, 'index');
        $body = $this->extractArgument($params, 'body');

        $endpoint = $this->endpointFactory->getEndpoint(PutAlias::class);
        $endpoint->setParams($params);
        $endpoint->setName($name);
        $endpoint->setIndex($index);
        $endpoint->setBody($body);

        return $this->performRequest($endpoint);
    }

    /**
     * Creates or updates an index template.
     *
     * @param array{name?: string, cause?: string, cluster_manager_timeout?: string, create?: bool, master_timeout?: string, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed, body?: mixed} $params
     * - name: Index or template name
     * - cause: User defined reason for creating/updating the index template. (Default: false)
     * - cluster_manager_timeout: Operation timeout for connection to cluster-manager node.
     * - create: If `true`, this request cannot replace or update existing index templates. (Default: false)
     * - master_timeout: Operation timeout for connection to cluster-manager node.
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * - body: The template definition (Required)
     * @return array
     */
    public function putIndexTemplate(array $params = [])
    {
        $name = $this->extractArgument($params, 'name');
        $body = $this->extractArgument($params, 'body');

        $endpoint = $this->endpointFactory->getEndpoint(PutIndexTemplate::class);
        $endpoint->setParams($params);
        $endpoint->setName($name);
        $endpoint->setBody($body);

        return $this->performRequest($endpoint);
    }

    /**
     * Updates the index mappings.
     *
     * @param array{index?: mixed, allow_no_indices?: bool, cluster_manager_timeout?: string, expand_wildcards?: mixed, ignore_unavailable?: bool, master_timeout?: string, timeout?: string, write_index_only?: bool, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed, body?: mixed} $params
     * - index: A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indexes.
     * - allow_no_indices: If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes.
     * - cluster_manager_timeout: Operation timeout for connection to cluster-manager node.
     * - expand_wildcards: Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`.
     * - ignore_unavailable: If `false`, the request returns an error if it targets a missing or closed index.
     * - master_timeout: Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error.
     * - timeout: Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.
     * - write_index_only: If `true`, the mappings are applied only to the current write index for the target. (Default: false)
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * - body: The mapping definition (Required)
     * @return array
     */
    public function putMapping(array $params = [])
    {
        $index = $this->extractArgument($params, 'index');
        $body = $this->extractArgument($params, 'body');

        $endpoint = $this->endpointFactory->getEndpoint(PutMapping::class);
        $endpoint->setParams($params);
        $endpoint->setIndex($index);
        $endpoint->setBody($body);

        return $this->performRequest($endpoint);
    }

    /**
     * Updates the index settings.
     *
     * @param array{index?: mixed, allow_no_indices?: bool, cluster_manager_timeout?: string, expand_wildcards?: mixed, flat_settings?: bool, ignore_unavailable?: bool, master_timeout?: string, preserve_existing?: bool, timeout?: string, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed, body?: mixed} $params
     * - index: A comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`.
     * - allow_no_indices: If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`.
     * - cluster_manager_timeout: Operation timeout for connection to cluster-manager node.
     * - expand_wildcards: Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`.
     * - flat_settings: If `true`, returns settings in flat format. (Default: false)
     * - ignore_unavailable: Whether specified concrete indexes should be ignored when unavailable (missing or closed).
     * - master_timeout: Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error.
     * - preserve_existing: If `true`, existing index settings remain unchanged. (Default: false)
     * - timeout: Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * - body: (Required)
     * @return array
     */
    public function putSettings(array $params = [])
    {
        $index = $this->extractArgument($params, 'index');
        $body = $this->extractArgument($params, 'body');

        $endpoint = $this->endpointFactory->getEndpoint(PutSettings::class);
        $endpoint->setParams($params);
        $endpoint->setIndex($index);
        $endpoint->setBody($body);

        return $this->performRequest($endpoint);
    }

    /**
     * Creates or updates an index template.
     *
     * @param array{name?: string, cluster_manager_timeout?: string, create?: bool, master_timeout?: string, order?: int, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed, body?: mixed} $params
     * - name: The name of the template
     * - cluster_manager_timeout: Operation timeout for connection to cluster-manager node.
     * - create: If `true`, this request cannot replace or update existing index templates. (Default: false)
     * - master_timeout: Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error.
     * - order: Order in which OpenSearch applies this template if index matches multiple templates. Templates with lower 'order' values are merged first. Templates with higher 'order' values are merged later, overriding templates with lower values.
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * - body: The template definition (Required)
     * @return array
     */
    public function putTemplate(array $params = [])
    {
        $name = $this->extractArgument($params, 'name');
        $body = $this->extractArgument($params, 'body');

        $endpoint = $this->endpointFactory->getEndpoint(PutTemplate::class);
        $endpoint->setParams($params);
        $endpoint->setName($name);
        $endpoint->setBody($body);

        return $this->performRequest($endpoint);
    }

    /**
     * Returns information about ongoing index shard recoveries.
     *
     * @param array{index?: mixed, active_only?: bool, detailed?: bool, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - index: A comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`.
     * - active_only: If `true`, the response only includes ongoing shard recoveries. (Default: false)
     * - detailed: If `true`, the response includes detailed information about shard recoveries. (Default: false)
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return array
     */
    public function recovery(array $params = [])
    {
        $index = $this->extractArgument($params, 'index');

        $endpoint = $this->endpointFactory->getEndpoint(Recovery::class);
        $endpoint->setParams($params);
        $endpoint->setIndex($index);

        return $this->performRequest($endpoint);
    }

    /**
     * Performs the refresh operation in one or more indexes.
     *
     * @param array{index?: mixed, allow_no_indices?: bool, expand_wildcards?: mixed, ignore_unavailable?: bool, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - index: A comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`.
     * - allow_no_indices: If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes.
     * - expand_wildcards: Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`.
     * - ignore_unavailable: If `false`, the request returns an error if it targets a missing or closed index.
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return array
     */
    public function refresh(array $params = [])
    {
        $index = $this->extractArgument($params, 'index');

        $endpoint = $this->endpointFactory->getEndpoint(Refresh::class);
        $endpoint->setParams($params);
        $endpoint->setIndex($index);

        return $this->performRequest($endpoint);
    }

    /**
     * Returns information about any matching indexes, aliases, and data streams.
     *
     * @param array{name?: mixed, expand_wildcards?: mixed, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - name: Comma-separated name(s) or index pattern(s) of the indexes, aliases, and data streams to resolve. Resources on remote clusters can be specified using the `<cluster>`:`<name>` syntax.
     * - expand_wildcards: Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`.
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return array
     */
    public function resolveIndex(array $params = [])
    {
        $name = $this->extractArgument($params, 'name');

        $endpoint = $this->endpointFactory->getEndpoint(ResolveIndex::class);
        $endpoint->setParams($params);
        $endpoint->setName($name);

        return $this->performRequest($endpoint);
    }

    /**
     * Updates an alias to point to a new index when the existing indexis considered to be too large or too old.
     *
     * @param array{alias?: string, new_index?: string, cluster_manager_timeout?: string, dry_run?: bool, master_timeout?: string, timeout?: string, wait_for_active_shards?: mixed, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed, body?: mixed} $params
     * - alias: Name of the data stream or index alias to roll over.
     * - new_index: The name of the index to create. Supports date math. Data streams do not support this parameter.
     * - cluster_manager_timeout: Operation timeout for connection to cluster-manager node.
     * - dry_run: If `true`, checks whether the current index satisfies the specified conditions but does not perform a rollover. (Default: false)
     * - master_timeout: Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error.
     * - timeout: Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.
     * - wait_for_active_shards: The number of shard copies that must be active before proceeding with the operation. Set to all or any positive integer up to the total number of shards in the index (`number_of_replicas+1`).
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * - body: The conditions that needs to be met for executing rollover
     * @return array
     */
    public function rollover(array $params = [])
    {
        $alias = $this->extractArgument($params, 'alias');
        $new_index = $this->extractArgument($params, 'new_index');
        $body = $this->extractArgument($params, 'body');

        $endpoint = $this->endpointFactory->getEndpoint(Rollover::class);
        $endpoint->setParams($params);
        $endpoint->setAlias($alias);
        $endpoint->setNewIndex($new_index);
        $endpoint->setBody($body);

        return $this->performRequest($endpoint);
    }

    /**
     * Provides low-level information about segments in a Lucene index.
     *
     * @param array{index?: mixed, allow_no_indices?: bool, expand_wildcards?: mixed, ignore_unavailable?: bool, verbose?: bool, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - index: A comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`.
     * - allow_no_indices: If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes.
     * - expand_wildcards: Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`.
     * - ignore_unavailable: If `false`, the request returns an error if it targets a missing or closed index.
     * - verbose: If `true`, the request returns a verbose response. (Default: false)
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return array
     */
    public function segments(array $params = [])
    {
        $index = $this->extractArgument($params, 'index');

        $endpoint = $this->endpointFactory->getEndpoint(Segments::class);
        $endpoint->setParams($params);
        $endpoint->setIndex($index);

        return $this->performRequest($endpoint);
    }

    /**
     * Provides store information for shard copies of indexes.
     *
     * @param array{index?: mixed, allow_no_indices?: bool, expand_wildcards?: mixed, ignore_unavailable?: bool, status?: mixed, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - index: Limits health reporting to a specific source. Can be a single source or a comma-separated list of sources (comprised of data streams, indexes, and aliases).
     * - allow_no_indices: If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. (Default: false)
     * - expand_wildcards: Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.
     * - ignore_unavailable: If `true`, missing or closed indexes are not included in the response. (Default: false)
     * - status: A list of shard health statuses used to limit the request. (Default: yellow, red)
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return array
     */
    public function shardStores(array $params = [])
    {
        $index = $this->extractArgument($params, 'index');

        $endpoint = $this->endpointFactory->getEndpoint(ShardStores::class);
        $endpoint->setParams($params);
        $endpoint->setIndex($index);

        return $this->performRequest($endpoint);
    }

    /**
     * Allow to shrink an existing index into a new index with fewer primary shards.
     *
     * @param array{index?: string, target?: string, cluster_manager_timeout?: string, copy_settings?: bool, master_timeout?: string, task_execution_timeout?: string, timeout?: string, wait_for_active_shards?: mixed, wait_for_completion?: bool, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed, body?: mixed} $params
     * - index: Name of the source index to shrink.
     * - target: Name of the target index to create.
     * - cluster_manager_timeout: Operation timeout for connection to cluster-manager node.
     * - copy_settings: whether or not to copy settings from the source index. (Default: false)
     * - master_timeout: Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error.
     * - task_execution_timeout: Explicit task execution timeout, only useful when `wait_for_completion` is false, defaults to `1h`.
     * - timeout: Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.
     * - wait_for_active_shards: The number of shard copies that must be active before proceeding with the operation. Set to `all` or any positive integer up to the total number of shards in the index (`number_of_replicas+1`).
     * - wait_for_completion: Should this request wait until the operation has completed before returning. (Default: true)
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * - body: The configuration for the target index (`settings` and `aliases`)
     * @return array
     */
    public function shrink(array $params = [])
    {
        $index = $this->extractArgument($params, 'index');
        $target = $this->extractArgument($params, 'target');
        $body = $this->extractArgument($params, 'body');

        $endpoint = $this->endpointFactory->getEndpoint(Shrink::class);
        $endpoint->setParams($params);
        $endpoint->setIndex($index);
        $endpoint->setTarget($target);
        $endpoint->setBody($body);

        return $this->performRequest($endpoint);
    }

    /**
     * Simulate matching the given index name against the index templates in the system.
     *
     * @param array{name?: string, cluster_manager_timeout?: string, master_timeout?: string, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed, body?: mixed} $params
     * - name: Index or template name to simulate
     * - cluster_manager_timeout: Operation timeout for connection to cluster-manager node.
     * - master_timeout: Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error.
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * - body: New index template definition, which will be included in the simulation, as if it already exists in the system
     * @return array
     */
    public function simulateIndexTemplate(array $params = [])
    {
        $name = $this->extractArgument($params, 'name');
        $body = $this->extractArgument($params, 'body');

        $endpoint = $this->endpointFactory->getEndpoint(SimulateIndexTemplate::class);
        $endpoint->setParams($params);
        $endpoint->setName($name);
        $endpoint->setBody($body);

        return $this->performRequest($endpoint);
    }

    /**
     * Simulate resolving the given template name or body.
     *
     * @param array{name?: string, cause?: string, cluster_manager_timeout?: string, create?: bool, master_timeout?: string, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed, body?: mixed} $params
     * - name: The name of the index template to simulate. To test a template configuration before you add it to the cluster, omit this parameter and specify the template configuration in the request body.
     * - cause: User defined reason for dry-run creating the new template for simulation purposes. (Default: false)
     * - cluster_manager_timeout: Operation timeout for connection to cluster-manager node.
     * - create: If `true`, the template passed in the body is only used if no existing templates match the same index patterns. If `false`, the simulation uses the template with the highest priority. Note that the template is not permanently added or updated in either case; it is only used for the simulation. (Default: false)
     * - master_timeout: Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error.
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * - body:
     * @return array
     */
    public function simulateTemplate(array $params = [])
    {
        $name = $this->extractArgument($params, 'name');
        $body = $this->extractArgument($params, 'body');

        $endpoint = $this->endpointFactory->getEndpoint(SimulateTemplate::class);
        $endpoint->setParams($params);
        $endpoint->setName($name);
        $endpoint->setBody($body);

        return $this->performRequest($endpoint);
    }

    /**
     * Allows you to split an existing index into a new index with more primary shards.
     *
     * @param array{index?: string, target?: string, cluster_manager_timeout?: string, copy_settings?: bool, master_timeout?: string, task_execution_timeout?: string, timeout?: string, wait_for_active_shards?: mixed, wait_for_completion?: bool, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed, body?: mixed} $params
     * - index: Name of the source index to split.
     * - target: Name of the target index to create.
     * - cluster_manager_timeout: Operation timeout for connection to cluster-manager node.
     * - copy_settings: whether or not to copy settings from the source index. (Default: false)
     * - master_timeout: Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error.
     * - task_execution_timeout: Explicit task execution timeout, only useful when `wait_for_completion` is false, defaults to `1h`.
     * - timeout: Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.
     * - wait_for_active_shards: The number of shard copies that must be active before proceeding with the operation. Set to `all` or any positive integer up to the total number of shards in the index (`number_of_replicas+1`).
     * - wait_for_completion: Should this request wait until the operation has completed before returning. (Default: true)
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * - body: The configuration for the target index (`settings` and `aliases`)
     * @return array
     */
    public function split(array $params = [])
    {
        $index = $this->extractArgument($params, 'index');
        $target = $this->extractArgument($params, 'target');
        $body = $this->extractArgument($params, 'body');

        $endpoint = $this->endpointFactory->getEndpoint(Split::class);
        $endpoint->setParams($params);
        $endpoint->setIndex($index);
        $endpoint->setTarget($target);
        $endpoint->setBody($body);

        return $this->performRequest($endpoint);
    }

    /**
     * Provides statistics on operations happening in an index.
     *
     * @param array{metric?: mixed, index?: mixed, completion_fields?: mixed, expand_wildcards?: mixed, fielddata_fields?: mixed, fields?: mixed, forbid_closed_indices?: bool, groups?: mixed, include_segment_file_sizes?: bool, include_unloaded_segments?: bool, level?: mixed, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - metric: Limit the information returned the specific metrics.
     * - index: A comma-separated list of index names; use `_all` or empty string to perform the operation on all indexes
     * - completion_fields: A comma-separated list or wildcard expressions of fields to include in field data and suggest statistics.
     * - expand_wildcards: Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`.
     * - fielddata_fields: A comma-separated list or wildcard expressions of fields to include in field data statistics.
     * - fields: A comma-separated list or wildcard expressions of fields to include in the statistics.
     * - forbid_closed_indices: If `true`, statistics are not collected from closed indexes. (Default: true)
     * - groups: A comma-separated list of search groups to include in the search statistics.
     * - include_segment_file_sizes: If `true`, the call reports the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested). (Default: false)
     * - include_unloaded_segments: If `true`, the response includes information from segments that are not loaded into memory. (Default: false)
     * - level: Indicates whether statistics are aggregated at the cluster, index, or shard level. (Options: cluster, indices, shards)
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return array
     */
    public function stats(array $params = [])
    {
        $metric = $this->extractArgument($params, 'metric');
        $index = $this->extractArgument($params, 'index');

        $endpoint = $this->endpointFactory->getEndpoint(Stats::class);
        $endpoint->setParams($params);
        $endpoint->setMetric($metric);
        $endpoint->setIndex($index);

        return $this->performRequest($endpoint);
    }

    /**
     * Updates index aliases.
     *
     * @param array{cluster_manager_timeout?: string, master_timeout?: string, timeout?: string, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed, body?: mixed} $params
     * - cluster_manager_timeout: Operation timeout for connection to cluster-manager node.
     * - master_timeout: Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error.
     * - timeout: Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * - body: The definition of `actions` to perform (Required)
     * @return array
     */
    public function updateAliases(array $params = [])
    {
        $body = $this->extractArgument($params, 'body');

        $endpoint = $this->endpointFactory->getEndpoint(UpdateAliases::class);
        $endpoint->setParams($params);
        $endpoint->setBody($body);

        return $this->performRequest($endpoint);
    }

    /**
     * The `_upgrade` API is no longer useful and will be removed.
     *
     * @param array{index?: mixed, allow_no_indices?: bool, expand_wildcards?: mixed, ignore_unavailable?: bool, only_ancient_segments?: bool, wait_for_completion?: bool, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - index: A comma-separated list of indexes; use `_all` or empty string to perform the operation on all indexes.
     * - allow_no_indices: Whether to ignore if a wildcard indexes expression resolves into no concrete indexes. (This includes `_all` string or when no indexes have been specified).
     * - expand_wildcards: Whether to expand wildcard expression to concrete indexes that are open, closed or both.
     * - ignore_unavailable: Whether specified concrete indexes should be ignored when unavailable (missing or closed).
     * - only_ancient_segments: If `true`, only ancient (an older Lucene major release) segments will be upgraded.
     * - wait_for_completion: Should this request wait until the operation has completed before returning. (Default: false)
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * @return array
     */
    public function upgrade(array $params = [])
    {
        $index = $this->extractArgument($params, 'index');

        $endpoint = $this->endpointFactory->getEndpoint(Upgrade::class);
        $endpoint->setParams($params);
        $endpoint->setIndex($index);

        return $this->performRequest($endpoint);
    }

    /**
     * Allows a user to validate a potentially expensive query without executing it.
     *
     * @param array{index?: mixed, all_shards?: bool, allow_no_indices?: bool, analyze_wildcard?: bool, analyzer?: string, default_operator?: mixed, df?: string, expand_wildcards?: mixed, explain?: bool, ignore_unavailable?: bool, lenient?: bool, q?: string, rewrite?: bool, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed, body?: mixed} $params
     * - index: A comma-separated list of data streams, indexes, and aliases to search. Supports wildcards (`*`). To search all data streams or indexes, omit this parameter or use `*` or `_all`.
     * - all_shards: If `true`, the validation is executed on all shards instead of one random shard per index.
     * - allow_no_indices: If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes.
     * - analyze_wildcard: If `true`, wildcard and prefix queries are analyzed. (Default: false)
     * - analyzer: Analyzer to use for the query string. This parameter can only be used when the `q` query string parameter is specified.
     * - default_operator: The default operator for query string query: `AND` or `OR`. (Options: and, AND, or, OR)
     * - df: Field to use as default where no field prefix is given in the query string. This parameter can only be used when the `q` query string parameter is specified.
     * - expand_wildcards: Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`.
     * - explain: If `true`, the response returns detailed information if an error has occurred.
     * - ignore_unavailable: If `false`, the request returns an error if it targets a missing or closed index.
     * - lenient: If `true`, format-based query failures (such as providing text to a numeric field) in the query string will be ignored.
     * - q: Query in the Lucene query string syntax.
     * - rewrite: If `true`, returns a more detailed explanation showing the actual Lucene query that will be executed.
     * - pretty: Whether to pretty-format the returned JSON response. (Default: false)
     * - human: Whether to return human-readable values for statistics. (Default: false)
     * - error_trace: Whether to include the stack trace of returned errors. (Default: false)
     * - source: The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
     * - filter_path: A comma-separated list of filters used to filter the response. Use wildcards to match any field or part of a field's name. To exclude fields, use `-`.
     * - body: The query definition specified with the Query DSL
     * @return array
     */
    public function validateQuery(array $params = [])
    {
        $index = $this->extractArgument($params, 'index');
        $body = $this->extractArgument($params, 'body');

        $endpoint = $this->endpointFactory->getEndpoint(ValidateQuery::class);
        $endpoint->setParams($params);
        $endpoint->setIndex($index);
        $endpoint->setBody($body);

        return $this->performRequest($endpoint);
    }

    /**
     * Alias function to getAlias()
     *
     * @deprecated added to prevent BC break introduced in 7.2.0
     * @see https://github.com/elastic/elasticsearch-php/issues/940
     */
    public function getAliases(array $params = [])
    {
        return $this->getAlias($params);
    }
    /**
     * $params['index']              = (list) A comma-separated list of index names to refresh analyzers for
     *
     * @param array $params Associative array of parameters
     * @return array
     */
    public function refreshSearchAnalyzers(array $params = [])
    {
        $index = $this->extractArgument($params, 'index');

        $endpoint = $this->endpointFactory->getEndpoint(RefreshSearchAnalyzers::class);
        $endpoint->setParams($params);
        $endpoint->setIndex($index);

        return $this->performRequest($endpoint);
    }
}
