mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-06 07:11:13 +02:00
feat(api): generate unique readable OpenAPI operationIds
This commit is contained in:
5 files changed
+149
-4
No files matched your search
@@ -21,6 +21,7 @@ from fastapi import Depends, FastAPI, Request
|
||||
from fastapi.responses import JSONResponse
|
||||
from starlette.exceptions import HTTPException as StarletteHTTPException
|
||||
|
||||
from gns3server.api.operation_ids import generate_operation_id
|
||||
from gns3server.compute.compute_error import (
|
||||
ComputeError,
|
||||
ComputeForbiddenError,
|
||||
@@ -61,6 +62,7 @@ compute_api = FastAPI(
|
||||
title="GNS3 compute API",
|
||||
description="This page describes the private compute API for GNS3. PLEASE DO NOT USE DIRECTLY!",
|
||||
version="3.0.0",
|
||||
generate_unique_id_function=generate_operation_id,
|
||||
)
|
||||
|
||||
compute_api.state.controller_host = None
|
||||
|
||||
@@ -18,6 +18,7 @@ from fastapi import APIRouter, Depends, HTTPException, status
|
||||
|
||||
# Check AI Copilot availability
|
||||
from gns3server.agent import AI_COPILOT_AVAILABLE
|
||||
from gns3server.api.operation_ids import add_stub_routes
|
||||
|
||||
# Conditionally import AI-dependent routes
|
||||
if AI_COPILOT_AVAILABLE:
|
||||
@@ -32,15 +33,16 @@ else:
|
||||
_copilot_router = APIRouter()
|
||||
_llm_router = APIRouter()
|
||||
|
||||
@_chat_router.api_route("/{path:path}", methods=["GET", "POST", "DELETE", "PATCH", "PUT"])
|
||||
@_copilot_router.api_route("/{path:path}", methods=["GET", "POST", "DELETE", "PATCH", "PUT"])
|
||||
@_llm_router.api_route("/{path:path}", methods=["GET", "POST", "DELETE", "PATCH", "PUT"])
|
||||
async def ai_not_available(path: str = ""):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_501_NOT_IMPLEMENTED,
|
||||
detail="AI Copilot is not available. Install AI dependencies with: pip install gns3-server[ai-features]",
|
||||
)
|
||||
|
||||
add_stub_routes(_chat_router, ai_not_available, "chat_not_available")
|
||||
add_stub_routes(_copilot_router, ai_not_available, "copilot_not_available")
|
||||
add_stub_routes(_llm_router, ai_not_available, "llm_not_available")
|
||||
|
||||
|
||||
from . import (
|
||||
acl,
|
||||
|
||||
Reference in new issue
Block a user