Hi use the following class to connect the client to Elastic Cloud running in Azure. The job runs in kubernetes updating my index with some data in a daily basis, and I need to setup the proxy from my organization in order to reach the es endpoint.
from elasticsearch import Elasticsearch, RequestsHttpConnection # v7.10.0
from elasticsearch.helpers import bulk
class ESManagement:
def __init__(self):
self.es_client = Elasticsearch(
hosts=os.environ.get('es_endpoint'),
http_auth=(os.environ.get('es_username'), os.environ.get('es_password')),
connection_class=MyConnection,
proxies={'https': os.environ.get('proxy4server'), 'http': os.environ.get('proxy4server')}
)
def create_index(self, index: str):
(...)
def delete_index(self, index_name):
(...)
def index_batch(self, docs):
(...)
class MyConnection(RequestsHttpConnection):
def __init__(self, *args, **kwargs):
proxies = kwargs.pop('proxies', {})
super(MyConnection, self).__init__(*args, **kwargs)
self.session.proxies = proxies
This class works fine running with elasticsearch 7.10.0. Now I want to update to elasticsearch api 8.5.1. I saw the migration page, but it doesn't mention anything about the proxies setup. Does any one have any idea about how to implement some similar code for the new version?
Also I realized that "RequestsHttpConnection" is not available anymore, so I guess the api will be using Urllib3 library everytime, rigth?