132 lines
8.2 KiB
Markdown
132 lines
8.2 KiB
Markdown
# API Contracts - Main
|
|
|
|
This document outlines the API endpoints available in the Pig Farm Controller application.
|
|
|
|
## Public Routes (No Authentication Required)
|
|
|
|
| Method | Path | Description |
|
|
| :----- | :------------------------- | :---------------------------------------- |
|
|
| POST | `/api/v1/users` | User registration |
|
|
| POST | `/api/v1/users/login` | User login |
|
|
| POST | `/upstream` | Handle device upstream events |
|
|
| GET | `/swagger/*any` | Swagger UI |
|
|
|
|
## Authenticated Routes (JWT Authentication and Audit Logging Required)
|
|
|
|
### User Endpoints (`/api/v1/users`)
|
|
|
|
| Method | Path | Description |
|
|
| :----- | :--------------------------------- | :------------------------ |
|
|
| POST | `/api/v1/users/:id/notifications/test` | Send test notification |
|
|
|
|
### Device Endpoints (`/api/v1/devices`)
|
|
|
|
| Method | Path | Description |
|
|
| :----- | :--------------------------------- | :------------------------ |
|
|
| POST | `/api/v1/devices` | Create device |
|
|
| GET | `/api/v1/devices` | List devices |
|
|
| GET | `/api/v1/devices/:id` | Get single device |
|
|
| PUT | `/api/v1/devices/:id` | Update device |
|
|
| DELETE | `/api/v1/devices/:id` | Delete device |
|
|
| POST | `/api/v1/devices/manual-control/:id` | Manual control device |
|
|
|
|
### Area Controller Endpoints (`/api/v1/area-controllers`)
|
|
|
|
| Method | Path | Description |
|
|
| :----- | :--------------------------------- | :------------------------ |
|
|
| POST | `/api/v1/area-controllers` | Create area controller |
|
|
| GET | `/api/v1/area-controllers` | List area controllers |
|
|
| GET | `/api/v1/area-controllers/:id` | Get single area controller|
|
|
| PUT | `/api/v1/area-controllers/:id` | Update area controller |
|
|
| DELETE | `/api/v1/area-controllers/:id` | Delete area controller |
|
|
|
|
### Device Template Endpoints (`/api/v1/device-templates`)
|
|
|
|
| Method | Path | Description |
|
|
| :----- | :--------------------------------- | :------------------------ |
|
|
| POST | `/api/v1/device-templates` | Create device template |
|
|
| GET | `/api/v1/device-templates` | List device templates |
|
|
| GET | `/api/v1/device-templates/:id` | Get single device template|
|
|
| PUT | `/api/v1/device-templates/:id` | Update device template |
|
|
| DELETE | `/api/v1/device-templates/:id` | Delete device template |
|
|
|
|
### Plan Endpoints (`/api/v1/plans`)
|
|
|
|
| Method | Path | Description |
|
|
| :----- | :--------------------------------- | :------------------------ |
|
|
| POST | `/api/v1/plans` | Create plan |
|
|
| GET | `/api/v1/plans` | List plans |
|
|
| GET | `/api/v1/plans/:id` | Get single plan |
|
|
| PUT | `/api/v1/plans/:id` | Update plan |
|
|
| DELETE | `/api/v1/plans/:id` | Delete plan |
|
|
| POST | `/api/v1/plans/:id/start` | Start plan |
|
|
| POST | `/api/v1/plans/:id/stop` | Stop plan |
|
|
|
|
### Pig House Endpoints (`/api/v1/pig-houses`)
|
|
|
|
| Method | Path | Description |
|
|
| :----- | :--------------------------------- | :------------------------ |
|
|
| POST | `/api/v1/pig-houses` | Create pig house |
|
|
| GET | `/api/v1/pig-houses` | List pig houses |
|
|
| GET | `/api/v1/pig-houses/:id` | Get single pig house |
|
|
| PUT | `/api/v1/pig-houses/:id` | Update pig house |
|
|
| DELETE | `/api/v1/pig-houses/:id` | Delete pig house |
|
|
|
|
### Pen Endpoints (`/api/v1/pens`)
|
|
|
|
| Method | Path | Description |
|
|
| :----- | :--------------------------------- | :------------------------ |
|
|
| POST | `/api/v1/pens` | Create pen |
|
|
| GET | `/api/v1/pens` | List pens |
|
|
| GET | `/api/v1/pens/:id` | Get single pen |
|
|
| PUT | `/api/v1/pens/:id` | Update pen |
|
|
| DELETE | `/api/v1/pens/:id` | Delete pen |
|
|
| PUT | `/api/v1/pens/:id/status` | Update pen status |
|
|
|
|
### Pig Batch Endpoints (`/api/v1/pig-batches`)
|
|
|
|
| Method | Path | Description |
|
|
| :----- | :----------------------------------------- | :-------------------------------- |
|
|
| POST | `/api/v1/pig-batches` | Create pig batch |
|
|
| GET | `/api/v1/pig-batches` | List pig batches |
|
|
| GET | `/api/v1/pig-batches/:id` | Get single pig batch |
|
|
| PUT | `/api/v1/pig-batches/:id` | Update pig batch |
|
|
| DELETE | `/api/v1/pig-batches/:id` | Delete pig batch |
|
|
| POST | `/api/v1/pig-batches/assign-pens/:id` | Assign empty pens to batch |
|
|
| POST | `/api/v1/pig-batches/reclassify-pen/:fromBatchID` | Reclassify pen to new batch |
|
|
| DELETE | `/api/v1/pig-batches/remove-pen/:penID/:batchID` | Remove empty pen from batch |
|
|
| POST | `/api/v1/pig-batches/move-pigs-into-pen/:id` | Move pigs into pen |
|
|
| POST | `/api/v1/pig-batches/sell-pigs/:id` | Sell pigs |
|
|
| POST | `/api/v1/pig-batches/buy-pigs/:id` | Buy pigs |
|
|
| POST | `/api/v1/pig-batches/transfer-across-batches/:sourceBatchID` | Transfer pigs across batches |
|
|
| POST | `/api/v1/pig-batches/transfer-within-batch/:id` | Transfer pigs within batch |
|
|
| POST | `/api/v1/pig-batches/record-sick-pigs/:id` | Record sick pigs event |
|
|
| POST | `/api/v1/pig-batches/record-sick-pig-recovery/:id` | Record sick pig recovery event |
|
|
| POST | `/api/v1/pig-batches/record-sick-pig-death/:id` | Record sick pig death event |
|
|
| POST | `/api/v1/pig-batches/record-sick-pig-cull/:id` | Record sick pig cull event |
|
|
| POST | `/api/v1/pig-batches/record-death/:id` | Record normal pig death event |
|
|
| POST | `/api/v1/pig-batches/record-cull/:id` | Record normal pig cull event |
|
|
|
|
### Monitor Endpoints (`/api/v1/monitor`)
|
|
|
|
| Method | Path | Description |
|
|
| :----- | :--------------------------------- | :------------------------ |
|
|
| GET | `/api/v1/monitor/sensor-data` | List sensor data |
|
|
| GET | `/api/v1/monitor/device-command-logs` | List device command logs |
|
|
| GET | `/api/v1/monitor/plan-execution-logs` | List plan execution logs |
|
|
| GET | `/api/v1/monitor/task-execution-logs` | List task execution logs |
|
|
| GET | `/api/v1/monitor/pending-collections` | List pending collections |
|
|
| GET | `/api/v1/monitor/user-action-logs` | List user action logs |
|
|
| GET | `/api/v1/monitor/raw-material-purchases` | List raw material purchases |
|
|
| GET | `/api/v1/monitor/raw-material-stock-logs` | List raw material stock logs |
|
|
| GET | `/api/v1/monitor/feed-usage-records` | List feed usage records |
|
|
| GET | `/api/v1/monitor/medication-logs` | List medication logs |
|
|
| GET | `/api/v1/monitor/pig-batch-logs` | List pig batch logs |
|
|
| GET | `/api/v1/monitor/weighing-batches` | List weighing batches |
|
|
| GET | `/api/v1/monitor/weighing-records` | List weighing records |
|
|
| GET | `/api/v1/monitor/pig-transfer-logs` | List pig transfer logs |
|
|
| GET | `/api/v1/monitor/pig-sick-logs` | List pig sick logs |
|
|
| GET | `/api/v1/monitor/pig-purchases` | List pig purchases |
|
|
| GET | `/api/v1/monitor/pig-sales` | List pig sales |
|
|
| GET | `/api/v1/monitor/notifications` | List notifications |
|