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

from __future__ import annotations
from .v3_workflows_getworkflowlogsresponse import (
    V3WorkflowsGetWorkflowLogsResponse,
    V3WorkflowsGetWorkflowLogsResponseTypedDict,
)
import pydantic
from pydantic import model_serializer
from squadcast.types import BaseModel, UNSET_SENTINEL
from squadcast.utils import FieldMetadata, PathParamMetadata, QueryParamMetadata
from typing import Callable, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class WorkflowsGetWorkflowLogsRequestTypedDict(TypedDict):
    workflow_id: str
    page_size: NotRequired[int]
    page_number: NotRequired[int]


class WorkflowsGetWorkflowLogsRequest(BaseModel):
    workflow_id: Annotated[
        str,
        pydantic.Field(alias="workflowID"),
        FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
    ]

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

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

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


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

    result: V3WorkflowsGetWorkflowLogsResponse
