Create and build RESTful APIs to perform CRUD operations for a home automation scenario leveraging PYTHON and FLASK in docker container(s).
All responses will have the form -
{
"data": "Mixed type holding the content of the response",
"message": "Description of what happened"
}Subsequent response definitions will only detail the expected value of data field.
Definition
GET /devices
Response
200 OKon success
[
{
"identifier": "floor-lamp",
"name": "Floor Lamp",
"device_type": "switch",
"controller_gateway": "192.1.68.0.2"
},
{
"identifier": "samsung-tv",
"name": "Samsung TV",
"device_type": "tv",
"controller_gateway": "192.1.68.0.9"
}
]Definition
POST /devices
Arguments
"identifier": stringa globally unique identifier for this device"name": stringa friendly name for this device"device_type": stringthe type of the device as understood by the client"controller_gateway": stringthe IP address of the device's controller
If a device with the given identifier already exists, the existing device will be overwritten.
Response
201 Createdon success
{
"identifier": "floor-lamp",
"name": "Floor Lamp",
"device_type": "switch",
"controller_gateway": "192.1.68.0.2"
}GET /device/<identifier>
Response
404 Not Foundif the device does not exist200 OKon success
{
"identifier": "floor-lamp",
"name": "Floor Lamp",
"device_type": "switch",
"controller_gateway": "192.1.68.0.2"
}Definition
DELETE /device/<identifier>
Response
404 Not Foundif the device does not exist204 No Contenton success
- docker-compose up
- docker-compose up --build [Rebuild image]