"""
Interface for upload validation services.

Defines the contract for validation operations including S3 access validation,
stage discovery coordination, and processing plan generation.
"""

from abc import ABC, abstractmethod
from typing import Dict, List
from ..models import (
    ValidationResult,
    StageDiscoveryResult,
    ConnectionValidationResult,
    ProcessingPlan,
    UploadConfig
)


class ValidationServiceInterface(ABC):
    """
    Interface for upload validation operations.
    
    Handles validation of upload preconditions including S3 access,
    stage discovery, connection validation, and processing plan generation.
    """
    
    @abstractmethod
    def validate_s3_access(self, bucket: str, region: str) -> ValidationResult:
        """
        Validate S3 bucket access and permissions.
        
        Args:
            bucket: S3 bucket name
            region: S3 region
            
        Returns:
            ValidationResult with S3 access validation outcome
        """
        pass
    
    @abstractmethod
    def discover_stages_for_organizations(
        self,
        upload_config: UploadConfig
    ) -> Dict[str, List[StageDiscoveryResult]]:
        """
        Perform stage discovery for all organizations.
        
        Args:
            upload_config: Upload configuration with dataset and org details
            
        Returns:
            Dict mapping organization name to list of StageDiscoveryResult
        """
        pass
    
    @abstractmethod
    def validate_connections_for_organizations(
        self,
        upload_config: UploadConfig
    ) -> Dict[str, ConnectionValidationResult]:
        """
        Validate connections for all organizations.
        
        Args:
            upload_config: Upload configuration with organization details
            
        Returns:
            Dict mapping organization name to ConnectionValidationResult
        """
        pass
    
    @abstractmethod
    def generate_processing_plan(
        self,
        connection_results: Dict[str, ConnectionValidationResult],
        discovery_results: Dict[str, List[StageDiscoveryResult]],
        is_dry_run: bool = False
    ) -> ProcessingPlan:
        """
        Generate processing plan from validation results.
        
        Args:
            connection_results: Connection validation results per organization
            discovery_results: Stage discovery results per organization
            is_dry_run: Whether this is a dry run validation
            
        Returns:
            ProcessingPlan with structured plan for upload execution
        """
        pass
    
    @abstractmethod
    def perform_unified_validation(self, upload_config: UploadConfig, is_dry_run: bool = False) -> ValidationResult:
        """
        Perform complete validation workflow.
        
        Coordinates S3 validation, stage discovery, connection validation,
        and processing plan generation in a single operation.
        
        Args:
            upload_config: Upload configuration
            is_dry_run: Whether this is a dry run validation
            
        Returns:
            ValidationResult with complete validation outcome and processing plan
        """
        pass