Skip to content

prefect.server.api.admin

Routes for admin-level interactions with the Prefect REST API.

clear_database async

Clear all database tables without dropping them.

Source code in /home/runner/work/docs/docs/prefect_source/src/prefect/server/api/admin.py
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
@router.post("/database/clear", status_code=status.HTTP_204_NO_CONTENT)
async def clear_database(
    db: PrefectDBInterface = Depends(provide_database_interface),
    confirm: bool = Body(
        False,
        embed=True,
        description="Pass confirm=True to confirm you want to modify the database.",
    ),
    response: Response = None,
):
    """Clear all database tables without dropping them."""
    if not confirm:
        response.status_code = status.HTTP_400_BAD_REQUEST
        return
    async with db.session_context(begin_transaction=True) as session:
        # work pool has a circular dependency on pool queue; delete it first
        await session.execute(db.WorkPool.__table__.delete())
        for table in reversed(db.Base.metadata.sorted_tables):
            await session.execute(table.delete())

create_database async

Create all database objects.

Source code in /home/runner/work/docs/docs/prefect_source/src/prefect/server/api/admin.py
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
@router.post("/database/create", status_code=status.HTTP_204_NO_CONTENT)
async def create_database(
    db: PrefectDBInterface = Depends(provide_database_interface),
    confirm: bool = Body(
        False,
        embed=True,
        description="Pass confirm=True to confirm you want to modify the database.",
    ),
    response: Response = None,
):
    """Create all database objects."""
    if not confirm:
        response.status_code = status.HTTP_400_BAD_REQUEST
        return

    await db.create_db()

drop_database async

Drop all database objects.

Source code in /home/runner/work/docs/docs/prefect_source/src/prefect/server/api/admin.py
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
@router.post("/database/drop", status_code=status.HTTP_204_NO_CONTENT)
async def drop_database(
    db: PrefectDBInterface = Depends(provide_database_interface),
    confirm: bool = Body(
        False,
        embed=True,
        description="Pass confirm=True to confirm you want to modify the database.",
    ),
    response: Response = None,
):
    """Drop all database objects."""
    if not confirm:
        response.status_code = status.HTTP_400_BAD_REQUEST
        return

    await db.drop_db()

read_settings async

Get the current Prefect REST API settings.

Secret setting values will be obfuscated.

Source code in /home/runner/work/docs/docs/prefect_source/src/prefect/server/api/admin.py
15
16
17
18
19
20
21
22
@router.get("/settings")
async def read_settings() -> prefect.settings.Settings:
    """
    Get the current Prefect REST API settings.

    Secret setting values will be obfuscated.
    """
    return prefect.settings.get_current_settings().with_obfuscated_secrets()

read_version async

Returns the Prefect version number

Source code in /home/runner/work/docs/docs/prefect_source/src/prefect/server/api/admin.py
25
26
27
28
@router.get("/version")
async def read_version() -> str:
    """Returns the Prefect version number"""
    return prefect.__version__