# app/modules/hosting/schemas/client_service.py
"""Pydantic schemas for client service management."""

from datetime import datetime

from pydantic import BaseModel, Field


class ClientServiceCreate(BaseModel):
    """Schema for creating a client service."""

    service_type: str = Field(..., pattern="^(domain|email|ssl|hosting|website_maintenance)$")
    name: str = Field(..., max_length=255)
    description: str | None = None
    billing_period: str | None = Field(None, pattern="^(monthly|annual|one_time)$")
    price_cents: int | None = None
    currency: str = Field("EUR", max_length=3)
    addon_product_id: int | None = None
    domain_name: str | None = Field(None, max_length=255)
    registrar: str | None = Field(None, max_length=100)
    mailbox_count: int | None = None
    expires_at: datetime | None = None
    period_start: datetime | None = None
    period_end: datetime | None = None
    auto_renew: bool = True
    notes: str | None = None


class ClientServiceUpdate(BaseModel):
    """Schema for updating a client service."""

    name: str | None = Field(None, max_length=255)
    description: str | None = None
    status: str | None = Field(None, pattern="^(pending|active|suspended|expired|cancelled)$")
    billing_period: str | None = Field(None, pattern="^(monthly|annual|one_time)$")
    price_cents: int | None = None
    currency: str | None = Field(None, max_length=3)
    addon_product_id: int | None = None
    domain_name: str | None = Field(None, max_length=255)
    registrar: str | None = Field(None, max_length=100)
    mailbox_count: int | None = None
    expires_at: datetime | None = None
    period_start: datetime | None = None
    period_end: datetime | None = None
    auto_renew: bool | None = None
    notes: str | None = None


class ClientServiceResponse(BaseModel):
    """Schema for client service response."""

    id: int
    hosted_site_id: int
    service_type: str
    name: str
    description: str | None = None
    status: str
    billing_period: str | None = None
    price_cents: int | None = None
    currency: str = "EUR"
    addon_product_id: int | None = None
    domain_name: str | None = None
    registrar: str | None = None
    mailbox_count: int | None = None
    expires_at: datetime | None = None
    period_start: datetime | None = None
    period_end: datetime | None = None
    auto_renew: bool = True
    notes: str | None = None
    created_at: datetime
    updated_at: datetime

    class Config:
        from_attributes = True


class ClientServiceDeleteResponse(BaseModel):
    """Response for client service deletion."""

    message: str
