tcex.tcex_args module

TcEx Framework

class tcex.tcex_args.TcExArgs(tcex)[source]

Bases: object

Module for handling args passed to App from CLI, SecureParams, and AOT

_load_secure_params()[source]

Load secure params from the API.

# API Response:

1
2
3
4
5
6
7
8
{
    "inputs":
        {
            "tc_playbook_db_type": "Redis",
            "fail_on_error": true,
            "api_default_org": "TCI"
        }
}
Returns:Parameters (“inputs”) from the TC API.
Return type:dict
_results_tc_args()[source]

Read data from results_tc file from previous run of app.

This method is only required when not running from the with the TcEX platform and is only intended for testing apps locally.

Returns:A dictionary of values written to results_tc.
Return type:(dictionary)
_unknown_args(args)[source]

Log argparser unknown arguments.

Parameters:args (list) – List of unknown arguments
args()[source]

Parse args if they have not already been parsed and return the Namespace for args.

Note

Accessing args should only be done directly in the App.

Returns:ArgParser parsed arguments.
Return type:(namespace)
args_update()[source]

Update the argparser namespace with any data from configuration file.

config(config_data)[source]

Add configuration data to be injected into sys.argv.

Below are the default args that the TcEx frameworks supports. Any App specific args should be included in the provided data.

{
  "api_access_id": "$env.API_ACCESS_ID",
  "api_default_org": "$env.API_DEFAULT_ORG",
  "api_secret_key": "$envs.API_SECRET_KEY",
  "tc_api_path": "$env.TC_API_PATH",
  "tc_log_level": "debug",
  "tc_log_path": "log",
  "tc_owner": "MyOwner",
  "tc_proxy_host": "$env.TC_PROXY_HOST",
  "tc_proxy_password": "$envs.TC_PROXY_PASSWORD",
  "tc_proxy_port": "$env.TC_PROXY_PORT",
  "tc_proxy_tc": false,
  "tc_proxy_username": "$env.TC_PROXY_USERNAME"
}
Parameters:config (dict) – A dictionary of configuration values.
config_file(filename)[source]

Load configuration data from provided file and inject values into sys.argv.

Parameters:config (str) – The configuration file name.
default_args

Parse args and return default args.

inject_params(params)[source]

Inject params into sys.argv from secureParams API, AOT, or user provided.

Parameters:params (dict) – A dictionary containing all parameters that need to be injected as args.
resolved_args()[source]

Parse args if they have not already been parsed and return the Namespace for args.

Note

Accessing args should only be done directly in the App.

Returns:ArgParser parsed arguments with Playbook variables automatically resolved.
Return type:(namespace)
tc_bool_args

A list of default ThreatConnect Args that are booleans.

tc_reserved_args

A list of all ThreatConnect reserved arg values.