adam.config_manager module¶
ADAM configuration manager
-
class
adam.config_manager.ConfigManager(file_name=None, raw_config=None)¶ Bases:
objectConfiguration object for ADAM client
A dict-like object holding the loaded ADAM configuration file. Individual items can be get/set/deleted via the
[]notation. The keys must be fully-qualified dot-separated names, such as:conf["envs.dev.workspace"] = " .... "
When a key does not refer to a leaf node, returns a nested dict of the key’s children, i.e.:
conf["envs.dev"] = " .... "
returns
dict(url=..., workspace=..., token=....).-
__init__(file_name=None, raw_config=None)¶ Load the ADAM configuration
Loads ADAM configuration from
file_name, or default config file iffile_name==None. Ifraw_configis given, uses its contents to load the configuration (file_nameis ignored in that case). The typical use is to instantiate this class w.file_nameandraw_configset to None (i.e., read from the default config file).- Parameters
file_name (str) – Path to config file to load, or None to search default locations.
raw_config (dict) – dict() of values to interpret as configuration data.
-
get_config(environment=None)¶ Get configuration of an ADAM environment
If
environmentis given, equivalent to calling:self[f"envs.{environment}"]
If
environmentis None, andself["default_env"]is set, equivalent to calling:self[f”envs.{self[‘default_env’]}”]
If
environmentis None, andself["default_env"]is not set, returns the first key in theself[envs]dict.- Parameters
environment (str) – environment name (e.g.,
prodordev)- Raises
KeyError – If the requested environment isn’t found.
-
get_default_env()¶
-
set_config(name, cfg)¶ Set configuration of an ADAM environment
Equivalent to calling:
self[f"envs.{name}"] = cfg
- Parameters
name (str) – environment name (e.g.,
prodordev)cfg (dict) – environment data
-
set_default_env(env_name)¶
-
to_file(file_name=None)¶ Save configuration to
file_nameor the default locationSaves to location proscribed by XDG spec (typically
~/.config/adam/config) or tofile_name, if it’s not set toNone.- Parameters
file_name (str) – Path to config file to save, or None to save to default location.
-