TruStar (Main Class)

For each API endpoint, there is a method on this class for making calls to it. The instance can be configured with either a dictionary or config file. If using a config file, it should be an INI file with the extension .conf or .ini. The configuration file can use sections to hold different configurations within the same file. For instance, if a user has both a standard account and a demo account, they could use an configuration file like the one below:

auth_endpoint =
api_endpoint =
user_api_key = <api_key>
user_api_secret = <api_secret>
enclave_ids = <enclave1_id>,<enclave2_id>,...

auth_endpoint =
api_endpoint =
user_api_key = <api_key>
user_api_secret = <api_secret>
enclave_ids = <demo_enclave1_id>,<demo_enclave2_id>,...

An instance could then be configured to use the API with the demo account as follows:

ts = TruStar(config_file="trustar.conf", config_role="demo")
class trustar.trustar.TruStar(config_file=None, config_role=None, config=None)
__init__(config_file=None, config_role=None, config=None)

Constructs and configures the instance. Initially attempts to use config; if it is None, then attempts to use config_file instead.

The only required config keys are user_api_key and user_api_secret. To obtain these values, login to TruSTAR Station in your browser and visit the API tab under SETTINGS to generate an API key and secret.

All available keys, and their defaults, are listed below:

key required default description
user_api_key Yes True API key
user_api_secret Yes True API secret
enclave_ids No [] a list (or comma-separated list) of enclave ids
auth_endpoint No "" the URL used to obtain OAuth2 tokens
api_endpoint No "" the base URL used for making API calls
station_base_url No "" the base URL for Station
verify No True whether to use SSL verification
retry No True whether to wait and retry requests that fail with 429
max_wait_time No 60 fail if 429 wait time is greater than this (seconds)
client_type No "Python_SDK" the name of the client being used
client_version No the version of the Python SDK in use the version of the client being used
client_metatag No(*) None any additional information (ex. email address of user)
http_proxy No None http proxy being used - http(s)://user:pwd@{ip}:{port}
https_proxy No None https proxy being used - http(s)://user:pwd@{ip}:{port}

(*): It will become mandatory on future versions of trustar, please try and update your code accordingly

  • config_file (str) – Path to configuration file (conf, json, or yaml). If no value is passed, the environment variable TRUSTAR_PYTHON_CONFIG_FILE will be used. If that is not defined, defaults to “trustar.conf”.
  • config_role (str) – The section in the configuration file to use. If no value is passed, the environment variable TRUSTAR_PYTHON_CONFIG_ROLE will be used. If that is not defined, defaults to “trustar”.
  • config (dict) – A dictionary of configuration options. This will override the config file path passed in the config_file parameter.