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

namespace Google\Cloud\Firestore\V1;

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

/**
 * A request for [Firestore.Listen][google.firestore.v1.Firestore.Listen]
 *
 * Generated from protobuf message <code>google.firestore.v1.ListenRequest</code>
 */
class ListenRequest extends \Google\Protobuf\Internal\Message
{
    /**
     * The database name. In the format:
     * `projects/{project_id}/databases/{database_id}`.
     *
     * Generated from protobuf field <code>string database = 1;</code>
     */
    private $database = '';
    /**
     * Labels associated with this target change.
     *
     * Generated from protobuf field <code>map<string, string> labels = 4;</code>
     */
    private $labels;
    protected $target_change;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type string $database
     *           The database name. In the format:
     *           `projects/{project_id}/databases/{database_id}`.
     *     @type \Google\Cloud\Firestore\V1\Target $add_target
     *           A target to add to this stream.
     *     @type int $remove_target
     *           The ID of a target to remove from this stream.
     *     @type array|\Google\Protobuf\Internal\MapField $labels
     *           Labels associated with this target change.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Firestore\V1\Firestore::initOnce();
        parent::__construct($data);
    }

    /**
     * The database name. In the format:
     * `projects/{project_id}/databases/{database_id}`.
     *
     * Generated from protobuf field <code>string database = 1;</code>
     * @return string
     */
    public function getDatabase()
    {
        return $this->database;
    }

    /**
     * The database name. In the format:
     * `projects/{project_id}/databases/{database_id}`.
     *
     * Generated from protobuf field <code>string database = 1;</code>
     * @param string $var
     * @return $this
     */
    public function setDatabase($var)
    {
        GPBUtil::checkString($var, True);
        $this->database = $var;

        return $this;
    }

    /**
     * A target to add to this stream.
     *
     * Generated from protobuf field <code>.google.firestore.v1.Target add_target = 2;</code>
     * @return \Google\Cloud\Firestore\V1\Target
     */
    public function getAddTarget()
    {
        return $this->readOneof(2);
    }

    /**
     * A target to add to this stream.
     *
     * Generated from protobuf field <code>.google.firestore.v1.Target add_target = 2;</code>
     * @param \Google\Cloud\Firestore\V1\Target $var
     * @return $this
     */
    public function setAddTarget($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Firestore\V1\Target::class);
        $this->writeOneof(2, $var);

        return $this;
    }

    /**
     * The ID of a target to remove from this stream.
     *
     * Generated from protobuf field <code>int32 remove_target = 3;</code>
     * @return int
     */
    public function getRemoveTarget()
    {
        return $this->readOneof(3);
    }

    /**
     * The ID of a target to remove from this stream.
     *
     * Generated from protobuf field <code>int32 remove_target = 3;</code>
     * @param int $var
     * @return $this
     */
    public function setRemoveTarget($var)
    {
        GPBUtil::checkInt32($var);
        $this->writeOneof(3, $var);

        return $this;
    }

    /**
     * Labels associated with this target change.
     *
     * Generated from protobuf field <code>map<string, string> labels = 4;</code>
     * @return \Google\Protobuf\Internal\MapField
     */
    public function getLabels()
    {
        return $this->labels;
    }

    /**
     * Labels associated with this target change.
     *
     * Generated from protobuf field <code>map<string, string> labels = 4;</code>
     * @param array|\Google\Protobuf\Internal\MapField $var
     * @return $this
     */
    public function setLabels($var)
    {
        $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING);
        $this->labels = $arr;

        return $this;
    }

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

}

