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

from __future__ import annotations
from .v3_teams_addbulkteammemberrequest import (
    V3TeamsAddBulkTeamMemberRequest,
    V3TeamsAddBulkTeamMemberRequestTypedDict,
)
import pydantic
from pydantic import model_serializer
from squadcast.types import BaseModel, UNSET_SENTINEL
from squadcast.utils import FieldMetadata, PathParamMetadata, RequestMetadata
from typing import List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class TeamsAddBulkTeamMemberRequestTypedDict(TypedDict):
    team_id: str
    v3_teams_add_bulk_team_member_request: V3TeamsAddBulkTeamMemberRequestTypedDict


class TeamsAddBulkTeamMemberRequest(BaseModel):
    team_id: Annotated[
        str,
        pydantic.Field(alias="teamId"),
        FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
    ]

    v3_teams_add_bulk_team_member_request: Annotated[
        V3TeamsAddBulkTeamMemberRequest,
        FieldMetadata(request=RequestMetadata(media_type="application/json")),
    ]


class TeamsAddBulkTeamMemberMemberTypedDict(TypedDict):
    user_id: NotRequired[str]
    role_ids: NotRequired[List[str]]


class TeamsAddBulkTeamMemberMember(BaseModel):
    user_id: Optional[str] = None

    role_ids: Optional[List[str]] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["user_id", "role_ids"])
        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 TeamsAddBulkTeamMemberDataTypedDict(TypedDict):
    team_id: str
    members: List[TeamsAddBulkTeamMemberMemberTypedDict]


class TeamsAddBulkTeamMemberData(BaseModel):
    team_id: str

    members: List[TeamsAddBulkTeamMemberMember]


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

    data: TeamsAddBulkTeamMemberDataTypedDict


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

    data: TeamsAddBulkTeamMemberData
