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

import datetime as dt
import typing

import pydantic
import typing_extensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from ..core.serialization import FieldMetadata
from .function_code_package_response_body import FunctionCodePackageResponseBody
from .function_config_response_body import FunctionConfigResponseBody
from .function_effects_response_body import FunctionEffectsResponseBody


class CreateFunctionDetailResponseBody(UniversalBaseModel):
    """
    Details of a newly created Function, including a URL for uploading the code package. After uploading, call the deploy endpoint to make the function runnable.
    """

    code_package: typing_extensions.Annotated[
        FunctionCodePackageResponseBody, FieldMetadata(alias="codePackage"), pydantic.Field(alias="codePackage")
    ]
    config: FunctionConfigResponseBody
    created_at_time: typing_extensions.Annotated[
        dt.datetime,
        FieldMetadata(alias="createdAtTime"),
        pydantic.Field(alias="createdAtTime", description="RFC 3339 timestamp when the Function was created."),
    ]
    description: typing.Optional[str] = pydantic.Field(default=None)
    """
    Description of the Function.
    """

    effects: FunctionEffectsResponseBody
    last_update_timestamp_ms: typing_extensions.Annotated[
        int,
        FieldMetadata(alias="lastUpdateTimestampMs"),
        pydantic.Field(
            alias="lastUpdateTimestampMs",
            description="Epoch milliseconds of the last update. Use this value for optimistic locking in PATCH requests.",
        ),
    ]
    name: str = pydantic.Field()
    """
    Name of the Function.
    """

    updated_at_time: typing_extensions.Annotated[
        dt.datetime,
        FieldMetadata(alias="updatedAtTime"),
        pydantic.Field(alias="updatedAtTime", description="RFC 3339 timestamp when the Function was last updated."),
    ]
    upload_put_url: typing_extensions.Annotated[
        str,
        FieldMetadata(alias="uploadPutUrl"),
        pydantic.Field(
            alias="uploadPutUrl",
            description="A presigned PUT URL for uploading the function's code package. Valid for a limited time. After uploading, call `POST /functions/{name}/deploy` to make the function runnable.",
        ),
    ]

    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
