t31-facility-count-readonly.ps1 846 B

12345678910
  1. param([string]$BaseUrl = 'http://192.168.110.96:8301')
  2. $ErrorActionPreference = 'Stop'
  3. $rows = foreach ($endpoint in @('/infrastructure/base-archives', '/overview/infrastructure', '/infrastructure/management-information')) {
  4. $response = Invoke-RestMethod -Method Get -Uri ($BaseUrl.TrimEnd('/') + '/api/cockpit/v1' + $endpoint) -TimeoutSec 10
  5. if ($response.code -ne 200 -or $null -eq $response.data.totals.facilityCount) { throw "Invalid business response: $endpoint" }
  6. [pscustomobject]@{ endpoint = $endpoint; facilityCount = $response.data.totals.facilityCount; excluded = $response.data.excluded }
  7. }
  8. $rows | ConvertTo-Json -Depth 5
  9. if (@($rows.facilityCount | Select-Object -Unique).Count -ne 1) { throw 'Facility count mismatch across three endpoints' }
  10. Write-Output 'PASS: three facility counts agree (stable dataset required).'