  def _BuildUsageFilter(
      self, metric_type: str, instance_ids: Optional[List[str]]) -> str:
    """Builds a metrics query filter based on a list of instance IDs.

    Args:
      metric_type str: the type of metric to filter on.
      instance_ids list[str]: a list of instance ids.

    Returns:
      str: the filter to use in a metrics query.
    """
    instances_filter = (
          ['metric.type = "{0:s}"'.format(metric_type)])
    if instance_ids:
      instances_filter.append(
          ' AND (resource.label.instance_id = "{0:s}"'.format(instance_ids[0]))
      if len(instance_ids) > 1:
        for instance_name in instance_ids[1:]:
          instances_filter.append(
              ' OR resource.label.instance_id = "{0:s}"'.format(instance_name))
      instances_filter.append(')')

    return ''.join(instances_filter)
Builds a metrics query filter based on a list of instance IDs.

Args:
metric_type str: the type of metric to filter on.
instance_ids list[str]: a list of instance ids.

Returns:
str: the filter to use in a metrics query.
libcloudforensics/providers/gcp/internal/monitoring.py