# generated by datamodel-codegen:
#   filename:  _internal

from __future__ import annotations

from typing import Literal

from pydantic import BaseModel, ConfigDict, Field

from . import github_com_Mnexa_AI_e2a_internal_identity


class APIKeyExportEntry(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    created_at: str | None = None
    id: str | None = None
    key_prefix: str | None = None
    last_used_at: str | None = None
    name: str | None = None
    revoked_at: str | None = None


class Agent(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    agent_mode: Literal['cloud', 'local'] | None = Field(None, examples=['cloud'])
    created_at: str | None = None
    domain: str | None = Field(None, examples=['agents.example.com'])
    domain_verified: bool | None = None
    email: str | None = Field(None, examples=['my-bot@example.com'])
    hitl_enabled: bool | None = None
    hitl_expiration_action: Literal['approve', 'reject'] | None = Field(
        None, examples=['reject']
    )
    hitl_ttl_seconds: int | None = Field(None, examples=[604800])
    id: str | None = Field(None, examples=['ag_abc123'])
    name: str | None = Field(None, examples=['My Bot'])
    webhook_url: str | None = None


class ApprovePendingMessageResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    edited: bool | None = None
    message_id: str | None = None
    method: str | None = Field(None, examples=['smtp'])
    provider_message_id: str | None = None
    status: str | None = Field(None, examples=['sent'])


class DNSRecord(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    host: str | None = Field(None, examples=['@'])
    priority: int | None = Field(None, examples=[10])
    value: str | None = Field(None, examples=['mx.example.com'])


class DNSRecords(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    mx: DNSRecord | None = None
    txt: DNSRecord | None = None


class DeploymentInfo(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    public_url: str | None = Field(
        None,
        description='PublicURL is the externally visible base URL of the API itself —\nthe same value the operator sets in `http.public_url`. Empty when\nnot configured.',
        examples=['https://e2a.example.com'],
    )
    shared_domain: str | None = Field(
        None,
        description='SharedDomain is the mail domain backing slug-based agent registration\non this deployment (e.g. "agents.example.com"). Empty when the\noperator hasn\'t configured one — in that case slug registration is\ndisabled and every agent must use a custom domain.',
        examples=['agents.example.com'],
    )
    slug_registration_enabled: bool | None = Field(
        None,
        description='SlugRegistrationEnabled mirrors `shared_domain != ""` for clients\nthat prefer a boolean. Equivalent to checking SharedDomain directly.',
        examples=[True],
    )


class Domain(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    created_at: str | None = None
    dns_records: DNSRecords | None = None
    domain: str | None = Field(None, examples=['yourdomain.com'])
    verification_token: str | None = Field(None, examples=['e2a-verify=abc123'])
    verified: bool | None = None
    verified_at: str | None = None


class ListAgentsResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    agents: list[Agent] | None = None


class ListDomainsResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    domains: list[Domain] | None = None


class MessageDetail(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    auth_headers: dict[str, str] | None = None
    conversation_id: str | None = None
    created_at: str | None = None
    from_: str | None = Field(None, alias='from', examples=['alice@example.com'])
    message_id: str | None = Field(None, examples=['msg_abc123'])
    raw_message: str | None = None
    reply_to: list[str] | None = None
    status: str | None = Field(None, examples=['read'])
    subject: str | None = Field(None, examples=['Hello'])
    to: str | None = Field(None, examples=['my-bot@example.com'])


class MessageSummary(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    conversation_id: str | None = None
    created_at: str | None = Field(None, examples=['2025-01-15T10:30:00Z'])
    from_: str | None = Field(None, alias='from', examples=['alice@example.com'])
    message_id: str | None = Field(None, examples=['msg_abc123'])
    reply_to: list[str] | None = None
    status: Literal['unread', 'read'] | None = Field(None, examples=['unread'])
    subject: str | None = Field(None, examples=['Hello'])
    to: str | None = Field(None, examples=['my-bot@example.com'])


class PendingMessageSummary(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    agent_id: str | None = Field(None, examples=['my-bot@example.com'])
    approval_expires_at: str | None = Field(None, examples=['2025-01-15T10:30:00Z'])
    bcc: list[str] | None = None
    cc: list[str] | None = None
    conversation_id: str | None = None
    created_at: str | None = None
    direction: str | None = Field(None, examples=['outbound'])
    id: str | None = Field(None, examples=['msg_abc123'])
    status: (
        Literal[
            'sent',
            'pending_approval',
            'rejected',
            'expired_approved',
            'expired_rejected',
        ]
        | None
    ) = Field(None, examples=['pending_approval'])
    subject: str | None = Field(None, examples=['Re: contract details'])
    to: list[str] | None = Field(None, examples=[['alice@example.com']])
    type: Literal['send', 'reply', 'test'] | None = Field(None, examples=['send'])


class RegisterAgentRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    agent_mode: str | None = None
    email: str | None = None
    name: str | None = None
    slug: str | None = None
    webhook_url: str | None = None


class RegisterAgentResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    domain: str | None = None
    email: str | None = None
    id: str | None = None


class RegisterDomainRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    domain: str | None = Field(None, examples=['yourdomain.com'])


class RejectPendingMessageRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    reason: str | None = Field(None, examples=['wrong recipient'])


class RejectPendingMessageResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    message_id: str | None = None
    rejection_reason: str | None = None
    status: str | None = Field(None, examples=['rejected'])


class SendEmailResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    approval_expires_at: str | None = Field(None, examples=['2025-01-15T10:30:00Z'])
    message_id: str | None = Field(None, examples=['msg_abc123'])
    method: str | None = Field(None, examples=['smtp'])
    status: Literal['sent', 'pending_approval'] | None = Field(None, examples=['sent'])


class UpdateAgentRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    agent_mode: Literal['cloud', 'local'] | None = None
    hitl_enabled: bool | None = None
    hitl_expiration_action: Literal['approve', 'reject'] | None = None
    hitl_ttl_seconds: int | None = Field(None, examples=[604800])
    webhook_url: str | None = None


class UsageEventEntry(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    agent_id: str | None = None
    created_at: str | None = None
    direction: str | None = None
    domain: str | None = None
    event_type: str | None = None
    id: str | None = None


class UserExportUser(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    created_at: str | None = None
    email: str | None = None
    id: str | None = None
    name: str | None = None


class VerifyDomainResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    domain: str | None = Field(None, examples=['yourdomain.com'])
    verified: bool | None = None
    verified_at: str | None = None


class ApprovePendingMessageRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    attachments: list[Attachment] | None = None
    bcc: list[str] | None = None
    body_html: str | None = None
    body_text: str | None = None
    cc: list[str] | None = None
    subject: str | None = None
    to: list[str] | None = None


class ListMessagesResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    messages: list[MessageSummary] | None = None
    next_token: str | None = None


class ListPendingMessagesResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    messages: list[PendingMessageSummary] | None = None


class PendingMessageDetail(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    agent_id: str | None = Field(None, examples=['my-bot@example.com'])
    approval_expires_at: str | None = Field(None, examples=['2025-01-15T10:30:00Z'])
    attachments: list[Attachment] | None = None
    bcc: list[str] | None = None
    body_html: str | None = None
    body_text: str | None = None
    cc: list[str] | None = None
    conversation_id: str | None = None
    created_at: str | None = None
    direction: str | None = Field(None, examples=['outbound'])
    edited: bool | None = None
    email_message_id: str | None = Field(None, examples=['<orig@gmail.com>'])
    id: str | None = Field(None, examples=['msg_abc123'])
    method: str | None = Field(None, examples=['smtp'])
    provider_message_id: str | None = None
    rejection_reason: str | None = None
    reviewed_at: str | None = Field(None, examples=['2025-01-15T10:35:00Z'])
    status: (
        Literal[
            'sent',
            'pending_approval',
            'rejected',
            'expired_approved',
            'expired_rejected',
        ]
        | None
    ) = Field(None, examples=['pending_approval'])
    subject: str | None = Field(None, examples=['Re: contract details'])
    to: list[str] | None = Field(None, examples=[['alice@example.com']])
    type: Literal['send', 'reply', 'test'] | None = Field(None, examples=['send'])


class ReplyToMessageRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    attachments: list[Attachment] | None = None
    bcc: list[str] | None = Field(None, examples=[['carol@example.com']])
    body: str | None = Field(None, examples=['Thanks for your email!'])
    cc: list[str] | None = Field(None, examples=[['bob@example.com']])
    conversation_id: str | None = None
    html_body: str | None = Field(None, examples=['<p>Thanks for your email!</p>'])
    reply_all: bool | None = Field(None, examples=[False])


class SendEmailRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    attachments: list[Attachment] | None = None
    bcc: list[str] | None = Field(None, examples=[['carol@example.com']])
    body: str | None = Field(
        None, examples=['Hi Alice, this is my agent reaching out.']
    )
    cc: list[str] | None = Field(None, examples=[['bob@example.com']])
    conversation_id: str | None = Field(None, examples=['conv_abc123'])
    from_: str | None = Field(None, alias='from', examples=['my-bot@example.com'])
    html_body: str | None = Field(None, examples=['<p>Hi Alice</p>'])
    subject: str | None = Field(None, examples=['Hello from my agent'])
    to: list[str] | None = Field(None, examples=[['alice@example.com']])


class Attachment(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    content_type: str | None = Field(None, examples=['application/pdf'])
    data: str | None = Field(
        None, description='base64-encoded', examples=['base64-encoded-content']
    )
    filename: str | None = Field(None, examples=['report.pdf'])


class DeleteUserDataResult(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    agents_deleted: int | None = None
    api_keys_deleted: int | None = None
    domains_deleted: int | None = None
    messages_deleted: int | None = None
    sessions_deleted: int | None = None
    usage_events_deleted: int | None = None
    usage_summaries_deleted: int | None = None
    user_deleted: bool | None = None


class UserExport(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    agents: list[github_com_Mnexa_AI_e2a_internal_identity.AgentIdentity] | None = None
    api_keys: list[APIKeyExportEntry] | None = None
    domains: list[github_com_Mnexa_AI_e2a_internal_identity.Domain] | None = None
    generated_at: str | None = None
    messages: list[github_com_Mnexa_AI_e2a_internal_identity.Message] | None = None
    schema_version: str | None = None
    usage_events: list[UsageEventEntry] | None = None
    user: UserExportUser | None = None
