Replaces LICENSE (GPLv3 -> AGPLv3) and prepends `SPDX-License-Identifier: AGPL-3.0-or-later` to every source file across decnet/, decnet_web/, tests/, scripts/, and tools/. Rationale: closes the GPLv3 ASP loophole so any party operating a modified DECNET as a network service must offer their modified source. Personal copyright (Samuel Paschuan) + inbound=outbound contributions make a future unilateral relicense infeasible. - LICENSE: full AGPL-3.0 text (gnu.org/licenses/agpl-3.0.txt) - COPYRIGHT: project copyright notice - tools/add_spdx_headers.py: idempotent header injector (shebang- and PEP 263-aware) Touches 1565 source files (.py, .ts, .tsx, .js, .jsx, .css, .sh). No behavior change; comments only.
53 lines
1.9 KiB
Python
53 lines
1.9 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""DELETE /topologies/{id} — cascade-delete a pending or torn-down topology."""
|
|
from __future__ import annotations
|
|
|
|
from fastapi import APIRouter, Depends, HTTPException, Response, status
|
|
|
|
from decnet.telemetry import traced as _traced
|
|
from decnet.topology.status import TopologyStatus
|
|
from decnet.web.dependencies import repo, require_admin
|
|
|
|
router = APIRouter()
|
|
|
|
# Only allow delete when containers are guaranteed not to be running.
|
|
# ACTIVE / DEPLOYING / DEGRADED / TEARING_DOWN must teardown first.
|
|
_DELETABLE: frozenset[str] = frozenset(
|
|
{TopologyStatus.PENDING, TopologyStatus.TORN_DOWN, TopologyStatus.FAILED}
|
|
)
|
|
|
|
|
|
@router.delete(
|
|
"/{topology_id}",
|
|
tags=["MazeNET Topologies"],
|
|
status_code=status.HTTP_204_NO_CONTENT,
|
|
responses={
|
|
400: {"description": "Malformed path parameters"},
|
|
401: {"description": "Missing or invalid credentials"},
|
|
403: {"description": "Insufficient permissions"},
|
|
404: {"description": "Topology not found"},
|
|
409: {"description": "Topology has running resources; teardown first"},
|
|
},
|
|
)
|
|
@_traced("api.topology.delete")
|
|
async def api_delete_topology(
|
|
topology_id: str,
|
|
_admin: dict = Depends(require_admin),
|
|
) -> Response:
|
|
topo = await repo.get_topology(topology_id)
|
|
if topo is None:
|
|
raise HTTPException(status_code=404, detail="Topology not found")
|
|
if topo.status not in _DELETABLE:
|
|
raise HTTPException(
|
|
status_code=409,
|
|
detail=(
|
|
f"Topology is {topo.status!r}; teardown to 'torn_down' "
|
|
f"before delete."
|
|
),
|
|
)
|
|
deleted = await repo.delete_topology_cascade(topology_id)
|
|
if not deleted:
|
|
# Race: row vanished between the status check and the cascade.
|
|
raise HTTPException(status_code=404, detail="Topology not found")
|
|
return Response(status_code=status.HTTP_204_NO_CONTENT)
|