plugin_pb.py 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. # Copyright (c) 2025-2026 Buf Technologies, Inc.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # Generated from google/protobuf/compiler/plugin.proto. DO NOT EDIT.
  15. # Generated by protoc-gen-py v0.1.1 with parameter "no_fmt_off".
  16. # ruff: noqa: PGH004
  17. # ruff: noqa
  18. from __future__ import annotations
  19. from typing import Literal, TYPE_CHECKING, TypeAlias
  20. from protobuf import Enum, Message
  21. from protobuf._codegen import file_desc
  22. from .. import descriptor_pb
  23. if TYPE_CHECKING:
  24. from protobuf import DescFile
  25. from ..descriptor_pb import FileDescriptorProto, GeneratedCodeInfo
  26. _VersionFields: TypeAlias = Literal["major", "minor", "patch", "suffix"]
  27. class Version(Message[_VersionFields]):
  28. """
  29. The version number of protocol compiler.
  30. ```proto
  31. message google.protobuf.compiler.Version
  32. ```
  33. Attributes:
  34. major:
  35. ```proto
  36. optional int32 major = 1;
  37. ```
  38. minor:
  39. ```proto
  40. optional int32 minor = 2;
  41. ```
  42. patch:
  43. ```proto
  44. optional int32 patch = 3;
  45. ```
  46. suffix:
  47. A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should
  48. be empty for mainline stable releases.
  49. ```proto
  50. optional string suffix = 4;
  51. ```
  52. """
  53. __slots__ = ("major", "minor", "patch", "suffix")
  54. if TYPE_CHECKING:
  55. def __init__(
  56. self,
  57. *,
  58. major: int | None = None,
  59. minor: int | None = None,
  60. patch: int | None = None,
  61. suffix: str | None = None,
  62. ) -> None:
  63. pass
  64. major: int
  65. minor: int
  66. patch: int
  67. suffix: str
  68. _CodeGeneratorRequestFields: TypeAlias = Literal[
  69. "file_to_generate",
  70. "parameter",
  71. "proto_file",
  72. "source_file_descriptors",
  73. "compiler_version",
  74. ]
  75. class CodeGeneratorRequest(Message[_CodeGeneratorRequestFields]):
  76. """
  77. An encoded CodeGeneratorRequest is written to the plugin's stdin.
  78. ```proto
  79. message google.protobuf.compiler.CodeGeneratorRequest
  80. ```
  81. Attributes:
  82. file_to_generate:
  83. The .proto files that were explicitly listed on the command-line. The
  84. code generator should generate code only for these files. Each file's
  85. descriptor will be included in proto_file, below.
  86. ```proto
  87. repeated string file_to_generate = 1;
  88. ```
  89. parameter:
  90. The generator parameter passed on the command-line.
  91. ```proto
  92. optional string parameter = 2;
  93. ```
  94. proto_file:
  95. FileDescriptorProtos for all files in files_to_generate and everything
  96. they import. The files will appear in topological order, so each file
  97. appears before any file that imports it.
  98. Note: the files listed in files_to_generate will include runtime-retention
  99. options only, but all other files will include source-retention options.
  100. The source_file_descriptors field below is available in case you need
  101. source-retention options for files_to_generate.
  102. protoc guarantees that all proto_files will be written after
  103. the fields above, even though this is not technically guaranteed by the
  104. protobuf wire format. This theoretically could allow a plugin to stream
  105. in the FileDescriptorProtos and handle them one by one rather than read
  106. the entire set into memory at once. However, as of this writing, this
  107. is not similarly optimized on protoc's end -- it will store all fields in
  108. memory at once before sending them to the plugin.
  109. Type names of fields and extensions in the FileDescriptorProto are always
  110. fully qualified.
  111. ```proto
  112. repeated google.protobuf.FileDescriptorProto proto_file = 15;
  113. ```
  114. source_file_descriptors:
  115. File descriptors with all options, including source-retention options.
  116. These descriptors are only provided for the files listed in
  117. files_to_generate.
  118. ```proto
  119. repeated google.protobuf.FileDescriptorProto source_file_descriptors = 17;
  120. ```
  121. compiler_version:
  122. The version number of protocol compiler.
  123. ```proto
  124. optional google.protobuf.compiler.Version compiler_version = 3;
  125. ```
  126. """
  127. __slots__ = (
  128. "file_to_generate",
  129. "parameter",
  130. "proto_file",
  131. "source_file_descriptors",
  132. "compiler_version",
  133. )
  134. if TYPE_CHECKING:
  135. def __init__(
  136. self,
  137. *,
  138. file_to_generate: list[str] | None = None,
  139. parameter: str | None = None,
  140. proto_file: list[FileDescriptorProto] | None = None,
  141. source_file_descriptors: list[FileDescriptorProto] | None = None,
  142. compiler_version: Version | None = None,
  143. ) -> None:
  144. pass
  145. file_to_generate: list[str]
  146. parameter: str
  147. proto_file: list[FileDescriptorProto]
  148. source_file_descriptors: list[FileDescriptorProto]
  149. compiler_version: Version | None
  150. _CodeGeneratorResponseFields: TypeAlias = Literal[
  151. "error", "supported_features", "minimum_edition", "maximum_edition", "file"
  152. ]
  153. class CodeGeneratorResponse(Message[_CodeGeneratorResponseFields]):
  154. """
  155. The plugin writes an encoded CodeGeneratorResponse to stdout.
  156. ```proto
  157. message google.protobuf.compiler.CodeGeneratorResponse
  158. ```
  159. Attributes:
  160. error:
  161. Error message. If non-empty, code generation failed. The plugin process
  162. should exit with status code zero even if it reports an error in this way.
  163. This should be used to indicate errors in .proto files which prevent the
  164. code generator from generating correct code. Errors which indicate a
  165. problem in protoc itself -- such as the input CodeGeneratorRequest being
  166. unparseable -- should be reported by writing a message to stderr and
  167. exiting with a non-zero status code.
  168. ```proto
  169. optional string error = 1;
  170. ```
  171. supported_features:
  172. A bitmask of supported features that the code generator supports.
  173. This is a bitwise "or" of values from the Feature enum.
  174. ```proto
  175. optional uint64 supported_features = 2;
  176. ```
  177. minimum_edition:
  178. The minimum edition this plugin supports. This will be treated as an
  179. Edition enum, but we want to allow unknown values. It should be specified
  180. according the edition enum value, *not* the edition number. Only takes
  181. effect for plugins that have FEATURE_SUPPORTS_EDITIONS set.
  182. ```proto
  183. optional int32 minimum_edition = 3;
  184. ```
  185. maximum_edition:
  186. The maximum edition this plugin supports. This will be treated as an
  187. Edition enum, but we want to allow unknown values. It should be specified
  188. according the edition enum value, *not* the edition number. Only takes
  189. effect for plugins that have FEATURE_SUPPORTS_EDITIONS set.
  190. ```proto
  191. optional int32 maximum_edition = 4;
  192. ```
  193. file:
  194. ```proto
  195. repeated google.protobuf.compiler.CodeGeneratorResponse.File file = 15;
  196. ```
  197. """
  198. __slots__ = (
  199. "error",
  200. "supported_features",
  201. "minimum_edition",
  202. "maximum_edition",
  203. "file",
  204. )
  205. if TYPE_CHECKING:
  206. def __init__(
  207. self,
  208. *,
  209. error: str | None = None,
  210. supported_features: int | None = None,
  211. minimum_edition: int | None = None,
  212. maximum_edition: int | None = None,
  213. file: list[CodeGeneratorResponse.File] | None = None,
  214. ) -> None:
  215. pass
  216. error: str
  217. supported_features: int
  218. minimum_edition: int
  219. maximum_edition: int
  220. file: list[CodeGeneratorResponse.File]
  221. _FileFields: TypeAlias = Literal[
  222. "name", "insertion_point", "content", "generated_code_info"
  223. ]
  224. class File(Message[_FileFields]):
  225. """
  226. Represents a single generated file.
  227. ```proto
  228. message google.protobuf.compiler.CodeGeneratorResponse.File
  229. ```
  230. Attributes:
  231. name:
  232. The file name, relative to the output directory. The name must not
  233. contain "." or ".." components and must be relative, not be absolute (so,
  234. the file cannot lie outside the output directory). "/" must be used as
  235. the path separator, not "\\".
  236. If the name is omitted, the content will be appended to the previous
  237. file. This allows the generator to break large files into small chunks,
  238. and allows the generated text to be streamed back to protoc so that large
  239. files need not reside completely in memory at one time. Note that as of
  240. this writing protoc does not optimize for this -- it will read the entire
  241. CodeGeneratorResponse before writing files to disk.
  242. ```proto
  243. optional string name = 1;
  244. ```
  245. insertion_point:
  246. If non-empty, indicates that the named file should already exist, and the
  247. content here is to be inserted into that file at a defined insertion
  248. point. This feature allows a code generator to extend the output
  249. produced by another code generator. The original generator may provide
  250. insertion points by placing special annotations in the file that look
  251. like:
  252. @@protoc_insertion_point(NAME)
  253. The annotation can have arbitrary text before and after it on the line,
  254. which allows it to be placed in a comment. NAME should be replaced with
  255. an identifier naming the point -- this is what other generators will use
  256. as the insertion_point. Code inserted at this point will be placed
  257. immediately above the line containing the insertion point (thus multiple
  258. insertions to the same point will come out in the order they were added).
  259. The double-@ is intended to make it unlikely that the generated code
  260. could contain things that look like insertion points by accident.
  261. For example, the C++ code generator places the following line in the
  262. .pb.h files that it generates:
  263. // @@protoc_insertion_point(namespace_scope)
  264. This line appears within the scope of the file's package namespace, but
  265. outside of any particular class. Another plugin can then specify the
  266. insertion_point "namespace_scope" to generate additional classes or
  267. other declarations that should be placed in this scope.
  268. Note that if the line containing the insertion point begins with
  269. whitespace, the same whitespace will be added to every line of the
  270. inserted text. This is useful for languages like Python, where
  271. indentation matters. In these languages, the insertion point comment
  272. should be indented the same amount as any inserted code will need to be
  273. in order to work correctly in that context.
  274. The code generator that generates the initial file and the one which
  275. inserts into it must both run as part of a single invocation of protoc.
  276. Code generators are executed in the order in which they appear on the
  277. command line.
  278. If |insertion_point| is present, |name| must also be present.
  279. ```proto
  280. optional string insertion_point = 2;
  281. ```
  282. content:
  283. The file contents.
  284. ```proto
  285. optional string content = 15;
  286. ```
  287. generated_code_info:
  288. Information describing the file content being inserted. If an insertion
  289. point is used, this information will be appropriately offset and inserted
  290. into the code generation metadata for the generated files.
  291. ```proto
  292. optional google.protobuf.GeneratedCodeInfo generated_code_info = 16;
  293. ```
  294. """
  295. __slots__ = ("name", "insertion_point", "content", "generated_code_info")
  296. if TYPE_CHECKING:
  297. def __init__(
  298. self,
  299. *,
  300. name: str | None = None,
  301. insertion_point: str | None = None,
  302. content: str | None = None,
  303. generated_code_info: GeneratedCodeInfo | None = None,
  304. ) -> None:
  305. pass
  306. name: str
  307. insertion_point: str
  308. content: str
  309. generated_code_info: GeneratedCodeInfo | None
  310. class Feature(Enum):
  311. """
  312. Sync with code_generator.h.
  313. ```proto
  314. enum google.protobuf.compiler.CodeGeneratorResponse.Feature
  315. ```
  316. Attributes:
  317. NONE:
  318. ```proto
  319. FEATURE_NONE = 0
  320. ```
  321. PROTO3_OPTIONAL:
  322. ```proto
  323. FEATURE_PROTO3_OPTIONAL = 1
  324. ```
  325. SUPPORTS_EDITIONS:
  326. ```proto
  327. FEATURE_SUPPORTS_EDITIONS = 2
  328. ```
  329. """
  330. NONE = 0
  331. PROTO3_OPTIONAL = 1
  332. SUPPORTS_EDITIONS = 2
  333. _DESC = file_desc(
  334. 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',
  335. [descriptor_pb.desc()],
  336. {
  337. "Version": Version,
  338. "CodeGeneratorRequest": CodeGeneratorRequest,
  339. "CodeGeneratorResponse": CodeGeneratorResponse,
  340. "CodeGeneratorResponse.File": CodeGeneratorResponse.File,
  341. "CodeGeneratorResponse.Feature": CodeGeneratorResponse.Feature,
  342. },
  343. )
  344. def desc() -> DescFile:
  345. """Returns the descriptor for the file `google/protobuf/compiler/plugin.proto`."""
  346. return _DESC