Helper Methods¶
-
es_client.helpers.utils.
check_config
(config)¶ Ensure that the top-level key
elasticsearch
and its sub-keys,other_settings
andclient
are inconfig
before passing it toSchemaCheck
for value validation.
-
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.
get_yaml
(path)¶ Read the file identified by path and import its YAML contents.
Parameters: path – The path to a YAML configuration file. Return type: dict
-
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.
-
es_client.helpers.utils.
verify_url_schema
(url)¶ Ensure that a valid URL schema (HTTP[S]://URL:PORT) is used
-
class
es_client.helpers.schemacheck.
SchemaCheck
(config, schema, test_what, location)¶ Validate
config
with the providedvoluptuous.Schema
.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: - config (dict) – A configuration dictionary.
- schema (
voluptuous.schema_builder.Schema
) – A voluptuous schema definition - test_what (str) – which configuration block is being validated
- location (str) – An string to report which configuration sub-block is being tested.
-
result
()¶ Return the result of the Schema test, if successful. Otherwise, raise a
ConfigurationError