/**
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License. See License.txt in the project root for
 * license information.
 *
 * Code generated by Microsoft (R) AutoRest Code Generator.
 */

package com.microsoft.azure.batch.protocol.models;

import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * Specifies details of the Jobs to be created on a schedule.
 */
public class JobSpecification {
    /**
     * The priority of Jobs created under this schedule.
     * Priority values can range from -1000 to 1000, with -1000 being the
     * lowest priority and 1000 being the highest priority. The default value
     * is 0. This priority is used as the default for all Jobs under the Job
     * Schedule. You can update a Job's priority after it has been created
     * using by using the update Job API.
     */
    @JsonProperty(value = "priority")
    private Integer priority;

    /**
     * Whether Tasks in this job can be preempted by other high priority jobs.
     * If the value is set to True, other high priority jobs submitted to the
     * system will take precedence and will be able requeue tasks from this
     * job. You can update a job's allowTaskPreemption after it has been
     * created using the update job API.
     */
    @JsonProperty(value = "allowTaskPreemption")
    private Boolean allowTaskPreemption;

    /**
     * The maximum number of tasks that can be executed in parallel for the
     * job.
     * The value of maxParallelTasks must be -1 or greater than 0 if specified.
     * If not specified, the default value is -1, which means there's no limit
     * to the number of tasks that can be run at once. You can update a job's
     * maxParallelTasks after it has been created using the update job API.
     */
    @JsonProperty(value = "maxParallelTasks")
    private Integer maxParallelTasks;

    /**
     * The display name for Jobs created under this schedule.
     * The name need not be unique and can contain any Unicode characters up to
     * a maximum length of 1024.
     */
    @JsonProperty(value = "displayName")
    private String displayName;

    /**
     * Whether Tasks in the Job can define dependencies on each other. The
     * default is false.
     */
    @JsonProperty(value = "usesTaskDependencies")
    private Boolean usesTaskDependencies;

    /**
     * The action the Batch service should take when all Tasks in a Job created
     * under this schedule are in the completed state.
     * Note that if a Job contains no Tasks, then all Tasks are considered
     * complete. This option is therefore most commonly used with a Job Manager
     * task; if you want to use automatic Job termination without a Job
     * Manager, you should initially set onAllTasksComplete to noaction and
     * update the Job properties to set onAllTasksComplete to terminatejob once
     * you have finished adding Tasks. The default is noaction. Possible values
     * include: 'noAction', 'terminateJob'.
     */
    @JsonProperty(value = "onAllTasksComplete")
    private OnAllTasksComplete onAllTasksComplete;

    /**
     * The action the Batch service should take when any Task fails in a Job
     * created under this schedule. A Task is considered to have failed if it
     * have failed if has a failureInfo. A failureInfo is set if the Task
     * completes with a non-zero exit code after exhausting its retry count, or
     * if there was an error starting the Task, for example due to a resource
     * file download error.
     * The default is noaction. Possible values include: 'noAction',
     * 'performExitOptionsJobAction'.
     */
    @JsonProperty(value = "onTaskFailure")
    private OnTaskFailure onTaskFailure;

    /**
     * The network configuration for the Job.
     */
    @JsonProperty(value = "networkConfiguration")
    private JobNetworkConfiguration networkConfiguration;

    /**
     * The execution constraints for Jobs created under this schedule.
     */
    @JsonProperty(value = "constraints")
    private JobConstraints constraints;

    /**
     * The details of a Job Manager Task to be launched when a Job is started
     * under this schedule.
     * If the Job does not specify a Job Manager Task, the user must explicitly
     * add Tasks to the Job using the Task API. If the Job does specify a Job
     * Manager Task, the Batch service creates the Job Manager Task when the
     * Job is created, and will try to schedule the Job Manager Task before
     * scheduling other Tasks in the Job.
     */
    @JsonProperty(value = "jobManagerTask")
    private JobManagerTask jobManagerTask;

    /**
     * The Job Preparation Task for Jobs created under this schedule.
     * If a Job has a Job Preparation Task, the Batch service will run the Job
     * Preparation Task on a Node before starting any Tasks of that Job on that
     * Compute Node.
     */
    @JsonProperty(value = "jobPreparationTask")
    private JobPreparationTask jobPreparationTask;

    /**
     * The Job Release Task for Jobs created under this schedule.
     * The primary purpose of the Job Release Task is to undo changes to Nodes
     * made by the Job Preparation Task. Example activities include deleting
     * local files, or shutting down services that were started as part of Job
     * preparation. A Job Release Task cannot be specified without also
     * specifying a Job Preparation Task for the Job. The Batch service runs
     * the Job Release Task on the Compute Nodes that have run the Job
     * Preparation Task.
     */
    @JsonProperty(value = "jobReleaseTask")
    private JobReleaseTask jobReleaseTask;

    /**
     * A list of common environment variable settings. These environment
     * variables are set for all Tasks in Jobs created under this schedule
     * (including the Job Manager, Job Preparation and Job Release Tasks).
     * Individual Tasks can override an environment setting specified here by
     * specifying the same setting name with a different value.
     */
    @JsonProperty(value = "commonEnvironmentSettings")
    private List<EnvironmentSetting> commonEnvironmentSettings;

    /**
     * The Pool on which the Batch service runs the Tasks of Jobs created under
     * this schedule.
     */
    @JsonProperty(value = "poolInfo", required = true)
    private PoolInformation poolInfo;

    /**
     * A list of name-value pairs associated with each Job created under this
     * schedule as metadata.
     * The Batch service does not assign any meaning to metadata; it is solely
     * for the use of user code.
     */
    @JsonProperty(value = "metadata")
    private List<MetadataItem> metadata;

    /**
     * Get priority values can range from -1000 to 1000, with -1000 being the lowest priority and 1000 being the highest priority. The default value is 0. This priority is used as the default for all Jobs under the Job Schedule. You can update a Job's priority after it has been created using by using the update Job API.
     *
     * @return the priority value
     */
    public Integer priority() {
        return this.priority;
    }

    /**
     * Set priority values can range from -1000 to 1000, with -1000 being the lowest priority and 1000 being the highest priority. The default value is 0. This priority is used as the default for all Jobs under the Job Schedule. You can update a Job's priority after it has been created using by using the update Job API.
     *
     * @param priority the priority value to set
     * @return the JobSpecification object itself.
     */
    public JobSpecification withPriority(Integer priority) {
        this.priority = priority;
        return this;
    }

    /**
     * Get if the value is set to True, other high priority jobs submitted to the system will take precedence and will be able requeue tasks from this job. You can update a job's allowTaskPreemption after it has been created using the update job API.
     *
     * @return the allowTaskPreemption value
     */
    public Boolean allowTaskPreemption() {
        return this.allowTaskPreemption;
    }

    /**
     * Set if the value is set to True, other high priority jobs submitted to the system will take precedence and will be able requeue tasks from this job. You can update a job's allowTaskPreemption after it has been created using the update job API.
     *
     * @param allowTaskPreemption the allowTaskPreemption value to set
     * @return the JobSpecification object itself.
     */
    public JobSpecification withAllowTaskPreemption(Boolean allowTaskPreemption) {
        this.allowTaskPreemption = allowTaskPreemption;
        return this;
    }

    /**
     * Get the value of maxParallelTasks must be -1 or greater than 0 if specified. If not specified, the default value is -1, which means there's no limit to the number of tasks that can be run at once. You can update a job's maxParallelTasks after it has been created using the update job API.
     *
     * @return the maxParallelTasks value
     */
    public Integer maxParallelTasks() {
        return this.maxParallelTasks;
    }

    /**
     * Set the value of maxParallelTasks must be -1 or greater than 0 if specified. If not specified, the default value is -1, which means there's no limit to the number of tasks that can be run at once. You can update a job's maxParallelTasks after it has been created using the update job API.
     *
     * @param maxParallelTasks the maxParallelTasks value to set
     * @return the JobSpecification object itself.
     */
    public JobSpecification withMaxParallelTasks(Integer maxParallelTasks) {
        this.maxParallelTasks = maxParallelTasks;
        return this;
    }

    /**
     * Get the name need not be unique and can contain any Unicode characters up to a maximum length of 1024.
     *
     * @return the displayName value
     */
    public String displayName() {
        return this.displayName;
    }

    /**
     * Set the name need not be unique and can contain any Unicode characters up to a maximum length of 1024.
     *
     * @param displayName the displayName value to set
     * @return the JobSpecification object itself.
     */
    public JobSpecification withDisplayName(String displayName) {
        this.displayName = displayName;
        return this;
    }

    /**
     * Get the usesTaskDependencies value.
     *
     * @return the usesTaskDependencies value
     */
    public Boolean usesTaskDependencies() {
        return this.usesTaskDependencies;
    }

    /**
     * Set the usesTaskDependencies value.
     *
     * @param usesTaskDependencies the usesTaskDependencies value to set
     * @return the JobSpecification object itself.
     */
    public JobSpecification withUsesTaskDependencies(Boolean usesTaskDependencies) {
        this.usesTaskDependencies = usesTaskDependencies;
        return this;
    }

    /**
     * Get note that if a Job contains no Tasks, then all Tasks are considered complete. This option is therefore most commonly used with a Job Manager task; if you want to use automatic Job termination without a Job Manager, you should initially set onAllTasksComplete to noaction and update the Job properties to set onAllTasksComplete to terminatejob once you have finished adding Tasks. The default is noaction. Possible values include: 'noAction', 'terminateJob'.
     *
     * @return the onAllTasksComplete value
     */
    public OnAllTasksComplete onAllTasksComplete() {
        return this.onAllTasksComplete;
    }

    /**
     * Set note that if a Job contains no Tasks, then all Tasks are considered complete. This option is therefore most commonly used with a Job Manager task; if you want to use automatic Job termination without a Job Manager, you should initially set onAllTasksComplete to noaction and update the Job properties to set onAllTasksComplete to terminatejob once you have finished adding Tasks. The default is noaction. Possible values include: 'noAction', 'terminateJob'.
     *
     * @param onAllTasksComplete the onAllTasksComplete value to set
     * @return the JobSpecification object itself.
     */
    public JobSpecification withOnAllTasksComplete(OnAllTasksComplete onAllTasksComplete) {
        this.onAllTasksComplete = onAllTasksComplete;
        return this;
    }

    /**
     * Get the default is noaction. Possible values include: 'noAction', 'performExitOptionsJobAction'.
     *
     * @return the onTaskFailure value
     */
    public OnTaskFailure onTaskFailure() {
        return this.onTaskFailure;
    }

    /**
     * Set the default is noaction. Possible values include: 'noAction', 'performExitOptionsJobAction'.
     *
     * @param onTaskFailure the onTaskFailure value to set
     * @return the JobSpecification object itself.
     */
    public JobSpecification withOnTaskFailure(OnTaskFailure onTaskFailure) {
        this.onTaskFailure = onTaskFailure;
        return this;
    }

    /**
     * Get the networkConfiguration value.
     *
     * @return the networkConfiguration value
     */
    public JobNetworkConfiguration networkConfiguration() {
        return this.networkConfiguration;
    }

    /**
     * Set the networkConfiguration value.
     *
     * @param networkConfiguration the networkConfiguration value to set
     * @return the JobSpecification object itself.
     */
    public JobSpecification withNetworkConfiguration(JobNetworkConfiguration networkConfiguration) {
        this.networkConfiguration = networkConfiguration;
        return this;
    }

    /**
     * Get the constraints value.
     *
     * @return the constraints value
     */
    public JobConstraints constraints() {
        return this.constraints;
    }

    /**
     * Set the constraints value.
     *
     * @param constraints the constraints value to set
     * @return the JobSpecification object itself.
     */
    public JobSpecification withConstraints(JobConstraints constraints) {
        this.constraints = constraints;
        return this;
    }

    /**
     * Get if the Job does not specify a Job Manager Task, the user must explicitly add Tasks to the Job using the Task API. If the Job does specify a Job Manager Task, the Batch service creates the Job Manager Task when the Job is created, and will try to schedule the Job Manager Task before scheduling other Tasks in the Job.
     *
     * @return the jobManagerTask value
     */
    public JobManagerTask jobManagerTask() {
        return this.jobManagerTask;
    }

    /**
     * Set if the Job does not specify a Job Manager Task, the user must explicitly add Tasks to the Job using the Task API. If the Job does specify a Job Manager Task, the Batch service creates the Job Manager Task when the Job is created, and will try to schedule the Job Manager Task before scheduling other Tasks in the Job.
     *
     * @param jobManagerTask the jobManagerTask value to set
     * @return the JobSpecification object itself.
     */
    public JobSpecification withJobManagerTask(JobManagerTask jobManagerTask) {
        this.jobManagerTask = jobManagerTask;
        return this;
    }

    /**
     * Get if a Job has a Job Preparation Task, the Batch service will run the Job Preparation Task on a Node before starting any Tasks of that Job on that Compute Node.
     *
     * @return the jobPreparationTask value
     */
    public JobPreparationTask jobPreparationTask() {
        return this.jobPreparationTask;
    }

    /**
     * Set if a Job has a Job Preparation Task, the Batch service will run the Job Preparation Task on a Node before starting any Tasks of that Job on that Compute Node.
     *
     * @param jobPreparationTask the jobPreparationTask value to set
     * @return the JobSpecification object itself.
     */
    public JobSpecification withJobPreparationTask(JobPreparationTask jobPreparationTask) {
        this.jobPreparationTask = jobPreparationTask;
        return this;
    }

    /**
     * Get the primary purpose of the Job Release Task is to undo changes to Nodes made by the Job Preparation Task. Example activities include deleting local files, or shutting down services that were started as part of Job preparation. A Job Release Task cannot be specified without also specifying a Job Preparation Task for the Job. The Batch service runs the Job Release Task on the Compute Nodes that have run the Job Preparation Task.
     *
     * @return the jobReleaseTask value
     */
    public JobReleaseTask jobReleaseTask() {
        return this.jobReleaseTask;
    }

    /**
     * Set the primary purpose of the Job Release Task is to undo changes to Nodes made by the Job Preparation Task. Example activities include deleting local files, or shutting down services that were started as part of Job preparation. A Job Release Task cannot be specified without also specifying a Job Preparation Task for the Job. The Batch service runs the Job Release Task on the Compute Nodes that have run the Job Preparation Task.
     *
     * @param jobReleaseTask the jobReleaseTask value to set
     * @return the JobSpecification object itself.
     */
    public JobSpecification withJobReleaseTask(JobReleaseTask jobReleaseTask) {
        this.jobReleaseTask = jobReleaseTask;
        return this;
    }

    /**
     * Get individual Tasks can override an environment setting specified here by specifying the same setting name with a different value.
     *
     * @return the commonEnvironmentSettings value
     */
    public List<EnvironmentSetting> commonEnvironmentSettings() {
        return this.commonEnvironmentSettings;
    }

    /**
     * Set individual Tasks can override an environment setting specified here by specifying the same setting name with a different value.
     *
     * @param commonEnvironmentSettings the commonEnvironmentSettings value to set
     * @return the JobSpecification object itself.
     */
    public JobSpecification withCommonEnvironmentSettings(List<EnvironmentSetting> commonEnvironmentSettings) {
        this.commonEnvironmentSettings = commonEnvironmentSettings;
        return this;
    }

    /**
     * Get the poolInfo value.
     *
     * @return the poolInfo value
     */
    public PoolInformation poolInfo() {
        return this.poolInfo;
    }

    /**
     * Set the poolInfo value.
     *
     * @param poolInfo the poolInfo value to set
     * @return the JobSpecification object itself.
     */
    public JobSpecification withPoolInfo(PoolInformation poolInfo) {
        this.poolInfo = poolInfo;
        return this;
    }

    /**
     * Get the Batch service does not assign any meaning to metadata; it is solely for the use of user code.
     *
     * @return the metadata value
     */
    public List<MetadataItem> metadata() {
        return this.metadata;
    }

    /**
     * Set the Batch service does not assign any meaning to metadata; it is solely for the use of user code.
     *
     * @param metadata the metadata value to set
     * @return the JobSpecification object itself.
     */
    public JobSpecification withMetadata(List<MetadataItem> metadata) {
        this.metadata = metadata;
        return this;
    }

}
