api.routes.internal.scripts =========================== .. py:module:: api.routes.internal.scripts Attributes ---------- .. autoapisummary:: api.routes.internal.scripts.logger api.routes.internal.scripts.router Functions --------- .. autoapisummary:: api.routes.internal.scripts.list_scripts api.routes.internal.scripts.run_script_endpoint api.routes.internal.scripts.script_runs api.routes.internal.scripts.script_current_stage api.routes.internal.scripts.script_status Module Contents --------------- .. py:data:: logger .. py:data:: router .. py:function:: list_scripts() :async: List every registered script by name (see ``api/scripts/registry.py``). .. py:function:: run_script_endpoint(name: str, record_id: str | None = None, model_id: str | None = None) :async: Queue a run of the named script. :param name: A registered script name (see ``GET /internal/scripts``). :param record_id: Required by ``create_product_shopify`` (an Airtable Model id -- yes, confusingly, see the create-product guide on the documentation site) and, for ``update_product``, an Airtable Variation id (its default entry point -- exactly one of ``record_id``/``model_id`` is required for that script, not both). :param model_id: ``update_product`` only -- an Airtable Model id, updating every Variation of that Model in one go. Ignored by every other script. :returns: JSON avec task_id à utiliser sur GET /scripts/status/{task_id} ou GET /scripts/{name}/runs. .. py:function:: script_runs(name: str, limit: int = 20, offset: int = 0) :async: A page of this script's recorded runs, newest first (``limit``, default 20, max 100; ``offset`` to page further back). ``total`` is how many runs are currently stored in total (up to ``RunStore.MAX_RUNS_PER_SCRIPT``) -- an ``offset + len(runs) < total`` caller knows there's more to fetch. .. py:function:: script_current_stage(name: str) :async: Every live stage of an in-progress run of this script, for polling while it executes (see ``api/tasks.py``'s ``report_stage``). Empty when nothing is currently running. More than one entry when several runs are in flight at once for different record_ids -- e.g. create_product_shopify's bulk "create all missing" button. .. py:function:: script_status(task_id: str) :async: Poll the status/result of a task queued by POST /scripts/{name}/run. :returns: JSON avec status (PENDING/STARTED/RETRY/SUCCESS/FAILURE) et, une fois terminé, result ou error.