#!/usr/bin/env bash
set -euo pipefail

WORKFLOW_ID="${1:-}"
IOC_TYPE="${2:-domain}"
IOC_VALUE="${3:-malicious.example}"

if [[ -z "${WORKFLOW_ID}" ]]; then
  echo "usage: $0 <workflow_id> [ioc_type] [ioc_value]"
  echo "example: $0 123e4567-e89b-12d3-a456-426614174000 domain malicious.example"
  exit 1
fi

curl -sS -X POST "http://localhost:8088/action/trigger-shuffle" \
  -H "Content-Type: application/json" \
  -d "{\"workflow_id\":\"${WORKFLOW_ID}\",\"execution_argument\":{\"ioc_type\":\"${IOC_TYPE}\",\"ioc_value\":\"${IOC_VALUE}\",\"source_event\":{\"event_id\":\"cli-$(date +%s)\",\"asset\":{\"hostname\":\"fw01\"},\"network\":{\"src_ip\":\"198.51.100.25\"}}}}"

echo
