from backend.business.document_manager import ( DocumentManager, ) from common.log.module_logger import ModuleLogger class DocumentHub: def __init__( self, ): self.document_manager = DocumentManager() self.module_logger = ModuleLogger(sender_id="DocumentHub") return async def retrieve_document_info(self, document_id: str): await self.module_logger.log_info(f"Retrieving document info for ID: {document_id}") result = await self.document_manager.retrieve_document_info(document_id) await self.module_logger.log_info(f"Document info retrieved successfully for ID: {document_id}") return result async def read_document_file_as_http_media_data(self, document_id: str): await self.module_logger.log_info(f"Reading document as HTTP media for ID: {document_id}") result = await self.document_manager.read_document_file_as_http_media_data( document_id ) await self.module_logger.log_info(f"Document media data read successfully for ID: {document_id}") return result async def upload_document( self, associated_with: str, file_name: str, file_data: bytes ) -> bool: """Upload a file Args: file_name: the name of the file file (bytes): the file to be uploaded """ await self.module_logger.log_info(f"Uploading document {file_name} for user {associated_with}") result = await self.document_manager.upload_file( associated_with, file_name, file_data ) await self.module_logger.log_info(f"Document upload completed for {file_name}, result: {result}") return result async def delete_documents(self, document_ids: list): await self.module_logger.log_info(f"Deleting documents: {document_ids}") for document_id in document_ids: await self.document_manager.delete_document(document_id) await self.module_logger.log_info(f"Documents deleted successfully: {document_ids}") return