feat(web/api): expose archetype catalog endpoint
/api/v1/topologies/archetypes returns the archetype registry (slug, display name, description, preferred services/distros, nmap_os fingerprint) so the frontend wizard can render a live catalog instead of hardcoding a copy.
This commit is contained in:
@@ -7,6 +7,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||||
|
|
||||||
|
from decnet.archetypes import all_archetypes
|
||||||
from decnet.fleet import all_service_names
|
from decnet.fleet import all_service_names
|
||||||
from decnet.telemetry import traced as _traced
|
from decnet.telemetry import traced as _traced
|
||||||
from decnet.topology.allocator import (
|
from decnet.topology.allocator import (
|
||||||
@@ -16,6 +17,8 @@ from decnet.topology.allocator import (
|
|||||||
reserved_subnets,
|
reserved_subnets,
|
||||||
)
|
)
|
||||||
from decnet.web.db.models import (
|
from decnet.web.db.models import (
|
||||||
|
ArchetypeCatalogResponse,
|
||||||
|
ArchetypeEntry,
|
||||||
NextIPResponse,
|
NextIPResponse,
|
||||||
NextSubnetResponse,
|
NextSubnetResponse,
|
||||||
ServiceCatalogResponse,
|
ServiceCatalogResponse,
|
||||||
@@ -42,6 +45,34 @@ async def api_list_services(
|
|||||||
return ServiceCatalogResponse(services=all_service_names())
|
return ServiceCatalogResponse(services=all_service_names())
|
||||||
|
|
||||||
|
|
||||||
|
@router.get(
|
||||||
|
"/archetypes",
|
||||||
|
tags=["MazeNET Topologies"],
|
||||||
|
response_model=ArchetypeCatalogResponse,
|
||||||
|
responses={
|
||||||
|
401: {"description": "Missing or invalid credentials"},
|
||||||
|
403: {"description": "Insufficient permissions"},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
@_traced("api.topology.catalog.archetypes")
|
||||||
|
async def api_list_archetypes(
|
||||||
|
_viewer: dict = Depends(require_viewer),
|
||||||
|
) -> ArchetypeCatalogResponse:
|
||||||
|
return ArchetypeCatalogResponse(
|
||||||
|
archetypes=[
|
||||||
|
ArchetypeEntry(
|
||||||
|
slug=a.slug,
|
||||||
|
display_name=a.display_name,
|
||||||
|
description=a.description,
|
||||||
|
services=list(a.services),
|
||||||
|
preferred_distros=list(a.preferred_distros),
|
||||||
|
nmap_os=a.nmap_os,
|
||||||
|
)
|
||||||
|
for a in all_archetypes().values()
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@router.get(
|
@router.get(
|
||||||
"/next-subnet",
|
"/next-subnet",
|
||||||
tags=["MazeNET Topologies"],
|
tags=["MazeNET Topologies"],
|
||||||
|
|||||||
Reference in New Issue
Block a user