"""
Provider mapping service for upload operations.

Provides centralized provider name transformations for S3 paths,
column values, and connection lookups.
"""


class ProviderMappingService:
    """
    Maps provider display names for upload operations.

    Single responsibility: Provider name transformations.
    Centralizes all provider mapping logic in one place to follow DRY principle.
    """

    # Each provider uploads to its own folder
    PROVIDER_TO_FOLDER = {
        "AWS": "AWS",
        "AWS Marketplace": "AWS Marketplace",  # Separate folder to preserve column schema
        "Azure": "Azure",
        "GCP": "GCP",
        "Oracle Cloud": "Oracle Cloud"
    }

    # Cloud provider column values preserve original provider name for differentiation
    PROVIDER_TO_CLOUD_PROVIDER = {
        "AWS": "AWS",
        "AWS Marketplace": "AWS Marketplace",
        "Azure": "Azure",
        "GCP": "GCP",
        "Oracle Cloud": "Oracle Cloud"
    }

    # Each provider uses its own connection
    CONNECTION_PROVIDER_MAP = {
        "AWS": "AWS",
        "AWS Marketplace": "AWS Marketplace",  # Separate connection to preserve column schema
        "Azure": "Azure",
        "GCP": "GCP",
        "Oracle Cloud": "Oracle Cloud"
    }

    def get_s3_folder_name(self, provider: str) -> str:
        """
        Map provider name to S3 folder name.

        Args:
            provider: Provider name (e.g., "AWS", "AWS Marketplace")

        Returns:
            S3 folder name (each provider uses its own folder)
        """
        return self.PROVIDER_TO_FOLDER.get(provider, provider)

    def get_cloud_provider_value(self, provider: str) -> str:
        """
        Get cloud_provider column value for provider.

        Args:
            provider: Provider name

        Returns:
            Value for lineitem/cloud_provider column (preserves original name)
        """
        return self.PROVIDER_TO_CLOUD_PROVIDER.get(provider, provider)

    def get_connection_provider(self, provider: str) -> str:
        """
        Get provider name for connection lookup.

        Args:
            provider: Provider name

        Returns:
            Provider name to use for connection lookup (each provider uses its own connection)
        """
        return self.CONNECTION_PROVIDER_MAP.get(provider, provider)
