# Test monitors endpoint $apiUrl = "http://localhost:8000" Write-Host "Testing Monitors Endpoint..." -ForegroundColor Cyan try { # Login to get token $loginBody = @{ username = "admin" password = "admin123" } | ConvertTo-Json $loginResponse = Invoke-RestMethod -Uri "$apiUrl/api/v1/auth/login" -Method Post -Body $loginBody -ContentType "application/json" $token = $loginResponse.access_token Write-Host "Login successful" -ForegroundColor Green # Get monitors $headers = @{ "Authorization" = "Bearer $token" } Write-Host "`nFetching monitors (bypassing cache)..." -ForegroundColor Yellow $response = Invoke-RestMethod -Uri "$apiUrl/api/v1/monitors?use_cache=false" -Method Get -Headers $headers Write-Host "`n=== MONITORS ===" -ForegroundColor Cyan Write-Host "Total monitors found: $($response.total)" -ForegroundColor Green if ($response.monitors.Count -gt 0) { Write-Host "`nMonitor List:" -ForegroundColor Yellow foreach ($monitor in $response.monitors) { Write-Host " - ID: $($monitor.id) | Name: $($monitor.name) | Status: $($monitor.status) | Active: $($monitor.is_active)" -ForegroundColor White Write-Host " Description: $($monitor.description)" -ForegroundColor Gray if ($monitor.current_camera_id -ne -1) { Write-Host " Currently showing: Camera $($monitor.current_camera_id)" -ForegroundColor Magenta } } Write-Host "`nFull Response:" -ForegroundColor Yellow $response | ConvertTo-Json -Depth 5 } else { Write-Host "`nNo monitors found in the system." -ForegroundColor Red Write-Host "Monitors need to be configured in GeViServer/GeViScope." -ForegroundColor Yellow } } catch { Write-Host "Error: $($_.Exception.Message)" -ForegroundColor Red if ($_.ErrorDetails.Message) { Write-Host "Details: $($_.ErrorDetails.Message)" -ForegroundColor Red } }