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

IRIS_BASE_URL="${IRIS_BASE_URL:-https://localhost:8443}"
IRIS_API_KEY="${IRIS_API_KEY:-}"
INTEGRATOR_URL="${INTEGRATOR_URL:-http://localhost:8088}"

echo "[1/2] Direct IRIS API call"
curl -k -sS -X POST "${IRIS_BASE_URL}/api/v2/cases" \
  -H "Content-Type: application/json" \
  ${IRIS_API_KEY:+-H "Authorization: Bearer ${IRIS_API_KEY}"} \
  -d '{
    "title": "Sample SOC case from curl",
    "description": "Direct IRIS API example",
    "tags": ["soc", "sample", "curl"]
  }' | sed 's/^/  /'

echo
echo "[2/2] Call IRIS through SOC Integrator"
curl -sS -X POST "${INTEGRATOR_URL}/action/create-iris-case" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Sample SOC case via integrator (curl)",
    "severity": "medium",
    "source": "soc-integrator-curl-sample",
    "payload": {
      "description": "Case created through integrator endpoint",
      "tags": ["soc", "integrator", "curl"]
    }
  }' | sed 's/^/  /'

echo
