def format_metric(metric):
    """Format a single metric.

    Parameters:
        metric (dict): The metric to format

    Returns:
        metric (dict): The new metric in
        the format needed for the put_metric_data
        API.

    """
    metric_keys = metric.keys()
    metric["MetricName"] = metric.pop("metric_name")
    if "dimensions" in metric_keys:
        for dimension in metric["dimensions"]:
            dimension["Name"] = dimension.pop("name")
            dimension["Value"] = dimension.pop("value")
        metric["Dimensions"] = metric.pop("dimensions")
    if "timestamp" in metric_keys:
        metric["Timestamp"] = metric.pop("timestamp")
    if "value" in metric_keys:
        metric["Value"] = metric.pop("value")
    else:
        metric["statistic_values"]["SampleCount"] =\
            metric["statistic_values"].pop("sample_count")
        metric["statistic_values"]["Sum"] =\
            metric["statistic_values"].pop("sum")
        metric["statistic_values"]["Minimum"] =\
            metric["statistic_values"].pop("minimum")
        metric["statistic_values"]["Maximum"] =\
            metric["statistic_values"].pop("maximum")
        metric["StatisticValues"] = metric.pop("statistic_values")
    if "unit" in metric_keys:
        metric["Unit"] = metric.pop("unit")
    if "storage_resolution" in metric_keys:
        metric["StorageResolution"] = metric.pop("storage_resolution")
    return metric