from typing import Any
from typing import Dict
from typing import List


def get_data_list_from_timeseries(data: Any) -> Dict[str, List[float]]:
    """Constructs a Dict as keys are the container names and
    values are a list of data taken from given timeseries data."""
    if data['status'] != 'success':
        raise Exception('command failed: ' + data['status'] + str(data))
    if data['data']['resultType'] != 'matrix':
        raise Exception('resultType is not matrix: ' +
                        data['data']['resultType'])

    container_name_to_data_list = {}
    for res in data["data"]["result"]:
        container_name = res["metric"]["container"]
        container_data_timeseries = res["values"]

        container_data = []
        for d in container_data_timeseries:
            container_data.append(float(d[1]))
        container_name_to_data_list[container_name] = container_data
    return container_name_to_data_list