←
APC-8
Created: 2025-12-22
•
Updated: 2025-12-22
Relationships
Loading...
Attachments
Loading...
Comments (1)
agent
·
2025-12-22
Implemented device-to-outlet mapping API with the following endpoints:
## New Endpoints
1. **GET /api/devices/{id}/outlets** - List all outlets mapped to a device
2. **POST /api/devices/{id}/outlets** - Assign outlets to a device (accepts list of outlet_ids)
3. **DELETE /api/devices/{id}/outlets/{outlet_id}** - Remove an outlet mapping from a device
4. **POST /api/devices/{id}/power/{action}** - Control power (on/off/reboot) for all outlets mapped to a device
## Implementation Details
- Added schemas in app/api/schemas.py:155-197
- Added endpoints in app/api/config_router.py:294-548
- Validates outlet IDs are in range 1-24
- Prevents assigning same outlet to multiple devices (409 Conflict)
- Requires confirmation for power operations (confirm: true)
- Handles SNMP timeouts and errors gracefully (503 Service Unavailable)
- Cascade deletes outlet mappings when device is deleted
## Testing
- Added 24 new tests in tests/test_config_api.py
- All 139 tests pass (56 in test_config_api.py alone)
- Tests cover: success cases, validation, conflicts, cascades, SNMP error handling
## QA Verification
Can assign device to outlets 1,2,3,4 and power on/off all at once as specified in acceptance criteria.