Executes a query that requires a job for completion. This function will wait for the job to complete
    and return the results.

def _get_job_results(query=None):
    '''
    Executes a query that requires a job for completion. This function will wait for the job to complete
    and return the results.
    '''
    if not query:
        raise CommandExecutionError("Query parameters cannot be empty.")

    response = __proxy__['panos.call'](query)

    # If the response contains a job, we will wait for the results
    if 'result' in response and 'job' in response['result']:
        jid = response['result']['job']

        while get_job(jid)['result']['job']['status'] != 'FIN':
            time.sleep(5)

        return get_job(jid)
    else:
        return response