mxcubeweb.core.models.configmodels#
Classes
|
|
|
|
|
|
|
|
|
Used to define which adapter properties and methods that are exported over HTTP. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- class mxcubeweb.core.models.configmodels.ModeEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
- class mxcubeweb.core.models.configmodels.ResourceHandlerConfigModel(*, url_prefix: str = '', exports: list[dict[str, str | list]] = [], commands: list[str] = [], attributes: list[str] = [])[source]#
Bases:
BaseModel
Used to define which adapter properties and methods that are exported over HTTP. An endpoint for each method and/or property is created by the AdapterResourceHandler and attached to the server.
The exports list defines the methods and properties exported, the HTTP verb to use and the decorators to apply to the view function,
The format is: [
{“attr”: “get_value”, “method”: “PUT”, “decorators”:[]}
]
Where “attr” is the method or property of the adapter, “method” is the http verb i.e GET, PUT, POST. and decoratoes are a list decroator functions to apply to the resulting view function.
There are two structures that can be used for convenience, that use defualt vlaues for “method” and “decorators”. These are commands and attributes.
Commands is list of functions/methods to export. A dictionary like the one above:
({“attr”: “get_value”, “method”: “PUT”, “decorators”:[]})
Will be generated from the commands list. With the values “method” and decorators set to defualt values, PUT and [restrict, require_control]
Example
commands = [“set_value”, “get_value”]
Will export the methods as …/set_value with HTTP verb PUT
In the same way:
Example
attributes = [“data”]
Will export the property as …/data with HTTP verb GET