hertzforge.service.descriptors¶
descriptors
¶
Operation descriptors: the typed form of the schema's operation.
The shell builds an operation's panel from its descriptor, so the
descriptor is also where a request's params are checked: resolve fills
defaults and refuses a value the panel could not have sent, naming the
param and what it accepts.
Classes:
| Name | Description |
|---|---|
Option |
One choice of an enum param: the value sent back and the label shown. |
Param |
One input of an operation's panel. |
Operation |
An operation's descriptor, plus the function that runs it. |
Functions:
| Name | Description |
|---|---|
json_type |
How a JSON value's type reads in an error message. |
Classes¶
Option
dataclass
¶
Param
dataclass
¶
Param(name: str, label: str, type: ParamType, default: Any = REQUIRED, unit: str | None = None, min: float | None = None, max: float | None = None, step: float | None = None, options: Sequence[Option] = (), options_from: str | None = None, in_view: bool = False, setting: str | None = None, length: bool = False, quantity: str | None = None, suggest: str | None = None, shown_with: tuple[str, Any] | None = None)
One input of an operation's panel.
Methods:
| Name | Description |
|---|---|
to_json |
The param as the schema's descriptor writes it. Fields left unset |
check |
|
Attributes:
| Name | Type | Description |
|---|---|---|
optional |
bool
|
Whether this is an object param that may name none (''). |
kinds |
tuple[str, ...]
|
The object kinds an |
verb |
str
|
The core verb a |
Attributes¶
kinds
property
¶
The object kinds an objects: param takes; empty for any other.
Methods:¶
to_json
¶
The param as the schema's descriptor writes it. Fields left unset are omitted rather than sent as null, and so is a required param's default.
check
¶
value as this param's type, or a bad_request naming why not.
choices are the allowed values of an options_from enum.
Operation
dataclass
¶
Operation(id: str, title: str, workspace: Workspace, summary: str, params: Sequence[Param], outputs: Sequence[ViewKind], run: Callable[[Any, dict[str, Any]], list[dict[str, Any]]], edits: bool = False, edits_when: Callable[[dict[str, Any]], bool] | None = None, everywhere: bool = False, previews: bool = False, commits: str | None = None, opens_previewed: bool = False, says_lengths: bool = False)
An operation's descriptor, plus the function that runs it.
run(project, params) receives the connection's Project and the
resolved params and returns the result's list of views.
Methods:
| Name | Description |
|---|---|
to_json |
The descriptor |
resolve |
The params to run with: each given value checked, each missing |
Methods:¶
to_json
¶
The descriptor catalog.list sends for this operation; run
stays behind.
resolve
¶
resolve(given: Any, objects: Mapping[str, str] | None = None, verbs: Mapping[str, Collection[str]] | None = None) -> dict[str, Any]
The params to run with: each given value checked, each missing
one its default. An options_from param with no default takes the
first of its choices: the names in objects (name to kind, the
project's order) of the kinds it takes, or the names in verbs
(name to the verbs that apply to it) its verb applies to.