# Auto-generated by DjangoCFG - see CLAUDE.md

from __future__ import annotations
from typing import Any

from pydantic import BaseModel, ConfigDict, Field


class ServiceSummary(BaseModel):
    """
    Summary information for a single service.

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

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

    name: str = Field(description='Service name (e.g., myapp.UserSe...')
    full_name: str = Field(description='Full service name with package')
    package: str = Field(description='Package name')
    methods_count: int = Field(description='Number of methods in service')
    total_requests: int | None = Field(None, description='Total requests to this service')
    success_rate: float | None = Field(None, description='Success rate percentage')
    avg_duration_ms: float | None = Field(None, description='Average duration in milliseconds')
    last_activity_at: str | None = Field(None, description='Last activity timestamp')



class PaginatedServiceSummaryList(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[ServiceSummary] = Field(description='Array of items for current page')



class RecentError(BaseModel):
    """
    Recent error information.

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

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

    method: str = Field(description='Method name where error occurred')
    error_message: str = Field(description='Error message')
    grpc_status_code: str = Field(description='gRPC status code')
    occurred_at: str = Field(description='When error occurred (ISO timestamp)')



class ServiceStats(BaseModel):
    """
    Service statistics.

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

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

    total_requests: int | None = Field(None, description='Total requests')
    successful: int | None = Field(None, description='Successful requests')
    errors: int | None = Field(None, description='Failed requests')
    success_rate: float | None = Field(None, description='Success rate percentage')
    avg_duration_ms: float | None = Field(None, description='Average duration in milliseconds')
    last_24h_requests: int | None = Field(None, description='Requests in last 24 hours')



class MethodInfo(BaseModel):
    """
    Information about a service method.

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

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

    name: str = Field(description='Method name')
    full_name: str = Field(description='Full method name (/service/method)')
    request_type: str | None = Field(None, description='Request message type')
    response_type: str | None = Field(None, description='Response message type')
    streaming: bool | None = Field(None, description='Whether method uses streaming')
    auth_required: bool | None = Field(None, description='Whether authentication is required')



class ServiceDetail(BaseModel):
    """
    Detailed information about a service.

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

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

    name: str = Field(description='Service name')
    full_name: str = Field(description='Full service name with package')
    package: str = Field(description='Package name')
    description: str | None = Field(None, description='Service description from docstring')
    file_path: str | None = Field(None, description='Path to service file')
    class_name: str = Field(description='Service class name')
    base_class: str | None = Field(None, description='Base class name')
    methods: list[MethodInfo] | None = Field(None, description='Service methods')
    stats: ServiceStats = ...
    recent_errors: list[RecentError] | None = Field(None, description='Recent errors')



class GRPCServiceRegistryMethodStats(BaseModel):
    """
    Statistics for a single method.

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

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

    total_requests: int | None = Field(None, description='Total requests')
    successful: int | None = Field(None, description='Successful requests')
    errors: int | None = Field(None, description='Failed requests')
    success_rate: float | None = Field(None, description='Success rate percentage')
    avg_duration_ms: float | None = Field(None, description='Average duration in milliseconds')
    p50_duration_ms: float | None = Field(None, description='P50 duration in milliseconds')
    p95_duration_ms: float | None = Field(None, description='P95 duration in milliseconds')
    p99_duration_ms: float | None = Field(None, description='P99 duration in milliseconds')



class MethodSummary(BaseModel):
    """
    Summary information for a method.

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

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

    name: str = Field(description='Method name')
    full_name: str = Field(description='Full method path')
    service_name: str = Field(description='Service name')
    request_type: str | None = Field(None, description='Request message type')
    response_type: str | None = Field(None, description='Response message type')
    stats: GRPCServiceRegistryMethodStats = ...



class ServiceMethods(BaseModel):
    """
    List of methods for a service.

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

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

    service_name: str = Field(description='Service name')
    methods: list[MethodSummary] | None = Field(None, description='List of methods')
    total_methods: int = Field(description='Total number of methods')



