"""Organization API schemas.

⚠️ AUTO-GENERATED BY PRISM - DO NOT EDIT
"""

from __future__ import annotations

from datetime import datetime

from pydantic import BaseModel, Field


# ── Organization schemas ─────────────────────────────────────────


class OrganizationCreateRequest(BaseModel):
    """Request to create a new organization."""

    name: str = Field(..., min_length=1, max_length=255)
    slug: str | None = Field(default=None, max_length=255)
    description: str | None = Field(default=None, max_length=2000)


class OrganizationUpdateRequest(BaseModel):
    """Request to update organization details."""

    name: str | None = Field(default=None, min_length=1, max_length=255)
    description: str | None = Field(default=None, max_length=2000)
    avatar_url: str | None = Field(default=None, max_length=512)


class OrganizationResponse(BaseModel):
    """Organization data returned to clients."""

    id: int
    name: str
    {{ slug_field }}: str
    description: str | None = None
    avatar_url: str | None = None
    is_active: bool
    created_at: datetime
    updated_at: datetime
    member_count: int | None = None
    current_user_role: str | None = None

    model_config = {"from_attributes": True}


class OrganizationListResponse(BaseModel):
    """Paginated list of organizations."""

    organizations: list[OrganizationResponse]
    total: int
    skip: int
    limit: int


# ── Membership schemas ───────────────────────────────────────────


class MemberResponse(BaseModel):
    """Organization member data."""

    id: int
    user_id: int
    {{ username_field }}: str | None = None
    role: str
    is_active: bool
    joined_at: datetime

    model_config = {"from_attributes": True}


class MemberListResponse(BaseModel):
    """Paginated list of members."""

    members: list[MemberResponse]
    total: int
    skip: int
    limit: int


class UpdateMemberRoleRequest(BaseModel):
    """Request to update a member's role."""

    role: str = Field(..., min_length=1, max_length=50)


class AddMemberRequest(BaseModel):
    """Request to add a member directly by user ID."""

    user_id: int
    role: str = Field(default="{{ default_org_role }}", min_length=1, max_length=50)


# ── Invitation schemas ───────────────────────────────────────────


class InvitationCreateRequest(BaseModel):
    """Request to invite a user to an organization."""

    email: str = Field(..., min_length=1, max_length=255)
    role: str = Field(default="{{ default_org_role }}", min_length=1, max_length=50)


class InvitationResponse(BaseModel):
    """Invitation data returned to clients."""

    id: int
    email: str
    role: str
    created_at: datetime
    expires_at: datetime

    model_config = {"from_attributes": True}


class AcceptInvitationRequest(BaseModel):
    """Request to accept an invitation."""

    token: str = Field(..., min_length=1)


# ── Role schemas ─────────────────────────────────────────────────


class OrgRoleResponse(BaseModel):
    """Organization role definition."""

    name: str
    permissions: list[str]
    description: str
