from src.domain.connectors.catalog._base import (
    ConnectorActionDef,
    ConnectorChangelogEntry,
    ConnectorDef,
    ConnectorFieldDef,
)

CONNECTOR = ConnectorDef(
    key="ses",
    name="Amazon SES",
    category="email",
    auth_type="api_key",
    version="01.00.00",
    icon="ses",
    image_url=None,
    description="Transactional email delivery through Amazon Simple Email Service (API v2).",
    docs_url="https://docs.aws.amazon.com/ses/latest/dg/send-email.html",
    config_fields=("region", "from_email", "from_name", "configuration_set"),
    secret_fields=("access_key_id", "secret_access_key"),
    config_field_defs=(
        ConnectorFieldDef(
            key="region",
            label="AWS region",
            description="SES region where the sending identity is verified.",
            placeholder="us-east-1",
            default="us-east-1",
            required=True,
        ),
        ConnectorFieldDef(
            key="from_email",
            label="From email",
            description="A sending address or domain verified in this SES account/region.",
            placeholder="noreply@yourdomain.com",
            required=True,
        ),
        ConnectorFieldDef(
            key="from_name",
            label="From name",
            description="Display name shown to recipients.",
            placeholder="Acme Inc.",
        ),
        ConnectorFieldDef(
            key="configuration_set",
            label="Configuration set",
            description="Optional SES configuration set for events and reputation.",
            placeholder="transactional",
        ),
    ),
    secret_field_defs=(
        ConnectorFieldDef(
            key="access_key_id",
            label="Access key ID",
            description="IAM access key with ses:SendEmail (and related) permission.",
            placeholder="AKIA...",
            required=True,
            input_type="password",
        ),
        ConnectorFieldDef(
            key="secret_access_key",
            label="Secret access key",
            required=True,
            input_type="password",
        ),
    ),
    actions=(
        ConnectorActionDef(
            key="send_email",
            slug="ses.send_email",
            name="Send email",
            description="Send a transactional email through Amazon SES.",
            input_schema={
                "type": "object",
                "properties": {
                    "to": {"type": ["string", "array"]},
                    "subject": {"type": "string"},
                    "html": {"type": "string"},
                    "text": {"type": "string"},
                    "from": {"type": "string"},
                    "reply_to": {"type": ["string", "array"]},
                    "cc": {"type": ["string", "array"]},
                    "bcc": {"type": ["string", "array"]},
                    "headers": {"type": "object"},
                    "tags": {"type": "array"},
                    "configuration_set": {"type": "string"},
                },
                "required": ["to", "subject"],
                "additionalProperties": True,
            },
            required_capabilities=("integrations.execute",),
            implements=("email.send",),
        ),
    ),
    changelog=(
        ConnectorChangelogEntry(
            version="01.00.00",
            date="2026-09-09",
            notes="Initial Amazon SES connector with send_email.",
        ),
    ),
)
