
# JSON payload variant of the import. Same data as the four CSV files,
# same endpoint - only the media type differs. No -F file parts.

curl -k -X POST "https://{ipf_server}/api/aim/import/{snapshotId}" \
  -H "X-API-Token: {api_token}" \
  -H "Content-Type: application/json" \
  --data-binary @import.json


# $last (and $lastLocked / $prev) now resolve server-side. Note the SINGLE quotes:
# in double quotes the shell would expand $last to an empty string.

curl -k -X POST 'https://{ipf_server}/api/aim/import/$last' \
  -H "X-API-Token: {api_token}" \
  -H "Content-Type: application/json" \
  --data-binary @import.json


# Expected: 202 {"jobId":"..."}
# Then poll the job. Note the action is now 'aimImport', not 'aimCsvImport':

curl -k -X POST "https://{ipf_server}/api/tables/jobs" \
  -H "X-API-Token: {api_token}" \
  -H "Content-Type: application/json" \
  -d '{"columns":["id","name","status","isDone","reason"],
       "filters":{"name":["eq","aimImport"]},
       "sort":{"column":"scheduledAt","order":"desc"},
       "pagination":{"limit":5,"start":0}}'


# Negative check - row-level validation is now synchronous. This returns 422 with
# errors[].field = ["flows",0,"protocol"] rather than scheduling a job that fails
# later. (protocol must be a number; "6" as a string is rejected.)

curl -k -X POST "https://{ipf_server}/api/aim/import/{snapshotId}" \
  -H "X-API-Token: {api_token}" \
  -H "Content-Type: application/json" \
  -d '{"flows":[{"srcIp":"10.0.1.10","dstIp":"10.0.2.20","protocol":"6",
       "policyDecision":"allowed","srcWorkloadExternalId":"wl-001",
       "dstWorkloadExternalId":"wl-002"}]}'


# Negative check - empty payload returns 400 "At least one file must be provided",
# the same error the multipart path gives when no files are attached.

curl -k -X POST "https://{ipf_server}/api/aim/import/{snapshotId}" \
  -H "X-API-Token: {api_token}" \
  -H "Content-Type: application/json" \
  -d '{}'
