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

package com.azure.resourcemanager.batchai.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.annotation.JsonFlatten;
import com.azure.core.util.logging.ClientLogger;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** Job creation parameters. */
@JsonFlatten
@Fluent
public class JobCreateParameters {
    @JsonIgnore private final ClientLogger logger = new ClientLogger(JobCreateParameters.class);

    /*
     * Scheduling priority associated with the job. Possible values: low,
     * normal, high.
     */
    @JsonProperty(value = "properties.schedulingPriority")
    private JobPriority schedulingPriority;

    /*
     * Resource ID of the cluster on which this job will run.
     */
    @JsonProperty(value = "properties.cluster")
    private ResourceId cluster;

    /*
     * Information on mount volumes to be used by the job. These volumes will
     * be mounted before the job execution and will be unmounted after the job
     * completion. The volumes will be mounted at location specified by
     * $AZ_BATCHAI_JOB_MOUNT_ROOT environment variable.
     */
    @JsonProperty(value = "properties.mountVolumes")
    private MountVolumes mountVolumes;

    /*
     * Number of compute nodes to run the job on. The job will be gang
     * scheduled on that many compute nodes.
     */
    @JsonProperty(value = "properties.nodeCount")
    private Integer nodeCount;

    /*
     * Docker container settings for the job. If not provided, the job will run
     * directly on the node.
     */
    @JsonProperty(value = "properties.containerSettings")
    private ContainerSettings containerSettings;

    /*
     * Settings for CNTK (aka Microsoft Cognitive Toolkit) job.
     */
    @JsonProperty(value = "properties.cntkSettings")
    private CntKsettings cntkSettings;

    /*
     * Settings for pyTorch job.
     */
    @JsonProperty(value = "properties.pyTorchSettings")
    private PyTorchSettings pyTorchSettings;

    /*
     * Settings for Tensor Flow job.
     */
    @JsonProperty(value = "properties.tensorFlowSettings")
    private TensorFlowSettings tensorFlowSettings;

    /*
     * Settings for Caffe job.
     */
    @JsonProperty(value = "properties.caffeSettings")
    private CaffeSettings caffeSettings;

    /*
     * Settings for Caffe2 job.
     */
    @JsonProperty(value = "properties.caffe2Settings")
    private Caffe2Settings caffe2Settings;

    /*
     * Settings for Chainer job.
     */
    @JsonProperty(value = "properties.chainerSettings")
    private ChainerSettings chainerSettings;

    /*
     * Settings for custom tool kit job.
     */
    @JsonProperty(value = "properties.customToolkitSettings")
    private CustomToolkitSettings customToolkitSettings;

    /*
     * Settings for custom MPI job.
     */
    @JsonProperty(value = "properties.customMpiSettings")
    private CustomMpiSettings customMpiSettings;

    /*
     * Settings for Horovod job.
     */
    @JsonProperty(value = "properties.horovodSettings")
    private HorovodSettings horovodSettings;

    /*
     * A command line to be executed on each node allocated for the job before
     * tool kit is launched.
     */
    @JsonProperty(value = "properties.jobPreparation")
    private JobPreparation jobPreparation;

    /*
     * The path where the Batch AI service will store stdout, stderror and
     * execution log of the job.
     */
    @JsonProperty(value = "properties.stdOutErrPathPrefix")
    private String stdOutErrPathPrefix;

    /*
     * A list of input directories for the job.
     */
    @JsonProperty(value = "properties.inputDirectories")
    private List<InputDirectory> inputDirectories;

    /*
     * A list of output directories for the job.
     */
    @JsonProperty(value = "properties.outputDirectories")
    private List<OutputDirectory> outputDirectories;

    /*
     * A list of user defined environment variables which will be setup for the
     * job.
     */
    @JsonProperty(value = "properties.environmentVariables")
    private List<EnvironmentVariable> environmentVariables;

    /*
     * A list of user defined environment variables with secret values which
     * will be setup for the job. Server will never report values of these
     * variables back.
     */
    @JsonProperty(value = "properties.secrets")
    private List<EnvironmentVariableWithSecretValue> secrets;

    /*
     * Constraints associated with the Job.
     */
    @JsonProperty(value = "properties.constraints")
    private JobBasePropertiesConstraints constraints;

    /**
     * Get the schedulingPriority property: Scheduling priority associated with the job. Possible values: low, normal,
     * high.
     *
     * @return the schedulingPriority value.
     */
    public JobPriority schedulingPriority() {
        return this.schedulingPriority;
    }

    /**
     * Set the schedulingPriority property: Scheduling priority associated with the job. Possible values: low, normal,
     * high.
     *
     * @param schedulingPriority the schedulingPriority value to set.
     * @return the JobCreateParameters object itself.
     */
    public JobCreateParameters withSchedulingPriority(JobPriority schedulingPriority) {
        this.schedulingPriority = schedulingPriority;
        return this;
    }

    /**
     * Get the cluster property: Resource ID of the cluster on which this job will run.
     *
     * @return the cluster value.
     */
    public ResourceId cluster() {
        return this.cluster;
    }

    /**
     * Set the cluster property: Resource ID of the cluster on which this job will run.
     *
     * @param cluster the cluster value to set.
     * @return the JobCreateParameters object itself.
     */
    public JobCreateParameters withCluster(ResourceId cluster) {
        this.cluster = cluster;
        return this;
    }

    /**
     * Get the mountVolumes property: Information on mount volumes to be used by the job. These volumes will be mounted
     * before the job execution and will be unmounted after the job completion. The volumes will be mounted at location
     * specified by $AZ_BATCHAI_JOB_MOUNT_ROOT environment variable.
     *
     * @return the mountVolumes value.
     */
    public MountVolumes mountVolumes() {
        return this.mountVolumes;
    }

    /**
     * Set the mountVolumes property: Information on mount volumes to be used by the job. These volumes will be mounted
     * before the job execution and will be unmounted after the job completion. The volumes will be mounted at location
     * specified by $AZ_BATCHAI_JOB_MOUNT_ROOT environment variable.
     *
     * @param mountVolumes the mountVolumes value to set.
     * @return the JobCreateParameters object itself.
     */
    public JobCreateParameters withMountVolumes(MountVolumes mountVolumes) {
        this.mountVolumes = mountVolumes;
        return this;
    }

    /**
     * Get the nodeCount property: Number of compute nodes to run the job on. The job will be gang scheduled on that
     * many compute nodes.
     *
     * @return the nodeCount value.
     */
    public Integer nodeCount() {
        return this.nodeCount;
    }

    /**
     * Set the nodeCount property: Number of compute nodes to run the job on. The job will be gang scheduled on that
     * many compute nodes.
     *
     * @param nodeCount the nodeCount value to set.
     * @return the JobCreateParameters object itself.
     */
    public JobCreateParameters withNodeCount(Integer nodeCount) {
        this.nodeCount = nodeCount;
        return this;
    }

    /**
     * Get the containerSettings property: Docker container settings for the job. If not provided, the job will run
     * directly on the node.
     *
     * @return the containerSettings value.
     */
    public ContainerSettings containerSettings() {
        return this.containerSettings;
    }

    /**
     * Set the containerSettings property: Docker container settings for the job. If not provided, the job will run
     * directly on the node.
     *
     * @param containerSettings the containerSettings value to set.
     * @return the JobCreateParameters object itself.
     */
    public JobCreateParameters withContainerSettings(ContainerSettings containerSettings) {
        this.containerSettings = containerSettings;
        return this;
    }

    /**
     * Get the cntkSettings property: Settings for CNTK (aka Microsoft Cognitive Toolkit) job.
     *
     * @return the cntkSettings value.
     */
    public CntKsettings cntkSettings() {
        return this.cntkSettings;
    }

    /**
     * Set the cntkSettings property: Settings for CNTK (aka Microsoft Cognitive Toolkit) job.
     *
     * @param cntkSettings the cntkSettings value to set.
     * @return the JobCreateParameters object itself.
     */
    public JobCreateParameters withCntkSettings(CntKsettings cntkSettings) {
        this.cntkSettings = cntkSettings;
        return this;
    }

    /**
     * Get the pyTorchSettings property: Settings for pyTorch job.
     *
     * @return the pyTorchSettings value.
     */
    public PyTorchSettings pyTorchSettings() {
        return this.pyTorchSettings;
    }

    /**
     * Set the pyTorchSettings property: Settings for pyTorch job.
     *
     * @param pyTorchSettings the pyTorchSettings value to set.
     * @return the JobCreateParameters object itself.
     */
    public JobCreateParameters withPyTorchSettings(PyTorchSettings pyTorchSettings) {
        this.pyTorchSettings = pyTorchSettings;
        return this;
    }

    /**
     * Get the tensorFlowSettings property: Settings for Tensor Flow job.
     *
     * @return the tensorFlowSettings value.
     */
    public TensorFlowSettings tensorFlowSettings() {
        return this.tensorFlowSettings;
    }

    /**
     * Set the tensorFlowSettings property: Settings for Tensor Flow job.
     *
     * @param tensorFlowSettings the tensorFlowSettings value to set.
     * @return the JobCreateParameters object itself.
     */
    public JobCreateParameters withTensorFlowSettings(TensorFlowSettings tensorFlowSettings) {
        this.tensorFlowSettings = tensorFlowSettings;
        return this;
    }

    /**
     * Get the caffeSettings property: Settings for Caffe job.
     *
     * @return the caffeSettings value.
     */
    public CaffeSettings caffeSettings() {
        return this.caffeSettings;
    }

    /**
     * Set the caffeSettings property: Settings for Caffe job.
     *
     * @param caffeSettings the caffeSettings value to set.
     * @return the JobCreateParameters object itself.
     */
    public JobCreateParameters withCaffeSettings(CaffeSettings caffeSettings) {
        this.caffeSettings = caffeSettings;
        return this;
    }

    /**
     * Get the caffe2Settings property: Settings for Caffe2 job.
     *
     * @return the caffe2Settings value.
     */
    public Caffe2Settings caffe2Settings() {
        return this.caffe2Settings;
    }

    /**
     * Set the caffe2Settings property: Settings for Caffe2 job.
     *
     * @param caffe2Settings the caffe2Settings value to set.
     * @return the JobCreateParameters object itself.
     */
    public JobCreateParameters withCaffe2Settings(Caffe2Settings caffe2Settings) {
        this.caffe2Settings = caffe2Settings;
        return this;
    }

    /**
     * Get the chainerSettings property: Settings for Chainer job.
     *
     * @return the chainerSettings value.
     */
    public ChainerSettings chainerSettings() {
        return this.chainerSettings;
    }

    /**
     * Set the chainerSettings property: Settings for Chainer job.
     *
     * @param chainerSettings the chainerSettings value to set.
     * @return the JobCreateParameters object itself.
     */
    public JobCreateParameters withChainerSettings(ChainerSettings chainerSettings) {
        this.chainerSettings = chainerSettings;
        return this;
    }

    /**
     * Get the customToolkitSettings property: Settings for custom tool kit job.
     *
     * @return the customToolkitSettings value.
     */
    public CustomToolkitSettings customToolkitSettings() {
        return this.customToolkitSettings;
    }

    /**
     * Set the customToolkitSettings property: Settings for custom tool kit job.
     *
     * @param customToolkitSettings the customToolkitSettings value to set.
     * @return the JobCreateParameters object itself.
     */
    public JobCreateParameters withCustomToolkitSettings(CustomToolkitSettings customToolkitSettings) {
        this.customToolkitSettings = customToolkitSettings;
        return this;
    }

    /**
     * Get the customMpiSettings property: Settings for custom MPI job.
     *
     * @return the customMpiSettings value.
     */
    public CustomMpiSettings customMpiSettings() {
        return this.customMpiSettings;
    }

    /**
     * Set the customMpiSettings property: Settings for custom MPI job.
     *
     * @param customMpiSettings the customMpiSettings value to set.
     * @return the JobCreateParameters object itself.
     */
    public JobCreateParameters withCustomMpiSettings(CustomMpiSettings customMpiSettings) {
        this.customMpiSettings = customMpiSettings;
        return this;
    }

    /**
     * Get the horovodSettings property: Settings for Horovod job.
     *
     * @return the horovodSettings value.
     */
    public HorovodSettings horovodSettings() {
        return this.horovodSettings;
    }

    /**
     * Set the horovodSettings property: Settings for Horovod job.
     *
     * @param horovodSettings the horovodSettings value to set.
     * @return the JobCreateParameters object itself.
     */
    public JobCreateParameters withHorovodSettings(HorovodSettings horovodSettings) {
        this.horovodSettings = horovodSettings;
        return this;
    }

    /**
     * Get the jobPreparation property: A command line to be executed on each node allocated for the job before tool kit
     * is launched.
     *
     * @return the jobPreparation value.
     */
    public JobPreparation jobPreparation() {
        return this.jobPreparation;
    }

    /**
     * Set the jobPreparation property: A command line to be executed on each node allocated for the job before tool kit
     * is launched.
     *
     * @param jobPreparation the jobPreparation value to set.
     * @return the JobCreateParameters object itself.
     */
    public JobCreateParameters withJobPreparation(JobPreparation jobPreparation) {
        this.jobPreparation = jobPreparation;
        return this;
    }

    /**
     * Get the stdOutErrPathPrefix property: The path where the Batch AI service will store stdout, stderror and
     * execution log of the job.
     *
     * @return the stdOutErrPathPrefix value.
     */
    public String stdOutErrPathPrefix() {
        return this.stdOutErrPathPrefix;
    }

    /**
     * Set the stdOutErrPathPrefix property: The path where the Batch AI service will store stdout, stderror and
     * execution log of the job.
     *
     * @param stdOutErrPathPrefix the stdOutErrPathPrefix value to set.
     * @return the JobCreateParameters object itself.
     */
    public JobCreateParameters withStdOutErrPathPrefix(String stdOutErrPathPrefix) {
        this.stdOutErrPathPrefix = stdOutErrPathPrefix;
        return this;
    }

    /**
     * Get the inputDirectories property: A list of input directories for the job.
     *
     * @return the inputDirectories value.
     */
    public List<InputDirectory> inputDirectories() {
        return this.inputDirectories;
    }

    /**
     * Set the inputDirectories property: A list of input directories for the job.
     *
     * @param inputDirectories the inputDirectories value to set.
     * @return the JobCreateParameters object itself.
     */
    public JobCreateParameters withInputDirectories(List<InputDirectory> inputDirectories) {
        this.inputDirectories = inputDirectories;
        return this;
    }

    /**
     * Get the outputDirectories property: A list of output directories for the job.
     *
     * @return the outputDirectories value.
     */
    public List<OutputDirectory> outputDirectories() {
        return this.outputDirectories;
    }

    /**
     * Set the outputDirectories property: A list of output directories for the job.
     *
     * @param outputDirectories the outputDirectories value to set.
     * @return the JobCreateParameters object itself.
     */
    public JobCreateParameters withOutputDirectories(List<OutputDirectory> outputDirectories) {
        this.outputDirectories = outputDirectories;
        return this;
    }

    /**
     * Get the environmentVariables property: A list of user defined environment variables which will be setup for the
     * job.
     *
     * @return the environmentVariables value.
     */
    public List<EnvironmentVariable> environmentVariables() {
        return this.environmentVariables;
    }

    /**
     * Set the environmentVariables property: A list of user defined environment variables which will be setup for the
     * job.
     *
     * @param environmentVariables the environmentVariables value to set.
     * @return the JobCreateParameters object itself.
     */
    public JobCreateParameters withEnvironmentVariables(List<EnvironmentVariable> environmentVariables) {
        this.environmentVariables = environmentVariables;
        return this;
    }

    /**
     * Get the secrets property: A list of user defined environment variables with secret values which will be setup for
     * the job. Server will never report values of these variables back.
     *
     * @return the secrets value.
     */
    public List<EnvironmentVariableWithSecretValue> secrets() {
        return this.secrets;
    }

    /**
     * Set the secrets property: A list of user defined environment variables with secret values which will be setup for
     * the job. Server will never report values of these variables back.
     *
     * @param secrets the secrets value to set.
     * @return the JobCreateParameters object itself.
     */
    public JobCreateParameters withSecrets(List<EnvironmentVariableWithSecretValue> secrets) {
        this.secrets = secrets;
        return this;
    }

    /**
     * Get the constraints property: Constraints associated with the Job.
     *
     * @return the constraints value.
     */
    public JobBasePropertiesConstraints constraints() {
        return this.constraints;
    }

    /**
     * Set the constraints property: Constraints associated with the Job.
     *
     * @param constraints the constraints value to set.
     * @return the JobCreateParameters object itself.
     */
    public JobCreateParameters withConstraints(JobBasePropertiesConstraints constraints) {
        this.constraints = constraints;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (cluster() != null) {
            cluster().validate();
        }
        if (mountVolumes() != null) {
            mountVolumes().validate();
        }
        if (containerSettings() != null) {
            containerSettings().validate();
        }
        if (cntkSettings() != null) {
            cntkSettings().validate();
        }
        if (pyTorchSettings() != null) {
            pyTorchSettings().validate();
        }
        if (tensorFlowSettings() != null) {
            tensorFlowSettings().validate();
        }
        if (caffeSettings() != null) {
            caffeSettings().validate();
        }
        if (caffe2Settings() != null) {
            caffe2Settings().validate();
        }
        if (chainerSettings() != null) {
            chainerSettings().validate();
        }
        if (customToolkitSettings() != null) {
            customToolkitSettings().validate();
        }
        if (customMpiSettings() != null) {
            customMpiSettings().validate();
        }
        if (horovodSettings() != null) {
            horovodSettings().validate();
        }
        if (jobPreparation() != null) {
            jobPreparation().validate();
        }
        if (inputDirectories() != null) {
            inputDirectories().forEach(e -> e.validate());
        }
        if (outputDirectories() != null) {
            outputDirectories().forEach(e -> e.validate());
        }
        if (environmentVariables() != null) {
            environmentVariables().forEach(e -> e.validate());
        }
        if (secrets() != null) {
            secrets().forEach(e -> e.validate());
        }
        if (constraints() != null) {
            constraints().validate();
        }
    }
}
