prefect.automations

Classes

Automation

Methods:

create

create(self: Self) -> Self

Create a new automation.

Examples:

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()

update

update(self: Self)

Updates an existing automation.

Examples:

auto = Automation.read(id=123)
auto.name = "new name"
auto.update()

read

read(cls, id: Optional[UUID] = None, name: Optional[str] = None) -> Self

Read an automation by ID or name.

Examples:

automation = Automation.read(name="woodchonk")
automation = Automation.read(id=UUID("b3514963-02b1-47a5-93d1-6eeb131041cb"))

delete

delete(self: Self) -> bool

Delete an automation.

Examples:

auto = Automation.read(id = 123)
auto.delete()

disable

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:

auto = Automation.read(id = 123)
auto.disable()

enable

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:

auto = Automation.read(id = 123)
auto.enable()