<?php

declare(strict_types=1);

/**
 * SPDX-License-Identifier: Apache-2.0
 *
 * The OpenSearch Contributors require contributions made to
 * this file be licensed under the Apache-2.0 license or a
 * compatible open source license.
 *
 * Modifications Copyright OpenSearch Contributors. See
 * GitHub history for details.
 */

namespace OpenSearch\Namespaces;

use OpenSearch\Endpoints\Sm\CreatePolicy;
use OpenSearch\Endpoints\Sm\DeletePolicy;
use OpenSearch\Endpoints\Sm\ExplainPolicy;
use OpenSearch\Endpoints\Sm\GetPolicies;
use OpenSearch\Endpoints\Sm\GetPolicy;
use OpenSearch\Endpoints\Sm\StartPolicy;
use OpenSearch\Endpoints\Sm\StopPolicy;
use OpenSearch\Endpoints\Sm\UpdatePolicy;

/**
 * Class SmNamespace
 *
 * NOTE: This file is autogenerated using util/GenerateEndpoints.php
 */
class SmNamespace extends AbstractNamespace
{
    /**
     * Creates a snapshot management policy.
     *
     * @param array{policy_name?: string, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed, body?: mixed} $params
     * - policy_name: The name of the snapshot management policy to create.
     * - 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 createPolicy(array $params = [])
    {
        $policy_name = $this->extractArgument($params, 'policy_name');
        $body = $this->extractArgument($params, 'body');

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

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

    /**
     * Deletes a snapshot management policy.
     *
     * @param array{policy_name?: string, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - policy_name: The name of the snapshot management policy to delete.
     * - 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 deletePolicy(array $params = [])
    {
        $policy_name = $this->extractArgument($params, 'policy_name');

        $endpoint = $this->endpointFactory->getEndpoint(DeletePolicy::class);
        $endpoint->setParams($params);
        $endpoint->setPolicyName($policy_name);

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

    /**
     * Explains the state of the snapshot management policy.
     *
     * @param array{policy_name?: string, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - policy_name: The name of the snapshot management policy to explain.
     * - 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 explainPolicy(array $params = [])
    {
        $policy_name = $this->extractArgument($params, 'policy_name');

        $endpoint = $this->endpointFactory->getEndpoint(ExplainPolicy::class);
        $endpoint->setParams($params);
        $endpoint->setPolicyName($policy_name);

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

    /**
     * Retrieves all snapshot management policies with optional pagination and filtering.
     *
     * @param array{from?: int, queryString?: string, size?: int, sortField?: string, sortOrder?: mixed, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - from: The starting index from which to retrieve snapshot management policies. (Default: 0)
     * - queryString: The query string to filter the returned snapshot management policies.
     * - size: The number of snapshot management policies to return.
     * - sortField: The name of the field to sort the snapshot management policies by.
     * - sortOrder: The order to sort the snapshot management policies. (Options: asc, desc)
     * - 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 getPolicies(array $params = [])
    {

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

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

    /**
     * Retrieves a specific snapshot management policy by name.
     *
     * @param array{policy_name?: string, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - policy_name: The name of the snapshot management policy to retrieve.
     * - 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 getPolicy(array $params = [])
    {
        $policy_name = $this->extractArgument($params, 'policy_name');

        $endpoint = $this->endpointFactory->getEndpoint(GetPolicy::class);
        $endpoint->setParams($params);
        $endpoint->setPolicyName($policy_name);

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

    /**
     * Starts a snapshot management policy.
     *
     * @param array{policy_name?: string, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - policy_name: The name of the snapshot management policy to start.
     * - 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 startPolicy(array $params = [])
    {
        $policy_name = $this->extractArgument($params, 'policy_name');

        $endpoint = $this->endpointFactory->getEndpoint(StartPolicy::class);
        $endpoint->setParams($params);
        $endpoint->setPolicyName($policy_name);

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

    /**
     * Stops a snapshot management policy.
     *
     * @param array{policy_name?: string, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed} $params
     * - policy_name: The name of the snapshot management policy to stop.
     * - 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 stopPolicy(array $params = [])
    {
        $policy_name = $this->extractArgument($params, 'policy_name');

        $endpoint = $this->endpointFactory->getEndpoint(StopPolicy::class);
        $endpoint->setParams($params);
        $endpoint->setPolicyName($policy_name);

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

    /**
     * Updates an existing snapshot management policy. Requires `if_seq_no` and `if_primary_term`.
     *
     * @param array{policy_name?: string, if_primary_term?: int, if_seq_no?: int, pretty?: bool, human?: bool, error_trace?: bool, source?: string, filter_path?: mixed, body?: mixed} $params
     * - policy_name: The name of the snapshot management policy to update.
     * - if_primary_term: The primary term of the policy to update.
     * - if_seq_no: The sequence number of the policy to update.
     * - 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 updatePolicy(array $params = [])
    {
        $policy_name = $this->extractArgument($params, 'policy_name');
        $body = $this->extractArgument($params, 'body');

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

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

}
