from typing import Dict
from datetime import datetime


def transform_metadata(record) -> Dict:
    """Format the metadata record we got from the database to adhere to the response schema."""
    response = dict(record)
    response["info"] = {"accessType": response.pop("accessType")}
    if "createDateTime" in response and isinstance(response["createDateTime"], datetime):
        response["createDateTime"] = response.pop("createDateTime").strftime("%Y-%m-%dT%H:%M:%SZ")
    if "updateDateTime" in record and isinstance(response["updateDateTime"], datetime):
        response["updateDateTime"] = response.pop("updateDateTime").strftime("%Y-%m-%dT%H:%M:%SZ")

    return response