Exists Class¶
Exists¶
- class es_wait.exists.Exists(client: Elasticsearch, pause: float = 1.5, timeout: float = 15.0, max_exceptions: int = 10, name: str = '', kind: Literal['index', 'data_stream', 'index_template', 'component_template'] = 'index')¶
Bases:
WaiterWait for an entity to ‘exist’ according to Elasticsearch
Init the Exists class
- Parameters:
client (Elasticsearch) – The Elasticsearch client
pause (float) – The delay between checks. Default is 1.5
timeout (float) – How long is too long. Default is 10.0
max_exceptions (int) – The maximum number of exceptions to allow. Default is 10
name (str) – The entity name
kind (ExistsTypes) – What kind of entity
- Raises:
ValueError – If kind is not one of the valid types
- add_exception(value: Exception) None¶
This method appends value the exceptions list.
- Parameters:
value (Exception) – An exception to add
- announce() None¶
This method is called when the Waiter class is initialized. It logs a level 1 debug message using
waitstr.
- check() bool¶
Check if the named entity exists in Elasticsearch. The proper function call is returned by
func_map(), which returns a tuple of the function to call and the keyword arguments to pass to that function.- ‘index’: Checks for an index using
- ‘data_stream’: Checks for a data_stream using
- ‘index_template’: Checks for an index template using
- ‘component_template’: Checks for a component template using
- Returns:
bool: True if the entity exists, False otherwise or if an error occurs.
- client¶
An
Elasticsearchclient instance
- do_health_report¶
Only changes to True in certain circumstances
- property exception_count_msg: str¶
This property returns a messgage showing the current number of exceptions raised and the maximum number of exceptions allowed.
- Getter:
Returns ‘X exceptions raised out of Y allowed’
- Type:
- property exceptions: list¶
This property returns a list of exceptions raised during the wait.
- Getter:
Returns a list of exceptions raised
- Type:
- exceptions_raised¶
The number of exceptions raised
- func_map() Tuple[Callable, Dict]¶
This method maps
kindto the proper function to call based on the kind of entity we’re checking and the keyword arguments to pass to that function.For indices and data_streams, the call is
indices.exists(). The keyword argument isindex, with the valuename.For index templates, the call is
indices.exists_index_template(). The keyword argument isname, with the valuename.For component templates, it is
cluster.exists_component_template(). The keyword argument isname, with the valuename.- Returns:
Tuple of the function to call and the keyword arguments
- Return type:
- kind¶
What kind of entity
- max_exceptions¶
The maximum number of exceptions to allow
- name¶
The entity name
- pause¶
The delay between checks for completion
- timeout¶
The number of seconds before giving up. -1 means no timeout.
- too_many_exceptions() None¶
If the number of exceptions raised is greater than or equal to the maximum number of exceptions allowed, then a
ExceptionCountwill be raised.
- wait(frequency: int = 5) None¶
This method is where the actual waiting occurs. Depending on what frequency is set to, you should see non-DEBUG level logs no more than every frequency seconds.
If
timeouthas been reached withoutcheck()returning asTrue, then aTimeoutErrorwill be raised.If
check()returnsFalse, then the method will waitpauseseconds before callingcheck()again.Elapsed time will be logged every frequency seconds, when
check()isTrue, or whentimeoutis reached.If
do_health_reportisTrue, then callclient.health_report()and pass the results toutils.health_report().- Parameters:
frequency – The number of seconds between log reports on progress.