import requests


def trailing_resource_id_from_response(response: requests.Response) -> int:
    """Extract the resource ID from the response. Assumes that a `location` header is
    included in the response, indicating the location of the resource, and that the
    ID is the last part of the location path

    Args:
        response (requests.Response): response containing location header

    Raises:
        ValueError: location header not present in response

    Returns:
        int: resource ID
    """
    if hasattr(response, 'headers'):
        if 'location' in response.headers:
            return int(response.headers['location'].split('/')[-1])
    raise ValueError('Response object has no location resource.')