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

from __future__ import annotations
import httpx
from leonardo_ai_sdk.types import (
    BaseModel,
    Nullable,
    OptionalNullable,
    UNSET,
    UNSET_SENTINEL,
)
import pydantic
from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class UsersTypedDict(TypedDict):
    r"""columns and relationships of \"users\" """

    id: NotRequired[Nullable[str]]
    username: NotRequired[Nullable[str]]
    r"""Username of the user."""


class Users(BaseModel):
    r"""columns and relationships of \"users\" """

    id: OptionalNullable[str] = UNSET

    username: OptionalNullable[str] = UNSET
    r"""Username of the user."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["id", "username"]
        nullable_fields = ["id", "username"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class UserDetailsTypedDict(TypedDict):
    r"""columns and relationships of \"user_details\" """

    api_concurrency_slots: NotRequired[int]
    r"""API Concurrency Slots."""
    api_paid_tokens: NotRequired[Nullable[int]]
    r"""Current balance of API paid tokens the user has."""
    api_plan_token_renewal_date: NotRequired[Nullable[str]]
    r"""API Plan Token Renewal Date."""
    api_subscription_tokens: NotRequired[int]
    r"""Current balance of Enterprise API subscriptions tokens the user has."""
    paid_tokens: NotRequired[Nullable[int]]
    r"""Current balance of paid tokens the user has."""
    subscription_gpt_tokens: NotRequired[int]
    r"""Current balance of user plan GPT tokens the user has."""
    subscription_model_tokens: NotRequired[int]
    r"""Current balance of model training tokens the user has."""
    subscription_tokens: NotRequired[int]
    r"""Current balance of user plan subscription tokens the user has."""
    token_renewal_date: NotRequired[Nullable[str]]
    r"""User Plan Token Renewal Date."""
    user: NotRequired[Nullable[UsersTypedDict]]
    r"""columns and relationships of \"users\" """


class UserDetails(BaseModel):
    r"""columns and relationships of \"user_details\" """

    api_concurrency_slots: Annotated[
        Optional[int], pydantic.Field(alias="apiConcurrencySlots")
    ] = None
    r"""API Concurrency Slots."""

    api_paid_tokens: Annotated[
        OptionalNullable[int], pydantic.Field(alias="apiPaidTokens")
    ] = UNSET
    r"""Current balance of API paid tokens the user has."""

    api_plan_token_renewal_date: Annotated[
        OptionalNullable[str], pydantic.Field(alias="apiPlanTokenRenewalDate")
    ] = UNSET
    r"""API Plan Token Renewal Date."""

    api_subscription_tokens: Annotated[
        Optional[int], pydantic.Field(alias="apiSubscriptionTokens")
    ] = None
    r"""Current balance of Enterprise API subscriptions tokens the user has."""

    paid_tokens: Annotated[
        OptionalNullable[int], pydantic.Field(alias="paidTokens")
    ] = UNSET
    r"""Current balance of paid tokens the user has."""

    subscription_gpt_tokens: Annotated[
        Optional[int], pydantic.Field(alias="subscriptionGptTokens")
    ] = None
    r"""Current balance of user plan GPT tokens the user has."""

    subscription_model_tokens: Annotated[
        Optional[int], pydantic.Field(alias="subscriptionModelTokens")
    ] = None
    r"""Current balance of model training tokens the user has."""

    subscription_tokens: Annotated[
        Optional[int], pydantic.Field(alias="subscriptionTokens")
    ] = None
    r"""Current balance of user plan subscription tokens the user has."""

    token_renewal_date: Annotated[
        OptionalNullable[str], pydantic.Field(alias="tokenRenewalDate")
    ] = UNSET
    r"""User Plan Token Renewal Date."""

    user: OptionalNullable[Users] = UNSET
    r"""columns and relationships of \"users\" """

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "apiConcurrencySlots",
            "apiPaidTokens",
            "apiPlanTokenRenewalDate",
            "apiSubscriptionTokens",
            "paidTokens",
            "subscriptionGptTokens",
            "subscriptionModelTokens",
            "subscriptionTokens",
            "tokenRenewalDate",
            "user",
        ]
        nullable_fields = [
            "apiPaidTokens",
            "apiPlanTokenRenewalDate",
            "paidTokens",
            "tokenRenewalDate",
            "user",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class GetUserSelfResponseBodyTypedDict(TypedDict):
    r"""Responses for GET /me"""

    user_details: NotRequired[List[UserDetailsTypedDict]]


class GetUserSelfResponseBody(BaseModel):
    r"""Responses for GET /me"""

    user_details: Optional[List[UserDetails]] = None


class GetUserSelfResponseTypedDict(TypedDict):
    content_type: str
    r"""HTTP response content type for this operation"""
    status_code: int
    r"""HTTP response status code for this operation"""
    raw_response: httpx.Response
    r"""Raw HTTP response; suitable for custom response parsing"""
    object: NotRequired[GetUserSelfResponseBodyTypedDict]
    r"""Responses for GET /me"""


class GetUserSelfResponse(BaseModel):
    content_type: str
    r"""HTTP response content type for this operation"""

    status_code: int
    r"""HTTP response status code for this operation"""

    raw_response: httpx.Response
    r"""Raw HTTP response; suitable for custom response parsing"""

    object: Optional[GetUserSelfResponseBody] = None
    r"""Responses for GET /me"""
