import requests


def fetch_remote_job(job_system_url, job_id):
    """
    Helper funtion to fetch remote jobs.
    :param job_system_url: url to the job system
    :param job_id: only fetch the job whith this ID
    :returns: a job, raises an HTTPError otherwise
    """
    response = requests.get(
        "%s/api/jobs/%s" % (job_system_url, job_id),
        headers={'content-type': 'application/json'}
    )
    response.raise_for_status()

    return dict(
        response.json(),
        **{
            'etag': response.headers['ETag'],
            'last_modified': response.headers['Last-Modified']
        }
    )