import uuid
import requests


def get_dns_records(params):
    """Return dictionary of all DNS records in Dreamhost account."""
    url = "https://api.dreamhost.com/" + \
          "?key=" + str(params["api_key"]) + \
          "&cmd=dns-list_records" + \
          "&unique_id=" + str(uuid.uuid4()) + \
          "&format=json"
    r = requests.get(url)
    r.raise_for_status()
    records = r.json()
    if "data" in records:
        return records["data"]
    else:
        raise ValueError("Error getting records from Dreamhost.")