Skip to content

API Documentation

API Entrypoint

threatpatrols_action.api

load_api_app

load_api_app(config, action: Callable)

Load the API app, returning a callable FastAPI entrypoint.

Source code in threatpatrols_action/api/__init__.py
def load_api_app(config, action: Callable):
    """Load the API app, returning a callable `FastAPI` entrypoint."""

    logger = logger_get(name=config.LOGGER_NAME)
    logger_setlevel(name=config.LOGGER_NAME, loglevel=config.LOGGER_LEVEL)

    try:
        return load_api_app_wrapper(config, action, logger)
    except (ValueError, ThreatPatrolsException) as e:
        logger.fatal(str(e))
        logger.debug("stack-trace", exc_info=e)
        exit(1)

Example API entrypoint

from threatpatrols_action.api import load_api_app

from . import config
from .action.action import dev_sample

entrypoint = load_api_app(config=config, action=dev_sample)

CLI Entrypoint

threatpatrols_action.cli

load_cli_app

load_cli_app(config, action: Callable)

Load the CLI app, returning a callable CommandRouter entrypoint.

Source code in threatpatrols_action/cli/__init__.py
def load_cli_app(config, action: Callable):
    """Load the CLI app, returning a callable `CommandRouter` entrypoint."""

    logger = logger_get(name=config.LOGGER_NAME, with_request_id=False)
    logger_setlevel(name=config.LOGGER_NAME, loglevel=config.LOGGER_LEVEL)

    try:
        return load_cli_app_wrapper(config, action)
    except (ValueError, ThreatPatrolsException, ValidationError) as e:
        logger.fatal(str(e))
        logger.debug("stack-trace", exc_info=e)
        exit(1)

Example CLI entrypoint

from threatpatrols_action.cli import load_cli_app

from . import config
from .action.action import dev_sample

entrypoint = load_cli_app(config=config, action=dev_sample)