Database API

Records

Writing test results, and getting a document back out.

Contents
GET/db/equipment/{eid}/recordsUnlimited
POST/db/equipment/{eid}/records201
GET/db/records/{rid}
PUT/db/records/{rid}
POST/db/records/{rid}/unlock
DELETE/db/records/{rid}204
FieldTypeNotes
test_datestringYYYY-MM-DD. Stored as written, no timezone is applied.
tested_bystringThe technician's name as it should appear on the report, not a user id.
form_typestringSelects the renderer. Usually matches the device's device_type.
form_dataobjectThe measurements. Not validated.
statusstring"pass" / "fail" / anything else counts as incomplete.
lockedbooleanBlocks further PUTs. Clear it with POST …/unlock.
notesstring

Records are returned newest first, so [0] is the current state of the device, which is what the roll-up counts and last_status are computed from.

Importing trip-test data#

Bulk import runs as two calls on purpose. The preview parses the file and tells you what it matched without writing anything; the confirm applies it. That split exists because an import that silently attaches results to the wrong breaker is worse than one that fails.

POST/db/assemblies/{aid}/import-trip-test/preview
POST/db/assemblies/{aid}/import-trip-test/confirm

Generating the project report#

Renders every record on the project into one NETA document. The response is the file, not JSON.

GET/db/projects/{pid}/generate-reportreturns a file
curl
curl "$BASE/db/projects/312/generate-report" \
  -H "Authorization: Bearer $TOKEN" \
  --max-time 120 \
  -o cedar-ridge.pdf

# Content-Type: application/pdf
# Errors still come back as JSON: check the type before writing the file.