<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def __get_query_agg_ts(cls, field, time_field, interval=None, time_zone=None, start=None, end=None, agg_type='count', offset=None):
 """ Create an es_dsl aggregation object for getting the time series values for a field. :param field: field to get the time series values :param time_field: field with the date :param interval: interval to be used to generate the time series values, such as:(year(y), quarter(q), month(M), week(w), day(d), hour(h), minute(m), second(s)) :param time_zone: time zone for the time_field :param start: date from for the time series, should be a datetime.datetime object :param end: date to for the time series, should be a datetime.datetime object :param agg_type: kind of aggregation for the field (cardinality, avg, percentiles) :param offset: offset to be added to the time_field in days :return: a aggregation object to calculate timeseries values of a field """

        """ Time series for an aggregation metric """
        if not interval:
            interval = '1M'
        if not time_zone:
            time_zone = 'UTC'

        if not field:
            field_agg = ''
        else:
            if agg_type == "cardinality":
                agg_id, field_agg = cls.__get_query_agg_cardinality(field, agg_id=cls.AGGREGATION_ID + 1)
            elif agg_type == "avg":
                agg_id, field_agg = cls.__get_query_agg_avg(field, agg_id=cls.AGGREGATION_ID + 1)
            elif agg_type == "percentiles":
                agg_id, field_agg = cls.__get_query_agg_percentiles(field, agg_id=cls.AGGREGATION_ID + 1)
            else:
                raise RuntimeError("Aggregation of %s in ts not supported" % agg_type)

        bounds = {}
        if start or end:
            if not offset:
                # With offset and quarter interval bogus buckets are added
                # to the start and to the end if extended_bounds is used
                # https://github.com/elastic/elasticsearch/issues/23776
                bounds = cls.__get_bounds(start, end)
            else:
                bounds = {'offset': offset}

        query_agg = A("date_histogram", field=time_field, interval=interval,
                      time_zone=time_zone, min_doc_count=0, **bounds)

        agg_dict = field_agg.to_dict()[field_agg.name]
        query_agg.bucket(agg_id, field_agg.name, **agg_dict)

        return (cls.AGGREGATION_ID, query_agg)