3.1.4. Service Description¶
in service implementation, you can implement the optional describe() method to provide service documentation. This description is used by the admin embedded to describe the service, and to provide a standard way to interact with it.
a Web interface permit to use it and run implemented methods.
3.1.4.1. Implementing a describe method in the service¶
You can implement the optional describe() method to provide service documentation:
def describe():
return json.dumps({
"name": "temperature",
"description": "Temperature monitoring service",
"methods": {
"get_temperature": {
"name": "get_temperature",
"description": "Get current temperature reading",
"parameters": [],
"returns": "json"
},
"set_unit": {
"name": "set_unit",
"description": "Set temperature unit (Celsius/Fahrenheit)",
"parameters": [
{
"name": "unit",
"description": "Temperature unit to use",
"required": True,
"default_value": None,
"parameter_type": "string"
}
],
"returns": "json"
}
}
})
# Don't forget to register the describe function
server.register_function(describe)