def flatten_metadata(metadata):
    """Flatten the given API-style dictionary into a Python dictionary.

    This takes a mapping of key-value pairs as returned by the Google
    Compute Engine API, and converts it to a Python dictionary.

    The `metadata` argument is an object that has an `items` field
    containing a list of key->value mappings. Each key->value mapping
    is an object with a `key` field and a `value` field.

    Example:
       Given the following input:
          { "items": [
              { "key": "a",
                "value": 1
              },
              { "key": "b",
                "value": 2
              },
            ],
            "fingerprint": "<something>"
          }
       ... this will return {"a": 1, "b": 2}
    """
    items = metadata.get('items', [])
    result = {}
    for mapping in items:
        result[mapping.get('key', '')] = mapping.get('value', '')
    return result