// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.hdinsight.models;

import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** The parameters for the script actions to execute on a running cluster. */
@Fluent
public final class ExecuteScriptActionParameters {
    /*
     * The list of run time script actions.
     */
    @JsonProperty(value = "scriptActions")
    private List<RuntimeScriptAction> scriptActions;

    /*
     * Gets or sets if the scripts needs to be persisted.
     */
    @JsonProperty(value = "persistOnSuccess", required = true)
    private boolean persistOnSuccess;

    /** Creates an instance of ExecuteScriptActionParameters class. */
    public ExecuteScriptActionParameters() {
    }

    /**
     * Get the scriptActions property: The list of run time script actions.
     *
     * @return the scriptActions value.
     */
    public List<RuntimeScriptAction> scriptActions() {
        return this.scriptActions;
    }

    /**
     * Set the scriptActions property: The list of run time script actions.
     *
     * @param scriptActions the scriptActions value to set.
     * @return the ExecuteScriptActionParameters object itself.
     */
    public ExecuteScriptActionParameters withScriptActions(List<RuntimeScriptAction> scriptActions) {
        this.scriptActions = scriptActions;
        return this;
    }

    /**
     * Get the persistOnSuccess property: Gets or sets if the scripts needs to be persisted.
     *
     * @return the persistOnSuccess value.
     */
    public boolean persistOnSuccess() {
        return this.persistOnSuccess;
    }

    /**
     * Set the persistOnSuccess property: Gets or sets if the scripts needs to be persisted.
     *
     * @param persistOnSuccess the persistOnSuccess value to set.
     * @return the ExecuteScriptActionParameters object itself.
     */
    public ExecuteScriptActionParameters withPersistOnSuccess(boolean persistOnSuccess) {
        this.persistOnSuccess = persistOnSuccess;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (scriptActions() != null) {
            scriptActions().forEach(e -> e.validate());
        }
    }
}
