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

from __future__ import annotations
from datetime import datetime
import pydantic
from pydantic import model_serializer
from squadcast_sdk.types import BaseModel, UNSET_SENTINEL
from typing import List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class V4StatusPagesIssuesCreateIssueRequestComponentTypedDict(TypedDict):
    id: NotRequired[int]
    status_id: NotRequired[int]


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

    status_id: Annotated[Optional[int], pydantic.Field(alias="statusID")] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["id", "statusID"])
        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


class V4StatusPagesIssuesCreateIssueRequestStateMessageTypedDict(TypedDict):
    text: NotRequired[str]
    timestamp: NotRequired[datetime]


class V4StatusPagesIssuesCreateIssueRequestStateMessage(BaseModel):
    text: Optional[str] = None

    timestamp: Optional[datetime] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["text", "timestamp"])
        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


class V4StatusPagesIssuesCreateIssueRequestIssueTypedDict(TypedDict):
    state_id: NotRequired[int]
    state_messages: NotRequired[
        List[V4StatusPagesIssuesCreateIssueRequestStateMessageTypedDict]
    ]


class V4StatusPagesIssuesCreateIssueRequestIssue(BaseModel):
    state_id: Annotated[Optional[int], pydantic.Field(alias="stateID")] = None

    state_messages: Annotated[
        Optional[List[V4StatusPagesIssuesCreateIssueRequestStateMessage]],
        pydantic.Field(alias="stateMessages"),
    ] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["stateID", "stateMessages"])
        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


class V4StatusPagesIssuesCreateIssueRequestTypedDict(TypedDict):
    title: str
    components: List[V4StatusPagesIssuesCreateIssueRequestComponentTypedDict]
    issues: List[V4StatusPagesIssuesCreateIssueRequestIssueTypedDict]
    status_id: NotRequired[int]


class V4StatusPagesIssuesCreateIssueRequest(BaseModel):
    title: str

    components: List[V4StatusPagesIssuesCreateIssueRequestComponent]

    issues: List[V4StatusPagesIssuesCreateIssueRequestIssue]

    status_id: Annotated[Optional[int], pydantic.Field(alias="statusID")] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["statusID"])
        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:
    V4StatusPagesIssuesCreateIssueRequestComponent.model_rebuild()
except NameError:
    pass
try:
    V4StatusPagesIssuesCreateIssueRequestIssue.model_rebuild()
except NameError:
    pass
try:
    V4StatusPagesIssuesCreateIssueRequest.model_rebuild()
except NameError:
    pass
