api/flake/list_history: init

Add an api endpoint to list the history of clan flakes that have been interacted with

Also add `clan flake list`
This commit is contained in:
DavHau
2023-11-17 17:56:07 +07:00
parent 441a15bab8
commit 2306417145
5 changed files with 85 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ from typing import Annotated
from fastapi import APIRouter, Body, HTTPException, status
from pydantic import AnyUrl
from clan_cli import flakes
from clan_cli.webui.api_inputs import (
FlakeCreateInput,
)
@@ -50,6 +51,11 @@ async def add_flake(flake_dir: Path) -> None:
await add.add_flake(flake_dir)
@router.get("/api/flake/list_history", tags=[Tags.flake])
async def list_flakes() -> list[Path]:
return flakes.list_history.list_history()
# TODO: Check for directory traversal
@router.get("/api/flake/attrs", tags=[Tags.flake])
async def inspect_flake_attrs(url: AnyUrl | Path) -> FlakeAttrResponse: