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

from __future__ import annotations
from .v3_escalationpolicies_escalationpolicyresponse import (
    V3EscalationPoliciesEscalationPolicyResponse,
    V3EscalationPoliciesEscalationPolicyResponseTypedDict,
)
from pydantic import model_serializer
from squadcast.types import BaseModel, UNSET_SENTINEL
from squadcast.utils import FieldMetadata, QueryParamMetadata
from typing import Callable, List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class EscalationPoliciesGetEscalationPolicyByTeamRequestTypedDict(TypedDict):
    owner_id: str
    r"""here owner_id represents team_id, if  team_id is not provided, it will return escalation policies of all teams."""
    page_number: NotRequired[int]
    page_size: NotRequired[int]


class EscalationPoliciesGetEscalationPolicyByTeamRequest(BaseModel):
    owner_id: Annotated[
        str, FieldMetadata(query=QueryParamMetadata(style="form", explode=True))
    ]
    r"""here owner_id represents team_id, if  team_id is not provided, it will return escalation policies of all teams."""

    page_number: Annotated[
        Optional[int],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    page_size: Annotated[
        Optional[int],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["page_number", "page_size"])
        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 EscalationPoliciesGetEscalationPolicyByTeamMetaTypedDict(TypedDict):
    total_count: int


class EscalationPoliciesGetEscalationPolicyByTeamMeta(BaseModel):
    total_count: int


class EscalationPoliciesGetEscalationPolicyByTeamResponseBodyTypedDict(TypedDict):
    r"""The request has succeeded."""

    data: List[V3EscalationPoliciesEscalationPolicyResponseTypedDict]
    meta: EscalationPoliciesGetEscalationPolicyByTeamMetaTypedDict


class EscalationPoliciesGetEscalationPolicyByTeamResponseBody(BaseModel):
    r"""The request has succeeded."""

    data: List[V3EscalationPoliciesEscalationPolicyResponse]

    meta: EscalationPoliciesGetEscalationPolicyByTeamMeta


class EscalationPoliciesGetEscalationPolicyByTeamResponseTypedDict(TypedDict):
    result: EscalationPoliciesGetEscalationPolicyByTeamResponseBodyTypedDict


class EscalationPoliciesGetEscalationPolicyByTeamResponse(BaseModel):
    next: Callable[[], Optional[EscalationPoliciesGetEscalationPolicyByTeamResponse]]

    result: EscalationPoliciesGetEscalationPolicyByTeamResponseBody
