ros_sugar.ui_node.api#

JSON / WebSocket API for the UI node

Module Contents#

Functions#

build_interfaces

Build the discovery document describing every declared interface.

build_api_app

Build the application exposing the JSON / WS API.

API#

ros_sugar.ui_node.api.build_interfaces(ros_node: ros_sugar.ui_node.ui_node.UINode) → Dict[str, Any]#

Build the discovery document describing every declared interface.

Parameters:

ros_node – The running UI node.

Returns:

A JSON-serializable discovery document.

ros_sugar.ui_node.api.build_api_app(ros_node: ros_sugar.ui_node.ui_node.UINode, browser_app: Optional[Any] = None, keys: Optional[ros_sugar.ui_node.security.ApiKeys] = None, session_key: Optional[str] = None) → starlette.applications.Starlette#

Build the application exposing the JSON / WS API.

If browser_app is given, it is mounted under / as the last route, Omit it to run the API headless.

Parameters:
  • ros_node – The running UI node providing the declared interfaces.

  • browser_app – Optional FastHTML browser app to mount at /.

  • keys – API keys the API requires. None serves it without keys

  • session_key – Secret of the cookie giving the browser front end the API without a key. Used only with keys and a browser_app

Returns:

The Starlette API application.