Flask app with a REST API to manage a fleet of distributed devices.
-
Get list of devices:
GET /devices/
- Pass:
- Returns: List of found devices.
- Status: 200
- Fail:
- Returns: "No devices found"
- Status: 404
- Pass:
-
Get device properties:
GET /devices/<int:id>
- Pass:
- Returns: Found device.
- Status: 200
- Fail:
- Returns: "Device {device_id} not found"
- Status: 404
- Pass:
-
Create device:
POST /devices/<int:id>
- Pass:
- Returns: "Device {device_id} created successfully"
- Status: 201
- Pass (device already exists):
- Returns: ""
- Status: 204
- Pass:
-
Update device:
PUT /devices/<int:id>
- Pass:
- Returns: "Device {device_id} updated successfully"
- Status: 200
- Fail:
- Returns: "Device {device_id} not found"
- Status: 404
- Pass:
-
Remove device:
DELETE /devices/<int:id>
- Pass:
- Returns: "Device {device_id} deleted successfully"
- Status: 200
- Pass (device doesn't exist):
- Returns: ""
- Status: 204
- Pass:
Set the database user and admin passwords, eg.
echo "very_long_but_easy_to_remember_user_password" > app/mongo/secrets/mongo_password.txt
echo "very_long_but_easy_to_remember_admin_password" > app/mongo/secrets/mongo_root_password.txt
To build the images run
docker compose build
Execute the fleet management system:
docker compose run -d server
and then the test client:
docker compose run --rm test_client
The server unit test can be used to verify the API endpoints with an ephemeral database.
python3 -m unittest app.app_test