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

### ColumnSort

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

`from roboto.domain.views import ColumnSort`

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

Bases: `pydantic.BaseModel`

Sort that orders a View's results by one field.

Constructing one raises `pydantic.ValidationError` for a `kind` other than `"column"`.

Carried in `ViewDisplay.sort`.

**Parameters**

- **data** (`Any`)

**Attributes**

- **ColumnSort.by** (`str`): Field to sort by, such as `"created"`.
- **ColumnSort.direction** (`roboto.query.SortDirection`): Direction to sort in, [`Ascending`](/docs/reference/python-sdk/roboto/query/specification#roboto.query.specification.SortDirection.Ascending) by default.
- **ColumnSort.kind** (`Literal['column']`) = `'column'`: Kind of sort, always `"column"`.

### DefaultSort

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

`from roboto.domain.views import DefaultSort`

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

Bases: `pydantic.BaseModel`

Sort that shows a View's results in the order its target's list shows when no sort is chosen.

Constructing one raises `pydantic.ValidationError` for a `kind` other than `"default"`.

Carried in `ViewDisplay.sort`.

**Parameters**

- **data** (`Any`)

**Attributes**

- **DefaultSort.kind** (`Literal['default']`) = `'default'`: Kind of sort, always `"default"`.

### NoSort

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

`from roboto.domain.views import NoSort`

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

Bases: `pydantic.BaseModel`

Sort that shows a View's results in no particular order.

A View saved from a table whose sort was cleared stores this, so the table reopens unsorted; `DefaultSort` would reopen it in the target's default order.

Constructing one raises `pydantic.ValidationError` for a `kind` other than `"unsorted"`.

Carried in `ViewDisplay.sort`.

**Parameters**

- **data** (`Any`)

**Attributes**

- **NoSort.kind** (`Literal['unsorted']`) = `'unsorted'`: Kind of sort, always `"unsorted"`.

### 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#L233-L235)

Targets whose Views can be written in RoboQL: datasets, files, and events.

The list pages for the other targets, such as sessions, devices, and collections, have filter controls only, so Roboto rejects a RoboQL View on them.

### 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#L35-L35)

Value of `ViewRecord.schema_version` for a `"view_v1"` definition.

No SDK method reads it.

### VIEW_SCHEMA_VERSION_V2

```python
roboto.domain.views.record.VIEW_SCHEMA_VERSION_V2: Final[int] = 2
```

`from roboto.domain.views import VIEW_SCHEMA_VERSION_V2`

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

Value of `ViewRecord.schema_version` for a `"view_v2"` definition.

No SDK method reads it.

### 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#L20-L20)

Value of `ViewDefinition.scheme` for the first shape of a View's definition.

That shape states the display's sort in three fields, `sort_by`, `sort_direction` and `unsorted`. `ViewDefinition` reads a definition in it as `VIEW_SCHEME_V2`, so no definition the SDK builds carries this value.

### VIEW_SCHEME_V2

```python
roboto.domain.views.record.VIEW_SCHEME_V2: Final = 'view_v2'
```

`from roboto.domain.views import VIEW_SCHEME_V2`

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

Value of `ViewDefinition.scheme` for the current shape of a View's definition.

That shape states the display's sort in one field, `ViewDisplay.sort`.

### 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#L169-L228)

Bases: `pydantic.BaseModel`

Saved contents of a View: the search its author made, and how its results are shown.

A definition records what the author entered, RoboQL text or filter controls, and the client builds a query from it each time the View loads. It does not store a [`QuerySpecification`](/docs/reference/python-sdk/roboto/query/specification#roboto.query.specification.QuerySpecification), because a query specification cannot express a relative date such as "the last 7 days": converting the filter fixes its dates, and the View would show the week it was saved in from then on.

Filter controls are recorded as [`SavedFilters`](/docs/reference/python-sdk/roboto/query/filters#roboto.query.filters.SavedFilters), so any caller can build a View's filters. The Roboto web app converts them to a query when the View loads; RoboQL text runs as written.

At most one of `roboql` and `filters` is set, and a definition with neither filters nothing. Constructing a definition raises `pydantic.ValidationError` when it sets both, or when its `scheme` is neither `"view_v1"` nor `"view_v2"`. The View's target is not part of its definition; `ViewRecord.target` holds it.

Carried in `ViewRecord.definition`, [`definition`](/docs/reference/python-sdk/roboto/domain/views/operations#roboto.domain.views.operations.CreateViewRequest.definition) and [`definition`](/docs/reference/python-sdk/roboto/domain/views/operations#roboto.domain.views.operations.UpdateViewRequest.definition).

**Parameters**

- **data** (`Any`)

**Attributes**

- **ViewDefinition.display** (`ViewDisplay`) = `None`: Columns, sort, and page size to restore when the View loads.

- **ViewDefinition.filters** (`roboto.query.SavedFilters | None`) = `None`: Filter controls the author set, or `None` when the View uses RoboQL or filters nothing.

  A View with neither `roboql` nor `filters` saves a column layout and sort over the unfiltered list, so `None` here does not mean the View uses RoboQL.

- **ViewDefinition.roboql** (`str | None`) = `None`: RoboQL text the author wrote, or `None` when the View uses filter controls or filters nothing.

  RoboQL has no relative-date syntax, so the text means the same thing whenever it runs. Only Views on the targets in `ROBOQL_VIEW_TARGETS` can use RoboQL.

- **ViewDefinition.scheme** (`Literal['view_v2']`) = `'view_v2'`: Version of the definition's shape, always `"view_v2"`.

  A definition saved as `"view_v1"` is read as this shape, since the two differ only in how the display states its sort. A definition saved in a later shape fails validation instead of being read 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#L115-L166)

Bases: `pydantic.BaseModel`

How a View shows its results: which columns, in what order, sorted how, and how many rows per page.

None of these settings changes which records match. Constructing a display raises `pydantic.ValidationError` for a `page_size` below 1.

A display may also state its sort as a `"view_v1"` definition does, in `sort_by`, `sort_direction` and `unsorted`, and is read into `sort`: `unsorted` set to `True` gives `NoSort`, otherwise `sort_by` gives `ColumnSort`, ascending unless `sort_direction` says otherwise, and neither gives `DefaultSort`. A `sort` given beside those fields wins.

Carried in `ViewDefinition.display`.

**Parameters**

- **data** (`Any`)

**Attributes**

- **ViewDisplay.page_size** (`int | None`) = `None`: Rows per page, greater than zero, or `None` to leave the page size to the client.

- **ViewDisplay.sort** (`ViewSort`) = `None`: Order to show results in, `DefaultSort` unless set.

- **ViewDisplay.visible_columns** (`list[str]`) = `None`: Columns to show, in display order.

  A column not in the list is hidden. An empty list leaves the choice of columns to the client's defaults.

### 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#L265-L323)

Bases: `pydantic.BaseModel`

Data record of a View, as `GET /v1/views/id/{view_id}` returns it.

`POST /v1/views/create`, `PUT /v1/views/id/{view_id}`, `POST /v1/views/id/{view_id}/duplicate` and `GET /v1/views/` return it too.

A View is a named, shareable search over one resource type, saved with the columns, sort, and page size its author chose, so the author or a teammate can return to it without rebuilding it. The record carries one part of who can access the View, its `visibility`, so a client can tell a caller's own Views from those shared with the organization without a request per View. Individual grants are listed by `GET /v1/views/id/{view_id}/access`.

**Parameters**

- **data** (`Any`)

**Attributes**

- **ViewRecord.created** (`datetime.datetime`): Time the View was created.

- **ViewRecord.created_by** (`str`): ID of the user who created the View, its author.

  Only the author and owners of the View's organization can delete it or change who can see it.

- **ViewRecord.definition** (`ViewDefinition`): Saved search and presentation settings.

- **ViewRecord.modified** (`datetime.datetime`): Time the View's name or definition was last modified.

- **ViewRecord.modified_by** (`str`): ID of the user who last modified the View's name or definition.

- **ViewRecord.name** (`str`): Human-readable name of the View. Names are not unique.

- **ViewRecord.org_id** (`str`): ID of the organization that owns the View.

- **ViewRecord.schema_version** (`int`): Version of the shape `definition` was saved in.

  One of `VIEW_SCHEMA_VERSION_V1` and `VIEW_SCHEMA_VERSION_V2`. `definition` is always read in the current shape, so a View saved as `"view_v1"` reports `1` here beside a `"view_v2"` definition. Updating the View's definition saves it in the current shape and sets this to `2`.

- **ViewRecord.target** (`roboto.query.QueryTarget`): Resource type the View searches, such as datasets or files.

  Fixed when the View is created, because the View's filters are written against that target's fields.

- **ViewRecord.view_id** (`str`): Unique ID of the View, beginning with `vw_`. Shareable URLs address a View by this ID.

- **ViewRecord.visibility** (`ViewVisibility | None`) = `None`: Who can see the View, or `None` when it was not looked up.

  Roboto sets it on the View it returns from fetching, listing, creating, or duplicating Views, but not from an update. `None` does not mean `ViewVisibility.Private`.

### ViewSort

```python
roboto.domain.views.record.ViewSort
```

`from roboto.domain.views import ViewSort`

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

Sort of any kind: one of the sort models, told apart by `kind`.

The models are `DefaultSort`, `NoSort` and `ColumnSort`.

### 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#L48-L60)

Bases: `roboto.compat.StrEnum`

Visibility of a View: who can see it, chosen when the View is created and reported when it is read.

Visibility decides only who can read a View. Whatever its visibility, a View can be edited only by its author, users and groups granted `editor` on it, and admins and owners of its organization.

**Attributes**

- **ViewVisibility.Organization** = `'organization'`: Visible to every member of the organization that owns the View.
- **ViewVisibility.Private** = `'private'`: Visible to the View's author, users and groups granted access to it, and admins and owners of its organization.

### 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#L243-L262)

Reject a definition written in RoboQL for a target whose list page has no RoboQL mode.

Roboto calls this when a View is created and when its definition is updated, so calling it first only reports the rejection sooner. A definition that uses filter controls, or filters nothing, passes for every target.

**Parameters**

- **target** (`roboto.query.QueryTarget`): Resource type the View searches.
- **definition** (`ViewDefinition`): Definition the View would store.

**Raises**

- [`RobotoInvalidRequestException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoInvalidRequestException): `definition` sets `roboql` and `target` is not in `ROBOQL_VIEW_TARGETS`.

**Returns**

- `None`
