roboto.domain.views.record#
Module Contents#
- roboto.domain.views.record.ROBOQL_VIEW_TARGETS: Final[frozenset[roboto.query.QueryTarget]]#
Targets whose list page can show a View written in RoboQL.
The other View targets (sessions, devices, collections) have filter controls only, so a RoboQL View saved against one of them stores without complaint and then fails for whoever opens it. The web app’s counterpart is the
roboqlconfig each of these three lists passes to its filter bar; a list that gains RoboQL mode is added here at the same time.
- roboto.domain.views.record.VIEW_SCHEMA_VERSION_V1: Final[int] = 1#
Value stored in the
schema_versioncolumn for aVIEW_SCHEME_V1definition.
- roboto.domain.views.record.VIEW_SCHEME_V1: Final = 'view_v1'#
Identifier for the first version of the View definition schema.
- class roboto.domain.views.record.ViewDefinition(/, **data)#
Bases:
pydantic.BaseModelThe saved contents of a View: what its author searched for, and how they were shown it.
Stored as JSON, with no schema constraint behind it: this model is the only thing enforcing the shape.
A View records intent, not a query. It holds what the author expressed — filter controls or RoboQL text — and the client rebuilds an executable query from that on load. It does not hold a ready-made
QuerySpecification, because one cannot be stored faithfully:Comparatorhas no way to say “the last 7 days”, so translating a relative date filter resolves it to fixed instants. A stored query would show the week the View was saved forever after, presented as though it were live.Intent is nonetheless recorded in a typed form —
SavedFilters— so that anything able to call the API can create a View, not only a client that already knows how a filter control is shaped. A filter-backed View still has to be translated into a query before it runs, and the Roboto web app is what does that; a RoboQL View needs no translation, since its text runs anywhere.A View’s search target is not part of this definition. The View itself carries it, and repeating it here would let the two disagree.
- Parameters:
data (Any)
- display: ViewDisplay = None#
columns, sort, and page size.
- Type:
Presentation state to restore when the View is loaded
- filters: roboto.query.SavedFilters | None = None#
The filter controls the author built.
Serves the same purpose as
roboqlfor Views built from filter controls rather than typed queries: it records what the author expressed, so a client can rebuild the query on load rather than replaying a translation that has since gone stale.This and
roboqlare alternatives, not a pair: at most one is ever set. Both areNonefor a View that filters nothing, which is a legitimate thing to save — it captures a column layout and a sort over the unfiltered list. SoNonehere does not imply the View is a RoboQL one.Typed rather than an opaque blob, so that a View is something any caller can construct. An untyped shape would leave an SDK user, the CLI, or an agent with nothing to build against and no way to learn they got it wrong — the row would store, and only fail later when a client tried to render it. That would make Views a web-UI feature rather than a platform one.
The cost is a definition that must agree with the filter UI’s own. That agreement was always required; it was simply unchecked before, and is now enforced where the data enters.
- roboql: str | None = None#
The RoboQL text the author wrote, when the View came from RoboQL rather than filter controls.
RoboQL has no relative-date syntax, so this text does not go stale — it means the same thing whenever it is run, and a backend can execute it directly.
Nonefor a View built from structured filters, and also for one that filters nothing at all — seefilters.
- scheme: Literal['view_v1'] = 'view_v1'#
Version tag for this definition’s shape.
Readers dispatch on this field, so a definition saved in a later shape is recognized as such instead of being misread as this one.
- class roboto.domain.views.record.ViewDisplay(/, **data)#
Bases:
pydantic.BaseModelHow a View presents its results: which columns, in what order, sorted how, how many rows.
Presentation state only. Nothing here changes which records match.
- Parameters:
data (Any)
- page_size: int | None = None#
Rows per page, or
Noneto accept whatever the client’s table would pick on its own.
- sort_by: str | None = None#
Field to sort results by, or
Noneto leave the target’s default sort in place.
- sort_direction: roboto.query.SortDirection | None = None#
Direction to sort in. Only meaningful alongside
sort_by.
- visible_columns: list[str] = None#
Columns to show, in display order.
Visibility and ordering are carried by this one list rather than a visibility map plus a separate order: two fields could disagree about a column, and there is no sensible way to resolve that. A column absent from the list is hidden. An empty list means the client falls back to its own defaults, which is what a View saved before a new column shipped will do.
- class roboto.domain.views.record.ViewRecord(/, **data)#
Bases:
pydantic.BaseModelA wire-transmissible representation of a View.
A View is a named, org-scoped, shareable search over one resource type. Who may see or edit it is held in the authorization service rather than in the table this record is read from.
visibilityis the one part of that answer carried here, because a client cannot otherwise separate a caller’s own Views from their team’s without a request per row; every finer-grained grant stays behind the access endpoint.- Parameters:
data (Any)
- created: datetime.datetime#
When the View was first saved.
- created_by: str#
User who created the View. The author, who alone may delete it or change who can see it.
- definition: ViewDefinition#
The saved query and presentation state.
- modified: datetime.datetime#
When the View’s name or definition last changed. Shown in the picker alongside
modified_by, so a shared View can be judged on how current it is.
- modified_by: str#
User who last changed the View. Surfaced in the picker so a shared View can be judged.
- name: str#
Display name. Not unique — Views are addressed by
view_id, never by name.
- org_id: str#
Organization that owns the View.
- schema_version: int#
Version of
definition’s shape, mirroring itsschemeso rows can be selected by version in SQL without parsing the JSON.
- target: roboto.query.QueryTarget#
The resource type this View searches, e.g. datasets or files.
Fixed at creation: a View’s conditions are written against one target’s fields.
- view_id: str#
Unique identifier for the View, and the token that addresses it in a shareable URL.
- visibility: ViewVisibility | None = None#
Who can see this View, or
Nonewhen it has not been resolved.Every API response carrying a View fills this in.
Nonemeans only that the question was not asked — it does not mean private, and a client treating it as private would show a shared View under a personal heading.
- class roboto.domain.views.record.ViewVisibility#
Bases:
roboto.compat.StrEnumWho a View is visible to: asked for when it is created, reported when it is read.
Governs who can see a View, never who can change it. An
organizationView is readable by the whole org and still editable only by its author, anyone grantededitoron it, and org admins.- Organization = 'organization'#
Visible to every member of the owning org.
- Private = 'private'#
Visible to its author, anyone later granted access directly, and the org’s admins.
- roboto.domain.views.record.ensure_definition_renders_for(target, definition)#
Refuse a definition that no client could show for the target it is saved against.
Applied wherever a definition enters storage, on create and on update, for every caller. The check is per target rather than global because RoboQL is a legitimate way to write a datasets, files, or events View; it is only unrenderable on the targets outside
ROBOQL_VIEW_TARGETS. Filter controls and unfiltered definitions render everywhere.- Parameters:
target (roboto.query.QueryTarget) – Resource type the View searches.
definition (ViewDefinition) – What the View would store.
- Raises:
RobotoInvalidRequestException –
definitioncarries RoboQL text andtargethas no RoboQL-capable list.- Return type:
None