Back to Prefect

flows

docs/v3/api-ref/python/prefect-server-api-flows.mdx

3.6.30.dev35.0 KB
Original Source

prefect.server.api.flows

Routes for interacting with flow objects.

Functions

create_flow <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/flows.py#L26" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

python
create_flow(flow: schemas.actions.FlowCreate, response: Response, db: PrefectDBInterface = Depends(provide_database_interface)) -> schemas.core.Flow

Creates a new flow from the provided schema. If a flow with the same name already exists, the existing flow is returned.

For more information, see https://docs.prefect.io/v3/concepts/flows.

update_flow <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/flows.py#L50" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

python
update_flow(flow: schemas.actions.FlowUpdate, flow_id: UUID = Path(..., description='The flow id', alias='id'), db: PrefectDBInterface = Depends(provide_database_interface)) -> None

Updates a flow.

count_flows <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/flows.py#L69" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

python
count_flows(flows: schemas.filters.FlowFilter = None, flow_runs: schemas.filters.FlowRunFilter = None, task_runs: schemas.filters.TaskRunFilter = None, deployments: schemas.filters.DeploymentFilter = None, work_pools: schemas.filters.WorkPoolFilter = None, db: PrefectDBInterface = Depends(provide_database_interface)) -> int

Count flows.

read_flow_by_name <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/flows.py#L92" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

python
read_flow_by_name(name: str = Path(..., description='The name of the flow'), db: PrefectDBInterface = Depends(provide_database_interface)) -> schemas.core.Flow

Get a flow by name.

read_flow <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/flows.py#L109" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

python
read_flow(flow_id: UUID = Path(..., description='The flow id', alias='id'), db: PrefectDBInterface = Depends(provide_database_interface)) -> schemas.core.Flow

Get a flow by id.

read_flows <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/flows.py#L126" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

python
read_flows(limit: int = dependencies.LimitBody(), offset: int = Body(0, ge=0), flows: schemas.filters.FlowFilter = None, flow_runs: schemas.filters.FlowRunFilter = None, task_runs: schemas.filters.TaskRunFilter = None, deployments: schemas.filters.DeploymentFilter = None, work_pools: schemas.filters.WorkPoolFilter = None, sort: schemas.sorting.FlowSort = Body(schemas.sorting.FlowSort.NAME_ASC), db: PrefectDBInterface = Depends(provide_database_interface)) -> List[schemas.core.Flow]

Query for flows.

delete_flow <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/flows.py#L155" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

python
delete_flow(flow_id: UUID = Path(..., description='The flow id', alias='id'), db: PrefectDBInterface = Depends(provide_database_interface)) -> None

Delete a flow by id.

bulk_delete_flows <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/flows.py#L174" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

python
bulk_delete_flows(flows: Optional[schemas.filters.FlowFilter] = Body(None, description='Filter criteria for flows to delete'), limit: int = Body(BULK_OPERATION_LIMIT, ge=1, le=BULK_OPERATION_LIMIT, description=f'Maximum number of flows to delete. Defaults to {BULK_OPERATION_LIMIT}.'), db: PrefectDBInterface = Depends(provide_database_interface)) -> FlowBulkDeleteResponse

Bulk delete flows matching the specified filter criteria.

This also deletes all associated deployments.

Returns the IDs of flows that were deleted.

paginate_flows <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/flows.py#L216" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

python
paginate_flows(limit: int = dependencies.LimitBody(), page: int = Body(1, ge=1), flows: Optional[schemas.filters.FlowFilter] = None, flow_runs: Optional[schemas.filters.FlowRunFilter] = None, task_runs: Optional[schemas.filters.TaskRunFilter] = None, deployments: Optional[schemas.filters.DeploymentFilter] = None, work_pools: Optional[schemas.filters.WorkPoolFilter] = None, sort: schemas.sorting.FlowSort = Body(schemas.sorting.FlowSort.NAME_ASC), db: PrefectDBInterface = Depends(provide_database_interface)) -> FlowPaginationResponse

Pagination query for flows.