ES Client API reference¶
ClientArgs Class¶
- class es_client.builder.ClientArgs¶
Initialize with None values for all accepted client settings update_settings and asdict methods
Updatable object that will contain client arguments for connecting to Elasticsearch
- asdict()¶
Return as a dictionary
- update_settings(config)¶
Update individual settings from provided config dict
OtherArgs Class¶
- class es_client.builder.OtherArgs¶
Initialize with None values for all ‘other’ client settings Return
Updatable object that will contain ‘other’ client arguments for connecting to Elasticsearch
- asdict()¶
Return as a dictionary
- update_settings(config)¶
Update individual settings from provided config dict
Builder Class¶
- class es_client.builder.Builder(configdict=None, configfile=None, autoconnect=False, version_min=(8, 0, 0), version_max=(8, 99, 99))¶
Build a client out of settings from
configfile
orconfigdict
If neitherconfigfile
norconfigdict
is provided, empty defaults will be used. If both are provided,configdict
will be used, and configfile ignored.- Parameters:
- _check_api_key()¶
Create
api_key
tuple fromother_args
['api_key']
subkeysid
andapi_key
Or ifapi_key
subkeytoken
is present, deriveid
andapi_key
fromtoken
- _check_basic_auth()¶
Create
basic_auth
tuple from username and password
- _check_cloud_id()¶
Remove
hosts
key ifcloud_id
provided
- _check_master()¶
If
master_only
isTrue
and we are not connected to the elected master node, raiseNotMaster
- _check_version()¶
Compare the Elasticsearch cluster version to
min_version
andmax_version
- _find_master()¶
Find out if we are connected to the elected master node
- _get_client()¶
Instantiate the
Elasticsearch
object and populateclient
- client¶
The
Elasticsearch
client connection object
- client_args¶
The
ClientArgs
object
- config¶
The validated configuration, either from file or dict
- connect()¶
Attempt connection and do post-connection checks
- is_master¶
Am I connected to the elected master node?
- master_only¶
Is node is elected master?
- test_connection()¶
Connect and execute
elasticsearch8.Elasticsearch.info()
- update_config()¶
Update object with values provided
- validate()¶
Validate that what has been supplied is acceptable to attempt a connection
- version_max¶
Assigned
version_max
- version_min¶
Assigned
version_min
Builder Attribute Errata¶
- client:
The
Elasticsearch
object is only created after passing all other tests, and ifautoconnect
isTrue
, orconnect()
has been called.- is_master:
Initially set to
None
, this value is set automatically ifautoconnect
isTrue
. It can otherwise be set by calling_find_master()
after_get_client()
has been called first.
Class Instantiation Flow¶
Check to see if
elasticsearch
key is in the suppliedraw_config
dictionary. Log a warning about using defaults if it is not.Run
_check_config()
onraw_config
Set instance attributes
version_max
andversion_min
with the provided values.Set instance attribute
master_only
to the value fromraw_config
Initialize instance attribute
is_master
with aNone
Set instance attribute
skip_version_test
to the value fromraw_config
Set instance attribute
client_args
to the value ofraw_config['elasticsearch']['client']
Execute
_check_basic_auth()
to build thebasic_auth
tuple, ifusername
andpassword
are notNone
.Execute
_check_api_key()
to build theapi_key
tuple, if theid
andapi_key
sub-keys are notNone
.Execute
_check_cloud_id()
to ensure the client connects to the definedcloud_id
rather than anything inhosts
.Execute
_check_ssl()
to ensure we have at least the certifi signing certificates.If
autoconnect
is True:Execute
_get_client()
to finally build theElasticsearch
client object.Execute
_check_version()
and_check_master()
as post-checks. Nothing will happen if these checks are not enabled inraw_config