> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# automations

# `prefect.server.events.models.automations`

## Functions

### `emit_automation_created_event` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L29](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L29)</sup>

```python theme={null}
emit_automation_created_event(automation: Automation) -> None
```

Emit an event when an automation is created.

### `emit_automation_updated_event` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L37](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L37)</sup>

```python theme={null}
emit_automation_updated_event(automation: Automation) -> None
```

Emit an event when an automation is updated.

### `emit_automation_deleted_event` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L45](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L45)</sup>

```python theme={null}
emit_automation_deleted_event(automation: Automation) -> None
```

Emit an event when an automation is deleted.

### `automations_session` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L61](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L61)</sup>

```python theme={null}
automations_session(db: PrefectDBInterface, begin_transaction: bool = False) -> AsyncGenerator[AsyncSession, None]
```

### `read_automations_for_workspace` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L69](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L69)</sup>

```python theme={null}
read_automations_for_workspace(db: PrefectDBInterface, session: AsyncSession, sort: AutomationSort = AutomationSort.NAME_ASC, limit: Optional[int] = None, offset: Optional[int] = None, automation_filter: Optional[filters.AutomationFilter] = None) -> Sequence[Automation]
```

### `count_automations_for_workspace` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L97](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L97)</sup>

```python theme={null}
count_automations_for_workspace(db: PrefectDBInterface, session: AsyncSession, automation_filter: Optional[filters.AutomationFilter] = None) -> int
```

### `read_automation` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L113](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L113)</sup>

```python theme={null}
read_automation(db: PrefectDBInterface, session: AsyncSession, automation_id: UUID) -> Optional[Automation]
```

### `read_automation_by_id` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L127](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L127)</sup>

```python theme={null}
read_automation_by_id(db: PrefectDBInterface, session: AsyncSession, automation_id: UUID) -> Optional[Automation]
```

### `create_automation` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L213](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L213)</sup>

```python theme={null}
create_automation(db: PrefectDBInterface, session: AsyncSession, automation: Automation) -> Automation
```

### `update_automation` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L229](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L229)</sup>

```python theme={null}
update_automation(db: PrefectDBInterface, session: AsyncSession, automation_update: Union[AutomationUpdate, AutomationPartialUpdate], automation_id: UUID) -> bool
```

### `delete_automation` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L278](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L278)</sup>

```python theme={null}
delete_automation(db: PrefectDBInterface, session: AsyncSession, automation_id: UUID) -> bool
```

### `delete_automations_for_workspace` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L319](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L319)</sup>

```python theme={null}
delete_automations_for_workspace(db: PrefectDBInterface, session: AsyncSession) -> bool
```

### `disable_automations_for_workspace` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L341](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L341)</sup>

```python theme={null}
disable_automations_for_workspace(db: PrefectDBInterface, session: AsyncSession) -> bool
```

### `disable_automation` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L353](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L353)</sup>

```python theme={null}
disable_automation(db: PrefectDBInterface, session: AsyncSession, automation_id: UUID) -> bool
```

### `relate_automation_to_resource` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L406](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L406)</sup>

```python theme={null}
relate_automation_to_resource(db: PrefectDBInterface, session: AsyncSession, automation_id: UUID, resource_id: str, owned_by_resource: bool) -> None
```

### `read_automations_related_to_resource` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L437](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L437)</sup>

```python theme={null}
read_automations_related_to_resource(db: PrefectDBInterface, session: AsyncSession, resource_id: str, owned_by_resource: Optional[bool] = None, automation_filter: Optional[filters.AutomationFilter] = None) -> Sequence[Automation]
```

### `delete_automations_owned_by_resource` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L468](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/models/automations.py#L468)</sup>

```python theme={null}
delete_automations_owned_by_resource(db: PrefectDBInterface, session: AsyncSession, resource_id: str, automation_filter: Optional[filters.AutomationFilter] = None) -> Sequence[UUID]
```
