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

import datetime as dt
import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .json_list_string_write import JsonListStringWrite
from .optimization_studio_config_write import OptimizationStudioConfigWrite
from .optimization_write_status import OptimizationWriteStatus


class OptimizationWrite(UniversalBaseModel):
    id: typing.Optional[str] = None
    name: typing.Optional[str] = None
    dataset_name: str
    project_name: typing.Optional[str] = pydantic.Field(default=None)
    """
    Project name. Creates project if it doesn't exist. Ignored when project_id is provided.
    """

    project_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    Project ID. Takes precedence over project_name when both are provided.
    """

    objective_name: str
    status: OptimizationWriteStatus
    metadata: typing.Optional[JsonListStringWrite] = None
    studio_config: typing.Optional[OptimizationStudioConfigWrite] = None
    last_updated_at: typing.Optional[dt.datetime] = None

    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
