mxcubecore.ipc.whitelist¶
Whitelist of HardwareObject methods callable over IPC.
See IPC_FORMAT.md, section 4, for the eligibility rules.
Functions
|
Build a pydantic request model from the parameters of func. |
|
Build the whitelist from the configured "role.method" entries. |
|
Implementation of the _describe reserved IPC method. |
|
Validate params, call a whitelisted method and return a JSON-safe result. |
|
Mark a method as IPC-eligible with explicit request/response models. |
|
Validate params and return them as keyword arguments. |
Classes
|
A resolved and validated whitelist entry. |
Exceptions
Invalid whitelist configuration or call to a non-whitelisted method. |
- exception mxcubecore.ipc.whitelist.IPCWhitelistError[source]¶
Bases:
ExceptionInvalid whitelist configuration or call to a non-whitelisted method.
- class mxcubecore.ipc.whitelist.WhitelistEntry(method_path: str, role: str, method_name: str, request_model: Type[BaseModel], response_type: Any)[source]¶
Bases:
objectA resolved and validated whitelist entry.
- mxcubecore.ipc.whitelist.build_request_model(func: Callable) Type[BaseModel][source]¶
Build a pydantic request model from the parameters of func.
- Raises:
IPCWhitelistError – when a parameter is untyped, is *args/**kwargs, or has a type pydantic can’t handle.
- Parameters:
func (Callable)
- Return type:
Type[BaseModel]
- mxcubecore.ipc.whitelist.build_whitelist(beamline: Any, allowed_methods: List[str]) Dict[str, WhitelistEntry][source]¶
Build the whitelist from the configured “role.method” entries.
- Raises:
IPCWhitelistError – when a role or method could not be resolved, or a method is not IPC-eligible.
- Parameters:
- Return type:
- mxcubecore.ipc.whitelist.describe(registry: Dict[str, WhitelistEntry]) Dict[str, Dict[str, Any]][source]¶
Implementation of the _describe reserved IPC method.
Returns request and response schemas for each whitelisted method.
- mxcubecore.ipc.whitelist.dispatch(beamline: Any, registry: Dict[str, WhitelistEntry], method_path: str, params: Dict[str, Any]) Any[source]¶
Validate params, call a whitelisted method and return a JSON-safe result.
- Raises:
IPCWhitelistError – when method_path is not whitelisted.
pydantic.ValidationError – when params don’t validate.
TypeError – when the method returns something other than its declared pydantic response model.
- Parameters:
- Return type:
- mxcubecore.ipc.whitelist.ipc_method(request_model: Type[BaseModel] | None = None, response_model: Type[BaseModel] | None = None) Callable[[Callable], Callable][source]¶
Mark a method as IPC-eligible with explicit request/response models.
Only needed when the models can’t be inferred from the method signature.