api_pb.py 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  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/api.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 Message
  21. from protobuf._codegen import file_desc
  22. from . import source_context_pb, type_pb
  23. if TYPE_CHECKING:
  24. from protobuf import DescFile
  25. from .source_context_pb import SourceContext
  26. from .type_pb import Option, Syntax
  27. _ApiFields: TypeAlias = Literal[
  28. "name",
  29. "methods",
  30. "options",
  31. "version",
  32. "source_context",
  33. "mixins",
  34. "syntax",
  35. "edition",
  36. ]
  37. class Api(Message[_ApiFields]):
  38. """
  39. Api is a light-weight descriptor for an API Interface.
  40. Interfaces are also described as "protocol buffer services" in some contexts,
  41. such as by the "service" keyword in a .proto file, but they are different
  42. from API Services, which represent a concrete implementation of an interface
  43. as opposed to simply a description of methods and bindings. They are also
  44. sometimes simply referred to as "APIs" in other contexts, such as the name of
  45. this message itself. See https://cloud.google.com/apis/design/glossary for
  46. detailed terminology.
  47. New usages of this message as an alternative to ServiceDescriptorProto are
  48. strongly discouraged. This message does not reliability preserve all
  49. information necessary to model the schema and preserve semantics. Instead
  50. make use of FileDescriptorSet which preserves the necessary information.
  51. ```proto
  52. message google.protobuf.Api
  53. ```
  54. Attributes:
  55. name:
  56. The fully qualified name of this interface, including package name
  57. followed by the interface's simple name.
  58. ```proto
  59. string name = 1;
  60. ```
  61. methods:
  62. The methods of this interface, in unspecified order.
  63. ```proto
  64. repeated google.protobuf.Method methods = 2;
  65. ```
  66. options:
  67. Any metadata attached to the interface.
  68. ```proto
  69. repeated google.protobuf.Option options = 3;
  70. ```
  71. version:
  72. A version string for this interface. If specified, must have the form
  73. `major-version.minor-version`, as in `1.10`. If the minor version is
  74. omitted, it defaults to zero. If the entire version field is empty, the
  75. major version is derived from the package name, as outlined below. If the
  76. field is not empty, the version in the package name will be verified to be
  77. consistent with what is provided here.
  78. The versioning schema uses [semantic
  79. versioning](http://semver.org) where the major version number
  80. indicates a breaking change and the minor version an additive,
  81. non-breaking change. Both version numbers are signals to users
  82. what to expect from different versions, and should be carefully
  83. chosen based on the product plan.
  84. The major version is also reflected in the package name of the
  85. interface, which must end in `v<major-version>`, as in
  86. `google.feature.v1`. For major versions 0 and 1, the suffix can
  87. be omitted. Zero major versions must only be used for
  88. experimental, non-GA interfaces.
  89. ```proto
  90. string version = 4;
  91. ```
  92. source_context:
  93. Source context for the protocol buffer service represented by this
  94. message.
  95. ```proto
  96. optional google.protobuf.SourceContext source_context = 5;
  97. ```
  98. mixins:
  99. Included interfaces. See [Mixin][].
  100. ```proto
  101. repeated google.protobuf.Mixin mixins = 6;
  102. ```
  103. syntax:
  104. The source syntax of the service.
  105. ```proto
  106. google.protobuf.Syntax syntax = 7;
  107. ```
  108. edition:
  109. The source edition string, only valid when syntax is SYNTAX_EDITIONS.
  110. ```proto
  111. string edition = 8;
  112. ```
  113. """
  114. __slots__ = (
  115. "name",
  116. "methods",
  117. "options",
  118. "version",
  119. "source_context",
  120. "mixins",
  121. "syntax",
  122. "edition",
  123. )
  124. if TYPE_CHECKING:
  125. def __init__(
  126. self,
  127. *,
  128. name: str = "",
  129. methods: list[Method] | None = None,
  130. options: list[Option] | None = None,
  131. version: str = "",
  132. source_context: SourceContext | None = None,
  133. mixins: list[Mixin] | None = None,
  134. syntax: Syntax | None = None,
  135. edition: str = "",
  136. ) -> None:
  137. pass
  138. name: str
  139. methods: list[Method]
  140. options: list[Option]
  141. version: str
  142. source_context: SourceContext | None
  143. mixins: list[Mixin]
  144. syntax: Syntax
  145. edition: str
  146. _MethodFields: TypeAlias = Literal[
  147. "name",
  148. "request_type_url",
  149. "request_streaming",
  150. "response_type_url",
  151. "response_streaming",
  152. "options",
  153. "syntax",
  154. "edition",
  155. ]
  156. class Method(Message[_MethodFields]):
  157. """
  158. Method represents a method of an API interface.
  159. New usages of this message as an alternative to MethodDescriptorProto are
  160. strongly discouraged. This message does not reliability preserve all
  161. information necessary to model the schema and preserve semantics. Instead
  162. make use of FileDescriptorSet which preserves the necessary information.
  163. ```proto
  164. message google.protobuf.Method
  165. ```
  166. Attributes:
  167. name:
  168. The simple name of this method.
  169. ```proto
  170. string name = 1;
  171. ```
  172. request_type_url:
  173. A URL of the input message type.
  174. ```proto
  175. string request_type_url = 2;
  176. ```
  177. request_streaming:
  178. If true, the request is streamed.
  179. ```proto
  180. bool request_streaming = 3;
  181. ```
  182. response_type_url:
  183. The URL of the output message type.
  184. ```proto
  185. string response_type_url = 4;
  186. ```
  187. response_streaming:
  188. If true, the response is streamed.
  189. ```proto
  190. bool response_streaming = 5;
  191. ```
  192. options:
  193. Any metadata attached to the method.
  194. ```proto
  195. repeated google.protobuf.Option options = 6;
  196. ```
  197. syntax:
  198. The source syntax of this method.
  199. This field should be ignored, instead the syntax should be inherited from
  200. Api. This is similar to Field and EnumValue.
  201. ```proto
  202. google.protobuf.Syntax syntax = 7 [deprecated = true];
  203. ```
  204. edition:
  205. The source edition string, only valid when syntax is SYNTAX_EDITIONS.
  206. This field should be ignored, instead the edition should be inherited from
  207. Api. This is similar to Field and EnumValue.
  208. ```proto
  209. string edition = 8 [deprecated = true];
  210. ```
  211. """
  212. __slots__ = (
  213. "name",
  214. "request_type_url",
  215. "request_streaming",
  216. "response_type_url",
  217. "response_streaming",
  218. "options",
  219. "syntax",
  220. "edition",
  221. )
  222. if TYPE_CHECKING:
  223. def __init__(
  224. self,
  225. *,
  226. name: str = "",
  227. request_type_url: str = "",
  228. request_streaming: bool = False,
  229. response_type_url: str = "",
  230. response_streaming: bool = False,
  231. options: list[Option] | None = None,
  232. syntax: Syntax | None = None,
  233. edition: str = "",
  234. ) -> None:
  235. pass
  236. name: str
  237. request_type_url: str
  238. request_streaming: bool
  239. response_type_url: str
  240. response_streaming: bool
  241. options: list[Option]
  242. syntax: Syntax
  243. edition: str
  244. _MixinFields: TypeAlias = Literal["name", "root"]
  245. class Mixin(Message[_MixinFields]):
  246. """
  247. Declares an API Interface to be included in this interface. The including
  248. interface must redeclare all the methods from the included interface, but
  249. documentation and options are inherited as follows:
  250. - If after comment and whitespace stripping, the documentation
  251. string of the redeclared method is empty, it will be inherited
  252. from the original method.
  253. - Each annotation belonging to the service config (http,
  254. visibility) which is not set in the redeclared method will be
  255. inherited.
  256. - If an http annotation is inherited, the path pattern will be
  257. modified as follows. Any version prefix will be replaced by the
  258. version of the including interface plus the [root][] path if
  259. specified.
  260. Example of a simple mixin:
  261. package google.acl.v1;
  262. service AccessControl {
  263. // Get the underlying ACL object.
  264. rpc GetAcl(GetAclRequest) returns (Acl) {
  265. option (google.api.http).get = "/v1/{resource=**}:getAcl";
  266. }
  267. }
  268. package google.storage.v2;
  269. service Storage {
  270. rpc GetAcl(GetAclRequest) returns (Acl);
  271. // Get a data record.
  272. rpc GetData(GetDataRequest) returns (Data) {
  273. option (google.api.http).get = "/v2/{resource=**}";
  274. }
  275. }
  276. Example of a mixin configuration:
  277. apis:
  278. - name: google.storage.v2.Storage
  279. mixins:
  280. - name: google.acl.v1.AccessControl
  281. The mixin construct implies that all methods in `AccessControl` are
  282. also declared with same name and request/response types in
  283. `Storage`. A documentation generator or annotation processor will
  284. see the effective `Storage.GetAcl` method after inheriting
  285. documentation and annotations as follows:
  286. service Storage {
  287. // Get the underlying ACL object.
  288. rpc GetAcl(GetAclRequest) returns (Acl) {
  289. option (google.api.http).get = "/v2/{resource=**}:getAcl";
  290. }
  291. ...
  292. }
  293. Note how the version in the path pattern changed from `v1` to `v2`.
  294. If the `root` field in the mixin is specified, it should be a
  295. relative path under which inherited HTTP paths are placed. Example:
  296. apis:
  297. - name: google.storage.v2.Storage
  298. mixins:
  299. - name: google.acl.v1.AccessControl
  300. root: acls
  301. This implies the following inherited HTTP annotation:
  302. service Storage {
  303. // Get the underlying ACL object.
  304. rpc GetAcl(GetAclRequest) returns (Acl) {
  305. option (google.api.http).get = "/v2/acls/{resource=**}:getAcl";
  306. }
  307. ...
  308. }
  309. ```proto
  310. message google.protobuf.Mixin
  311. ```
  312. Attributes:
  313. name:
  314. The fully qualified name of the interface which is included.
  315. ```proto
  316. string name = 1;
  317. ```
  318. root:
  319. If non-empty specifies a path under which inherited HTTP paths
  320. are rooted.
  321. ```proto
  322. string root = 2;
  323. ```
  324. """
  325. __slots__ = ("name", "root")
  326. if TYPE_CHECKING:
  327. def __init__(self, *, name: str = "", root: str = "") -> None:
  328. pass
  329. name: str
  330. root: str
  331. _DESC = file_desc(
  332. b'\n\x19google/protobuf/api.proto\x12\x0fgoogle.protobuf\x1a$google/protobuf/source_context.proto\x1a\x1agoogle/protobuf/type.proto"\xdb\x02\n\x03Api\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x121\n\x07methods\x18\x02 \x03(\x0b2\x17.google.protobuf.MethodR\x07methods\x121\n\x07options\x18\x03 \x03(\x0b2\x17.google.protobuf.OptionR\x07options\x12\x18\n\x07version\x18\x04 \x01(\tR\x07version\x12E\n\x0esource_context\x18\x05 \x01(\x0b2\x1e.google.protobuf.SourceContextR\rsourceContext\x12.\n\x06mixins\x18\x06 \x03(\x0b2\x16.google.protobuf.MixinR\x06mixins\x12/\n\x06syntax\x18\x07 \x01(\x0e2\x17.google.protobuf.SyntaxR\x06syntax\x12\x18\n\x07edition\x18\x08 \x01(\tR\x07edition"\xd4\x02\n\x06Method\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12(\n\x10request_type_url\x18\x02 \x01(\tR\x0erequestTypeUrl\x12+\n\x11request_streaming\x18\x03 \x01(\x08R\x10requestStreaming\x12*\n\x11response_type_url\x18\x04 \x01(\tR\x0fresponseTypeUrl\x12-\n\x12response_streaming\x18\x05 \x01(\x08R\x11responseStreaming\x121\n\x07options\x18\x06 \x03(\x0b2\x17.google.protobuf.OptionR\x07options\x123\n\x06syntax\x18\x07 \x01(\x0e2\x17.google.protobuf.SyntaxR\x06syntaxB\x02\x18\x01\x12\x1c\n\x07edition\x18\x08 \x01(\tR\x07editionB\x02\x18\x01"/\n\x05Mixin\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12\x12\n\x04root\x18\x02 \x01(\tR\x04rootBv\n\x13com.google.protobufB\x08ApiProtoP\x01Z,google.golang.org/protobuf/types/known/apipb\xa2\x02\x03GPB\xaa\x02\x1eGoogle.Protobuf.WellKnownTypesb\x06proto3',
  333. [source_context_pb.desc(), type_pb.desc()],
  334. {"Api": Api, "Method": Method, "Mixin": Mixin},
  335. )
  336. def desc() -> DescFile:
  337. """Returns the descriptor for the file `google/protobuf/api.proto`."""
  338. return _DESC