# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# pyformat: disable
# pylint: skip-file

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

from __future__ import annotations
from ..types import BaseModel, UNSET_SENTINEL, current_exclude_none, serialize_with_info
from ..types.basemodel import (
    current_by_alias,
    current_filtered_dump,
    current_serialization_methods_dump,
)
from ..utils import FieldMetadata, PathParamMetadata, QueryParamMetadata
import pydantic
from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class ListVoicesGlobalsTypedDict(TypedDict):
    api_version: NotRequired[str]
    r"""API version for request routing."""


class ListVoicesGlobals(BaseModel):
    api_version: Annotated[
        Optional[str],
        FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
    ] = None
    r"""API version for request routing."""

    @model_serializer(mode="wrap")
    def _serialize_model_with_info(self, handler, info):
        return serialize_with_info(self.serialize_model, handler, info)

    def serialize_model(self, handler):
        optional_fields = set(["api_version"])
        exclude_none = current_exclude_none()
        by_alias = current_by_alias()
        use_field_names = by_alias is False
        serialization_methods_dump = current_serialization_methods_dump()
        skip_filtered = (
            serialization_methods_dump
            or exclude_none is False
            or current_filtered_dump()
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias if f.alias is not None else n
            key = k if by_alias or k in serialized else n
            if key not in serialized and skip_filtered:
                continue
            val = serialized.pop(key, None)

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[n if use_field_names else k] = val
        for k, v in serialized.items():
            m[k] = v

        return m


class ListVoicesRequestParam(TypedDict):
    api_version: NotRequired[str]
    r"""API version for request routing."""
    accent: NotRequired[List[str]]
    r"""Optional. Filter by accent description (e.g. \"American\", \"British\").
    Case-insensitive exact match. If multiple values are specified, matches
    voices with any of the specified accents (OR).
    """
    contexts: NotRequired[List[str]]
    r"""Optional. Filter by intended context or domain (e.g. \"News, Commercial\").
    Case-insensitive exact match. If multiple values are specified, matches
    voices with any of the specified contexts (OR).
    """
    gender: NotRequired[List[str]]
    r"""Optional. Filter by gender presentation (e.g. \"female\", \"male\", \"neutral\").
    Case-insensitive exact match. If multiple values are specified, matches
    voices with any of the specified genders (OR).
    """
    language_code: NotRequired[List[str]]
    r"""Optional. Filter by BCP-47 language code (e.g. \"en-US\").
    Case-insensitive exact match. If multiple values are specified, matches
    voices with any of the specified language codes (OR).
    """
    page_size: NotRequired[int]
    r"""Optional. The maximum number of voices to return per page. The service may
    return fewer than this value. If unspecified, at most 50 voices are
    returned. The maximum value is 1000; values above 1000 are coerced to
    1000.
    """
    page_token: NotRequired[str]
    r"""Optional. A page token received from a previous `ListVoices` call. Provide
    this to retrieve the subsequent page.

    When paginating, all filter query parameters (`language_code`,
    `region_code`, `accent`, `persona`, `context`, `gender`, `pitch`, `type`,
    and `search`) must match the call that returned this token; otherwise the
    request fails with `INVALID_ARGUMENT`. `page_size` may change between
    pages.
    """
    persona: NotRequired[List[str]]
    r"""Optional. Filter by vocal persona (e.g. \"Warm, Friendly\").
    Case-insensitive exact match. If multiple values are specified, matches
    voices with any of the specified personas (OR).
    """
    pitch: NotRequired[List[str]]
    r"""Optional. Filter by vocal pitch. Accepts `\"low\"`, `\"medium\"`, `\"high\"`
    (case-insensitive). If multiple values are specified, matches voices with
    any of the specified pitches (OR).
    """
    region_code: NotRequired[List[str]]
    r"""Optional. Filter by ISO 3166-1 alpha-2 or UN M.49 region code (e.g. \"US\",
    \"001\").
    Case-insensitive exact match. If multiple values are specified, matches
    voices with any of the specified region codes (OR).
    """
    search: NotRequired[str]
    r"""Optional. Free-text substring search query matched case-insensitively
    against both `display_name` and `description`. Maximum 2048 bytes.
    """
    type: NotRequired[List[str]]
    r"""Optional. Filter by voice type. Accepts `\"prebuilt\"`, `\"replicated\"`,
    `\"prompted\"` (case-insensitive). If multiple values are specified, matches
    voices with any of the specified types (OR).
    """


class ListVoicesRequest(BaseModel):
    api_version: Annotated[
        Optional[str],
        FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
    ] = None
    r"""API version for request routing."""

    accent: Annotated[
        Optional[List[str]],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Optional. Filter by accent description (e.g. \"American\", \"British\").
    Case-insensitive exact match. If multiple values are specified, matches
    voices with any of the specified accents (OR).
    """

    contexts: Annotated[
        Optional[List[str]],
        pydantic.Field(alias="context"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Optional. Filter by intended context or domain (e.g. \"News, Commercial\").
    Case-insensitive exact match. If multiple values are specified, matches
    voices with any of the specified contexts (OR).
    """

    gender: Annotated[
        Optional[List[str]],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Optional. Filter by gender presentation (e.g. \"female\", \"male\", \"neutral\").
    Case-insensitive exact match. If multiple values are specified, matches
    voices with any of the specified genders (OR).
    """

    language_code: Annotated[
        Optional[List[str]],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Optional. Filter by BCP-47 language code (e.g. \"en-US\").
    Case-insensitive exact match. If multiple values are specified, matches
    voices with any of the specified language codes (OR).
    """

    page_size: Annotated[
        Optional[int],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Optional. The maximum number of voices to return per page. The service may
    return fewer than this value. If unspecified, at most 50 voices are
    returned. The maximum value is 1000; values above 1000 are coerced to
    1000.
    """

    page_token: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Optional. A page token received from a previous `ListVoices` call. Provide
    this to retrieve the subsequent page.

    When paginating, all filter query parameters (`language_code`,
    `region_code`, `accent`, `persona`, `context`, `gender`, `pitch`, `type`,
    and `search`) must match the call that returned this token; otherwise the
    request fails with `INVALID_ARGUMENT`. `page_size` may change between
    pages.
    """

    persona: Annotated[
        Optional[List[str]],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Optional. Filter by vocal persona (e.g. \"Warm, Friendly\").
    Case-insensitive exact match. If multiple values are specified, matches
    voices with any of the specified personas (OR).
    """

    pitch: Annotated[
        Optional[List[str]],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Optional. Filter by vocal pitch. Accepts `\"low\"`, `\"medium\"`, `\"high\"`
    (case-insensitive). If multiple values are specified, matches voices with
    any of the specified pitches (OR).
    """

    region_code: Annotated[
        Optional[List[str]],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Optional. Filter by ISO 3166-1 alpha-2 or UN M.49 region code (e.g. \"US\",
    \"001\").
    Case-insensitive exact match. If multiple values are specified, matches
    voices with any of the specified region codes (OR).
    """

    search: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Optional. Free-text substring search query matched case-insensitively
    against both `display_name` and `description`. Maximum 2048 bytes.
    """

    type: Annotated[
        Optional[List[str]],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Optional. Filter by voice type. Accepts `\"prebuilt\"`, `\"replicated\"`,
    `\"prompted\"` (case-insensitive). If multiple values are specified, matches
    voices with any of the specified types (OR).
    """

    @model_serializer(mode="wrap")
    def _serialize_model_with_info(self, handler, info):
        return serialize_with_info(self.serialize_model, handler, info)

    def serialize_model(self, handler):
        optional_fields = set(
            [
                "api_version",
                "accent",
                "contexts",
                "gender",
                "language_code",
                "page_size",
                "page_token",
                "persona",
                "pitch",
                "region_code",
                "search",
                "type",
            ]
        )
        exclude_none = current_exclude_none()
        by_alias = current_by_alias()
        use_field_names = by_alias is False
        serialization_methods_dump = current_serialization_methods_dump()
        skip_filtered = (
            serialization_methods_dump
            or exclude_none is False
            or current_filtered_dump()
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias if f.alias is not None else n
            key = k if by_alias or k in serialized else n
            if key not in serialized and skip_filtered:
                continue
            val = serialized.pop(key, None)

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[n if use_field_names else k] = val
        for k, v in serialized.items():
            m[k] = v

        return m
