in utils/es.py [0:0]
def get_client(elasticsearch_host, elasticsearch_ca_path, elasticsearch_user, elasticsearch_pwd, cloud_id, cloud_pwd):
"""
Create ES client.
If cloud values are provided, they will take priority over the local deployment.
:param elasticsearch_host: ES host.
:param elasticsearch_ca_path: Path to ES certificate.
:param elasticsearch_user: Name of the ES user.
:param elasticsearch_pwd: Password for ES.
:param cloud_id: Cloud ID. Default is empty.
:param cloud_pwd: Password for the elastic cloud. Default is empty.
:return: ES client.
"""
if cloud_id != "" and cloud_pwd != "":
print("Client will connect to the cloud.")
return Elasticsearch(
cloud_id=cloud_id,
basic_auth=("elastic", cloud_pwd)
)
return Elasticsearch(
hosts=elasticsearch_host,
ca_certs=elasticsearch_ca_path,
basic_auth=(elasticsearch_user, elasticsearch_pwd)
)