Module tripleblind.config
The Config object connects the SDK to the TripleBlind Router. It also provides access to the standard and custom variables and properties which reflect the current environment.
This is initialized from a tripleblind.yaml file, which looks something like this:
endpoint: "https://tripleblind.app"
data_for_examples: "/my/example/data_dir"
sdkuser_token: "" # obtained from the Router
mykey: "my value" # user defined value
Default values will be used for the first two items, but the sdkuser_token
must be defined in the YAML file.
Custom values can be defined within that YAML file as show above with mykey
.
This would be accessed in Python like this:
import tripleblind as tb
print(tb.config.mykey)
The YAML file is discovered by searching in the following order (first found wins):
1. Path specified in environment variable TB_API_CONFIG
2. "tripleblind.yaml" found in top-level script folder or a parent folder
Global variables
var VERBOSE
-
Explicitly show information about the config file loading via a '–verbose' command line parameter
Classes
class Config
-
Configuration settings and runtime environment information.
Instance variables
var active_team : int
-
int: ID of the active team or "" if using default
var ap_token : str
-
str: Token for the Access Point when operating in Enterprise Mode
var ap_url : str
-
str: URL for the Access Point when operating in Enterprise Mode
var config_file : Path
-
str: Path of the tripleblind.yaml config file
var data_dir : Path
-
str: Path to the standard data directory
var endpoint
-
str: URL for the API endpoint of the targeted Router
var gui_url
-
str: URL for the user interface of the targeted Router
var script_dir : Path
-
str: Path of the top-level script
Methods
def get_config_var(self, key: str) -> str
-
Read a variable out of the configuration YAML
Args
key
:str
- Key name of the value
Raises
TripleblindConfigError
- Invalid configuration file found
Returns
str
- Value from the config file, or None if not found
def resolve_path_rel_to_config(self, path)
-
Expand paths relative to the YAML file it was loaded from
Args
path
:str
- A path, can be relative or absolute
Returns
str
- An absolute path
def resolve_relative_path_var(self, key: str) -> str
-
Read a config variable and resolve relative paths
Args
key
:str
- a key name in the config YAML
Returns
str
- The loaded key value converted to an absolute path, or None if not found
def using_enterprise_mode(self) -> bool
-
Determine if in Enterprise Mode where API calls run through the Access Point
Enterprise Mode is enabled when the access_point_url and access_point_token values are set in the tripleblind.yaml.
Returns
bool
- True if operating in Enterprise Mode