def check_status(instance_session, instance_url, instance_key, instance_name=''):
    global api_version
    instance_status_url = get_status_path(instance_url, instance_key)
    error_message = f'Could not connect to instance{instance_name}: {instance_status_url}'
    status_response = None
    try:
        status_response = instance_session.get(instance_status_url)
        if (status_response.status_code != 200):
            logger.error(error_message)
            exit_system()
    except:
        logger.error(error_message)
        exit_system()
    if (status_response is None):
        logger.error(error_message)
        exit_system()
    else:
        try:
            status_response = status_response.json()
        except Exception as error:
            if (not isinstance(status_response, dict)):
                logger.error(f'Could not retrieve status for {instance_status_url}: {status_response} - {error}')
                exit_system()
        if status_response.get('error'):
            logger.error(f"{instance_status_url} error {status_response.get('error')}")
            exit_system()
        logger.debug(f"{instance_status_url} version {status_response.get('version')}")
    return status_response
def check_status(instance_session, instance_url, instance_key, instance_name=):
    global api_version
    instance_status_url = get_status_path(instance_url, instance_key)
    error_message = f'Could not connect to instance{instance_name}: {instance_status_url}'
    status_response = None
    try:
        status_response = instance_session.get(instance_status_url)
        if (status_response.status_code != 200):
            logger.error(error_message)
            exit_system()
    except:
        logger.error(error_message)
        exit_system()
    if (status_response is None):
        logger.error(error_message)
        exit_system()
    else:
        try:
            status_response = status_response.json()
        except Exception as error:
            if (not isinstance(status_response, dict)):
                logger.error(f'Could not retrieve status for {instance_status_url}: {status_response} - {error}')
                exit_system()
        if status_response.get('error'):
            logger.error(f"{instance_status_url} error {status_response.get('error')}")
            exit_system()
        logger.debug(f"{instance_status_url} version {status_response.get('version')}")
    return status_response