/**
 * 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 org.joda.time.Period;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * Execution constraints to apply to a Task.
 */
public class TaskConstraints {
    /**
     * The maximum elapsed time that the Task may run, measured from the time
     * the Task starts. If the Task does not complete within the time limit,
     * the Batch service terminates it.
     * If this is not specified, there is no time limit on how long the Task
     * may run.
     */
    @JsonProperty(value = "maxWallClockTime")
    private Period maxWallClockTime;

    /**
     * The minimum time to retain the Task directory on the Compute Node where
     * it ran, from the time it completes execution. After this time, the Batch
     * service may delete the Task directory and all its contents.
     * The default is 7 days, i.e. the Task directory will be retained for 7
     * days unless the Compute Node is removed or the Job is deleted.
     */
    @JsonProperty(value = "retentionTime")
    private Period retentionTime;

    /**
     * The maximum number of times the Task may be retried. The Batch service
     * retries a Task if its exit code is nonzero.
     * Note that this value specifically controls the number of retries for the
     * Task executable due to a nonzero exit code. The Batch service will try
     * the Task once, and may then retry up to this limit. For example, if the
     * maximum retry count is 3, Batch tries the Task up to 4 times (one
     * initial try and 3 retries). If the maximum retry count is 0, the Batch
     * service does not retry the Task after the first attempt. If the maximum
     * retry count is -1, the Batch service retries the Task without limit,
     * however this is not recommended for a start task or any task. The
     * default value is 0 (no retries).
     */
    @JsonProperty(value = "maxTaskRetryCount")
    private Integer maxTaskRetryCount;

    /**
     * Get if this is not specified, there is no time limit on how long the Task may run.
     *
     * @return the maxWallClockTime value
     */
    public Period maxWallClockTime() {
        return this.maxWallClockTime;
    }

    /**
     * Set if this is not specified, there is no time limit on how long the Task may run.
     *
     * @param maxWallClockTime the maxWallClockTime value to set
     * @return the TaskConstraints object itself.
     */
    public TaskConstraints withMaxWallClockTime(Period maxWallClockTime) {
        this.maxWallClockTime = maxWallClockTime;
        return this;
    }

    /**
     * Get the default is 7 days, i.e. the Task directory will be retained for 7 days unless the Compute Node is removed or the Job is deleted.
     *
     * @return the retentionTime value
     */
    public Period retentionTime() {
        return this.retentionTime;
    }

    /**
     * Set the default is 7 days, i.e. the Task directory will be retained for 7 days unless the Compute Node is removed or the Job is deleted.
     *
     * @param retentionTime the retentionTime value to set
     * @return the TaskConstraints object itself.
     */
    public TaskConstraints withRetentionTime(Period retentionTime) {
        this.retentionTime = retentionTime;
        return this;
    }

    /**
     * Get note that this value specifically controls the number of retries for the Task executable due to a nonzero exit code. The Batch service will try the Task once, and may then retry up to this limit. For example, if the maximum retry count is 3, Batch tries the Task up to 4 times (one initial try and 3 retries). If the maximum retry count is 0, the Batch service does not retry the Task after the first attempt. If the maximum retry count is -1, the Batch service retries the Task without limit, however this is not recommended for a start task or any task. The default value is 0 (no retries).
     *
     * @return the maxTaskRetryCount value
     */
    public Integer maxTaskRetryCount() {
        return this.maxTaskRetryCount;
    }

    /**
     * Set note that this value specifically controls the number of retries for the Task executable due to a nonzero exit code. The Batch service will try the Task once, and may then retry up to this limit. For example, if the maximum retry count is 3, Batch tries the Task up to 4 times (one initial try and 3 retries). If the maximum retry count is 0, the Batch service does not retry the Task after the first attempt. If the maximum retry count is -1, the Batch service retries the Task without limit, however this is not recommended for a start task or any task. The default value is 0 (no retries).
     *
     * @param maxTaskRetryCount the maxTaskRetryCount value to set
     * @return the TaskConstraints object itself.
     */
    public TaskConstraints withMaxTaskRetryCount(Integer maxTaskRetryCount) {
        this.maxTaskRetryCount = maxTaskRetryCount;
        return this;
    }

}
