#!/usr/bin/env bash
# fake maas: serves read endpoints from fixtures. `vlans read <fab>` is filtered
# by fabric_id to mimic real MAAS (which scopes vlans to the requested fabric).
prof="${1:-}"; obj="${2:-}"; act="${3:-}"; fab="${4:-}"
case "$obj $act" in
"subnets read") cat "${FIX_SUBNETS:?}"; exit 0 ;;
"spaces read") cat "${FIX_SPACES:?}"; exit 0 ;;
"ipranges read") cat "${FIX_IPRANGES:?}"; exit 0 ;;
"fabrics read") cat "${FIX_FABRICS:?}"; exit 0 ;;
"vlans read") jq --arg f "$fab" '[.[]|select((.fabric_id|tostring)==$f)]' "${FIX_VLANS:?}"; exit 0 ;;
esac
echo "{}"; exit 0