# Copyright (c) 2025-2026 Buf Technologies, Inc.
#
# 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.

# Generated from google/protobuf/compiler/plugin.proto. DO NOT EDIT.
# Generated by protoc-gen-py v0.1.1 with parameter "no_fmt_off".
# ruff: noqa: PGH004
# ruff: noqa

from __future__ import annotations

from typing import Literal, TYPE_CHECKING, TypeAlias

from protobuf import Enum, Message
from protobuf._codegen import file_desc

from .. import descriptor_pb

if TYPE_CHECKING:
    from protobuf import DescFile

    from ..descriptor_pb import FileDescriptorProto, GeneratedCodeInfo


_VersionFields: TypeAlias = Literal["major", "minor", "patch", "suffix"]


class Version(Message[_VersionFields]):
    """
    The version number of protocol compiler.

    ```proto
    message google.protobuf.compiler.Version
    ```

    Attributes:
        major:
            ```proto
            optional int32 major = 1;
            ```
        minor:
            ```proto
            optional int32 minor = 2;
            ```
        patch:
            ```proto
            optional int32 patch = 3;
            ```
        suffix:
            A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should
            be empty for mainline stable releases.

            ```proto
            optional string suffix = 4;
            ```
    """

    __slots__ = ("major", "minor", "patch", "suffix")

    if TYPE_CHECKING:

        def __init__(
            self,
            *,
            major: int | None = None,
            minor: int | None = None,
            patch: int | None = None,
            suffix: str | None = None,
        ) -> None:
            pass

        major: int
        minor: int
        patch: int
        suffix: str


_CodeGeneratorRequestFields: TypeAlias = Literal[
    "file_to_generate",
    "parameter",
    "proto_file",
    "source_file_descriptors",
    "compiler_version",
]


class CodeGeneratorRequest(Message[_CodeGeneratorRequestFields]):
    """
    An encoded CodeGeneratorRequest is written to the plugin's stdin.

    ```proto
    message google.protobuf.compiler.CodeGeneratorRequest
    ```

    Attributes:
        file_to_generate:
            The .proto files that were explicitly listed on the command-line.  The
            code generator should generate code only for these files.  Each file's
            descriptor will be included in proto_file, below.

            ```proto
            repeated string file_to_generate = 1;
            ```
        parameter:
            The generator parameter passed on the command-line.

            ```proto
            optional string parameter = 2;
            ```
        proto_file:
            FileDescriptorProtos for all files in files_to_generate and everything
            they import.  The files will appear in topological order, so each file
            appears before any file that imports it.

            Note: the files listed in files_to_generate will include runtime-retention
            options only, but all other files will include source-retention options.
            The source_file_descriptors field below is available in case you need
            source-retention options for files_to_generate.

            protoc guarantees that all proto_files will be written after
            the fields above, even though this is not technically guaranteed by the
            protobuf wire format.  This theoretically could allow a plugin to stream
            in the FileDescriptorProtos and handle them one by one rather than read
            the entire set into memory at once.  However, as of this writing, this
            is not similarly optimized on protoc's end -- it will store all fields in
            memory at once before sending them to the plugin.

            Type names of fields and extensions in the FileDescriptorProto are always
            fully qualified.

            ```proto
            repeated google.protobuf.FileDescriptorProto proto_file = 15;
            ```
        source_file_descriptors:
            File descriptors with all options, including source-retention options.
            These descriptors are only provided for the files listed in
            files_to_generate.

            ```proto
            repeated google.protobuf.FileDescriptorProto source_file_descriptors = 17;
            ```
        compiler_version:
            The version number of protocol compiler.

            ```proto
            optional google.protobuf.compiler.Version compiler_version = 3;
            ```
    """

    __slots__ = (
        "file_to_generate",
        "parameter",
        "proto_file",
        "source_file_descriptors",
        "compiler_version",
    )

    if TYPE_CHECKING:

        def __init__(
            self,
            *,
            file_to_generate: list[str] | None = None,
            parameter: str | None = None,
            proto_file: list[FileDescriptorProto] | None = None,
            source_file_descriptors: list[FileDescriptorProto] | None = None,
            compiler_version: Version | None = None,
        ) -> None:
            pass

        file_to_generate: list[str]
        parameter: str
        proto_file: list[FileDescriptorProto]
        source_file_descriptors: list[FileDescriptorProto]
        compiler_version: Version | None


_CodeGeneratorResponseFields: TypeAlias = Literal[
    "error", "supported_features", "minimum_edition", "maximum_edition", "file"
]


class CodeGeneratorResponse(Message[_CodeGeneratorResponseFields]):
    """
    The plugin writes an encoded CodeGeneratorResponse to stdout.

    ```proto
    message google.protobuf.compiler.CodeGeneratorResponse
    ```

    Attributes:
        error:
            Error message.  If non-empty, code generation failed.  The plugin process
            should exit with status code zero even if it reports an error in this way.

            This should be used to indicate errors in .proto files which prevent the
            code generator from generating correct code.  Errors which indicate a
            problem in protoc itself -- such as the input CodeGeneratorRequest being
            unparseable -- should be reported by writing a message to stderr and
            exiting with a non-zero status code.

            ```proto
            optional string error = 1;
            ```
        supported_features:
            A bitmask of supported features that the code generator supports.
            This is a bitwise "or" of values from the Feature enum.

            ```proto
            optional uint64 supported_features = 2;
            ```
        minimum_edition:
            The minimum edition this plugin supports.  This will be treated as an
            Edition enum, but we want to allow unknown values.  It should be specified
            according the edition enum value, *not* the edition number.  Only takes
            effect for plugins that have FEATURE_SUPPORTS_EDITIONS set.

            ```proto
            optional int32 minimum_edition = 3;
            ```
        maximum_edition:
            The maximum edition this plugin supports.  This will be treated as an
            Edition enum, but we want to allow unknown values.  It should be specified
            according the edition enum value, *not* the edition number.  Only takes
            effect for plugins that have FEATURE_SUPPORTS_EDITIONS set.

            ```proto
            optional int32 maximum_edition = 4;
            ```
        file:
            ```proto
            repeated google.protobuf.compiler.CodeGeneratorResponse.File file = 15;
            ```
    """

    __slots__ = (
        "error",
        "supported_features",
        "minimum_edition",
        "maximum_edition",
        "file",
    )

    if TYPE_CHECKING:

        def __init__(
            self,
            *,
            error: str | None = None,
            supported_features: int | None = None,
            minimum_edition: int | None = None,
            maximum_edition: int | None = None,
            file: list[CodeGeneratorResponse.File] | None = None,
        ) -> None:
            pass

        error: str
        supported_features: int
        minimum_edition: int
        maximum_edition: int
        file: list[CodeGeneratorResponse.File]

    _FileFields: TypeAlias = Literal[
        "name", "insertion_point", "content", "generated_code_info"
    ]

    class File(Message[_FileFields]):
        """
        Represents a single generated file.

        ```proto
        message google.protobuf.compiler.CodeGeneratorResponse.File
        ```

        Attributes:
            name:
                The file name, relative to the output directory.  The name must not
                contain "." or ".." components and must be relative, not be absolute (so,
                the file cannot lie outside the output directory).  "/" must be used as
                the path separator, not "\\".

                If the name is omitted, the content will be appended to the previous
                file.  This allows the generator to break large files into small chunks,
                and allows the generated text to be streamed back to protoc so that large
                files need not reside completely in memory at one time.  Note that as of
                this writing protoc does not optimize for this -- it will read the entire
                CodeGeneratorResponse before writing files to disk.

                ```proto
                optional string name = 1;
                ```
            insertion_point:
                If non-empty, indicates that the named file should already exist, and the
                content here is to be inserted into that file at a defined insertion
                point.  This feature allows a code generator to extend the output
                produced by another code generator.  The original generator may provide
                insertion points by placing special annotations in the file that look
                like:
                  @@protoc_insertion_point(NAME)
                The annotation can have arbitrary text before and after it on the line,
                which allows it to be placed in a comment.  NAME should be replaced with
                an identifier naming the point -- this is what other generators will use
                as the insertion_point.  Code inserted at this point will be placed
                immediately above the line containing the insertion point (thus multiple
                insertions to the same point will come out in the order they were added).
                The double-@ is intended to make it unlikely that the generated code
                could contain things that look like insertion points by accident.

                For example, the C++ code generator places the following line in the
                .pb.h files that it generates:
                  // @@protoc_insertion_point(namespace_scope)
                This line appears within the scope of the file's package namespace, but
                outside of any particular class.  Another plugin can then specify the
                insertion_point "namespace_scope" to generate additional classes or
                other declarations that should be placed in this scope.

                Note that if the line containing the insertion point begins with
                whitespace, the same whitespace will be added to every line of the
                inserted text.  This is useful for languages like Python, where
                indentation matters.  In these languages, the insertion point comment
                should be indented the same amount as any inserted code will need to be
                in order to work correctly in that context.

                The code generator that generates the initial file and the one which
                inserts into it must both run as part of a single invocation of protoc.
                Code generators are executed in the order in which they appear on the
                command line.

                If |insertion_point| is present, |name| must also be present.

                ```proto
                optional string insertion_point = 2;
                ```
            content:
                The file contents.

                ```proto
                optional string content = 15;
                ```
            generated_code_info:
                Information describing the file content being inserted. If an insertion
                point is used, this information will be appropriately offset and inserted
                into the code generation metadata for the generated files.

                ```proto
                optional google.protobuf.GeneratedCodeInfo generated_code_info = 16;
                ```
        """

        __slots__ = ("name", "insertion_point", "content", "generated_code_info")

        if TYPE_CHECKING:

            def __init__(
                self,
                *,
                name: str | None = None,
                insertion_point: str | None = None,
                content: str | None = None,
                generated_code_info: GeneratedCodeInfo | None = None,
            ) -> None:
                pass

            name: str
            insertion_point: str
            content: str
            generated_code_info: GeneratedCodeInfo | None

    class Feature(Enum):
        """
        Sync with code_generator.h.

        ```proto
        enum google.protobuf.compiler.CodeGeneratorResponse.Feature
        ```

        Attributes:
            NONE:
                ```proto
                FEATURE_NONE = 0
                ```
            PROTO3_OPTIONAL:
                ```proto
                FEATURE_PROTO3_OPTIONAL = 1
                ```
            SUPPORTS_EDITIONS:
                ```proto
                FEATURE_SUPPORTS_EDITIONS = 2
                ```
        """

        NONE = 0
        PROTO3_OPTIONAL = 1
        SUPPORTS_EDITIONS = 2


_DESC = file_desc(
    b'\n%google/protobuf/compiler/plugin.proto\x12\x18google.protobuf.compiler\x1a google/protobuf/descriptor.proto"c\n\x07Version\x12\x14\n\x05major\x18\x01 \x01(\x05R\x05major\x12\x14\n\x05minor\x18\x02 \x01(\x05R\x05minor\x12\x14\n\x05patch\x18\x03 \x01(\x05R\x05patch\x12\x16\n\x06suffix\x18\x04 \x01(\tR\x06suffix"\xcf\x02\n\x14CodeGeneratorRequest\x12(\n\x10file_to_generate\x18\x01 \x03(\tR\x0efileToGenerate\x12\x1c\n\tparameter\x18\x02 \x01(\tR\tparameter\x12C\n\nproto_file\x18\x0f \x03(\x0b2$.google.protobuf.FileDescriptorProtoR\tprotoFile\x12\\\n\x17source_file_descriptors\x18\x11 \x03(\x0b2$.google.protobuf.FileDescriptorProtoR\x15sourceFileDescriptors\x12L\n\x10compiler_version\x18\x03 \x01(\x0b2!.google.protobuf.compiler.VersionR\x0fcompilerVersion"\x85\x04\n\x15CodeGeneratorResponse\x12\x14\n\x05error\x18\x01 \x01(\tR\x05error\x12-\n\x12supported_features\x18\x02 \x01(\x04R\x11supportedFeatures\x12\'\n\x0fminimum_edition\x18\x03 \x01(\x05R\x0eminimumEdition\x12\'\n\x0fmaximum_edition\x18\x04 \x01(\x05R\x0emaximumEdition\x12H\n\x04file\x18\x0f \x03(\x0b24.google.protobuf.compiler.CodeGeneratorResponse.FileR\x04file\x1a\xb1\x01\n\x04File\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12\'\n\x0finsertion_point\x18\x02 \x01(\tR\x0einsertionPoint\x12\x18\n\x07content\x18\x0f \x01(\tR\x07content\x12R\n\x13generated_code_info\x18\x10 \x01(\x0b2".google.protobuf.GeneratedCodeInfoR\x11generatedCodeInfo"W\n\x07Feature\x12\x10\n\x0cFEATURE_NONE\x10\x00\x12\x1b\n\x17FEATURE_PROTO3_OPTIONAL\x10\x01\x12\x1d\n\x19FEATURE_SUPPORTS_EDITIONS\x10\x02Br\n\x1ccom.google.protobuf.compilerB\x0cPluginProtosZ)google.golang.org/protobuf/types/pluginpb\xaa\x02\x18Google.Protobuf.Compiler',
    [descriptor_pb.desc()],
    {
        "Version": Version,
        "CodeGeneratorRequest": CodeGeneratorRequest,
        "CodeGeneratorResponse": CodeGeneratorResponse,
        "CodeGeneratorResponse.File": CodeGeneratorResponse.File,
        "CodeGeneratorResponse.Feature": CodeGeneratorResponse.Feature,
    },
)


def desc() -> DescFile:
    """Returns the descriptor for the file `google/protobuf/compiler/plugin.proto`."""
    return _DESC
