Helpers¶
Utils¶
-
es_client.helpers.utils.
check_config
(config)¶ Ensure that the top-level key
elasticsearch
and its sub-keys,other_settings
andclient
as contained inconfig
before passing it (or empty defaults) toSchemaCheck
for value validation.Parameters: config (dict) – The configuration
-
es_client.helpers.utils.
ensure_list
(data)¶ Return a list, even if data is a single value
Parameters: data – A list or scalar variable to act upon Return type: list
-
es_client.helpers.utils.
file_exists
(file)¶ Verify the file exists
Parameters: file (str) – The file to test Returns: Whether the file exists Return type: bool
-
es_client.helpers.utils.
get_version
(client)¶ Get the Elasticsearch version of the connected node
Parameters: client ( Elasticsearch
) – An Elasticsearch client objectReturns: The Elasticsearch version as a 3-part tuple, (major, minor, patch) Return type: tuple
-
es_client.helpers.utils.
get_yaml
(path)¶ Read the file identified by path and import its YAML contents.
Parameters: path (str) – The path to a YAML configuration file. Returns: The contents of path
translated from YAML todict
Return type: dict
-
es_client.helpers.utils.
parse_apikey_token
(token)¶ Split a base64 encoded API Key Token into id and api_key
Parameters: token (str) – The base64 encoded API Key Returns: A tuple of (id, api_key) Return type: tuple
-
es_client.helpers.utils.
prune_nones
(mydict)¶ Remove keys from mydict whose values are None
Parameters: mydict – The dictionary to act on Return type: dict
-
es_client.helpers.utils.
read_file
(myfile)¶ Read a file and return the resulting data.
Parameters: myfile – A file to read. Return type: str
-
es_client.helpers.utils.
verify_ssl_paths
(args)¶ Verify that the various certificate/key paths are readable. The
read_file()
function will raise aConfigurationError
if a file fails to be read.Parameters: args (dict) – The client
block of the config dictionary.
SchemaCheck¶
-
es_client.helpers.schemacheck.
password_filter
(data)¶ Return a deepcopy of the dictionary with any password fields hidden
-
class
es_client.helpers.schemacheck.
SchemaCheck
(config, schema, test_what, location)¶ Validate
config
with the providedSchema
.test_what
andlocation
are for reporting the results, in case of failure. If validation is successful, the method returnsconfig
as valid through theresult()
method.Parameters: -
result
()¶ Return the result of the Schema test, if successful. Otherwise, raise a
ConfigurationError
-