# Auto-generated by DjangoCFG - see CLAUDE.md

from __future__ import annotations
import datetime
from typing import Any

from pydantic import BaseModel, ConfigDict, Field

from ..enums import AlertType


class ApiKeyResponse(BaseModel):
    """
    Response serializer that includes raw key (shown only once).

    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    id: str = ...
    workspace: str = ...
    name: Any = Field(description='Descriptive name for this API key')
    key_prefix: Any = Field(description='First 12 characters for display')
    raw_key: Any = ...
    created_by: int | None = None
    created_by_email: Any = ...
    created_at: datetime.datetime = ...



class ApiKey(BaseModel):
    """
    Read-only serializer for ApiKey (hides actual key).

    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    id: str = ...
    workspace: str = ...
    workspace_name: Any = ...
    name: Any = Field(description='Descriptive name for this API key')
    key_prefix: Any = Field(description='First 12 characters for display')
    last_used: datetime.datetime | None = None
    created_by: int | None = None
    created_by_email: Any = ...
    created_at: datetime.datetime = ...



class ApiKeyCreateRequest(BaseModel):
    """
    Serializer for creating new API key.

    Request model (no read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    name: str = Field(
    description='Descriptive name for this API key',
    min_length=1,
    max_length=100,
)
    workspace: str = Field(description='Workspace ID')



class Alert(BaseModel):
    """
    Serializer for Alert model.

    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    id: str = ...
    workspace: str = ...
    type: AlertType = Field(description='* `machine_offline` - Machine Of...')
    title: str = Field(max_length=200)
    message: str = ...
    machine: str | None = None
    machine_name: Any | None = Field(None, description='Get machine name.')
    read: bool | None = None
    is_unread: bool = ...
    created_at: datetime.datetime = ...



class PatchedAlertRequest(BaseModel):
    """
    Serializer for Alert model.

    Request model (no read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    workspace: str | None = None
    type: AlertType | None = Field(None, description='* `machine_offline` - Machine Of...')
    title: str | None = Field(None, min_length=1, max_length=200)
    message: str | None = Field(None, min_length=1)
    machine: str | None = None
    read: bool | None = None



class AlertCreate(BaseModel):
    """
    Serializer for creating alerts.

    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    workspace: str = ...
    type: AlertType = Field(description='* `machine_offline` - Machine Of...')
    title: str = Field(max_length=200)
    message: str = ...
    machine: str | None = None



class AlertCreateRequest(BaseModel):
    """
    Serializer for creating alerts.

    Request model (no read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    workspace: str = ...
    type: AlertType = Field(description='* `machine_offline` - Machine Of...')
    title: str = Field(min_length=1, max_length=200)
    message: str = Field(min_length=1)
    machine: str | None = None



class PaginatedApiKeyList(BaseModel):
    """
    
    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    count: int = Field(description='Total number of items across all...')
    page: int = Field(description='Current page number (1-based)')
    pages: int = Field(description='Total number of pages')
    page_size: int = Field(description='Number of items per page')
    has_next: bool = Field(description='Whether there is a next page')
    has_previous: bool = Field(description='Whether there is a previous page')
    next_page: int | None = Field(None, description='Next page number (null if no nex...')
    previous_page: int | None = Field(None, description='Previous page number (null if no...')
    results: list[ApiKey] = Field(description='Array of items for current page')



class AlertRequest(BaseModel):
    """
    Serializer for Alert model.

    Request model (no read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    workspace: str = ...
    type: AlertType = Field(description='* `machine_offline` - Machine Of...')
    title: str = Field(min_length=1, max_length=200)
    message: str = Field(min_length=1)
    machine: str | None = None
    read: bool | None = None



class PaginatedAlertList(BaseModel):
    """
    
    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    count: int = Field(description='Total number of items across all...')
    page: int = Field(description='Current page number (1-based)')
    pages: int = Field(description='Total number of pages')
    page_size: int = Field(description='Number of items per page')
    has_next: bool = Field(description='Whether there is a next page')
    has_previous: bool = Field(description='Whether there is a previous page')
    next_page: int | None = Field(None, description='Next page number (null if no nex...')
    previous_page: int | None = Field(None, description='Previous page number (null if no...')
    results: list[Alert] = Field(description='Array of items for current page')



