---
sidebar:
  hidden: true
title: roboto.domain.views.record
---
## Module Contents

### ROBOQL_VIEW_TARGETS

```python
roboto.domain.views.record.ROBOQL_VIEW_TARGETS: Final[frozenset[roboto.query.QueryTarget]]
```

`from roboto.domain.views import ROBOQL_VIEW_TARGETS`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/views/record.py#L150-L152)

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 `roboql` config each of these three lists passes to its filter bar; a list that gains RoboQL mode is added here at the same time.

### VIEW_SCHEMA_VERSION_V1

```python
roboto.domain.views.record.VIEW_SCHEMA_VERSION_V1: Final[int] = 1
```

`from roboto.domain.views import VIEW_SCHEMA_VERSION_V1`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/views/record.py#L25-L25)

Value stored in the `schema_version` column for a [`VIEW_SCHEME_V1`](/reference/python-sdk/roboto/domain/views/record#roboto.domain.views.record.VIEW_SCHEME_V1) definition.

### VIEW_SCHEME_V1

```python
roboto.domain.views.record.VIEW_SCHEME_V1: Final = 'view_v1'
```

`from roboto.domain.views import VIEW_SCHEME_V1`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/views/record.py#L22-L22)

Identifier for the first version of the View definition schema.

### ViewDefinition

```python
class roboto.domain.views.record.ViewDefinition(/, **data: Any)
```

`from roboto.domain.views import ViewDefinition`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/views/record.py#L69-L147)

Bases: `pydantic.BaseModel`

The 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`](/reference/python-sdk/roboto/query/specification#roboto.query.specification.QuerySpecification), because one cannot be stored faithfully: `Comparator` has 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`](/reference/python-sdk/roboto/query/filters#roboto.query.filters.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`)

**Attributes**

- **ViewDefinition.display** (`ViewDisplay`) = `None`: Presentation state to restore when the View is loaded: columns, sort, and page size.

- **ViewDefinition.filters** (`roboto.query.SavedFilters | None`) = `None`: The filter controls the author built.

  Serves the same purpose as `roboql` for 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 `roboql` are alternatives, not a pair: at most one is ever set. Both are `None` for a View that filters nothing, which is a legitimate thing to save — it captures a column layout and a sort over the unfiltered list. So `None` here 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.

- **ViewDefinition.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.

  `None` for a View built from structured filters, and also for one that filters nothing at all — see [`filters`](/reference/python-sdk/roboto/domain/views/record#roboto.domain.views.record.ViewDefinition.filters).

- **ViewDefinition.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.

### ViewDisplay

```python
class roboto.domain.views.record.ViewDisplay(/, **data: Any)
```

`from roboto.domain.views import ViewDisplay`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/views/record.py#L44-L66)

Bases: `pydantic.BaseModel`

How 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`)

**Attributes**

- **ViewDisplay.page_size** (`int | None`) = `None`: Rows per page, or `None` to accept whatever the client's table would pick on its own.

- **ViewDisplay.sort_by** (`str | None`) = `None`: Field to sort results by, or `None` to leave the target's default sort in place.

- **ViewDisplay.sort_direction** (`roboto.query.SortDirection | None`) = `None`: Direction to sort in. Only meaningful alongside [`sort_by`](/reference/python-sdk/roboto/domain/views/record#roboto.domain.views.record.ViewDisplay.sort_by).

- **ViewDisplay.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.

### ViewRecord

```python
class roboto.domain.views.record.ViewRecord(/, **data: Any)
```

`from roboto.domain.views import ViewRecord`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/views/record.py#L187-L238)

Bases: `pydantic.BaseModel`

A 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. [`visibility`](/reference/python-sdk/roboto/domain/views/record#roboto.domain.views.record.ViewRecord.visibility) is 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`)

**Attributes**

- **ViewRecord.created** (`datetime.datetime`): When the View was first saved.

- **ViewRecord.created_by** (`str`): User who created the View. The author, who alone may delete it or change who can see it.

- **ViewRecord.definition** (`ViewDefinition`): The saved query and presentation state.

- **ViewRecord.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.

- **ViewRecord.modified_by** (`str`): User who last changed the View. Surfaced in the picker so a shared View can be judged.

- **ViewRecord.name** (`str`): Display name. Not unique — Views are addressed by `view_id`, never by name.

- **ViewRecord.org_id** (`str`): Organization that owns the View.

- **ViewRecord.schema_version** (`int`): Version of `definition`'s shape, mirroring its `scheme` so rows can be selected by version in SQL without parsing the JSON.

- **ViewRecord.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.

- **ViewRecord.view_id** (`str`): Unique identifier for the View, and the token that addresses it in a shareable URL.

- **ViewRecord.visibility** (`ViewVisibility | None`) = `None`: Who can see this View, or `None` when it has not been resolved.

  Every API response carrying a View fills this in. `None` means 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.

### ViewVisibility

```python
class roboto.domain.views.record.ViewVisibility
```

`from roboto.domain.views import ViewVisibility`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/views/record.py#L29-L41)

Bases: `roboto.compat.StrEnum`

Who 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 `organization` View is readable by the whole org and still editable only by its author, anyone granted `editor` on it, and org admins.

**Attributes**

- **ViewVisibility.Organization** = `'organization'`: Visible to every member of the owning org.
- **ViewVisibility.Private** = `'private'`: Visible to its author, anyone later granted access directly, and the org's admins.

### ensure_definition_renders_for()

```python
def roboto.domain.views.record.ensure_definition_renders_for(
    target: roboto.query.QueryTarget,
    definition: ViewDefinition,
) -> None
```

`from roboto.domain.views import ensure_definition_renders_for`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/views/record.py#L162-L184)

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`](/reference/python-sdk/roboto/domain/views/record#roboto.domain.views.record.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`](/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoInvalidRequestException): `definition` carries RoboQL text and `target` has no RoboQL-capable list.

**Returns**

- `None`
