towerops/lib/towerops_web/controllers/api/v1
Graham McIntire edb82bcc40 feat(coverage): public REST API + KMZ export + email-on-complete
cnHeat-2.0-style automation hooks. Coverage prediction is now a
first-class API resource that Terraform / Ansible / cron can drive.

REST API (under /api/v1, Bearer-token auth scoped to one org)
- GET    /coverages              list
- POST   /coverages               create + auto-queue compute
- GET    /coverages/:id           read (includes status / progress_pct
                                  for polling-based providers)
- PATCH  /coverages/:id           update editable fields
- DELETE /coverages/:id           delete + cleanup
- POST   /coverages/:id/recompute requeue, returns 202
- GET    /coverages/:id/kmz       Google Earth bundle (KML + PNG)

Each response includes the full resource — Terraform read-after-write
reconciles cleanly; status polling hits a stable JSON shape.

Email-on-complete (Towerops.Coverages.Notifier)
- Worker fires deliver_compute_complete on both :ready and :failed
  paths. Sends a short text email to every member of the owning
  organisation with a link to the show page (or the failure
  reason). Mirrors cnHeat 2.0's per-project email alerts.
- Failures are non-fatal: a stuck SMTP relay never blocks the
  underlying coverage record from transitioning state.

KMZ export
- Builds a flat KMZ in-memory via :zip.create — doc.kml +
  overlay.png, with the LatLonBox set from the coverage's bbox.
  XML special chars are escaped. 409 if not yet ready.

Tests (11 new, all green)
- Bearer-token auth happy path + 401 missing
- index / show / create / update / delete + 404 cross-org
- create returns status:'queued' confirming the auto-enqueue
- recompute returns 202 with status:'queued'

Plus docs/terraform-coverages.md showing how to drive the new API
from a third-party restapi provider until the first-party
terraform-provider-towerops gets a coverage resource.
2026-05-06 17:15:57 -05:00
..
activity_controller.ex feat: expand REST API with alerts, agents, org settings, members, integrations, metrics, activity endpoints 2026-02-14 11:28:57 -06:00
agent_release_webhook_controller.ex tests: raise coverage to 70% via helper promotion + new unit/property tests 2026-04-24 09:49:06 -05:00
agents_controller.ex fix: resolve compilation errors, test failures, and credo issues 2026-02-14 12:23:10 -06:00
alerts_controller.ex fix: resolve compilation errors, test failures, and credo issues 2026-02-14 12:23:10 -06:00
check_results_controller.ex reliability-audit-fixes (#181) 2026-03-26 14:10:36 -05:00
checks_controller.ex dialyzer: fix all unmatched_return warnings (154 → 0) 2026-04-21 10:03:55 -05:00
coverages_controller.ex feat(coverage): public REST API + KMZ export + email-on-complete 2026-05-06 17:15:57 -05:00
devices_controller.ex dialyzer: fix all unmatched_return warnings (154 → 0) 2026-04-21 10:03:55 -05:00
escalation_policies_controller.ex feat: add REST API and GraphQL for on-call schedules and escalation policies 2026-03-11 14:01:15 -05:00
gaiia_webhook_controller.ex fix/findings-medium-priority (#188) 2026-03-27 12:31:53 -05:00
geoip_controller.ex dialyzer: fix remaining 88 warnings — clean dialyzer run 2026-04-21 10:32:42 -05:00
integrations_controller.ex perf+refactor: codebase-wide query and antipattern audit 2026-04-28 16:58:51 -05:00
invitations_controller.ex fix: resolve compilation errors, test failures, and credo issues 2026-02-14 12:23:10 -06:00
maintenance_windows_controller.ex add maintenance windows REST API and GraphQL support 2026-03-11 14:33:25 -05:00
members_controller.ex fix: resolve compilation errors, test failures, and credo issues 2026-02-14 12:23:10 -06:00
mib_controller.ex dialyzer: fix all unmatched_return warnings (154 → 0) 2026-04-21 10:03:55 -05:00
organization_controller.ex fix: use correct auth check for API organization updates 2026-03-10 13:41:38 -05:00
pagerduty_webhook_controller.ex reliability-audit-fixes (#181) 2026-03-26 14:10:36 -05:00
schedules_controller.ex feat: add REST API and GraphQL for on-call schedules and escalation policies 2026-03-11 14:01:15 -05:00
sites_controller.ex Refactor duplicate site API logic 2026-03-10 16:27:35 -05:00
stripe_webhook_controller.ex reliability-audit-fixes (#181) 2026-03-26 14:10:36 -05:00