import requests


def enumerate_a_by_view(cookies, url_root, view_name):
    """Given a view name, return all A records that are contained in that view."""
    url = url_root + "/wapi/v2.9.1/record:a"
    params = {
        "view": view_name,
    }
    try:
        response = requests.get(url, params=params, cookies=cookies, verify=False)
        try:
            response.raise_for_status()
        except requests.exceptions.HTTPError:
            # Whoops it wasn't a 200
            print("ERROR: Infoblox reported an error %s." %(response.status_code))
            print(response.text)
            return False
    except requests.exceptions.RequestException:
        # A serious problem happened, like an SSLError or InvalidURL
        print("WARN: Unable to communicate with Infoblox.")
        return False
    return response.json()