prefect.automations

Classes

Automation

Methods:

acreate

acreate(self: Self) -> Self
Asynchronously 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 = await auto_to_create.acreate()

adelete

adelete(self: Self) -> bool
Asynchronously delete an automation. Examples:
auto = Automation.read(id = 123)
await auto.adelete()

adisable

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:
auto = await Automation.aread(id = 123)
await auto.adisable()

aenable

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:
auto = await Automation.aread(id = 123)
await auto.aenable()

aread

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

aread

aread(cls, id: None = None, name: str = ...) -> Self

aread

aread(cls, id: Optional[UUID] = None, name: Optional[str] = None) -> Self
Asynchronously read an automation by ID or name. Examples:
automation = await Automation.aread(name="woodchonk")
automation = await Automation.aread(id=UUID("b3514963-02b1-47a5-93d1-6eeb131041cb"))

aupdate

aupdate(self: Self) -> None
Updates an existing automation. Examples:
auto = Automation.read(id=123)
auto.name = "new name"
auto.update()

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

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

read

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

read

read(cls, id: None = None, name: str = ...) -> Self

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

update

update(self: Self)
Updates an existing automation. Examples:
auto = Automation.read(id=123)
auto.name = "new name"
auto.update()