<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_metrics(self, path, from_time, to_time, metrics, view, params=None):
 """ Generic function for querying metrics. @param from_time: A datetime; start of the period to query (optional). @param to_time: A datetime; end of the period to query (default = now). @param metrics: List of metrics to query (default = all). @param view: View to materialize ('full' or 'summary') @param params: Other query parameters. @return: List of metrics and their readings. """

    if not params:
      params = { }
    if from_time:
      params['from'] = from_time.isoformat()
    if to_time:
      params['to'] = to_time.isoformat()
    if metrics:
      params['metrics'] = metrics
    if view:
      params['view'] = view
    resp = self.get(path, params=params)
    return types.ApiList.from_json_dict(resp, self, types.ApiMetric)