def es_client(): es_conn_config = build_es_conn_config({ 'es_host': es_host, 'es_port': es_port, 'es_conn_timeout': es_timeout }) return ElasticSearchClient(es_conn_config)
def elasticsearch_client(conf): """ returns an :class:`ElasticSearchClient` instance configured using an es_conn_config """ es_conn_conf = build_es_conn_config(conf) auth = Auth() username = es_conn_conf['es_username'] password = es_conn_conf['es_password'] if es_conn_conf['es_bearer'] or es_conn_conf['es_api_key']: username = None password = None es_conn_conf['http_auth'] = auth(host=es_conn_conf['es_host'], username=username, password=password, aws_region=es_conn_conf['aws_region'], profile_name=es_conn_conf['profile']) if es_conn_conf['es_bearer']: es_conn_conf['headers'] = { "Authorization": "Bearer " + es_conn_conf['es_bearer'] } if es_conn_conf['es_api_key']: es_conn_conf['headers'] = { "Authorization": "ApiKey " + es_conn_conf['es_api_key'] } return ElasticSearchClient(es_conn_conf)