FabrikFabrik
FabrikAPI Reference

AWX

AWX connections, automation templates, execution requests, webhook receiver, and reference data — endpoints under /api/awx/.

Eight ViewSets plus three webhook endpoints under /api/awx/. This is where network automation lives: connect Fabrik to AWX/Tower, define templates that turn Fabrik query results into playbook runs, and stream job status back over WebSocket.

Connections

GET /api/awx/connections/

List AWX connection records.

Resource shape:

{
  "id": "…",
  "name": "Production AWX",
  "base_url": "https://awx.example.com",
  "username": "fabrik-svc",
  "token_configured": true,
  "is_default": false,
  "last_tested_at": "…",
  "last_test_status": "success"
}

OAuth2 tokens are write-only and Fernet-encrypted.

POST /api/awx/connections/

Create.

{
  "name": "Production AWX",
  "base_url": "https://awx.example.com",
  "username": "fabrik-svc",
  "oauth_token": "…",
  "is_default": true
}

POST /api/awx/connections/<id>/test_connection/

Same semantics as the APIC test — always returns 200 with a status field.

Automation templates

Templates describe how Fabrik passes data to an AWX job template. They carry a schema (the columns the table needs), optional validation rules, and the execution mode.

GET /api/awx/templates/

List templates visible to the user. Permission-filtered via FabrikModelPermissions.

Filters: ?category=<id>, ?awx_connection=<id>, ?search=<term>.

POST /api/awx/templates/

Create a template.

Request:

{
  "name": "Tenant cleanup",
  "category": 3,
  "awx_connection": "<id>",
  "awx_job_template_id": 42,
  "execution_mode": "bulk",
  "schema": [
    { "name": "tenant", "field_type": "text", "required": true },
    { "name": "action", "field_type": "enum", "choices": ["shutdown", "delete"] }
  ],
  "validation_lists": [],
  "allowed_groups": [2, 3]
}

PATCH / DELETE /api/awx/templates/<id>/

Update or remove. Deleting a template with pending execution requests returns 409 Conflict.

POST /api/awx/templates/<id>/launch/

Create an AutomationRequest from a template without going through the wizard UI. Accepts rows directly.

Request:

{
  "rows": [
    { "tenant": "tn-prod", "action": "shutdown" },
    { "tenant": "tn-stage", "action": "delete" }
  ],
  "comment": "Clean up pre-decomm tenants"
}

Response 201: Full AutomationRequest including id and the websocket channel to subscribe to.

Automation requests

A request is the user's intent to run a template against a set of rows. It produces one or more AutomationExecution records depending on the execution mode.

GET /api/awx/requests/

Paginated list. Filters: ?template=<id>, ?status=<pending|running|succeeded|failed|cancelled>, ?user=<id>.

Resource shape:

{
  "id": "…",
  "template": "<id>",
  "user": "alice",
  "status": "running",
  "row_count": 12,
  "execution_count": 1,
  "started_at": "…",
  "finished_at": null,
  "scm_commit_sha": "abc123…",
  "comment": "…"
}

POST /api/awx/requests/<id>/cancel/

Request cancellation. Propagates to AWX where possible; queued rows that haven't launched are dropped.

Automation executions

One AutomationRequest can produce multiple AutomationExecution rows (one per AWX job launched). For bulk mode that's always one; future modes may fan out.

GET /api/awx/executions/

Filter by ?request=<id> to see all executions for a given request.

Resource shape:

{
  "id": "…",
  "request": "<id>",
  "awx_job_id": 8472,
  "awx_job_url": "https://awx.example.com/#/jobs/playbook/8472/output",
  "status": "successful",
  "started_at": "…",
  "finished_at": "…",
  "stdout_preview": "PLAY [Tenant cleanup] …",
  "extra_vars_snapshot": { /* what was passed to AWX */ }
}

GET /api/awx/executions/<id>/stdout/

Paginated stdout chunks. Full playbook output can be large — this endpoint chunks at 100 KB boundaries. Prefer the WebSocket stream for live runs.

Reference data

Three small ViewSets that power template authoring:

/api/awx/categories/

Folder hierarchy for organizing templates. Same pattern as query categories.

/api/awx/column-templates/

Reusable column definitions (e.g. "IPv4 address", "VLAN ID"). Reference them by ID from template schemas instead of re-defining.

/api/awx/validation-lists/

Named lists of allowed values (e.g. valid tenant names). Reference from a schema column's validation_list field.

/api/awx/regex-patterns/

Named regex patterns for column validation.

All four support standard CRUD.

Webhook receiver

AWX calls these when job state changes. Not for manual use — documented for firewall and debugging visibility.

POST /api/awx/webhooks/receiver/

AWX → Fabrik webhook. Requires the X-AWX-Webhook-Signature header matching AWX_WEBHOOK_SECRET. Drops the event onto RabbitMQ for one of the three event consumers to process.

GET /api/awx/webhooks/health/

Anonymous health check for AWX notification templates. Always returns { "status": "ok" }.

POST /api/awx/webhooks/test/

Admin-only. Sends a synthetic event through the RabbitMQ pipeline to verify the consumer chain is wired up.

If webhook events stop arriving, check three things in order: AWX's own notification delivery log, the RabbitMQ management UI queue depths (awx.job.status, etc.), and docker compose logs event-consumer-job. One of those three will tell you where the chain broke.