Improve the admin API
This commit is contained in:
@ -49,6 +49,7 @@ def create_router(dependencies: AdminDependencies) -> APIRouter:
|
||||
value=secret.get_secret(),
|
||||
clients=secret.clients,
|
||||
group=secret.group,
|
||||
distinguisher=secret.client_distinguisher,
|
||||
)
|
||||
|
||||
@app.get("/secrets/{name}")
|
||||
@ -86,9 +87,10 @@ def create_router(dependencies: AdminDependencies) -> APIRouter:
|
||||
async def get_secret_groups(
|
||||
admin: Annotated[AdminBackend, Depends(dependencies.get_admin_backend)],
|
||||
filter_regex: Annotated[str | None, Query()] = None,
|
||||
flat: bool = False,
|
||||
) -> ClientSecretGroupList:
|
||||
"""Get secret groups."""
|
||||
result = await admin.get_secret_groups(filter_regex)
|
||||
result = await admin.get_secret_groups(filter_regex, flat=flat)
|
||||
return result
|
||||
|
||||
@app.get("/secrets/groups/{group_path:path}/")
|
||||
@ -152,6 +154,19 @@ def create_router(dependencies: AdminDependencies) -> APIRouter:
|
||||
)
|
||||
return result
|
||||
|
||||
@app.delete("/secrets/group/{id}")
|
||||
async def delete_group_id(
|
||||
id: str,
|
||||
admin: Annotated[AdminBackend, Depends(dependencies.get_admin_backend)],
|
||||
) -> None:
|
||||
"""Remove a group by ID."""
|
||||
try:
|
||||
await admin.delete_secret_group_by_id(id)
|
||||
except InvalidGroupNameError:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND, detail="Group ID not found"
|
||||
)
|
||||
|
||||
@app.delete("/secrets/groups/{group_path:path}/")
|
||||
async def delete_secret_group(
|
||||
group_path: str,
|
||||
|
||||
Reference in New Issue
Block a user