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

package com.azure.resourcemanager.imagebuilder.models;

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

/** Configuration options and list of validations to be performed on the resulting image. */
@Fluent
public final class ImageTemplatePropertiesValidate {
    /*
     * If validation fails and this field is set to false, output image(s) will not be distributed. This is the default
     * behavior. If validation fails and this field is set to true, output image(s) will still be distributed. Please
     * use this option with caution as it may result in bad images being distributed for use. In either case (true or
     * false), the end to end image run will be reported as having failed in case of a validation failure. [Note: This
     * field has no effect if validation succeeds.]
     */
    @JsonProperty(value = "continueDistributeOnFailure")
    private Boolean continueDistributeOnFailure;

    /*
     * If this field is set to true, the image specified in the 'source' section will directly be validated. No
     * separate build will be run to generate and then validate a customized image.
     */
    @JsonProperty(value = "sourceValidationOnly")
    private Boolean sourceValidationOnly;

    /*
     * List of validations to be performed.
     */
    @JsonProperty(value = "inVMValidations")
    private List<ImageTemplateInVMValidator> inVMValidations;

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

    /**
     * Get the continueDistributeOnFailure property: If validation fails and this field is set to false, output image(s)
     * will not be distributed. This is the default behavior. If validation fails and this field is set to true, output
     * image(s) will still be distributed. Please use this option with caution as it may result in bad images being
     * distributed for use. In either case (true or false), the end to end image run will be reported as having failed
     * in case of a validation failure. [Note: This field has no effect if validation succeeds.].
     *
     * @return the continueDistributeOnFailure value.
     */
    public Boolean continueDistributeOnFailure() {
        return this.continueDistributeOnFailure;
    }

    /**
     * Set the continueDistributeOnFailure property: If validation fails and this field is set to false, output image(s)
     * will not be distributed. This is the default behavior. If validation fails and this field is set to true, output
     * image(s) will still be distributed. Please use this option with caution as it may result in bad images being
     * distributed for use. In either case (true or false), the end to end image run will be reported as having failed
     * in case of a validation failure. [Note: This field has no effect if validation succeeds.].
     *
     * @param continueDistributeOnFailure the continueDistributeOnFailure value to set.
     * @return the ImageTemplatePropertiesValidate object itself.
     */
    public ImageTemplatePropertiesValidate withContinueDistributeOnFailure(Boolean continueDistributeOnFailure) {
        this.continueDistributeOnFailure = continueDistributeOnFailure;
        return this;
    }

    /**
     * Get the sourceValidationOnly property: If this field is set to true, the image specified in the 'source' section
     * will directly be validated. No separate build will be run to generate and then validate a customized image.
     *
     * @return the sourceValidationOnly value.
     */
    public Boolean sourceValidationOnly() {
        return this.sourceValidationOnly;
    }

    /**
     * Set the sourceValidationOnly property: If this field is set to true, the image specified in the 'source' section
     * will directly be validated. No separate build will be run to generate and then validate a customized image.
     *
     * @param sourceValidationOnly the sourceValidationOnly value to set.
     * @return the ImageTemplatePropertiesValidate object itself.
     */
    public ImageTemplatePropertiesValidate withSourceValidationOnly(Boolean sourceValidationOnly) {
        this.sourceValidationOnly = sourceValidationOnly;
        return this;
    }

    /**
     * Get the inVMValidations property: List of validations to be performed.
     *
     * @return the inVMValidations value.
     */
    public List<ImageTemplateInVMValidator> inVMValidations() {
        return this.inVMValidations;
    }

    /**
     * Set the inVMValidations property: List of validations to be performed.
     *
     * @param inVMValidations the inVMValidations value to set.
     * @return the ImageTemplatePropertiesValidate object itself.
     */
    public ImageTemplatePropertiesValidate withInVMValidations(List<ImageTemplateInVMValidator> inVMValidations) {
        this.inVMValidations = inVMValidations;
        return this;
    }

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