// 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.Immutable;
import com.azure.core.util.logging.ClientLogger;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.OffsetDateTime;
import java.util.List;

/** Information about the execution of a job. */
@Immutable
public final class JobPropertiesExecutionInfo {
    @JsonIgnore private final ClientLogger logger = new ClientLogger(JobPropertiesExecutionInfo.class);

    /*
     * The time at which the job started running. 'Running' corresponds to the
     * running state. If the job has been restarted or retried, this is the
     * most recent time at which the job started running. This property is
     * present only for job that are in the running or completed state.
     */
    @JsonProperty(value = "startTime", access = JsonProperty.Access.WRITE_ONLY)
    private OffsetDateTime startTime;

    /*
     * The time at which the job completed. This property is only returned if
     * the job is in completed state.
     */
    @JsonProperty(value = "endTime", access = JsonProperty.Access.WRITE_ONLY)
    private OffsetDateTime endTime;

    /*
     * The exit code of the job. This property is only returned if the job is
     * in completed state.
     */
    @JsonProperty(value = "exitCode", access = JsonProperty.Access.WRITE_ONLY)
    private Integer exitCode;

    /*
     * A collection of errors encountered by the service during job execution.
     */
    @JsonProperty(value = "errors", access = JsonProperty.Access.WRITE_ONLY)
    private List<BatchAIError> errors;

    /**
     * Get the startTime property: The time at which the job started running. 'Running' corresponds to the running
     * state. If the job has been restarted or retried, this is the most recent time at which the job started running.
     * This property is present only for job that are in the running or completed state.
     *
     * @return the startTime value.
     */
    public OffsetDateTime startTime() {
        return this.startTime;
    }

    /**
     * Get the endTime property: The time at which the job completed. This property is only returned if the job is in
     * completed state.
     *
     * @return the endTime value.
     */
    public OffsetDateTime endTime() {
        return this.endTime;
    }

    /**
     * Get the exitCode property: The exit code of the job. This property is only returned if the job is in completed
     * state.
     *
     * @return the exitCode value.
     */
    public Integer exitCode() {
        return this.exitCode;
    }

    /**
     * Get the errors property: A collection of errors encountered by the service during job execution.
     *
     * @return the errors value.
     */
    public List<BatchAIError> errors() {
        return this.errors;
    }

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