Esta guía detalla cómo interactuar con el backend Rust (port 8000) utilizando curl.
Requisitos:
curlinstalado.jqinstalado (opcional, para ver el JSON con colores).- El backend corriendo en
localhost:8000.
La API utiliza cookies HttpOnly por seguridad. Debes iniciar sesión para generar el archivo cookies.txt que usarás en el resto de peticiones.
curl -v -c cookies.txt -X POST http://localhost:8000/login \
-H "Content-Type: application/json" \
-d '{
"email": "admin@secureot.space",
"password": "password123"
}'curl -b cookies.txt http://localhost:8000/users/me | jqcurl -b cookies.txt "http://localhost:8000/assets?page=1&size=20" | jqEste endpoint cruza la MAC Address con la base de datos de fabricantes para enriquecer la información.
curl -b cookies.txt "http://localhost:8000/assets/full?page=1&size=500" | jqBusca coincidencias por IP, Nombre o Tag.
curl -b cookies.txt "http://localhost:8000/assets/full?search=192.168.1.10" | jqcurl -b cookies.txt -X POST http://localhost:8000/assets \
-H "Content-Type: application/json" \
-d '{
"name": "PLC Critico Manual",
"tag": "PLC-MAN-01",
"business_criticality": "high",
"model": "S7-1200",
"description": "Creado via cURL"
}' | jqcurl -b cookies.txt -X DELETE "http://localhost:8000/assets/UUID_DEL_ACTIVO" | jqAnaliza un archivo .pcap, extrae IPs/MACs y crea activos automáticamente.
curl -v -b cookies.txt -X POST http://localhost:8000/pcap/upload \
-F "file=@./tu_captura.pcap" | jqCarga el JSON de maclookup para que el sistema aprenda a detectar fabricantes.
curl -v -b cookies.txt -X POST http://localhost:8000/import/mac-vendors \
-F "file=@./mac-vendors-export.json" | jqPara la carga masiva (/import/xlsx/preview), el archivo debe seguir esta estructura:
| Name | Tag | IP Address | MAC Address | Serial Number | Model | Type | Manufacturer | Site | Area | Criticality |
|---|---|---|---|---|---|---|---|---|---|---|
| Main PLC | PLC-01 | 192.168.1.10 | 00:1C:06:A1:B2:C3 | SN-9988 | S7-1500 | PLC | Siemens | Planta 1 | Ensamble | High |
| Repuesto | SPARE-1 | SN-5544 | PowerFlex | Drive | Rockwell | Almacén | Estante 4 | Low |
Devuelve Nodos y Aristas (relaciones) para dibujar mapas de red.
curl -b cookies.txt "http://localhost:8000/asset-connections/network-topology" | jqConteos de riesgo y estado.
curl -b cookies.txt "http://localhost:8000/dashboard/stats" | jq# Sitios
curl -b cookies.txt http://localhost:8000/sites | jq
# Tipos de Activo
curl -b cookies.txt http://localhost:8000/asset-types | jq
# Fabricantes Oficiales
curl -b cookies.txt http://localhost:8000/manufacturers | jq