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

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


class PutScimV2UsersUserIDRequestTypedDict(TypedDict):
    user_id: str
    r"""The ID of the SCIM user to replace."""


class PutScimV2UsersUserIDRequest(BaseModel):
    user_id: Annotated[
        str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
    ]
    r"""The ID of the SCIM user to replace."""


class PutScimV2UsersUserIDNameTypedDict(TypedDict):
    given_name: str
    family_name: str


class PutScimV2UsersUserIDName(BaseModel):
    given_name: Annotated[str, pydantic.Field(alias="givenName")]

    family_name: Annotated[str, pydantic.Field(alias="familyName")]


class PutScimV2UsersUserIDEmailTypedDict(TypedDict):
    value: str
    primary: bool
    type: NotRequired[str]


class PutScimV2UsersUserIDEmail(BaseModel):
    value: str

    primary: bool

    type: Optional[str] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["type"])
        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 PutScimV2UsersUserIDRoleTypedDict(TypedDict):
    value: str
    primary: bool


class PutScimV2UsersUserIDRole(BaseModel):
    value: str

    primary: bool


class PutScimV2UsersUserIDMetaTypedDict(TypedDict):
    resource_type: str
    created: str
    last_modified: str


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

    created: str

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


class PutScimV2UsersUserIDResponseTypedDict(TypedDict):
    r"""Success"""

    schemas: List[str]
    id: str
    user_name: str
    name: PutScimV2UsersUserIDNameTypedDict
    emails: List[PutScimV2UsersUserIDEmailTypedDict]
    roles: List[PutScimV2UsersUserIDRoleTypedDict]
    profile_url: Nullable[str]
    active: bool
    meta: PutScimV2UsersUserIDMetaTypedDict


class PutScimV2UsersUserIDResponse(BaseModel):
    r"""Success"""

    schemas: List[str]

    id: str

    user_name: Annotated[str, pydantic.Field(alias="userName")]

    name: PutScimV2UsersUserIDName

    emails: List[PutScimV2UsersUserIDEmail]

    roles: List[PutScimV2UsersUserIDRole]

    profile_url: Annotated[Nullable[str], pydantic.Field(alias="profileUrl")]

    active: bool

    meta: PutScimV2UsersUserIDMeta

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        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:
                m[k] = val

        return m


try:
    PutScimV2UsersUserIDName.model_rebuild()
except NameError:
    pass
try:
    PutScimV2UsersUserIDMeta.model_rebuild()
except NameError:
    pass
try:
    PutScimV2UsersUserIDResponse.model_rebuild()
except NameError:
    pass
