<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/cloud/tasks/v2beta2/task.proto

namespace Google\Cloud\Tasks\V2beta2;

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

/**
 * A unit of scheduled work.
 *
 * Generated from protobuf message <code>google.cloud.tasks.v2beta2.Task</code>
 */
class Task extends \Google\Protobuf\Internal\Message
{
    /**
     * Optionally caller-specified in [CreateTask][google.cloud.tasks.v2beta2.CloudTasks.CreateTask].
     * The task name.
     * The task name must have the following format:
     * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
     * * `PROJECT_ID` can contain letters ([A-Za-z]), numbers ([0-9]),
     *    hyphens (-), colons (:), or periods (.).
     *    For more information, see
     *    [Identifying
     *    projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects)
     * * `LOCATION_ID` is the canonical ID for the task's location.
     *    The list of available locations can be obtained by calling
     *    [ListLocations][google.cloud.location.Locations.ListLocations].
     *    For more information, see https://cloud.google.com/about/locations/.
     * * `QUEUE_ID` can contain letters ([A-Za-z]), numbers ([0-9]), or
     *   hyphens (-). The maximum length is 100 characters.
     * * `TASK_ID` can contain only letters ([A-Za-z]), numbers ([0-9]),
     *   hyphens (-), or underscores (_). The maximum length is 500 characters.
     *
     * Generated from protobuf field <code>string name = 1;</code>
     */
    private $name = '';
    /**
     * The time when the task is scheduled to be attempted.
     * For App Engine queues, this is when the task will be attempted or retried.
     * For pull queues, this is the time when the task is available to
     * be leased; if a task is currently leased, this is the time when
     * the current lease expires, that is, the time that the task was
     * leased plus the [lease_duration][google.cloud.tasks.v2beta2.LeaseTasksRequest.lease_duration].
     * `schedule_time` will be truncated to the nearest microsecond.
     *
     * Generated from protobuf field <code>.google.protobuf.Timestamp schedule_time = 5;</code>
     */
    private $schedule_time = null;
    /**
     * Output only. The time that the task was created.
     * `create_time` will be truncated to the nearest second.
     *
     * Generated from protobuf field <code>.google.protobuf.Timestamp create_time = 6;</code>
     */
    private $create_time = null;
    /**
     * Output only. The task status.
     *
     * Generated from protobuf field <code>.google.cloud.tasks.v2beta2.TaskStatus status = 7;</code>
     */
    private $status = null;
    /**
     * Output only. The view specifies which subset of the [Task][google.cloud.tasks.v2beta2.Task] has
     * been returned.
     *
     * Generated from protobuf field <code>.google.cloud.tasks.v2beta2.Task.View view = 8;</code>
     */
    private $view = 0;
    protected $payload_type;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type string $name
     *           Optionally caller-specified in [CreateTask][google.cloud.tasks.v2beta2.CloudTasks.CreateTask].
     *           The task name.
     *           The task name must have the following format:
     *           `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
     *           * `PROJECT_ID` can contain letters ([A-Za-z]), numbers ([0-9]),
     *              hyphens (-), colons (:), or periods (.).
     *              For more information, see
     *              [Identifying
     *              projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects)
     *           * `LOCATION_ID` is the canonical ID for the task's location.
     *              The list of available locations can be obtained by calling
     *              [ListLocations][google.cloud.location.Locations.ListLocations].
     *              For more information, see https://cloud.google.com/about/locations/.
     *           * `QUEUE_ID` can contain letters ([A-Za-z]), numbers ([0-9]), or
     *             hyphens (-). The maximum length is 100 characters.
     *           * `TASK_ID` can contain only letters ([A-Za-z]), numbers ([0-9]),
     *             hyphens (-), or underscores (_). The maximum length is 500 characters.
     *     @type \Google\Cloud\Tasks\V2beta2\AppEngineHttpRequest $app_engine_http_request
     *           App Engine HTTP request that is sent to the task's target. Can
     *           be set only if
     *           [app_engine_http_target][google.cloud.tasks.v2beta2.Queue.app_engine_http_target] is set
     *           on the queue.
     *           An App Engine task is a task that has [AppEngineHttpRequest][google.cloud.tasks.v2beta2.AppEngineHttpRequest] set.
     *     @type \Google\Cloud\Tasks\V2beta2\PullMessage $pull_message
     *           [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks] to process the task. Can be
     *           set only if [pull_target][google.cloud.tasks.v2beta2.Queue.pull_target] is set on the queue.
     *           A pull task is a task that has [PullMessage][google.cloud.tasks.v2beta2.PullMessage] set.
     *     @type \Google\Protobuf\Timestamp $schedule_time
     *           The time when the task is scheduled to be attempted.
     *           For App Engine queues, this is when the task will be attempted or retried.
     *           For pull queues, this is the time when the task is available to
     *           be leased; if a task is currently leased, this is the time when
     *           the current lease expires, that is, the time that the task was
     *           leased plus the [lease_duration][google.cloud.tasks.v2beta2.LeaseTasksRequest.lease_duration].
     *           `schedule_time` will be truncated to the nearest microsecond.
     *     @type \Google\Protobuf\Timestamp $create_time
     *           Output only. The time that the task was created.
     *           `create_time` will be truncated to the nearest second.
     *     @type \Google\Cloud\Tasks\V2beta2\TaskStatus $status
     *           Output only. The task status.
     *     @type int $view
     *           Output only. The view specifies which subset of the [Task][google.cloud.tasks.v2beta2.Task] has
     *           been returned.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Cloud\Tasks\V2Beta2\Task::initOnce();
        parent::__construct($data);
    }

    /**
     * Optionally caller-specified in [CreateTask][google.cloud.tasks.v2beta2.CloudTasks.CreateTask].
     * The task name.
     * The task name must have the following format:
     * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
     * * `PROJECT_ID` can contain letters ([A-Za-z]), numbers ([0-9]),
     *    hyphens (-), colons (:), or periods (.).
     *    For more information, see
     *    [Identifying
     *    projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects)
     * * `LOCATION_ID` is the canonical ID for the task's location.
     *    The list of available locations can be obtained by calling
     *    [ListLocations][google.cloud.location.Locations.ListLocations].
     *    For more information, see https://cloud.google.com/about/locations/.
     * * `QUEUE_ID` can contain letters ([A-Za-z]), numbers ([0-9]), or
     *   hyphens (-). The maximum length is 100 characters.
     * * `TASK_ID` can contain only letters ([A-Za-z]), numbers ([0-9]),
     *   hyphens (-), or underscores (_). The maximum length is 500 characters.
     *
     * Generated from protobuf field <code>string name = 1;</code>
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Optionally caller-specified in [CreateTask][google.cloud.tasks.v2beta2.CloudTasks.CreateTask].
     * The task name.
     * The task name must have the following format:
     * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
     * * `PROJECT_ID` can contain letters ([A-Za-z]), numbers ([0-9]),
     *    hyphens (-), colons (:), or periods (.).
     *    For more information, see
     *    [Identifying
     *    projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects)
     * * `LOCATION_ID` is the canonical ID for the task's location.
     *    The list of available locations can be obtained by calling
     *    [ListLocations][google.cloud.location.Locations.ListLocations].
     *    For more information, see https://cloud.google.com/about/locations/.
     * * `QUEUE_ID` can contain letters ([A-Za-z]), numbers ([0-9]), or
     *   hyphens (-). The maximum length is 100 characters.
     * * `TASK_ID` can contain only letters ([A-Za-z]), numbers ([0-9]),
     *   hyphens (-), or underscores (_). The maximum length is 500 characters.
     *
     * Generated from protobuf field <code>string name = 1;</code>
     * @param string $var
     * @return $this
     */
    public function setName($var)
    {
        GPBUtil::checkString($var, True);
        $this->name = $var;

        return $this;
    }

    /**
     * App Engine HTTP request that is sent to the task's target. Can
     * be set only if
     * [app_engine_http_target][google.cloud.tasks.v2beta2.Queue.app_engine_http_target] is set
     * on the queue.
     * An App Engine task is a task that has [AppEngineHttpRequest][google.cloud.tasks.v2beta2.AppEngineHttpRequest] set.
     *
     * Generated from protobuf field <code>.google.cloud.tasks.v2beta2.AppEngineHttpRequest app_engine_http_request = 3;</code>
     * @return \Google\Cloud\Tasks\V2beta2\AppEngineHttpRequest|null
     */
    public function getAppEngineHttpRequest()
    {
        return $this->readOneof(3);
    }

    public function hasAppEngineHttpRequest()
    {
        return $this->hasOneof(3);
    }

    /**
     * App Engine HTTP request that is sent to the task's target. Can
     * be set only if
     * [app_engine_http_target][google.cloud.tasks.v2beta2.Queue.app_engine_http_target] is set
     * on the queue.
     * An App Engine task is a task that has [AppEngineHttpRequest][google.cloud.tasks.v2beta2.AppEngineHttpRequest] set.
     *
     * Generated from protobuf field <code>.google.cloud.tasks.v2beta2.AppEngineHttpRequest app_engine_http_request = 3;</code>
     * @param \Google\Cloud\Tasks\V2beta2\AppEngineHttpRequest $var
     * @return $this
     */
    public function setAppEngineHttpRequest($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Tasks\V2beta2\AppEngineHttpRequest::class);
        $this->writeOneof(3, $var);

        return $this;
    }

    /**
     * [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks] to process the task. Can be
     * set only if [pull_target][google.cloud.tasks.v2beta2.Queue.pull_target] is set on the queue.
     * A pull task is a task that has [PullMessage][google.cloud.tasks.v2beta2.PullMessage] set.
     *
     * Generated from protobuf field <code>.google.cloud.tasks.v2beta2.PullMessage pull_message = 4;</code>
     * @return \Google\Cloud\Tasks\V2beta2\PullMessage|null
     */
    public function getPullMessage()
    {
        return $this->readOneof(4);
    }

    public function hasPullMessage()
    {
        return $this->hasOneof(4);
    }

    /**
     * [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks] to process the task. Can be
     * set only if [pull_target][google.cloud.tasks.v2beta2.Queue.pull_target] is set on the queue.
     * A pull task is a task that has [PullMessage][google.cloud.tasks.v2beta2.PullMessage] set.
     *
     * Generated from protobuf field <code>.google.cloud.tasks.v2beta2.PullMessage pull_message = 4;</code>
     * @param \Google\Cloud\Tasks\V2beta2\PullMessage $var
     * @return $this
     */
    public function setPullMessage($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Tasks\V2beta2\PullMessage::class);
        $this->writeOneof(4, $var);

        return $this;
    }

    /**
     * The time when the task is scheduled to be attempted.
     * For App Engine queues, this is when the task will be attempted or retried.
     * For pull queues, this is the time when the task is available to
     * be leased; if a task is currently leased, this is the time when
     * the current lease expires, that is, the time that the task was
     * leased plus the [lease_duration][google.cloud.tasks.v2beta2.LeaseTasksRequest.lease_duration].
     * `schedule_time` will be truncated to the nearest microsecond.
     *
     * Generated from protobuf field <code>.google.protobuf.Timestamp schedule_time = 5;</code>
     * @return \Google\Protobuf\Timestamp|null
     */
    public function getScheduleTime()
    {
        return $this->schedule_time;
    }

    public function hasScheduleTime()
    {
        return isset($this->schedule_time);
    }

    public function clearScheduleTime()
    {
        unset($this->schedule_time);
    }

    /**
     * The time when the task is scheduled to be attempted.
     * For App Engine queues, this is when the task will be attempted or retried.
     * For pull queues, this is the time when the task is available to
     * be leased; if a task is currently leased, this is the time when
     * the current lease expires, that is, the time that the task was
     * leased plus the [lease_duration][google.cloud.tasks.v2beta2.LeaseTasksRequest.lease_duration].
     * `schedule_time` will be truncated to the nearest microsecond.
     *
     * Generated from protobuf field <code>.google.protobuf.Timestamp schedule_time = 5;</code>
     * @param \Google\Protobuf\Timestamp $var
     * @return $this
     */
    public function setScheduleTime($var)
    {
        GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class);
        $this->schedule_time = $var;

        return $this;
    }

    /**
     * Output only. The time that the task was created.
     * `create_time` will be truncated to the nearest second.
     *
     * Generated from protobuf field <code>.google.protobuf.Timestamp create_time = 6;</code>
     * @return \Google\Protobuf\Timestamp|null
     */
    public function getCreateTime()
    {
        return $this->create_time;
    }

    public function hasCreateTime()
    {
        return isset($this->create_time);
    }

    public function clearCreateTime()
    {
        unset($this->create_time);
    }

    /**
     * Output only. The time that the task was created.
     * `create_time` will be truncated to the nearest second.
     *
     * Generated from protobuf field <code>.google.protobuf.Timestamp create_time = 6;</code>
     * @param \Google\Protobuf\Timestamp $var
     * @return $this
     */
    public function setCreateTime($var)
    {
        GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class);
        $this->create_time = $var;

        return $this;
    }

    /**
     * Output only. The task status.
     *
     * Generated from protobuf field <code>.google.cloud.tasks.v2beta2.TaskStatus status = 7;</code>
     * @return \Google\Cloud\Tasks\V2beta2\TaskStatus|null
     */
    public function getStatus()
    {
        return $this->status;
    }

    public function hasStatus()
    {
        return isset($this->status);
    }

    public function clearStatus()
    {
        unset($this->status);
    }

    /**
     * Output only. The task status.
     *
     * Generated from protobuf field <code>.google.cloud.tasks.v2beta2.TaskStatus status = 7;</code>
     * @param \Google\Cloud\Tasks\V2beta2\TaskStatus $var
     * @return $this
     */
    public function setStatus($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Tasks\V2beta2\TaskStatus::class);
        $this->status = $var;

        return $this;
    }

    /**
     * Output only. The view specifies which subset of the [Task][google.cloud.tasks.v2beta2.Task] has
     * been returned.
     *
     * Generated from protobuf field <code>.google.cloud.tasks.v2beta2.Task.View view = 8;</code>
     * @return int
     */
    public function getView()
    {
        return $this->view;
    }

    /**
     * Output only. The view specifies which subset of the [Task][google.cloud.tasks.v2beta2.Task] has
     * been returned.
     *
     * Generated from protobuf field <code>.google.cloud.tasks.v2beta2.Task.View view = 8;</code>
     * @param int $var
     * @return $this
     */
    public function setView($var)
    {
        GPBUtil::checkEnum($var, \Google\Cloud\Tasks\V2beta2\Task\View::class);
        $this->view = $var;

        return $this;
    }

    /**
     * @return string
     */
    public function getPayloadType()
    {
        return $this->whichOneof("payload_type");
    }

}

