'Constructor.
Args:
app: Optional app to query, derived from the environment if not specified.
namespace: Optional namespace to query, derived from the environment if
not specified.
kind: Optional kind to query.
ancestor: Optional ancestor to query, an entity_pb.Reference.
filter_predicate: Optional FilterPredicate by which to restrict the query.
order: Optional Order in which to return results.
group_by: Optional list of properties to group the results by.
Raises:
datastore_errors.BadArgumentError if any argument is invalid.'

@datastore_rpc._positional(1)
def __init__(self, app=None, namespace=None, kind=None, ancestor=None, filter_predicate=None, group_by=None, order=None):

    super(Query, self).__init__()
    if ((filter_predicate is not None) and (not isinstance(filter_predicate, FilterPredicate))):
        raise datastore_errors.BadArgumentError(('filter_predicate    should    be    datastore_query.FilterPredicate    (%r)' % (filter_predicate,)))
    if isinstance(order, CompositeOrder):
        if (order.size() == 0):
            order = None
    elif isinstance(order, Order):
        order = CompositeOrder([order])
    elif (order is not None):
        raise datastore_errors.BadArgumentError(('order    should    be    Order    (%r)' % (order,)))
    if (group_by is not None):
        if isinstance(group_by, list):
            group_by = tuple(group_by)
        elif (not isinstance(group_by, tuple)):
            raise datastore_errors.BadArgumentError(('group_by    argument    should    be    a    list    or    tuple    (%r)' % (group_by,)))
        if (not group_by):
            raise datastore_errors.BadArgumentError('group_by    argument    cannot    be    empty')
        for prop in group_by:
            if (not isinstance(prop, basestring)):
                raise datastore_errors.BadArgumentError(('group_by    argument    should    contain    only    strings    (%r)' % (prop,)))
    self._key_filter = _QueryKeyFilter(app=app, namespace=namespace, kind=kind, ancestor=ancestor)
    self._order = order
    self._filter_predicate = filter_predicate
    self._group_by = group_by
