Fraunhofer-IIS / libjapi

libjapi is a universal JSON to C API library. It receives newline-delimited JSON (NDJSON) messages via TCP and calls registered C functions. A JSON response is returned for each request. Furthermore, it is also possible to create push services, which asynchronously push JSON messages to the clients subscribed to them.
MIT License
3 stars 1 forks source link

Provide japi handler that lists registered commands #27

Closed fraunhofer-iis-bot closed 1 year ago

fraunhofer-iis-bot commented 4 years ago

In GitLab by @jannismain on Feb 27, 2020, 17:23

Summary

Provide JAPI command to discover commands registered with the controller.

Explanation

Similar to how push services can be discovered via the japi_pushsrv_list command, discovering registered japi commands via japi_cmd_list would be helpful in client development:

-> {"japi_request": "japi_cmd_list"}
<- {"japi_response": "japi_cmd_list", "data": {"commands": ["get_temperature", ...]}}

Alternatively, a slightly different API would provide even more utility:

-> {"japi_request": "japi_cmd_list"}
<- {"japi_response": "japi_cmd_list", "data": {"get_temperature": {"unit": "celsius"}, ...}}

Here, in addition to the command name (as key of data object), the accepted arguments and their default values are returned.

fraunhofer-iis-bot commented 4 years ago

In GitLab by @cstender on Mar 25, 2020, 08:49

Maybe this can be implemented together with the JSON schema validator since both features require knowledge about the json structure.

fraunhofer-iis-bot commented 3 years ago

In GitLab by @jannismain on Apr 30, 2021, 17:27

This feature is required by our general libjapi webframework in order to discover, which capabilities the server has (i.e. which requests it accepts).

fraunhofer-iis-bot commented 3 years ago

In GitLab by @cstender on May 4, 2021, 17:28

The first option is easy and could be implemented soon. The second option is really nice, but requires a formal JSON schema description of each/all requests.

fraunhofer-iis-bot commented 3 years ago

In GitLab by @jannismain on May 5, 2021, 08:25

Yes, I agree that some formal description of each JSON command would be required to implement the second approach.

For a general libjapi web client, this feature would allow to have the same client work with many different libjapi backends, which would further increase the usefulness of libjapi (because no custom client will be required at all for routine tasks).

For now, the libjapi web framework doesn't strictly need the second approach. The first one would suffice to at least verify, that the assumptions the client makes about the server are somewhat true.

fraunhofer-iis-bot commented 3 years ago

In GitLab by @cstender on May 5, 2021, 09:07

I really like the second approach as it would also allow a generic mobile app.

Nevertheless, let's implement the first version and later we can enhance it.

fraunhofer-iis-bot commented 1 year ago

In GitLab by @vornkat-iis on Jul 4, 2023, 15:16

created branch 27-provide-japi-handler-that-lists-registered-commands to address this issue