# 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
from ..utils import (
    FieldMetadata,
    HeaderMetadata,
    PathParamMetadata,
    QueryParamMetadata,
    validate_const,
)
import pydantic
from pydantic import model_serializer
from pydantic.functional_validators import AfterValidator
from typing import Dict, List, Literal, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


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


class StartEnvironmentFileUploadGlobals(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(self, handler):
        optional_fields = set(["api_version"])
        serialized = handler(self)
        m = {}

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

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


class StartEnvironmentFileUploadRequestParam(TypedDict):
    environment: str
    r"""The ID of the environment that owns the destination file."""
    path: str
    r"""The relative destination path inside the environment workspace."""
    x_goog_upload_header_content_length: int
    r"""Total number of file bytes that will be uploaded to the session URL."""
    x_goog_upload_header_content_type: str
    r"""MIME type of the file that will be uploaded to the session URL."""
    api_version: NotRequired[str]
    r"""API version for request routing."""
    extract: NotRequired[bool]
    r"""Optional. If true, treats the uploaded file as a tar/tar.gz archive and unpacks it into `path`."""
    overwrite: NotRequired[bool]
    r"""Optional. Whether to overwrite the destination file if it already exists."""
    x_goog_upload_command: Literal["start"]
    r"""Command that starts the resumable upload session."""
    x_goog_upload_protocol: Literal["resumable"]
    r"""Resumable upload protocol selector."""


class StartEnvironmentFileUploadRequest(BaseModel):
    environment: Annotated[
        str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
    ]
    r"""The ID of the environment that owns the destination file."""

    path: Annotated[
        str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
    ]
    r"""The relative destination path inside the environment workspace."""

    x_goog_upload_header_content_length: Annotated[
        int,
        pydantic.Field(alias="X-Goog-Upload-Header-Content-Length"),
        FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
    ]
    r"""Total number of file bytes that will be uploaded to the session URL."""

    x_goog_upload_header_content_type: Annotated[
        str,
        pydantic.Field(alias="X-Goog-Upload-Header-Content-Type"),
        FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
    ]
    r"""MIME type of the file that will be uploaded to the session URL."""

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

    extract: Annotated[
        Optional[bool],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Optional. If true, treats the uploaded file as a tar/tar.gz archive and unpacks it into `path`."""

    overwrite: Annotated[
        Optional[bool],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Optional. Whether to overwrite the destination file if it already exists."""

    x_goog_upload_command: Annotated[
        Annotated[Literal["start"], AfterValidator(validate_const("start"))],
        pydantic.Field(alias="X-Goog-Upload-Command"),
        FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
    ] = "start"
    r"""Command that starts the resumable upload session."""

    x_goog_upload_protocol: Annotated[
        Annotated[Literal["resumable"], AfterValidator(validate_const("resumable"))],
        pydantic.Field(alias="X-Goog-Upload-Protocol"),
        FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
    ] = "resumable"
    r"""Resumable upload protocol selector."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["api_version", "extract", "overwrite"])
        serialized = handler(self)
        m = {}

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

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


class StartEnvironmentFileUploadResponseTypedDict(TypedDict):
    headers: Dict[str, List[str]]


class StartEnvironmentFileUploadResponse(BaseModel):
    headers: Dict[str, List[str]]


try:
    StartEnvironmentFileUploadRequest.model_rebuild()
except NameError:
    pass
