# 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

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

from __future__ import annotations
from .. import BaseModel, UNSET_SENTINEL, UnrecognizedStr
from .filecontent import FileContent, FileContentParam
from pydantic import model_serializer
from typing import List, Literal, Optional, Union
from typing_extensions import NotRequired, TypedDict


Mode = Union[
    Literal[
        "scan",
        "verify",
    ],
    UnrecognizedStr,
]
r"""The mode of the find session."""


class FindRequestParam(TypedDict):
    r"""Request parameters specific to FIND sessions, used for discovering
    vulnerabilities in a codebase.
    """

    description: NotRequired[str]
    r"""Additional context or custom instructions provided by the user to guide
    the vulnerability analysis.
    """
    finding_id: NotRequired[str]
    r"""The identifier of a specific finding to verify. This is primarily used in
    VERIFY mode to focus the agent's execution-based validation on a single
    vulnerability.
    """
    mode: NotRequired[Mode]
    r"""The mode of the find session."""
    source_files: NotRequired[List[FileContentParam]]
    r"""A list of source files to provide as context for the scan."""


class FindRequest(BaseModel):
    r"""Request parameters specific to FIND sessions, used for discovering
    vulnerabilities in a codebase.
    """

    description: Optional[str] = None
    r"""Additional context or custom instructions provided by the user to guide
    the vulnerability analysis.
    """

    finding_id: Optional[str] = None
    r"""The identifier of a specific finding to verify. This is primarily used in
    VERIFY mode to focus the agent's execution-based validation on a single
    vulnerability.
    """

    mode: Optional[Mode] = None
    r"""The mode of the find session."""

    source_files: Optional[List[FileContent]] = None
    r"""A list of source files to provide as context for the scan."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["description", "finding_id", "mode", "source_files"])
        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
