39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
from fastapi import APIRouter
|
|
from infra.token.token_manager import TokenManager
|
|
from fastapi import APIRouter, Depends
|
|
from fastapi.encoders import jsonable_encoder
|
|
from fastapi.responses import JSONResponse
|
|
from fastapi import Depends, HTTPException
|
|
from starlette.status import HTTP_401_UNAUTHORIZED
|
|
from fastapi.encoders import jsonable_encoder
|
|
from fastapi.responses import JSONResponse
|
|
from infra.token.token_manager import TokenManager
|
|
from app.central_storage.backend.application.document_hub import DocumentHub
|
|
|
|
router = APIRouter()
|
|
token_manager = TokenManager()
|
|
|
|
|
|
# Web API
|
|
# Fetch document by ID
|
|
@router.get(
|
|
"/retrieve_document_info/{document_id}",
|
|
operation_id="retrieve_document_info",
|
|
summary="Fetch a document by its ID",
|
|
description="Retrieve a specific document by its document ID and return file name and download URL",
|
|
response_description="The document details including file name and download URL",
|
|
)
|
|
async def retrieve_document_info(
|
|
document_id: str
|
|
):
|
|
|
|
# Fetch the document using DocumentHub
|
|
document = await DocumentHub().retrieve_document_info(document_id)
|
|
|
|
# If document is not found, raise 404 error
|
|
if not document:
|
|
raise HTTPException(status_code=404, detail="Document not found")
|
|
|
|
# Return the document details
|
|
return JSONResponse(content=jsonable_encoder({"document": document}))
|