<?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\DanglingIndices\DeleteDanglingIndex;
use OpenSearch\Endpoints\DanglingIndices\ImportDanglingIndex;
use OpenSearch\Endpoints\DanglingIndices\ListDanglingIndices;

/**
 * Class DanglingIndicesNamespace
 *
 * NOTE: This file is autogenerated using util/GenerateEndpoints.php
 */
class DanglingIndicesNamespace extends AbstractNamespace
{
    /**
     * Deletes the specified dangling index.
     *
     * @param array{index_uuid?: string, accept_data_loss?: bool, cluster_manager_timeout?: string, master_timeout?: string, timeout?: string, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - index_uuid: The UUID of the dangling index.
     * - accept_data_loss: Must be set to true in order to delete the dangling index.
     * - cluster_manager_timeout: Operation timeout for connection to cluster-manager node.
     * - 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 deleteDanglingIndex(array $params = [])
    {
        $index_uuid = $this->extractArgument($params, 'index_uuid');

        $endpoint = $this->endpointFactory->getEndpoint(DeleteDanglingIndex::class);
        $endpoint->setParams($params);
        $endpoint->setIndexUuid($index_uuid);

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

    /**
     * Imports the specified dangling index.
     *
     * @param array{index_uuid?: string, accept_data_loss?: bool, cluster_manager_timeout?: string, master_timeout?: string, timeout?: string, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - index_uuid: The UUID of the dangling index.
     * - accept_data_loss: Must be set to true in order to import the dangling index.
     * - cluster_manager_timeout: Operation timeout for connection to cluster-manager node.
     * - 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 importDanglingIndex(array $params = [])
    {
        $index_uuid = $this->extractArgument($params, 'index_uuid');

        $endpoint = $this->endpointFactory->getEndpoint(ImportDanglingIndex::class);
        $endpoint->setParams($params);
        $endpoint->setIndexUuid($index_uuid);

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

    /**
     * Returns all dangling indexes.
     *
     * @param array{pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - 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 listDanglingIndices(array $params = [])
    {

        $endpoint = $this->endpointFactory->getEndpoint(ListDanglingIndices::class);
        $endpoint->setParams($params);

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

}
