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

from __future__ import annotations
from .v3_services_serviceresponse import (
    V3ServicesServiceResponse,
    V3ServicesServiceResponseTypedDict,
)
from pydantic import model_serializer
from squadcast.types import BaseModel, UNSET_SENTINEL
from squadcast.utils import FieldMetadata, QueryParamMetadata
from typing import List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class ServicesGetServicesRequestTypedDict(TypedDict):
    owner_id: str
    entity_owner: NotRequired[str]
    name: NotRequired[str]


class ServicesGetServicesRequest(BaseModel):
    owner_id: Annotated[
        str, FieldMetadata(query=QueryParamMetadata(style="form", explode=False))
    ]

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

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

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["entity_owner", "name"])
        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 ServicesGetServicesResponseTypedDict(TypedDict):
    r"""The request has succeeded."""

    data: List[V3ServicesServiceResponseTypedDict]


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

    data: List[V3ServicesServiceResponse]
