<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/cloud/batch/v1/job.proto

namespace Google\Cloud\Batch\V1;

use Google\Protobuf\Internal\GPBType;
use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;

/**
 * Job status.
 *
 * Generated from protobuf message <code>google.cloud.batch.v1.JobStatus</code>
 */
class JobStatus extends \Google\Protobuf\Internal\Message
{
    /**
     * Job state
     *
     * Generated from protobuf field <code>.google.cloud.batch.v1.JobStatus.State state = 1;</code>
     */
    private $state = 0;
    /**
     * Job status events
     *
     * Generated from protobuf field <code>repeated .google.cloud.batch.v1.StatusEvent status_events = 2;</code>
     */
    private $status_events;
    /**
     * Aggregated task status for each TaskGroup in the Job.
     * The map key is TaskGroup ID.
     *
     * Generated from protobuf field <code>map<string, .google.cloud.batch.v1.JobStatus.TaskGroupStatus> task_groups = 4;</code>
     */
    private $task_groups;
    /**
     * The duration of time that the Job spent in status RUNNING.
     *
     * Generated from protobuf field <code>.google.protobuf.Duration run_duration = 5;</code>
     */
    private $run_duration = null;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type int $state
     *           Job state
     *     @type array<\Google\Cloud\Batch\V1\StatusEvent>|\Google\Protobuf\Internal\RepeatedField $status_events
     *           Job status events
     *     @type array|\Google\Protobuf\Internal\MapField $task_groups
     *           Aggregated task status for each TaskGroup in the Job.
     *           The map key is TaskGroup ID.
     *     @type \Google\Protobuf\Duration $run_duration
     *           The duration of time that the Job spent in status RUNNING.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Cloud\Batch\V1\Job::initOnce();
        parent::__construct($data);
    }

    /**
     * Job state
     *
     * Generated from protobuf field <code>.google.cloud.batch.v1.JobStatus.State state = 1;</code>
     * @return int
     */
    public function getState()
    {
        return $this->state;
    }

    /**
     * Job state
     *
     * Generated from protobuf field <code>.google.cloud.batch.v1.JobStatus.State state = 1;</code>
     * @param int $var
     * @return $this
     */
    public function setState($var)
    {
        GPBUtil::checkEnum($var, \Google\Cloud\Batch\V1\JobStatus\State::class);
        $this->state = $var;

        return $this;
    }

    /**
     * Job status events
     *
     * Generated from protobuf field <code>repeated .google.cloud.batch.v1.StatusEvent status_events = 2;</code>
     * @return \Google\Protobuf\Internal\RepeatedField
     */
    public function getStatusEvents()
    {
        return $this->status_events;
    }

    /**
     * Job status events
     *
     * Generated from protobuf field <code>repeated .google.cloud.batch.v1.StatusEvent status_events = 2;</code>
     * @param array<\Google\Cloud\Batch\V1\StatusEvent>|\Google\Protobuf\Internal\RepeatedField $var
     * @return $this
     */
    public function setStatusEvents($var)
    {
        $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Batch\V1\StatusEvent::class);
        $this->status_events = $arr;

        return $this;
    }

    /**
     * Aggregated task status for each TaskGroup in the Job.
     * The map key is TaskGroup ID.
     *
     * Generated from protobuf field <code>map<string, .google.cloud.batch.v1.JobStatus.TaskGroupStatus> task_groups = 4;</code>
     * @return \Google\Protobuf\Internal\MapField
     */
    public function getTaskGroups()
    {
        return $this->task_groups;
    }

    /**
     * Aggregated task status for each TaskGroup in the Job.
     * The map key is TaskGroup ID.
     *
     * Generated from protobuf field <code>map<string, .google.cloud.batch.v1.JobStatus.TaskGroupStatus> task_groups = 4;</code>
     * @param array|\Google\Protobuf\Internal\MapField $var
     * @return $this
     */
    public function setTaskGroups($var)
    {
        $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Batch\V1\JobStatus\TaskGroupStatus::class);
        $this->task_groups = $arr;

        return $this;
    }

    /**
     * The duration of time that the Job spent in status RUNNING.
     *
     * Generated from protobuf field <code>.google.protobuf.Duration run_duration = 5;</code>
     * @return \Google\Protobuf\Duration|null
     */
    public function getRunDuration()
    {
        return $this->run_duration;
    }

    public function hasRunDuration()
    {
        return isset($this->run_duration);
    }

    public function clearRunDuration()
    {
        unset($this->run_duration);
    }

    /**
     * The duration of time that the Job spent in status RUNNING.
     *
     * Generated from protobuf field <code>.google.protobuf.Duration run_duration = 5;</code>
     * @param \Google\Protobuf\Duration $var
     * @return $this
     */
    public function setRunDuration($var)
    {
        GPBUtil::checkMessage($var, \Google\Protobuf\Duration::class);
        $this->run_duration = $var;

        return $this;
    }

}

