flip_api.scripts.generate_trust_api_keys ======================================== .. py:module:: flip_api.scripts.generate_trust_api_keys .. autoapi-nested-parse:: Generate per-trust API keys and write them into an environment file. Trust names are read from the ``TRUST_NAMES`` env var (a JSON list). Both plaintext keys (``TRUST_API_KEYS``) and their hashes (``TRUST_API_KEY_HASHES``) are written as JSON dicts into the environment file. Usage: make generate-trust-api-keys make generate-trust-api-keys ENV_FILE=.env.stag Attributes ---------- .. autoapisummary:: flip_api.scripts.generate_trust_api_keys.REPO_ROOT Functions --------- .. autoapisummary:: flip_api.scripts.generate_trust_api_keys._parse_trust_names flip_api.scripts.generate_trust_api_keys.main Module Contents --------------- .. py:data:: REPO_ROOT .. py:function:: _parse_trust_names(lines: list[str]) -> list[str] Extract trust names from the TRUST_NAMES env var line. :param lines: Lines of the environment file. :type lines: list[str] :returns: List of trust names, e.g. ``["Trust_1", "Trust_2"]``. :rtype: list[str] .. py:function:: main() -> None Generate per-trust API keys and write them into the specified environment file. Reads trust names from ``TRUST_NAMES``, generates a cryptographically secure key for each trust that doesn't already have a value in the ``TRUST_API_KEYS`` dict (or all if ``--force``), and updates both ``TRUST_API_KEYS`` and ``TRUST_API_KEY_HASHES`` JSON dicts in the env file. :raises SystemExit: If the env file is missing or contains no ``TRUST_NAMES`` entry.