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

# automations

# `prefect.automations`

## Classes

### `Automation` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L80](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L80)</sup>

**Methods:**

#### `acreate` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L83](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L83)</sup>

```python theme={null}
acreate(self: Self) -> Self
```

Asynchronously create a new automation.

Examples:

```python theme={null}
auto_to_create = Automation(
    name="woodchonk",
    trigger=EventTrigger(
        expect={"animal.walked"},
        match={
            "genus": "Marmota",
            "species": "monax",
        },
        posture="Reactive",
        threshold=3,
        within=timedelta(seconds=10),
    ),
    actions=[CancelFlowRun()]
)
created_automation = await auto_to_create.acreate()
```

#### `adelete` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L275](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L275)</sup>

```python theme={null}
adelete(self: Self) -> bool
```

Asynchronously delete an automation.

Examples:

```python theme={null}
auto = Automation.read(id = 123)
await auto.adelete()
```

#### `adisable` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L322](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L322)</sup>

```python theme={null}
adisable(self: Self) -> bool
```

Asynchronously disable an automation.

**Raises:**

* `ValueError`: If the automation does not have an id
* `PrefectHTTPStatusError`: If the automation cannot be disabled

Example:

```python theme={null}
auto = await Automation.aread(id = 123)
await auto.adisable()
```

#### `aenable` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L376](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L376)</sup>

```python theme={null}
aenable(self: Self) -> bool
```

Asynchronously enable an automation.

**Raises:**

* `ValueError`: If the automation does not have an id
* `PrefectHTTPStatusError`: If the automation cannot be enabled

Example:

```python theme={null}
auto = await Automation.aread(id = 123)
await auto.aenable()
```

#### `aread` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L184](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L184)</sup>

```python theme={null}
aread(cls, id: UUID, name: Optional[str] = ...) -> Self
```

#### `aread` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L188](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L188)</sup>

```python theme={null}
aread(cls, id: None = None, name: str = ...) -> Self
```

#### `aread` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L191](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L191)</sup>

```python theme={null}
aread(cls, id: Optional[UUID] = None, name: Optional[str] = None) -> Self
```

Asynchronously read an automation by ID or name.

Examples:

```python theme={null}
automation = await Automation.aread(name="woodchonk")
```

```python theme={null}
automation = await Automation.aread(id=UUID("b3514963-02b1-47a5-93d1-6eeb131041cb"))
```

#### `aupdate` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L142](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L142)</sup>

```python theme={null}
aupdate(self: Self) -> None
```

Updates an existing automation.

Examples:

```python theme={null}
auto = Automation.read(id=123)
auto.name = "new name"
auto.update()
```

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

```python theme={null}
create(self: Self) -> Self
```

Create a new automation.

Examples:

```python theme={null}
auto_to_create = Automation(
    name="woodchonk",
    trigger=EventTrigger(
        expect={"animal.walked"},
        match={
            "genus": "Marmota",
            "species": "monax",
        },
        posture="Reactive",
        threshold=3,
        within=timedelta(seconds=10),
    ),
    actions=[CancelFlowRun()]
)
created_automation = auto_to_create.create()
```

#### `delete` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L299](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L299)</sup>

```python theme={null}
delete(self: Self) -> bool
```

Delete an automation.

Examples:

```python theme={null}
auto = Automation.read(id = 123)
auto.delete()
```

#### `disable` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L349](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L349)</sup>

```python theme={null}
disable(self: Self) -> bool
```

Disable an automation.

**Raises:**

* `ValueError`: If the automation does not have an id
* `PrefectHTTPStatusError`: If the automation cannot be disabled

Example:

```python theme={null}
auto = Automation.read(id = 123)
auto.disable()
```

#### `enable` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L403](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L403)</sup>

```python theme={null}
enable(self: Self) -> bool
```

Enable an automation.

**Raises:**

* `ValueError`: If the automation does not have an id
* `PrefectHTTPStatusError`: If the automation cannot be enabled

Example:

```python theme={null}
auto = Automation.read(id = 123)
auto.enable()
```

#### `read` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L230](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L230)</sup>

```python theme={null}
read(cls, id: UUID, name: Optional[str] = ...) -> Self
```

#### `read` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L234](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L234)</sup>

```python theme={null}
read(cls, id: None = None, name: str = ...) -> Self
```

#### `read` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L238](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L238)</sup>

```python theme={null}
read(cls, id: Optional[UUID] = None, name: Optional[str] = None) -> Self
```

Read an automation by ID or name.

Examples:

```python theme={null}
automation = Automation.read(name="woodchonk")
```

```python theme={null}
automation = Automation.read(id=UUID("b3514963-02b1-47a5-93d1-6eeb131041cb"))
```

#### `update` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L162](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/automations.py#L162)</sup>

```python theme={null}
update(self: Self)
```

Updates an existing automation.

Examples:

```python theme={null}
auto = Automation.read(id=123)
auto.name = "new name"
auto.update()
```
