labthings_fastapi.descriptors.action
Define an object to represent an Action, as a descriptor.
Module Contents
Classes
Data
API
- labthings_fastapi.descriptors.action.ACTION_POST_NOTICE = <Multiline-String>
- labthings_fastapi.descriptors.action.ACTION_GET_DESCRIPTION = <Multiline-String>
- class labthings_fastapi.descriptors.action.ActionDescriptor(func: Callable, response_timeout: float = 1, retention_time: float = 300)
-
- __get__(obj: Optional[labthings_fastapi.thing.Thing], type=None) labthings_fastapi.thing_description.model.Union[labthings_fastapi.descriptors.action.ActionDescriptor, Callable]
The function, bound to an object as for a normal method.
This currently doesn’t validate the arguments, though it may do so in future. In its present form, this is equivalent to a regular Python method, i.e. all we do is supply the first argument,
self.If
objis None, the descriptor is returned, so we can get the descriptor conveniently as an attribute of the class.
- property name
The name of the wrapped function
- property title
A human-readable title
- property description
A description of the action
- _observers_set(obj)
A set used to notify changes
- emit_changed_event(obj, status)
Notify subscribers that the action status has changed
This function is run from within the
Invocationthread that is created when an action is called. It must be run from this thread as it is communicating with the event loop via anasyncioblocking portal.- Raises:
NotConnectedToServerError – if the Thing calling the action is not connected to a server with a running event loop.
- async emit_changed_event_async(obj: labthings_fastapi.thing.Thing, value: Any)
Notify subscribers that the action status has changed
- add_to_fastapi(app: fastapi.FastAPI, thing: labthings_fastapi.thing.Thing)
Add this action to a FastAPI app, bound to a particular Thing.
- action_affordance(thing: labthings_fastapi.thing.Thing, path: Optional[str] = None) labthings_fastapi.thing_description.model.ActionAffordance
Represent the property in a Thing Description.