Read data from multiple series according to a filter and apply a
        function across all the returned series to put the datapoints together
        into one aggregrate series.

        See the :meth:`list_series` method for a description of how the filter
        criteria are applied, and the :meth:`read_data` method for how to
        work with the start, end, and tz parameters.

        Valid aggregation functions are the same as valid rollup functions.

        :param string aggregation: the aggregation to perform
        :param keys: (optional) filter by one or more series keys
        :type keys: list or string
        :param tags: (optional) filter by one or more tags
        :type tags: list or string
        :param dict attrs: (optional) filter by one or more key-value
                           attributes
        :param start: the start time for the data points
        :type start: string or Datetime
        :param end: the end time for the data points
        :type end: string or Datetime
        :param string rollup: (optional) the name of a rollup function to use
        :param string period: (optional) downsampling rate for the data
        :param string interpolationf: (optional) an interpolation function
                                      to run over the series
        :param string interpolation_period: (optional) the period to
                                            interpolate data into
        :param string tz: (optional) the timezone to place the data into
        :rtype: :class:`tempodb.protocol.cursor.DataPointCursor` with an
                iterator over :class:`tempodb.protocol.objects.DataPoint`
                objects

def aggregate_data(self, start, end, aggregation, keys=[], tags=[],
                       attrs={}, rollup=None, period=None, interpolationf=None,
                       interpolation_period=None, tz=None, limit=1000):
        """Read data from multiple series according to a filter and apply a
        function across all the returned series to put the datapoints together
        into one aggregrate series.

        See the :meth:`list_series` method for a description of how the filter
        criteria are applied, and the :meth:`read_data` method for how to
        work with the start, end, and tz parameters.

        Valid aggregation functions are the same as valid rollup functions.

        :param string aggregation: the aggregation to perform
        :param keys: (optional) filter by one or more series keys
        :type keys: list or string
        :param tags: (optional) filter by one or more tags
        :type tags: list or string
        :param dict attrs: (optional) filter by one or more key-value
                           attributes
        :param start: the start time for the data points
        :type start: string or Datetime
        :param end: the end time for the data points
        :type end: string or Datetime
        :param string rollup: (optional) the name of a rollup function to use
        :param string period: (optional) downsampling rate for the data
        :param string interpolationf: (optional) an interpolation function
                                      to run over the series
        :param string interpolation_period: (optional) the period to
                                            interpolate data into
        :param string tz: (optional) the timezone to place the data into
        :rtype: :class:`tempodb.protocol.cursor.DataPointCursor` with an
                iterator over :class:`tempodb.protocol.objects.DataPoint`
                objects"""

        url = 'segment'

        vstart = check_time_param(start)
        vend = check_time_param(end)
        params = {
            'start': vstart,
            'end': vend,
            'key': keys,
            'tag': tags,
            'attr': attrs,
            'aggregation.fold': aggregation,
            'rollup.fold': rollup,
            'rollup.period': period,
            'interpolation.function': interpolationf,
            'interpolation.period': interpolation_period,
            'tz': tz,
            'limit': limit
        }
        url_args = endpoint.make_url_args(params)
        url = '?'.join([url, url_args])
        resp = self.session.get(url)
        return resp