API for water tank's data management.
The API is divided into Internal
and External
endpoints.
The External
ones are read-only access to tank's data, or a group of tanks.
The returned attributes are:
Name
Group
MaximumCapacity
TankState
Empty
Filling
Full
CurrentWaterLevel
LastFullTime
The Internal
exposes all the External
ones, plus the hability to register a new tank
and update any water level.
In order to provide a new water state, it must be passed an access_token
,
working as a password to prevent other API users to do malicious or multiple modifications.
Docker compose can be used to build and run both internal and external API, as the following:
docker-compose up
But, each API can also be deploy running build separately:
Internal
docker-compose build water-tank-api-internal-v1
docker run lo-han/water-tank-api-internal-v1 -p 8081:8080
External
docker-compose build water-tank-api-external-v1
docker run lo-han/water-tank-api-external-v1 -p 8082:8080
Ok (200)
Bad Request (400)
Unprocessable Entity (422)
{
"name": "TANK_7",
"group": "GROUP_2",
"maximum_capacity": 45
}
{
"access_token": "&e#&5C&F+zR726sHy9DaY&CftEX#Sinw" // example
}
No Content (204)
Bad Request (400)
Not Found (404)
Unprocessable Entity (422)
access_token
group
{
"water_level": 10
}
Ok (200)
Not Found (404)
group
{
"code": "WATERTANK_200",
"content": {
"current_water_level": "90.00L",
"datetime": "2023-09-25T19:34:39.775746328Z",
"group": "GROUP_3",
"maximum_capacity": "120.00L",
"name": "TANK_6",
"tank_state": "FILLING"
}
}
Ok (200)
Bad Request (400)
Not Found (404)
{
"code": "WATERTANK_200",
"content": {
"datetime": "2023-09-25T19:36:20.721605065Z",
"tanks": [
{
"current_water_level": "0.00L",
"group": "GROUP_1",
"maximum_capacity": "100.00L",
"name": "TANK_1",
"tank_state": "EMPTY"
},
{
"current_water_level": "50.00L",
"group": "GROUP_1",
"maximum_capacity": "80.00L",
"name": "TANK_2",
"tank_state": "FILLING"
},
{
"current_water_level": "120.00L",
"group": "GROUP_1",
"maximum_capacity": "120.00L",
"name": "TANK_3",
"tank_state": "FULL"
}
]
}
}