# Copyright (c) 2025 Patrick Motsch
# All rights reserved.
"""FTP/SFTP ProviderConnector stub.

Implements the ProviderConnector interface for FTP/SFTP file access.
Full implementation follows when FTP integration is prioritized.
"""

import logging
from typing import List, Optional

from modules.connectors.connectorProviderBase import ProviderConnector, ServiceAdapter
from modules.datamodels.datamodelDataSource import ExternalEntry

logger = logging.getLogger(__name__)


class FtpFilesAdapter(ServiceAdapter):
    """FTP files ServiceAdapter (stub)."""

    def __init__(self, accessToken: str):
        self._accessToken = accessToken

    async def browse(self, path: str, filter: Optional[str] = None) -> List[ExternalEntry]:
        logger.info(f"FTP browse stub: {path}")
        return []

    async def download(self, path: str) -> bytes:
        logger.info(f"FTP download stub: {path}")
        return b""

    async def upload(self, path: str, data: bytes, fileName: str) -> dict:
        return {"error": "FTP upload not yet implemented"}

    async def search(self, query: str, path: Optional[str] = None) -> List[ExternalEntry]:
        return []


class FtpConnector(ProviderConnector):
    """FTP ProviderConnector -- 1 connection -> files."""

    def getAvailableServices(self) -> List[str]:
        return ["files"]

    def getServiceAdapter(self, service: str) -> ServiceAdapter:
        if service != "files":
            raise ValueError(f"FTP only supports 'files' service, got '{service}'")
        return FtpFilesAdapter(self.accessToken)
