Пример #1
0
def health():
    ApiClient.health_test_observable = current_app.config['HEALTH_OBSERVABLE']
    client = ApiClient(api_key=get_api_key(),
                       base_url=current_app.config['AUTOFOCUS_API_URL'],
                       user_agent=current_app.config['USER_AGENT'])

    client.get_tic_indicator_data(current_app.config['HEALTH_OBSERVABLE'])
    return jsonify_data({'status': 'ok'})
def get_entities():
    api_key = get_api_key()
    observables = filter_observables(get_observables())

    if not observables:
        return {}

    ApiClient.health_test_observable = current_app.config['HEALTH_OBSERVABLE']
    client = ApiClient(api_key=api_key,
                       base_url=current_app.config['AUTOFOCUS_API_URL'],
                       user_agent=current_app.config['USER_AGENT'])

    with ThreadPoolExecutor(
            max_workers=get_workers(len(observables))) as executor:
        entities = executor.map(
            lambda observable: create_entity(
                response=client.get_tic_indicator_data(observable),
                observable=observable,
            ), observables)

    return entities