import requests
import json


def call_linode_api_to_change_domain_record_ip(token, domainId, recordId, newIP):
    """
    Call the Linode API to change the IP address of a domain record.
    """
    headers = {
        'Authorization': f'Bearer {token}',
        'Content-Type': 'application/json'
    }

    url = f"https://api.linode.com/v4/domains/{domainId}/records/{recordId}"
    data = {
        "target": newIP
    }
    # call the api endpoint
    response = requests.put(url, headers=headers, data=json.dumps(data))
    return response.json()