add stub api for machines
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
|
|
||||||
from .routers import health, root
|
from .routers import health, machines, root
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
app.include_router(health.router)
|
app.include_router(health.router)
|
||||||
|
app.include_router(machines.router)
|
||||||
app.include_router(root.router)
|
app.include_router(root.router)
|
||||||
|
|||||||
65
pkgs/clan-cli/clan_cli/webui/routers/machines.py
Normal file
65
pkgs/clan-cli/clan_cli/webui/routers/machines.py
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
from enum import Enum
|
||||||
|
|
||||||
|
from fastapi import APIRouter
|
||||||
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
|
router = APIRouter()
|
||||||
|
|
||||||
|
|
||||||
|
class Status(Enum):
|
||||||
|
ONLINE = "online"
|
||||||
|
OFFLINE = "offline"
|
||||||
|
|
||||||
|
|
||||||
|
class Machine(BaseModel):
|
||||||
|
name: str
|
||||||
|
status: Status
|
||||||
|
|
||||||
|
|
||||||
|
class MachinesResponse(BaseModel):
|
||||||
|
machines: list[Machine]
|
||||||
|
|
||||||
|
|
||||||
|
class MachineResponse(BaseModel):
|
||||||
|
machine: Machine
|
||||||
|
|
||||||
|
|
||||||
|
class Config(BaseModel):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ConfigResponse(BaseModel):
|
||||||
|
config: Config
|
||||||
|
|
||||||
|
|
||||||
|
class Schema(BaseModel):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class SchemaResponse(BaseModel):
|
||||||
|
schema_: Schema = Field(alias="schema")
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/api/machines")
|
||||||
|
async def list_machines() -> MachinesResponse:
|
||||||
|
return MachinesResponse(machines=[])
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/api/machines/{machine}")
|
||||||
|
async def get_machine(machine: str) -> MachineResponse:
|
||||||
|
return MachineResponse(machine=Machine(name=machine, status=Status.ONLINE))
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/api/machines/{machine}/config")
|
||||||
|
async def get_machine_config(machine: str) -> ConfigResponse:
|
||||||
|
return ConfigResponse(config=Config())
|
||||||
|
|
||||||
|
|
||||||
|
@router.post("/api/machines/{machine}/config")
|
||||||
|
async def set_machine_config(machine: str, config: Config) -> ConfigResponse:
|
||||||
|
return ConfigResponse(config=config)
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/api/machines/{machine}/schema")
|
||||||
|
async def get_machine_schema(machine: str) -> SchemaResponse:
|
||||||
|
return SchemaResponse(schema=Schema())
|
||||||
Reference in New Issue
Block a user