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

package com.azure.resourcemanager.recoveryservicessiterecovery.models;

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

/** Task of the Job. */
@Fluent
public final class AsrTask {
    /*
     * The Id.
     */
    @JsonProperty(value = "taskId")
    private String taskId;

    /*
     * The unique Task name.
     */
    @JsonProperty(value = "name")
    private String name;

    /*
     * The start time.
     */
    @JsonProperty(value = "startTime")
    private OffsetDateTime startTime;

    /*
     * The end time.
     */
    @JsonProperty(value = "endTime")
    private OffsetDateTime endTime;

    /*
     * The state/actions applicable on this task.
     */
    @JsonProperty(value = "allowedActions")
    private List<String> allowedActions;

    /*
     * The name.
     */
    @JsonProperty(value = "friendlyName")
    private String friendlyName;

    /*
     * The State. It is one of these values - NotStarted, InProgress, Succeeded, Failed, Cancelled, Suspended or Other.
     */
    @JsonProperty(value = "state")
    private String state;

    /*
     * The description of the task state. For example - For Succeeded state, description can be Completed,
     * PartiallySucceeded, CompletedWithInformation or Skipped.
     */
    @JsonProperty(value = "stateDescription")
    private String stateDescription;

    /*
     * The type of task. Details in CustomDetails property depend on this type.
     */
    @JsonProperty(value = "taskType")
    private String taskType;

    /*
     * The custom task details based on the task type.
     */
    @JsonProperty(value = "customDetails")
    private TaskTypeDetails customDetails;

    /*
     * The custom task details based on the task type, if the task type is GroupTaskDetails or one of the types derived
     * from it.
     */
    @JsonProperty(value = "groupTaskCustomDetails")
    private GroupTaskDetails groupTaskCustomDetails;

    /*
     * The task error details.
     */
    @JsonProperty(value = "errors")
    private List<JobErrorDetails> errors;

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

    /**
     * Get the taskId property: The Id.
     *
     * @return the taskId value.
     */
    public String taskId() {
        return this.taskId;
    }

    /**
     * Set the taskId property: The Id.
     *
     * @param taskId the taskId value to set.
     * @return the AsrTask object itself.
     */
    public AsrTask withTaskId(String taskId) {
        this.taskId = taskId;
        return this;
    }

    /**
     * Get the name property: The unique Task name.
     *
     * @return the name value.
     */
    public String name() {
        return this.name;
    }

    /**
     * Set the name property: The unique Task name.
     *
     * @param name the name value to set.
     * @return the AsrTask object itself.
     */
    public AsrTask withName(String name) {
        this.name = name;
        return this;
    }

    /**
     * Get the startTime property: The start time.
     *
     * @return the startTime value.
     */
    public OffsetDateTime startTime() {
        return this.startTime;
    }

    /**
     * Set the startTime property: The start time.
     *
     * @param startTime the startTime value to set.
     * @return the AsrTask object itself.
     */
    public AsrTask withStartTime(OffsetDateTime startTime) {
        this.startTime = startTime;
        return this;
    }

    /**
     * Get the endTime property: The end time.
     *
     * @return the endTime value.
     */
    public OffsetDateTime endTime() {
        return this.endTime;
    }

    /**
     * Set the endTime property: The end time.
     *
     * @param endTime the endTime value to set.
     * @return the AsrTask object itself.
     */
    public AsrTask withEndTime(OffsetDateTime endTime) {
        this.endTime = endTime;
        return this;
    }

    /**
     * Get the allowedActions property: The state/actions applicable on this task.
     *
     * @return the allowedActions value.
     */
    public List<String> allowedActions() {
        return this.allowedActions;
    }

    /**
     * Set the allowedActions property: The state/actions applicable on this task.
     *
     * @param allowedActions the allowedActions value to set.
     * @return the AsrTask object itself.
     */
    public AsrTask withAllowedActions(List<String> allowedActions) {
        this.allowedActions = allowedActions;
        return this;
    }

    /**
     * Get the friendlyName property: The name.
     *
     * @return the friendlyName value.
     */
    public String friendlyName() {
        return this.friendlyName;
    }

    /**
     * Set the friendlyName property: The name.
     *
     * @param friendlyName the friendlyName value to set.
     * @return the AsrTask object itself.
     */
    public AsrTask withFriendlyName(String friendlyName) {
        this.friendlyName = friendlyName;
        return this;
    }

    /**
     * Get the state property: The State. It is one of these values - NotStarted, InProgress, Succeeded, Failed,
     * Cancelled, Suspended or Other.
     *
     * @return the state value.
     */
    public String state() {
        return this.state;
    }

    /**
     * Set the state property: The State. It is one of these values - NotStarted, InProgress, Succeeded, Failed,
     * Cancelled, Suspended or Other.
     *
     * @param state the state value to set.
     * @return the AsrTask object itself.
     */
    public AsrTask withState(String state) {
        this.state = state;
        return this;
    }

    /**
     * Get the stateDescription property: The description of the task state. For example - For Succeeded state,
     * description can be Completed, PartiallySucceeded, CompletedWithInformation or Skipped.
     *
     * @return the stateDescription value.
     */
    public String stateDescription() {
        return this.stateDescription;
    }

    /**
     * Set the stateDescription property: The description of the task state. For example - For Succeeded state,
     * description can be Completed, PartiallySucceeded, CompletedWithInformation or Skipped.
     *
     * @param stateDescription the stateDescription value to set.
     * @return the AsrTask object itself.
     */
    public AsrTask withStateDescription(String stateDescription) {
        this.stateDescription = stateDescription;
        return this;
    }

    /**
     * Get the taskType property: The type of task. Details in CustomDetails property depend on this type.
     *
     * @return the taskType value.
     */
    public String taskType() {
        return this.taskType;
    }

    /**
     * Set the taskType property: The type of task. Details in CustomDetails property depend on this type.
     *
     * @param taskType the taskType value to set.
     * @return the AsrTask object itself.
     */
    public AsrTask withTaskType(String taskType) {
        this.taskType = taskType;
        return this;
    }

    /**
     * Get the customDetails property: The custom task details based on the task type.
     *
     * @return the customDetails value.
     */
    public TaskTypeDetails customDetails() {
        return this.customDetails;
    }

    /**
     * Set the customDetails property: The custom task details based on the task type.
     *
     * @param customDetails the customDetails value to set.
     * @return the AsrTask object itself.
     */
    public AsrTask withCustomDetails(TaskTypeDetails customDetails) {
        this.customDetails = customDetails;
        return this;
    }

    /**
     * Get the groupTaskCustomDetails property: The custom task details based on the task type, if the task type is
     * GroupTaskDetails or one of the types derived from it.
     *
     * @return the groupTaskCustomDetails value.
     */
    public GroupTaskDetails groupTaskCustomDetails() {
        return this.groupTaskCustomDetails;
    }

    /**
     * Set the groupTaskCustomDetails property: The custom task details based on the task type, if the task type is
     * GroupTaskDetails or one of the types derived from it.
     *
     * @param groupTaskCustomDetails the groupTaskCustomDetails value to set.
     * @return the AsrTask object itself.
     */
    public AsrTask withGroupTaskCustomDetails(GroupTaskDetails groupTaskCustomDetails) {
        this.groupTaskCustomDetails = groupTaskCustomDetails;
        return this;
    }

    /**
     * Get the errors property: The task error details.
     *
     * @return the errors value.
     */
    public List<JobErrorDetails> errors() {
        return this.errors;
    }

    /**
     * Set the errors property: The task error details.
     *
     * @param errors the errors value to set.
     * @return the AsrTask object itself.
     */
    public AsrTask withErrors(List<JobErrorDetails> errors) {
        this.errors = errors;
        return this;
    }

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