ES Client API reference¶
ClientArgs Class¶
- class es_client.builder.ClientArgs(settings=['hosts', 'cloud_id', 'api_key', 'basic_auth', 'bearer_auth', 'opaque_id', 'headers', 'connections_per_node', 'http_compress', 'verify_certs', 'ca_certs', 'client_cert', 'client_key', 'ssl_assert_hostname', 'ssl_assert_fingerprint', 'ssl_version', 'ssl_context', 'ssl_show_warn', 'transport_class', 'request_timeout', 'node_class', 'node_pool_class', 'randomize_nodes_in_pool', 'node_selector_class', 'dead_node_backoff_factor', 'max_dead_node_backoff', 'serializer', 'serializers', 'default_mimetype', 'max_retries', 'retry_on_status', 'retry_on_timeout', 'sniff_on_start', 'sniff_before_requests', 'sniff_on_node_failures', 'sniff_timeout', 'min_delay_between_sniffing', 'sniffed_node_callback', 'meta_header', 'host_info_callback', '_transport'])¶
ClientArgs object
Updatable object that will contain arguments for connecting to Elasticsearch
- _is_protocol = False¶
- clear() None. Remove all items from D. ¶
- copy() a shallow copy of D ¶
- fromkeys(value=None, /)¶
Create a new dictionary with keys from iterable and values set to value.
- get(key, default=None, /)¶
Return the value for key if key is in the dictionary, else default.
- items() a set-like object providing a view on D's items ¶
- keys() a set-like object providing a view on D's keys ¶
- pop(k[, d]) v, remove specified key and return the corresponding value. ¶
If the key is not found, return the default if given; otherwise, raise a KeyError.
- popitem()¶
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
- setdefault(key, default=None, /)¶
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- update([E, ]**F) None. Update D from dict/iterable E and F. ¶
If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- values() an object providing a view on D's values ¶
OtherArgs Class¶
- class es_client.builder.OtherArgs(settings=['master_only', 'skip_version_test', 'username', 'password', 'api_key'])¶
OtherArgs object
Updatable object that will contain arguments for connecting to Elasticsearch
- _is_protocol = False¶
- clear() None. Remove all items from D. ¶
- copy() a shallow copy of D ¶
- fromkeys(value=None, /)¶
Create a new dictionary with keys from iterable and values set to value.
- get(key, default=None, /)¶
Return the value for key if key is in the dictionary, else default.
- items() a set-like object providing a view on D's items ¶
- keys() a set-like object providing a view on D's keys ¶
- pop(k[, d]) v, remove specified key and return the corresponding value. ¶
If the key is not found, return the default if given; otherwise, raise a KeyError.
- popitem()¶
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
- setdefault(key, default=None, /)¶
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- update([E, ]**F) None. Update D from dict/iterable E and F. ¶
If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- values() an object providing a view on D's values ¶
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 if
api_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