#!/bin/bash # Create the inbound API methods on PROD from qa-export/api-methods.json (QA definitions, 2026-11-22). # Same name, script, timeout, parameter and return definitions, and traceAllCalls as QA. # The bundle route is blocked by the import reference-scanner false positive (System./Array.), hence the CLI. # usage: apply-api-methods.sh [--dry] [--include-legacy] # --include-legacy also creates IpsenMESMoveIn (no calls on QA in 30 days; excluded by default). set -euo pipefail SBP=$1; shift; DRY=0; LEGACY=0 for a in "$@"; do case $a in --dry) DRY=1;; --include-legacy) LEGACY=1;; esac; done J="$(cd "$(dirname "$0")" && pwd)/qa-export/api-methods.json" python3 - "$J" "$LEGACY" <<'PY' | while IFS= read -r name; do import json,sys for m in json.load(open(sys.argv[1])): if m['name']=='IpsenMESMoveIn' and sys.argv[2]!='1': continue print(m['name']) PY field(){ python3 -c "import json,sys;m=[x for x in json.load(open('$J')) if x['name']=='$name'][0];v=m['$1'];print(v if v is not None else '',end='')"; } args=(api-method create --name "$name" --script "$(field script)" --timeout "$(field timeoutSeconds)") p=$(field parameterDefinitions); [ -n "$p" ] && args+=(--parameters "$p") r=$(field returnDefinition); [ -n "$r" ] && args+=(--return-def "$r") [ "$(field traceAllCalls)" = True ] && args+=(--trace-all-calls) if [ $DRY = 1 ]; then echo "would create $name (timeout $(field timeoutSeconds)s)"; else echo "== $name"; "$SBP" "${args[@]}"; fi done [ $DRY = 1 ] || "$SBP" api-method list | python3 -c "import json,sys;[print(m['id'],m['name'],m['timeoutSeconds']) for m in json.load(sys.stdin)]"