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

namespace Google\Cloud\Firestore\V1;

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

/**
 * Firestore query for running an aggregation over a [StructuredQuery][google.firestore.v1.StructuredQuery].
 *
 * Generated from protobuf message <code>google.firestore.v1.StructuredAggregationQuery</code>
 */
class StructuredAggregationQuery extends \Google\Protobuf\Internal\Message
{
    /**
     * Optional. Series of aggregations to apply over the results of the `structured_query`.
     * Requires:
     * * A minimum of one and maximum of five aggregations per query.
     *
     * Generated from protobuf field <code>repeated .google.firestore.v1.StructuredAggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
     */
    private $aggregations;
    protected $query_type;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type \Google\Cloud\Firestore\V1\StructuredQuery $structured_query
     *           Nested structured query.
     *     @type array<\Google\Cloud\Firestore\V1\StructuredAggregationQuery\Aggregation>|\Google\Protobuf\Internal\RepeatedField $aggregations
     *           Optional. Series of aggregations to apply over the results of the `structured_query`.
     *           Requires:
     *           * A minimum of one and maximum of five aggregations per query.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Firestore\V1\Query::initOnce();
        parent::__construct($data);
    }

    /**
     * Nested structured query.
     *
     * Generated from protobuf field <code>.google.firestore.v1.StructuredQuery structured_query = 1;</code>
     * @return \Google\Cloud\Firestore\V1\StructuredQuery|null
     */
    public function getStructuredQuery()
    {
        return $this->readOneof(1);
    }

    public function hasStructuredQuery()
    {
        return $this->hasOneof(1);
    }

    /**
     * Nested structured query.
     *
     * Generated from protobuf field <code>.google.firestore.v1.StructuredQuery structured_query = 1;</code>
     * @param \Google\Cloud\Firestore\V1\StructuredQuery $var
     * @return $this
     */
    public function setStructuredQuery($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Firestore\V1\StructuredQuery::class);
        $this->writeOneof(1, $var);

        return $this;
    }

    /**
     * Optional. Series of aggregations to apply over the results of the `structured_query`.
     * Requires:
     * * A minimum of one and maximum of five aggregations per query.
     *
     * Generated from protobuf field <code>repeated .google.firestore.v1.StructuredAggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
     * @return \Google\Protobuf\Internal\RepeatedField
     */
    public function getAggregations()
    {
        return $this->aggregations;
    }

    /**
     * Optional. Series of aggregations to apply over the results of the `structured_query`.
     * Requires:
     * * A minimum of one and maximum of five aggregations per query.
     *
     * Generated from protobuf field <code>repeated .google.firestore.v1.StructuredAggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
     * @param array<\Google\Cloud\Firestore\V1\StructuredAggregationQuery\Aggregation>|\Google\Protobuf\Internal\RepeatedField $var
     * @return $this
     */
    public function setAggregations($var)
    {
        $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Firestore\V1\StructuredAggregationQuery\Aggregation::class);
        $this->aggregations = $arr;

        return $this;
    }

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

}

