Skip to content

prefect.server.api.task_workers

read_task_workers(task_worker_filter=Body(default=None, description='The task worker filter', embed=True)) async

Read active task workers. Optionally filter by task keys.

Source code in src/prefect/server/api/task_workers.py
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
@router.post("/filter")
async def read_task_workers(
    task_worker_filter: Optional[TaskWorkerFilter] = Body(
        default=None, description="The task worker filter", embed=True
    ),
) -> List[TaskWorkerResponse]:
    """Read active task workers. Optionally filter by task keys."""

    if task_worker_filter and task_worker_filter.task_keys:
        return await models.task_workers.get_workers_for_task_keys(
            task_keys=task_worker_filter.task_keys,
        )

    else:
        return await models.task_workers.get_all_workers()