<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def query_timeseries(resource_root, query, from_time=None, to_time=None, desired_rollup=None, must_use_desired_rollup=None, by_post=False):
 """ Query for time series data from the CM time series data store. @param query: Query string. @param from_time: Start of the period to query (optional). @type from_time: datetime.datetime Note the that datetime must either be time zone aware or specified in the server time zone. See the python datetime documentation for more details about python's time zone handling. @param to_time: End of the period to query (default = now). This may be an ISO format string, or a datetime object. @type to_time: datetime.datetime Note the that datetime must either be time zone aware or specified in the server time zone. See the python datetime documentation for more details about python's time zone handling. @param desired_rollup: The aggregate rollup to get data for. This can be RAW, TEN_MINUTELY, HOURLY, SIX_HOURLY, DAILY, or WEEKLY. Note that rollup desired is only a hint unless must_use_desired_rollup is set to true. @param must_use_desired_rollup: Indicates that the monitoring server should return the data at the rollup desired. @param by_post: If true, an HTTP POST request will be made to server. This allows longer query string to be accepted compared to HTTP GET request. @return: List of ApiTimeSeriesResponse """

  data = None
  params = {}
  request_method = resource_root.get
  if by_post:
    request = ApiTimeSeriesRequest(resource_root,
                                   query=query)
    data = request
    request_method = resource_root.post
  elif query:
    params['query'] = query

  if from_time:
    params['from'] = from_time.isoformat()
  if to_time:
    params['to'] = to_time.isoformat()
  if desired_rollup:
    params['desiredRollup'] = desired_rollup
  if must_use_desired_rollup:
    params['mustUseDesiredRollup'] = must_use_desired_rollup
  return call(request_method, TIME_SERIES_PATH,
      ApiTimeSeriesResponse, True, params=params, data=data)