-
-
Notifications
You must be signed in to change notification settings - Fork 546
Open
Labels
Description
Is your feature request related to a problem? Please describe.
Mobile clients (e.g. the Ed3n iOS app) add Inputs to Mycodo via the REST API.
When a required Python library is missing, the API currently returns an “unmet dependency” error and instructs users to log into the web UI to install it.
This breaks the mobile workflow and confuses non-technical users.
Describe the solution you’d like
Expose a secure endpoint that mirrors the web UI’s “Install dependencies” routine so apps can trigger the install directly.
📐 Proposed API
| Method | Path | Auth | JSON Body | Response 200 | Errors |
|---|---|---|---|---|---|
POST |
/api/dependencies/install |
Bearer JWT; role admin or install_dependencies |
Provide one: • input_type: "bh1750"• dependency_name: "smbus2" |
{ "job_id": "uuid", "state": "queued" } |
400 bad payload403 forbidden409 identical job running500 internal |
Job status/logs follow the existing /api/jobs/<job_id> pattern.
Security
- Uses existing JWT auth (
flask_jwt_extended); only users with roleadminorinstall_dependenciesmay call it.
Implementation Notes
- Blueprint:
mycodo/mycodo_api/routes/dependencies.py - Helper:
mycodo/utils/dependencies.py- Uses current
create_background_jobinfrastructure to runpip installcommands and stream logs.
- Uses current
- Mapping of
input_type➜ package list already lives inmycodo/inputs/REQUIRED_LIBS. - OpenAPI docstring added so Swagger UI auto-documents the endpoint.
Minimal example
curl -X POST https://<mycodo-host>/api/dependencies/install \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"dependency_name": "smbus2"}'