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

package com.azure.resourcemanager.appcontainers.models;

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

/**
 * Container Apps Job versioned application definition. Defines the desired state of an immutable revision. Any changes
 * to this section Will result in a new revision being created.
 */
@Fluent
public final class JobTemplate {
    /*
     * List of specialized containers that run before app containers.
     */
    @JsonProperty(value = "initContainers")
    private List<InitContainer> initContainers;

    /*
     * List of container definitions for the Container App.
     */
    @JsonProperty(value = "containers")
    private List<Container> containers;

    /*
     * List of volume definitions for the Container App.
     */
    @JsonProperty(value = "volumes")
    private List<Volume> volumes;

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

    /**
     * Get the initContainers property: List of specialized containers that run before app containers.
     *
     * @return the initContainers value.
     */
    public List<InitContainer> initContainers() {
        return this.initContainers;
    }

    /**
     * Set the initContainers property: List of specialized containers that run before app containers.
     *
     * @param initContainers the initContainers value to set.
     * @return the JobTemplate object itself.
     */
    public JobTemplate withInitContainers(List<InitContainer> initContainers) {
        this.initContainers = initContainers;
        return this;
    }

    /**
     * Get the containers property: List of container definitions for the Container App.
     *
     * @return the containers value.
     */
    public List<Container> containers() {
        return this.containers;
    }

    /**
     * Set the containers property: List of container definitions for the Container App.
     *
     * @param containers the containers value to set.
     * @return the JobTemplate object itself.
     */
    public JobTemplate withContainers(List<Container> containers) {
        this.containers = containers;
        return this;
    }

    /**
     * Get the volumes property: List of volume definitions for the Container App.
     *
     * @return the volumes value.
     */
    public List<Volume> volumes() {
        return this.volumes;
    }

    /**
     * Set the volumes property: List of volume definitions for the Container App.
     *
     * @param volumes the volumes value to set.
     * @return the JobTemplate object itself.
     */
    public JobTemplate withVolumes(List<Volume> volumes) {
        this.volumes = volumes;
        return this;
    }

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