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:
- es_client.helpers.utils.file_exists(file)¶
Verify the file exists
- es_client.helpers.utils.get_version(client)¶
Get the Elasticsearch version of the connected node
- Parameters:
client (
Elasticsearch
) – An Elasticsearch client object- Returns:
The Elasticsearch version as a 3-part tuple, (major, minor, patch)
- Return type:
- es_client.helpers.utils.get_yaml(path)¶
Read the file identified by path and import its YAML contents.
- es_client.helpers.utils.parse_apikey_token(token)¶
Split a base64 encoded API Key Token into id and api_key
- es_client.helpers.utils.prune_nones(mydict)¶
Remove keys from mydict whose values are None
- Parameters:
mydict – The dictionary to act on
- Return type:
- es_client.helpers.utils.read_file(myfile)¶
Read a file and return the resulting data.
- Parameters:
myfile – A file to read.
- Return type:
- 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