mirror of
https://github.com/hansjone/netx.git
synced 2026-10-09 03:10:46 +08:00
feat(managed-ne): add bulk import template download with device_type reference sheet
Expose GET /v1/managed-ne/import/template and a workbench button to download xlsx/csv templates listing supported Netmiko device types. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
042c015045
commit
3024e13812
6 changed files with 69 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from fastapi import APIRouter, Depends, File, HTTPException, Query, UploadFile
|
||||
from fastapi.responses import Response
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from .db import get_db
|
||||
|
|
@ -9,6 +10,7 @@ from .ne_connect import schedule_connect_tests
|
|||
from .ne_crypto import credentials_configured
|
||||
from .ne_schemas import ConnectTestRequest, ManagedNeCreate, ManagedNeUpdate
|
||||
from .ne_service import (
|
||||
build_managed_ne_import_template,
|
||||
create_managed_ne,
|
||||
delete_managed_ne,
|
||||
get_managed_ne,
|
||||
|
|
@ -70,6 +72,16 @@ def api_delete_managed_ne(ne_id: str, db: Session = Depends(get_db)):
|
|||
return delete_managed_ne(db, ne_id)
|
||||
|
||||
|
||||
@router.get("/import/template")
|
||||
def api_managed_ne_import_template(format: str = Query(default="xlsx")):
|
||||
filename, payload, media_type = build_managed_ne_import_template(format)
|
||||
return Response(
|
||||
content=payload,
|
||||
media_type=media_type,
|
||||
headers={"content-disposition": f'attachment; filename="{filename}"'},
|
||||
)
|
||||
|
||||
|
||||
@router.post("/import")
|
||||
async def api_import_managed_ne(file: UploadFile = File(...), db: Session = Depends(get_db)):
|
||||
content = await file.read()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue