ES Client API reference¶
Builder Class¶
- class es_client.builder.Builder(configdict: Dict | None = None, configfile: str | None = None, autoconnect: bool = False)¶
- Parameters:
configdict – A configuration dictionary
configfile – A YAML configuration file
autoconnect – Connect to client automatically
Build a client connection object out of settings from configfile or configdict.
If neither configfile nor configdict is provided, empty defaults will be used.
If both are provided, configdict will be used, and configfile ignored.
- attributes¶
The DotMap storage for attributes and settings
- client¶
The
Elasticsearchclient connection object
- property client_args: DotMap¶
The storage and workspace for
clientsettings- Getter:
Get
clientvalues- Setter:
Set
clientvalues- Type:
DotMap
- property config: DotMap¶
Configuration settings extracted from
configfileorconfigdict- Getter:
Get the configuration settings
- Setter:
Set the configuration settings
- Type:
DotMap
- property is_master: bool¶
Is the node we connected to the elected master?
- Getter:
Get the “Are we the elected master?” state
- Setter:
Set the “Are we the elected master?” state
- Type:
- property master_only: bool¶
Only allow connection to the elected master, if
True- Getter:
Get the “Only use the elected master?” state
- Setter:
Set the “Only use the elected master?” state
- Type:
- property other_args: DotMap¶
The storage and workspace for
other_settings- Getter:
Get
other_argsvalues- Setter:
Set
other_argsvalues- Type:
DotMap
- process_config_opts(configdict: Dict | None, configfile: str | None) None¶
Process whether to use a configdict or configfile
- property skip_version_test: bool¶
- Getter:
Get the
skip_version_testvalue- Setter:
Set the
skip_version_testvalue- Type:
- test_connection() ObjectApiResponse[Any]¶
Connect and execute
Elasticsearch.info()
Builder Attribute Errata¶
- client:
The
Elasticsearchobject is only created after passing all other tests, and ifautoconnectisTrue, orconnect()has been called.- is_master:
Initially set to
None, this value is set automatically ifautoconnectisTrue. It can otherwise be set by calling_find_master()after_get_client()has been called first.
Class Instantiation Flow¶
Check to see if
elasticsearchkey is in the suppliedraw_configdictionary. Log a warning about using defaults if it is not.Run
_check_config()onraw_configSet instance attributes
version_maxandversion_minwith the provided values.Set instance attribute
master_onlyto the value fromraw_configInitialize instance attribute
is_masterwith aNoneSet instance attribute
skip_version_testto the value fromraw_configSet instance attribute
client_argsto the value ofraw_config['elasticsearch']['client']Execute
_check_basic_auth()to build thebasic_authtuple, ifusernameandpasswordare notNone.Execute
_check_api_key()to build theapi_keytuple, if theidandapi_keysub-keys are notNone.Execute
_check_cloud_id()to ensure the client connects to the definedcloud_idrather than anything inhosts.Execute
_check_ssl()to ensure we have at least the certifi signing certificates.If
autoconnectis True:Execute
_get_client()to finally build theElasticsearchclient object.Execute
_check_version()and_check_master()as post-checks. Nothing will happen if these checks are not enabled inraw_config