# This file was auto-generated by Fern from our API Definition.

from ..core.pydantic_utilities import UniversalBaseModel
from .model_provider_connection_provider import ModelProviderConnectionProvider
import typing
from .model_provider_connection_scope import ModelProviderConnectionScope
from .model_provider_connection_organization import ModelProviderConnectionOrganization
from .model_provider_connection_created_by import ModelProviderConnectionCreatedBy
import datetime as dt
import pydantic
from .model_provider_connection_budget_reset_period import ModelProviderConnectionBudgetResetPeriod
from ..core.pydantic_utilities import IS_PYDANTIC_V2


class ModelProviderConnection(UniversalBaseModel):
    provider: ModelProviderConnectionProvider
    api_key: typing.Optional[str] = None
    deployment_name: typing.Optional[str] = None
    endpoint: typing.Optional[str] = None
    scope: typing.Optional[ModelProviderConnectionScope] = None
    organization: typing.Optional[ModelProviderConnectionOrganization] = None
    created_by: typing.Optional[ModelProviderConnectionCreatedBy] = None
    created_at: typing.Optional[dt.datetime] = None
    updated_at: typing.Optional[dt.datetime] = None
    is_internal: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Whether the model provider connection is internal, not visible to the user.
    """

    budget_limit: typing.Optional[float] = pydantic.Field(default=None)
    """
    Budget limit for the model provider connection (null if unlimited)
    """

    budget_last_reset_date: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    Date and time the budget was last reset
    """

    budget_reset_period: typing.Optional[ModelProviderConnectionBudgetResetPeriod] = pydantic.Field(default=None)
    """
    Budget reset period for the model provider connection (null if not reset)
    """

    budget_total_spent: typing.Optional[float] = pydantic.Field(default=None)
    """
    Tracked total budget spent for the given provider connection within the current budget period
    """

    budget_alert_threshold: typing.Optional[float] = pydantic.Field(default=None)
    """
    Budget alert threshold for the given provider connection
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
