from .base_agent import BaseAgent
from ..aws_connector import AWSConnector

class ACMAgent(BaseAgent):
    """
    An agent specialized in handling AWS Certificate Manager (ACM) tasks.
    """

    def execute(self, command: str, **kwargs):
        """
        Executes a given command related to ACM.
        """
        if command == 'list_certificates':
            return self._list_certificates(**kwargs)
        else:
            raise NotImplementedError(f"Command '{command}' is not supported by ACMAgent.")

    def _list_certificates(self, region: str):
        """Lists all ACM certificates in a specified region."""
        print(f"ACMAgent: Listing certificates in region {region}...")
        try:
            acm_client = AWSConnector.get_client('acm', region_name=region)
            response = acm_client.list_certificates()
            certificate_summaries = response.get('CertificateSummaryList', [])
            return {"status": "success", "certificates": certificate_summaries}
        except Exception as e:
            print(f"Error listing ACM certificates: {e}")
            return {"status": "error", "message": str(e)}
