<?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\Endpoints\FlowFramework;

use OpenSearch\Exception\RuntimeException;
use OpenSearch\Endpoints\AbstractEndpoint;

/**
 * NOTE: This file is autogenerated using util/GenerateEndpoints.php
 */
class Update extends AbstractEndpoint
{
    protected $workflow_id;

    public function getURI(): string
    {
        $workflow_id = $this->workflow_id ? rawurlencode($this->workflow_id) : null;
        if (isset($workflow_id)) {
            return "/_plugins/_flow_framework/workflow/$workflow_id";
        }
        throw new RuntimeException('Missing parameter for the endpoint flow_framework.update');
    }

    public function getParamWhitelist(): array
    {
        return [
            'provision',
            'reprovision',
            'update_fields',
            'use_case',
            'validation',
            'pretty',
            'human',
            'error_trace',
            'source',
            'filter_path'
        ];
    }

    public function getMethod(): string
    {
        return 'PUT';
    }

    public function setBody($body): static
    {
        if (is_null($body)) {
            return $this;
        }
        $this->body = $body;

        return $this;
    }

    public function setWorkflowId($workflow_id): static
    {
        if (is_null($workflow_id)) {
            return $this;
        }
        $this->workflow_id = $workflow_id;

        return $this;
    }
}
