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

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


class PostScimV2GroupsMemberTypedDict(TypedDict):
    value: str
    dollar_ref: str
    display: NotRequired[str]


class PostScimV2GroupsMember(BaseModel):
    value: str

    dollar_ref: Annotated[str, pydantic.Field(alias="$ref")]

    display: Optional[str] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["display"])
        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 PostScimV2GroupsMetaTypedDict(TypedDict):
    resource_type: str
    created: str
    last_modified: str


class PostScimV2GroupsMeta(BaseModel):
    resource_type: Annotated[str, pydantic.Field(alias="resourceType")]

    created: str

    last_modified: Annotated[str, pydantic.Field(alias="lastModified")]


class PostScimV2GroupsResponseTypedDict(TypedDict):
    r"""Created"""

    schemas: List[str]
    id: str
    display_name: str
    members: List[PostScimV2GroupsMemberTypedDict]
    meta: PostScimV2GroupsMetaTypedDict


class PostScimV2GroupsResponse(BaseModel):
    r"""Created"""

    schemas: List[str]

    id: str

    display_name: Annotated[str, pydantic.Field(alias="displayName")]

    members: List[PostScimV2GroupsMember]

    meta: PostScimV2GroupsMeta


try:
    PostScimV2GroupsMember.model_rebuild()
except NameError:
    pass
try:
    PostScimV2GroupsMeta.model_rebuild()
except NameError:
    pass
try:
    PostScimV2GroupsResponse.model_rebuild()
except NameError:
    pass
