"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from .v4_statuspages_components_componentstatus import (
    V4StatusPagesComponentsComponentStatus,
    V4StatusPagesComponentsComponentStatusTypedDict,
)
import pydantic
from pydantic import model_serializer
from squadcast.types import BaseModel, UNSET_SENTINEL
from typing import List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class V4StatusPagesComponentsComponentTypedDict(TypedDict):
    id: NotRequired[int]
    type: NotRequired[str]
    name: NotRequired[str]
    allow_subscription: NotRequired[bool]
    description: NotRequired[str]
    status: NotRequired[V4StatusPagesComponentsComponentStatusTypedDict]
    under_maintenance: NotRequired[bool]
    status_maintenance: NotRequired[V4StatusPagesComponentsComponentStatusTypedDict]
    components: NotRequired[List[V4StatusPagesComponentsComponentTypedDict]]
    is_hidden: NotRequired[bool]


class V4StatusPagesComponentsComponent(BaseModel):
    id: Optional[int] = None

    type: Optional[str] = None

    name: Optional[str] = None

    allow_subscription: Annotated[
        Optional[bool], pydantic.Field(alias="allowSubscription")
    ] = None

    description: Optional[str] = None

    status: Optional[V4StatusPagesComponentsComponentStatus] = None

    under_maintenance: Annotated[
        Optional[bool], pydantic.Field(alias="underMaintenance")
    ] = None

    status_maintenance: Annotated[
        Optional[V4StatusPagesComponentsComponentStatus],
        pydantic.Field(alias="statusMaintenance"),
    ] = None

    components: Optional[List[V4StatusPagesComponentsComponent]] = None

    is_hidden: Annotated[Optional[bool], pydantic.Field(alias="isHidden")] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "id",
                "type",
                "name",
                "allowSubscription",
                "description",
                "status",
                "underMaintenance",
                "statusMaintenance",
                "components",
                "isHidden",
            ]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k, serialized.get(n))

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


try:
    V4StatusPagesComponentsComponent.model_rebuild()
except NameError:
    pass
