---
sidebar:
  hidden: true
title: roboto.domain.triggers.samples
---
## Module Contents

- [SAMPLE_TIME](/docs/reference/python-sdk/roboto/domain/platform_events/samples#roboto.domain.platform_events.samples.SAMPLE_TIME) (data): Time every sample event and sample record is dated from, fixed so that samples are the same on every call.

- [sample_platform_event()](/docs/reference/python-sdk/roboto/domain/platform_events/samples#roboto.domain.platform_events.samples.sample_platform_event) (function): Build a sample platform event of `event_type`, with every optional payload field set.

### PlatformEventSample

```python
class roboto.domain.triggers.samples.PlatformEventSample(/, **data: Any)
```

`from roboto.domain.triggers import PlatformEventSample`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/triggers/samples.py#L317-L347)

Bases: `pydantic.BaseModel`

Sample of one platform event type: the event, every root it exposes, and the paths that resolve against them.

Use a sample to see what a trigger's condition fields and target template placeholders, such as `{{dataset.name}}`, resolve to before writing them. A sample is built with the same [`EventNamespace`](/docs/reference/python-sdk/roboto/domain/triggers/namespace#roboto.domain.triggers.namespace.EventNamespace) and record models that serve a real firing, so its roots have the shape a trigger sees. Every sample describes one scenario: one organization, robot, dataset, file, session, and action invocation. The values are made up and name nothing that exists in Roboto. Carried in `PlatformEventSamplesResponse.samples`.

**Parameters**

- **data** (`Any`)

**Attributes**

- **PlatformEventSample.event** (`dict[str, Any]`): [`PlatformEvent`](/docs/reference/python-sdk/roboto/domain/platform_events/events#roboto.domain.platform_events.events.PlatformEvent) as a JSON-compatible dictionary.

  It is the sample platform event, with its payload under `data`.

- **PlatformEventSample.event_type** (`roboto.domain.platform_events.PlatformEventType`): Platform event type the sample shows.

- **PlatformEventSample.namespace** (`dict[str, dict[str, Any]]`): Record of every root a condition or template may read for this event type, keyed by root name.

  Begins with `envelope` and `trigger`, then the roots the catalog exposes for the event type, sorted by name.

- **PlatformEventSample.paths** (`list[str]`): Every `root.path` a condition field or `{{ }}` placeholder may name.

  The paths follow the order of the roots and their fields in `namespace`.

### PlatformEventSamplesResponse

```python
class roboto.domain.triggers.samples.PlatformEventSamplesResponse(/, **data: Any)
```

`from roboto.domain.triggers import PlatformEventSamplesResponse`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/triggers/samples.py#L350-L366)

Bases: `pydantic.BaseModel`

Response body of [`platform_event_samples()`](/docs/reference/python-sdk/roboto/domain/triggers/trigger#roboto.domain.triggers.trigger.Trigger.platform_event_samples).

**Parameters**

- **data** (`Any`)

**Attributes**

- **PlatformEventSamplesResponse.samples** (`dict[roboto.domain.platform_events.PlatformEventType, PlatformEventSample]`): One sample per platform event type, keyed by type.

  A sample whose type this SDK's [`PlatformEventType`](/docs/reference/python-sdk/roboto/domain/platform_events/events#roboto.domain.platform_events.events.PlatformEventType) does not name is left out, so the response still parses when Roboto offers an event type newer than this SDK.

### SampleNamespaceSource

```python
class roboto.domain.triggers.samples.SampleNamespaceSource
```

`from roboto.domain.triggers import SampleNamespaceSource`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/triggers/samples.py#L266-L295)

Namespace source that loads every entity root, such as `dataset` and `file`, from the sample records.

Each root has the shape it has when a trigger fires: `action` is the sample invocation's action provenance, and `upload` holds only the upload's `transaction_id`. Pass it to [`EventNamespace`](/docs/reference/python-sdk/roboto/domain/triggers/namespace#roboto.domain.triggers.namespace.EventNamespace) with a sample platform event to evaluate a condition or template against the sample scenario.

#### SampleNamespaceSource.record_for_root()

```python
def record_for_root(
    root: str,
    event: roboto.domain.platform_events.PlatformEvent,
) -> Optional[collections.abc.Mapping[str, Any]]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/triggers/samples.py#L274-L295)

**Parameters**

- **root** (`str`)
- **event** (`roboto.domain.platform_events.PlatformEvent`)

**Returns**

- `Optional[collections.abc.Mapping[str, Any]]`

### platform_event_sample()

```python
def roboto.domain.triggers.samples.platform_event_sample(
    event_type: roboto.domain.platform_events.PlatformEventType,
    catalog: roboto.domain.platform_events.PlatformEventCatalog = DEFAULT_PLATFORM_EVENT_CATALOG,
) -> PlatformEventSample
```

`from roboto.domain.triggers import platform_event_sample`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/triggers/samples.py#L369-L405)

Build the sample of one platform event type.

The `envelope`, `trigger`, `changed`, `tag` and `schedule` roots come from the same [`EventNamespace`](/docs/reference/python-sdk/roboto/domain/triggers/namespace#roboto.domain.triggers.namespace.EventNamespace) that serves them when a trigger fires. The entity roots, such as `dataset` and `file`, come from `SampleNamespaceSource`.

**Parameters**

- **event_type** (`roboto.domain.platform_events.PlatformEventType`): Platform event type to return the sample of.
- **catalog** (`roboto.domain.platform_events.PlatformEventCatalog`): Catalog that says which roots `event_type` exposes. Defaults to [`DEFAULT_PLATFORM_EVENT_CATALOG`](/docs/reference/python-sdk/roboto/domain/platform_events/catalog#roboto.domain.platform_events.catalog.DEFAULT_PLATFORM_EVENT_CATALOG).

**Raises**

- `ValueError`: This version of the SDK has no sample payload for `event_type`, `catalog` has no descriptor for it, or `catalog` exposes a root the sample scenario cannot fill.

**Returns**

- `PlatformEventSample`

### platform_event_samples()

```python
def roboto.domain.triggers.samples.platform_event_samples(
    catalog: roboto.domain.platform_events.PlatformEventCatalog = DEFAULT_PLATFORM_EVENT_CATALOG,
) -> dict[roboto.domain.platform_events.PlatformEventType, PlatformEventSample]
```

`from roboto.domain.triggers import platform_event_samples`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/triggers/samples.py#L408-L421)

Build the sample of every platform event type in `catalog`, keyed by event type, in catalog order.

**Parameters**

- **catalog** (`roboto.domain.platform_events.PlatformEventCatalog`): Catalog of the event types to return samples of, and of the roots each exposes. Defaults to [`DEFAULT_PLATFORM_EVENT_CATALOG`](/docs/reference/python-sdk/roboto/domain/platform_events/catalog#roboto.domain.platform_events.catalog.DEFAULT_PLATFORM_EVENT_CATALOG).

**Raises**

- `ValueError`: This version of the SDK has no sample payload for one of the event types, or `catalog` exposes a root the sample scenario cannot fill.

**Returns**

- `dict[roboto.domain.platform_events.PlatformEventType, PlatformEventSample]`

### sample_trigger()

```python
def roboto.domain.triggers.samples.sample_trigger() -> roboto.domain.triggers.record.TriggerRecord
```

`from roboto.domain.triggers import sample_trigger`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/triggers/samples.py#L223-L247)

Build the sample trigger, which the `trigger` root shows in every sample but one.

It subscribes to [`FileUploaded`](/docs/reference/python-sdk/roboto/domain/platform_events/events#roboto.domain.platform_events.events.PlatformEventType.FileUploaded) once per file and invokes the sample action on the file's `.mcap` files. The [`ScheduleFired`](/docs/reference/python-sdk/roboto/domain/platform_events/events#roboto.domain.platform_events.events.PlatformEventType.ScheduleFired) sample shows `sample_schedule_trigger` instead.

**Returns**

- `roboto.domain.triggers.record.TriggerRecord`

### template_paths()

```python
def roboto.domain.triggers.samples.template_paths(
    record: collections.abc.Mapping[str, Any],
    prefix: str,
) -> list[str]
```

`from roboto.domain.triggers import template_paths`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/triggers/samples.py#L298-L314)

Return every dotted path a condition field or `{{ }}` placeholder may name in `record`, in key order.

Descends into nested mappings only. A list is a leaf, because a path resolves through mappings and stops at anything else: `dataset.tags` resolves, `dataset.tags.0` does not.

**Parameters**

- **record** (`collections.abc.Mapping[str, Any]`): Record of one namespace root, such as a dataset's.
- **prefix** (`str`): Path of `record` itself, such as `"dataset"`. Every returned path begins with it and a dot.

**Returns**

- `list[str]`
