Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/betterproto/lib/google/protobuf/__init__.py: 99%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

552 statements  

1# Generated by the protocol buffer compiler. DO NOT EDIT! 

2# sources: google/protobuf/any.proto, google/protobuf/api.proto, google/protobuf/descriptor.proto, google/protobuf/duration.proto, google/protobuf/empty.proto, google/protobuf/field_mask.proto, google/protobuf/source_context.proto, google/protobuf/struct.proto, google/protobuf/timestamp.proto, google/protobuf/type.proto, google/protobuf/wrappers.proto 

3# plugin: python-betterproto 

4# This file has been @generated 

5import warnings 

6from dataclasses import dataclass 

7from typing import ( 

8 Dict, 

9 List, 

10) 

11 

12import betterproto 

13 

14 

15class Syntax(betterproto.Enum): 

16 """The syntax in which a protocol buffer element is defined.""" 

17 

18 SYNTAX_PROTO2 = 0 

19 """Syntax `proto2`.""" 

20 

21 SYNTAX_PROTO3 = 1 

22 """Syntax `proto3`.""" 

23 

24 

25class FieldKind(betterproto.Enum): 

26 """Basic field types.""" 

27 

28 TYPE_UNKNOWN = 0 

29 """Field type unknown.""" 

30 

31 TYPE_DOUBLE = 1 

32 """Field type double.""" 

33 

34 TYPE_FLOAT = 2 

35 """Field type float.""" 

36 

37 TYPE_INT64 = 3 

38 """Field type int64.""" 

39 

40 TYPE_UINT64 = 4 

41 """Field type uint64.""" 

42 

43 TYPE_INT32 = 5 

44 """Field type int32.""" 

45 

46 TYPE_FIXED64 = 6 

47 """Field type fixed64.""" 

48 

49 TYPE_FIXED32 = 7 

50 """Field type fixed32.""" 

51 

52 TYPE_BOOL = 8 

53 """Field type bool.""" 

54 

55 TYPE_STRING = 9 

56 """Field type string.""" 

57 

58 TYPE_GROUP = 10 

59 """Field type group. Proto2 syntax only, and deprecated.""" 

60 

61 TYPE_MESSAGE = 11 

62 """Field type message.""" 

63 

64 TYPE_BYTES = 12 

65 """Field type bytes.""" 

66 

67 TYPE_UINT32 = 13 

68 """Field type uint32.""" 

69 

70 TYPE_ENUM = 14 

71 """Field type enum.""" 

72 

73 TYPE_SFIXED32 = 15 

74 """Field type sfixed32.""" 

75 

76 TYPE_SFIXED64 = 16 

77 """Field type sfixed64.""" 

78 

79 TYPE_SINT32 = 17 

80 """Field type sint32.""" 

81 

82 TYPE_SINT64 = 18 

83 """Field type sint64.""" 

84 

85 

86class FieldCardinality(betterproto.Enum): 

87 """Whether a field is optional, required, or repeated.""" 

88 

89 CARDINALITY_UNKNOWN = 0 

90 """For fields with unknown cardinality.""" 

91 

92 CARDINALITY_OPTIONAL = 1 

93 """For optional fields.""" 

94 

95 CARDINALITY_REQUIRED = 2 

96 """For required fields. Proto2 syntax only.""" 

97 

98 CARDINALITY_REPEATED = 3 

99 """For repeated fields.""" 

100 

101 

102class FieldDescriptorProtoType(betterproto.Enum): 

103 TYPE_DOUBLE = 1 

104 """0 is reserved for errors. Order is weird for historical reasons.""" 

105 

106 TYPE_FLOAT = 2 

107 TYPE_INT64 = 3 

108 """ 

109 Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if 

110 negative values are likely. 

111 """ 

112 

113 TYPE_UINT64 = 4 

114 TYPE_INT32 = 5 

115 """ 

116 Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if 

117 negative values are likely. 

118 """ 

119 

120 TYPE_FIXED64 = 6 

121 TYPE_FIXED32 = 7 

122 TYPE_BOOL = 8 

123 TYPE_STRING = 9 

124 TYPE_GROUP = 10 

125 """ 

126 Tag-delimited aggregate. Group type is deprecated and not supported in 

127 proto3. However, Proto3 implementations should still be able to parse the 

128 group wire format and treat group fields as unknown fields. 

129 """ 

130 

131 TYPE_MESSAGE = 11 

132 TYPE_BYTES = 12 

133 """New in version 2.""" 

134 

135 TYPE_UINT32 = 13 

136 TYPE_ENUM = 14 

137 TYPE_SFIXED32 = 15 

138 TYPE_SFIXED64 = 16 

139 TYPE_SINT32 = 17 

140 TYPE_SINT64 = 18 

141 

142 

143class FieldDescriptorProtoLabel(betterproto.Enum): 

144 LABEL_OPTIONAL = 1 

145 """0 is reserved for errors""" 

146 

147 LABEL_REQUIRED = 2 

148 LABEL_REPEATED = 3 

149 

150 

151class FileOptionsOptimizeMode(betterproto.Enum): 

152 """Generated classes can be optimized for speed or code size.""" 

153 

154 SPEED = 1 

155 CODE_SIZE = 2 

156 """etc.""" 

157 

158 LITE_RUNTIME = 3 

159 

160 

161class FieldOptionsCType(betterproto.Enum): 

162 STRING = 0 

163 """Default mode.""" 

164 

165 CORD = 1 

166 STRING_PIECE = 2 

167 

168 

169class FieldOptionsJsType(betterproto.Enum): 

170 JS_NORMAL = 0 

171 """Use the default type.""" 

172 

173 JS_STRING = 1 

174 """Use JavaScript strings.""" 

175 

176 JS_NUMBER = 2 

177 """Use JavaScript numbers.""" 

178 

179 

180class MethodOptionsIdempotencyLevel(betterproto.Enum): 

181 """ 

182 Is this method side-effect-free (or safe in HTTP parlance), or idempotent, 

183 or neither? HTTP based RPC implementation may choose GET verb for safe 

184 methods, and PUT verb for idempotent methods instead of the default POST. 

185 """ 

186 

187 IDEMPOTENCY_UNKNOWN = 0 

188 NO_SIDE_EFFECTS = 1 

189 IDEMPOTENT = 2 

190 

191 

192class NullValue(betterproto.Enum): 

193 """ 

194 `NullValue` is a singleton enumeration to represent the null value for the 

195 `Value` type union. The JSON representation for `NullValue` is JSON 

196 `null`. 

197 """ 

198 

199 NULL_VALUE = 0 

200 """Null value.""" 

201 

202 

203@dataclass(eq=False, repr=False) 

204class Any(betterproto.Message): 

205 """ 

206 `Any` contains an arbitrary serialized protocol buffer message along with a 

207 URL that describes the type of the serialized message. Protobuf library 

208 provides support to pack/unpack Any values in the form of utility functions 

209 or additional generated methods of the Any type. Example 1: Pack and unpack 

210 a message in C++. Foo foo = ...; Any any; any.PackFrom(foo); 

211 ... if (any.UnpackTo(&foo)) { ... } Example 2: Pack and 

212 unpack a message in Java. Foo foo = ...; Any any = Any.pack(foo); 

213 ... if (any.is(Foo.class)) { foo = any.unpack(Foo.class); } 

214 Example 3: Pack and unpack a message in Python. foo = Foo(...) any 

215 = Any() any.Pack(foo) ... if any.Is(Foo.DESCRIPTOR): 

216 any.Unpack(foo) ... Example 4: Pack and unpack a message in Go 

217 foo := &pb.Foo{...} any, err := anypb.New(foo) if err != nil { 

218 ... } ... foo := &pb.Foo{} if err := 

219 any.UnmarshalTo(foo); err != nil { ... } The pack methods 

220 provided by protobuf library will by default use 

221 'type.googleapis.com/full.type.name' as the type URL and the unpack methods 

222 only use the fully qualified type name after the last '/' in the type URL, 

223 for example "foo.bar.com/x/y.z" will yield type name "y.z". JSON The JSON 

224 representation of an `Any` value uses the regular representation of the 

225 deserialized, embedded message, with an additional field `@type` which 

226 contains the type URL. Example: package google.profile; message 

227 Person { string first_name = 1; string last_name = 2; } 

228 { "@type": "type.googleapis.com/google.profile.Person", 

229 "firstName": <string>, "lastName": <string> } If the embedded 

230 message type is well-known and has a custom JSON representation, that 

231 representation will be embedded adding a field `value` which holds the 

232 custom JSON in addition to the `@type` field. Example (for message 

233 [google.protobuf.Duration][]): { "@type": 

234 "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" 

235 } 

236 """ 

237 

238 type_url: str = betterproto.string_field(1) 

239 """ 

240 A URL/resource name that uniquely identifies the type of the serialized 

241 protocol buffer message. This string must contain at least one "/" 

242 character. The last segment of the URL's path must represent the fully 

243 qualified name of the type (as in `path/google.protobuf.Duration`). The 

244 name should be in a canonical form (e.g., leading "." is not accepted). In 

245 practice, teams usually precompile into the binary all types that they 

246 expect it to use in the context of Any. However, for URLs which use the 

247 scheme `http`, `https`, or no scheme, one can optionally set up a type 

248 server that maps type URLs to message definitions as follows: * If no 

249 scheme is provided, `https` is assumed. * An HTTP GET on the URL must yield 

250 a [google.protobuf.Type][] value in binary format, or produce an error. * 

251 Applications are allowed to cache lookup results based on the URL, or 

252 have them precompiled into a binary to avoid any lookup. Therefore, 

253 binary compatibility needs to be preserved on changes to types. (Use 

254 versioned type names to manage breaking changes.) Note: this 

255 functionality is not currently available in the official protobuf release, 

256 and it is not used for type URLs beginning with type.googleapis.com. 

257 Schemes other than `http`, `https` (or the empty scheme) might be used with 

258 implementation specific semantics. 

259 """ 

260 

261 value: bytes = betterproto.bytes_field(2) 

262 """ 

263 Must be a valid serialized protocol buffer of the above specified type. 

264 """ 

265 

266 

267@dataclass(eq=False, repr=False) 

268class SourceContext(betterproto.Message): 

269 """ 

270 `SourceContext` represents information about the source of a protobuf 

271 element, like the file in which it is defined. 

272 """ 

273 

274 file_name: str = betterproto.string_field(1) 

275 """ 

276 The path-qualified name of the .proto file that contained the associated 

277 protobuf element. For example: `"google/protobuf/source_context.proto"`. 

278 """ 

279 

280 

281@dataclass(eq=False, repr=False) 

282class Type(betterproto.Message): 

283 """A protocol buffer message type.""" 

284 

285 name: str = betterproto.string_field(1) 

286 """The fully qualified message name.""" 

287 

288 fields: List["Field"] = betterproto.message_field(2) 

289 """The list of fields.""" 

290 

291 oneofs: List[str] = betterproto.string_field(3) 

292 """The list of types appearing in `oneof` definitions in this type.""" 

293 

294 options: List["Option"] = betterproto.message_field(4) 

295 """The protocol buffer options.""" 

296 

297 source_context: "SourceContext" = betterproto.message_field(5) 

298 """The source context.""" 

299 

300 syntax: "Syntax" = betterproto.enum_field(6) 

301 """The source syntax.""" 

302 

303 

304@dataclass(eq=False, repr=False) 

305class Field(betterproto.Message): 

306 """A single field of a message type.""" 

307 

308 kind: "FieldKind" = betterproto.enum_field(1) 

309 """The field type.""" 

310 

311 cardinality: "FieldCardinality" = betterproto.enum_field(2) 

312 """The field cardinality.""" 

313 

314 number: int = betterproto.int32_field(3) 

315 """The field number.""" 

316 

317 name: str = betterproto.string_field(4) 

318 """The field name.""" 

319 

320 type_url: str = betterproto.string_field(6) 

321 """ 

322 The field type URL, without the scheme, for message or enumeration types. 

323 Example: `"type.googleapis.com/google.protobuf.Timestamp"`. 

324 """ 

325 

326 oneof_index: int = betterproto.int32_field(7) 

327 """ 

328 The index of the field type in `Type.oneofs`, for message or enumeration 

329 types. The first type has index 1; zero means the type is not in the list. 

330 """ 

331 

332 packed: bool = betterproto.bool_field(8) 

333 """Whether to use alternative packed wire representation.""" 

334 

335 options: List["Option"] = betterproto.message_field(9) 

336 """The protocol buffer options.""" 

337 

338 json_name: str = betterproto.string_field(10) 

339 """The field JSON name.""" 

340 

341 default_value: str = betterproto.string_field(11) 

342 """ 

343 The string value of the default value of this field. Proto2 syntax only. 

344 """ 

345 

346 

347@dataclass(eq=False, repr=False) 

348class Enum(betterproto.Message): 

349 """Enum type definition.""" 

350 

351 name: str = betterproto.string_field(1) 

352 """Enum type name.""" 

353 

354 enumvalue: List["EnumValue"] = betterproto.message_field( 

355 2, wraps=betterproto.TYPE_ENUM 

356 ) 

357 """Enum value definitions.""" 

358 

359 options: List["Option"] = betterproto.message_field(3) 

360 """Protocol buffer options.""" 

361 

362 source_context: "SourceContext" = betterproto.message_field(4) 

363 """The source context.""" 

364 

365 syntax: "Syntax" = betterproto.enum_field(5) 

366 """The source syntax.""" 

367 

368 

369@dataclass(eq=False, repr=False) 

370class EnumValue(betterproto.Message): 

371 """Enum value definition.""" 

372 

373 name: str = betterproto.string_field(1) 

374 """Enum value name.""" 

375 

376 number: int = betterproto.int32_field(2) 

377 """Enum value number.""" 

378 

379 options: List["Option"] = betterproto.message_field(3) 

380 """Protocol buffer options.""" 

381 

382 

383@dataclass(eq=False, repr=False) 

384class Option(betterproto.Message): 

385 """ 

386 A protocol buffer option, which can be attached to a message, field, 

387 enumeration, etc. 

388 """ 

389 

390 name: str = betterproto.string_field(1) 

391 """ 

392 The option's name. For protobuf built-in options (options defined in 

393 descriptor.proto), this is the short name. For example, `"map_entry"`. For 

394 custom options, it should be the fully-qualified name. For example, 

395 `"google.api.http"`. 

396 """ 

397 

398 value: "Any" = betterproto.message_field(2) 

399 """ 

400 The option's value packed in an Any message. If the value is a primitive, 

401 the corresponding wrapper type defined in google/protobuf/wrappers.proto 

402 should be used. If the value is an enum, it should be stored as an int32 

403 value using the google.protobuf.Int32Value type. 

404 """ 

405 

406 

407@dataclass(eq=False, repr=False) 

408class Api(betterproto.Message): 

409 """ 

410 Api is a light-weight descriptor for an API Interface. Interfaces are also 

411 described as "protocol buffer services" in some contexts, such as by the 

412 "service" keyword in a .proto file, but they are different from API 

413 Services, which represent a concrete implementation of an interface as 

414 opposed to simply a description of methods and bindings. They are also 

415 sometimes simply referred to as "APIs" in other contexts, such as the name 

416 of this message itself. See https://cloud.google.com/apis/design/glossary 

417 for detailed terminology. 

418 """ 

419 

420 name: str = betterproto.string_field(1) 

421 """ 

422 The fully qualified name of this interface, including package name followed 

423 by the interface's simple name. 

424 """ 

425 

426 methods: List["Method"] = betterproto.message_field(2) 

427 """The methods of this interface, in unspecified order.""" 

428 

429 options: List["Option"] = betterproto.message_field(3) 

430 """Any metadata attached to the interface.""" 

431 

432 version: str = betterproto.string_field(4) 

433 """ 

434 A version string for this interface. If specified, must have the form 

435 `major-version.minor-version`, as in `1.10`. If the minor version is 

436 omitted, it defaults to zero. If the entire version field is empty, the 

437 major version is derived from the package name, as outlined below. If the 

438 field is not empty, the version in the package name will be verified to be 

439 consistent with what is provided here. The versioning schema uses [semantic 

440 versioning](http://semver.org) where the major version number indicates a 

441 breaking change and the minor version an additive, non-breaking change. 

442 Both version numbers are signals to users what to expect from different 

443 versions, and should be carefully chosen based on the product plan. The 

444 major version is also reflected in the package name of the interface, which 

445 must end in `v<major-version>`, as in `google.feature.v1`. For major 

446 versions 0 and 1, the suffix can be omitted. Zero major versions must only 

447 be used for experimental, non-GA interfaces. 

448 """ 

449 

450 source_context: "SourceContext" = betterproto.message_field(5) 

451 """ 

452 Source context for the protocol buffer service represented by this message. 

453 """ 

454 

455 mixins: List["Mixin"] = betterproto.message_field(6) 

456 """Included interfaces. See [Mixin][].""" 

457 

458 syntax: "Syntax" = betterproto.enum_field(7) 

459 """The source syntax of the service.""" 

460 

461 

462@dataclass(eq=False, repr=False) 

463class Method(betterproto.Message): 

464 """Method represents a method of an API interface.""" 

465 

466 name: str = betterproto.string_field(1) 

467 """The simple name of this method.""" 

468 

469 request_type_url: str = betterproto.string_field(2) 

470 """A URL of the input message type.""" 

471 

472 request_streaming: bool = betterproto.bool_field(3) 

473 """If true, the request is streamed.""" 

474 

475 response_type_url: str = betterproto.string_field(4) 

476 """The URL of the output message type.""" 

477 

478 response_streaming: bool = betterproto.bool_field(5) 

479 """If true, the response is streamed.""" 

480 

481 options: List["Option"] = betterproto.message_field(6) 

482 """Any metadata attached to the method.""" 

483 

484 syntax: "Syntax" = betterproto.enum_field(7) 

485 """The source syntax of this method.""" 

486 

487 

488@dataclass(eq=False, repr=False) 

489class Mixin(betterproto.Message): 

490 """ 

491 Declares an API Interface to be included in this interface. The including 

492 interface must redeclare all the methods from the included interface, but 

493 documentation and options are inherited as follows: - If after comment and 

494 whitespace stripping, the documentation string of the redeclared method 

495 is empty, it will be inherited from the original method. - Each 

496 annotation belonging to the service config (http, visibility) which is 

497 not set in the redeclared method will be inherited. - If an http 

498 annotation is inherited, the path pattern will be modified as follows. 

499 Any version prefix will be replaced by the version of the including 

500 interface plus the [root][] path if specified. Example of a simple mixin: 

501 package google.acl.v1; service AccessControl { // Get the 

502 underlying ACL object. rpc GetAcl(GetAclRequest) returns (Acl) { 

503 option (google.api.http).get = "/v1/{resource=**}:getAcl"; } } 

504 package google.storage.v2; service Storage { rpc 

505 GetAcl(GetAclRequest) returns (Acl); // Get a data record. rpc 

506 GetData(GetDataRequest) returns (Data) { option 

507 (google.api.http).get = "/v2/{resource=**}"; } } Example of a 

508 mixin configuration: apis: - name: google.storage.v2.Storage 

509 mixins: - name: google.acl.v1.AccessControl The mixin construct 

510 implies that all methods in `AccessControl` are also declared with same 

511 name and request/response types in `Storage`. A documentation generator or 

512 annotation processor will see the effective `Storage.GetAcl` method after 

513 inheriting documentation and annotations as follows: service Storage { 

514 // Get the underlying ACL object. rpc GetAcl(GetAclRequest) returns 

515 (Acl) { option (google.api.http).get = "/v2/{resource=**}:getAcl"; 

516 } ... } Note how the version in the path pattern changed from 

517 `v1` to `v2`. If the `root` field in the mixin is specified, it should be a 

518 relative path under which inherited HTTP paths are placed. Example: 

519 apis: - name: google.storage.v2.Storage mixins: - name: 

520 google.acl.v1.AccessControl root: acls This implies the following 

521 inherited HTTP annotation: service Storage { // Get the 

522 underlying ACL object. rpc GetAcl(GetAclRequest) returns (Acl) { 

523 option (google.api.http).get = "/v2/acls/{resource=**}:getAcl"; } 

524 ... } 

525 """ 

526 

527 name: str = betterproto.string_field(1) 

528 """The fully qualified name of the interface which is included.""" 

529 

530 root: str = betterproto.string_field(2) 

531 """ 

532 If non-empty specifies a path under which inherited HTTP paths are rooted. 

533 """ 

534 

535 

536@dataclass(eq=False, repr=False) 

537class FileDescriptorSet(betterproto.Message): 

538 """ 

539 The protocol compiler can output a FileDescriptorSet containing the .proto 

540 files it parses. 

541 """ 

542 

543 file: List["FileDescriptorProto"] = betterproto.message_field(1) 

544 

545 

546@dataclass(eq=False, repr=False) 

547class FileDescriptorProto(betterproto.Message): 

548 """Describes a complete .proto file.""" 

549 

550 name: str = betterproto.string_field(1) 

551 package: str = betterproto.string_field(2) 

552 dependency: List[str] = betterproto.string_field(3) 

553 """Names of files imported by this file.""" 

554 

555 public_dependency: List[int] = betterproto.int32_field(10) 

556 """Indexes of the public imported files in the dependency list above.""" 

557 

558 weak_dependency: List[int] = betterproto.int32_field(11) 

559 """ 

560 Indexes of the weak imported files in the dependency list. For Google- 

561 internal migration only. Do not use. 

562 """ 

563 

564 message_type: List["DescriptorProto"] = betterproto.message_field(4) 

565 """All top-level definitions in this file.""" 

566 

567 enum_type: List["EnumDescriptorProto"] = betterproto.message_field(5) 

568 service: List["ServiceDescriptorProto"] = betterproto.message_field(6) 

569 extension: List["FieldDescriptorProto"] = betterproto.message_field(7) 

570 options: "FileOptions" = betterproto.message_field(8) 

571 source_code_info: "SourceCodeInfo" = betterproto.message_field(9) 

572 """ 

573 This field contains optional information about the original source code. 

574 You may safely remove this entire field without harming runtime 

575 functionality of the descriptors -- the information is needed only by 

576 development tools. 

577 """ 

578 

579 syntax: str = betterproto.string_field(12) 

580 """ 

581 The syntax of the proto file. The supported values are "proto2" and 

582 "proto3". 

583 """ 

584 

585 

586@dataclass(eq=False, repr=False) 

587class DescriptorProto(betterproto.Message): 

588 """Describes a message type.""" 

589 

590 name: str = betterproto.string_field(1) 

591 field: List["FieldDescriptorProto"] = betterproto.message_field(2) 

592 extension: List["FieldDescriptorProto"] = betterproto.message_field(6) 

593 nested_type: List["DescriptorProto"] = betterproto.message_field(3) 

594 enum_type: List["EnumDescriptorProto"] = betterproto.message_field(4) 

595 extension_range: List["DescriptorProtoExtensionRange"] = betterproto.message_field( 

596 5 

597 ) 

598 oneof_decl: List["OneofDescriptorProto"] = betterproto.message_field(8) 

599 options: "MessageOptions" = betterproto.message_field(7) 

600 reserved_range: List["DescriptorProtoReservedRange"] = betterproto.message_field(9) 

601 reserved_name: List[str] = betterproto.string_field(10) 

602 """ 

603 Reserved field names, which may not be used by fields in the same message. 

604 A given name may only be reserved once. 

605 """ 

606 

607 

608@dataclass(eq=False, repr=False) 

609class DescriptorProtoExtensionRange(betterproto.Message): 

610 start: int = betterproto.int32_field(1) 

611 end: int = betterproto.int32_field(2) 

612 options: "ExtensionRangeOptions" = betterproto.message_field(3) 

613 

614 

615@dataclass(eq=False, repr=False) 

616class DescriptorProtoReservedRange(betterproto.Message): 

617 """ 

618 Range of reserved tag numbers. Reserved tag numbers may not be used by 

619 fields or extension ranges in the same message. Reserved ranges may not 

620 overlap. 

621 """ 

622 

623 start: int = betterproto.int32_field(1) 

624 end: int = betterproto.int32_field(2) 

625 

626 

627@dataclass(eq=False, repr=False) 

628class ExtensionRangeOptions(betterproto.Message): 

629 uninterpreted_option: List["UninterpretedOption"] = betterproto.message_field(999) 

630 """The parser stores options it doesn't recognize here. See above.""" 

631 

632 

633@dataclass(eq=False, repr=False) 

634class FieldDescriptorProto(betterproto.Message): 

635 """Describes a field within a message.""" 

636 

637 name: str = betterproto.string_field(1) 

638 number: int = betterproto.int32_field(3) 

639 label: "FieldDescriptorProtoLabel" = betterproto.enum_field(4) 

640 type: "FieldDescriptorProtoType" = betterproto.enum_field(5) 

641 """ 

642 If type_name is set, this need not be set. If both this and type_name are 

643 set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. 

644 """ 

645 

646 type_name: str = betterproto.string_field(6) 

647 """ 

648 For message and enum types, this is the name of the type. If the name 

649 starts with a '.', it is fully-qualified. Otherwise, C++-like scoping 

650 rules are used to find the type (i.e. first the nested types within this 

651 message are searched, then within the parent, on up to the root namespace). 

652 """ 

653 

654 extendee: str = betterproto.string_field(2) 

655 """ 

656 For extensions, this is the name of the type being extended. It is 

657 resolved in the same manner as type_name. 

658 """ 

659 

660 default_value: str = betterproto.string_field(7) 

661 """ 

662 For numeric types, contains the original text representation of the value. 

663 For booleans, "true" or "false". For strings, contains the default text 

664 contents (not escaped in any way). For bytes, contains the C escaped value. 

665 All bytes >= 128 are escaped. 

666 """ 

667 

668 oneof_index: int = betterproto.int32_field(9) 

669 """ 

670 If set, gives the index of a oneof in the containing type's oneof_decl 

671 list. This field is a member of that oneof. 

672 """ 

673 

674 json_name: str = betterproto.string_field(10) 

675 """ 

676 JSON name of this field. The value is set by protocol compiler. If the user 

677 has set a "json_name" option on this field, that option's value will be 

678 used. Otherwise, it's deduced from the field's name by converting it to 

679 camelCase. 

680 """ 

681 

682 options: "FieldOptions" = betterproto.message_field(8) 

683 proto3_optional: bool = betterproto.bool_field(17) 

684 """ 

685 If true, this is a proto3 "optional". When a proto3 field is optional, it 

686 tracks presence regardless of field type. When proto3_optional is true, 

687 this field must be belong to a oneof to signal to old proto3 clients that 

688 presence is tracked for this field. This oneof is known as a "synthetic" 

689 oneof, and this field must be its sole member (each proto3 optional field 

690 gets its own synthetic oneof). Synthetic oneofs exist in the descriptor 

691 only, and do not generate any API. Synthetic oneofs must be ordered after 

692 all "real" oneofs. For message fields, proto3_optional doesn't create any 

693 semantic change, since non-repeated message fields always track presence. 

694 However it still indicates the semantic detail of whether the user wrote 

695 "optional" or not. This can be useful for round-tripping the .proto file. 

696 For consistency we give message fields a synthetic oneof also, even though 

697 it is not required to track presence. This is especially important because 

698 the parser can't tell if a field is a message or an enum, so it must always 

699 create a synthetic oneof. Proto2 optional fields do not set this flag, 

700 because they already indicate optional with `LABEL_OPTIONAL`. 

701 """ 

702 

703 

704@dataclass(eq=False, repr=False) 

705class OneofDescriptorProto(betterproto.Message): 

706 """Describes a oneof.""" 

707 

708 name: str = betterproto.string_field(1) 

709 options: "OneofOptions" = betterproto.message_field(2) 

710 

711 

712@dataclass(eq=False, repr=False) 

713class EnumDescriptorProto(betterproto.Message): 

714 """Describes an enum type.""" 

715 

716 name: str = betterproto.string_field(1) 

717 value: List["EnumValueDescriptorProto"] = betterproto.message_field(2) 

718 options: "EnumOptions" = betterproto.message_field(3) 

719 reserved_range: List[ 

720 "EnumDescriptorProtoEnumReservedRange" 

721 ] = betterproto.message_field(4) 

722 """ 

723 Range of reserved numeric values. Reserved numeric values may not be used 

724 by enum values in the same enum declaration. Reserved ranges may not 

725 overlap. 

726 """ 

727 

728 reserved_name: List[str] = betterproto.string_field(5) 

729 """ 

730 Reserved enum value names, which may not be reused. A given name may only 

731 be reserved once. 

732 """ 

733 

734 

735@dataclass(eq=False, repr=False) 

736class EnumDescriptorProtoEnumReservedRange(betterproto.Message): 

737 """ 

738 Range of reserved numeric values. Reserved values may not be used by 

739 entries in the same enum. Reserved ranges may not overlap. Note that this 

740 is distinct from DescriptorProto.ReservedRange in that it is inclusive such 

741 that it can appropriately represent the entire int32 domain. 

742 """ 

743 

744 start: int = betterproto.int32_field(1) 

745 end: int = betterproto.int32_field(2) 

746 

747 

748@dataclass(eq=False, repr=False) 

749class EnumValueDescriptorProto(betterproto.Message): 

750 """Describes a value within an enum.""" 

751 

752 name: str = betterproto.string_field(1) 

753 number: int = betterproto.int32_field(2) 

754 options: "EnumValueOptions" = betterproto.message_field(3) 

755 

756 

757@dataclass(eq=False, repr=False) 

758class ServiceDescriptorProto(betterproto.Message): 

759 """Describes a service.""" 

760 

761 name: str = betterproto.string_field(1) 

762 method: List["MethodDescriptorProto"] = betterproto.message_field(2) 

763 options: "ServiceOptions" = betterproto.message_field(3) 

764 

765 

766@dataclass(eq=False, repr=False) 

767class MethodDescriptorProto(betterproto.Message): 

768 """Describes a method of a service.""" 

769 

770 name: str = betterproto.string_field(1) 

771 input_type: str = betterproto.string_field(2) 

772 """ 

773 Input and output type names. These are resolved in the same way as 

774 FieldDescriptorProto.type_name, but must refer to a message type. 

775 """ 

776 

777 output_type: str = betterproto.string_field(3) 

778 options: "MethodOptions" = betterproto.message_field(4) 

779 client_streaming: bool = betterproto.bool_field(5) 

780 """Identifies if client streams multiple client messages""" 

781 

782 server_streaming: bool = betterproto.bool_field(6) 

783 """Identifies if server streams multiple server messages""" 

784 

785 

786@dataclass(eq=False, repr=False) 

787class FileOptions(betterproto.Message): 

788 java_package: str = betterproto.string_field(1) 

789 """ 

790 Sets the Java package where classes generated from this .proto will be 

791 placed. By default, the proto package is used, but this is often 

792 inappropriate because proto packages do not normally start with backwards 

793 domain names. 

794 """ 

795 

796 java_outer_classname: str = betterproto.string_field(8) 

797 """ 

798 Controls the name of the wrapper Java class generated for the .proto file. 

799 That class will always contain the .proto file's getDescriptor() method as 

800 well as any top-level extensions defined in the .proto file. If 

801 java_multiple_files is disabled, then all the other classes from the .proto 

802 file will be nested inside the single wrapper outer class. 

803 """ 

804 

805 java_multiple_files: bool = betterproto.bool_field(10) 

806 """ 

807 If enabled, then the Java code generator will generate a separate .java 

808 file for each top-level message, enum, and service defined in the .proto 

809 file. Thus, these types will *not* be nested inside the wrapper class 

810 named by java_outer_classname. However, the wrapper class will still be 

811 generated to contain the file's getDescriptor() method as well as any top- 

812 level extensions defined in the file. 

813 """ 

814 

815 java_generate_equals_and_hash: bool = betterproto.bool_field(20) 

816 """This option does nothing.""" 

817 

818 java_string_check_utf8: bool = betterproto.bool_field(27) 

819 """ 

820 If set true, then the Java2 code generator will generate code that throws 

821 an exception whenever an attempt is made to assign a non-UTF-8 byte 

822 sequence to a string field. Message reflection will do the same. However, 

823 an extension field still accepts non-UTF-8 byte sequences. This option has 

824 no effect on when used with the lite runtime. 

825 """ 

826 

827 optimize_for: "FileOptionsOptimizeMode" = betterproto.enum_field(9) 

828 go_package: str = betterproto.string_field(11) 

829 """ 

830 Sets the Go package where structs generated from this .proto will be 

831 placed. If omitted, the Go package will be derived from the following: - 

832 The basename of the package import path, if provided. - Otherwise, the 

833 package statement in the .proto file, if present. - Otherwise, the 

834 basename of the .proto file, without extension. 

835 """ 

836 

837 cc_generic_services: bool = betterproto.bool_field(16) 

838 """ 

839 Should generic services be generated in each language? "Generic" services 

840 are not specific to any particular RPC system. They are generated by the 

841 main code generators in each language (without additional plugins). Generic 

842 services were the only kind of service generation supported by early 

843 versions of google.protobuf. Generic services are now considered deprecated 

844 in favor of using plugins that generate code specific to your particular 

845 RPC system. Therefore, these default to false. Old code which depends on 

846 generic services should explicitly set them to true. 

847 """ 

848 

849 java_generic_services: bool = betterproto.bool_field(17) 

850 py_generic_services: bool = betterproto.bool_field(18) 

851 php_generic_services: bool = betterproto.bool_field(42) 

852 deprecated: bool = betterproto.bool_field(23) 

853 """ 

854 Is this file deprecated? Depending on the target platform, this can emit 

855 Deprecated annotations for everything in the file, or it will be completely 

856 ignored; in the very least, this is a formalization for deprecating files. 

857 """ 

858 

859 cc_enable_arenas: bool = betterproto.bool_field(31) 

860 """ 

861 Enables the use of arenas for the proto messages in this file. This applies 

862 only to generated classes for C++. 

863 """ 

864 

865 objc_class_prefix: str = betterproto.string_field(36) 

866 """ 

867 Sets the objective c class prefix which is prepended to all objective c 

868 generated classes from this .proto. There is no default. 

869 """ 

870 

871 csharp_namespace: str = betterproto.string_field(37) 

872 """Namespace for generated classes; defaults to the package.""" 

873 

874 swift_prefix: str = betterproto.string_field(39) 

875 """ 

876 By default Swift generators will take the proto package and CamelCase it 

877 replacing '.' with underscore and use that to prefix the types/symbols 

878 defined. When this options is provided, they will use this value instead to 

879 prefix the types/symbols defined. 

880 """ 

881 

882 php_class_prefix: str = betterproto.string_field(40) 

883 """ 

884 Sets the php class prefix which is prepended to all php generated classes 

885 from this .proto. Default is empty. 

886 """ 

887 

888 php_namespace: str = betterproto.string_field(41) 

889 """ 

890 Use this option to change the namespace of php generated classes. Default 

891 is empty. When this option is empty, the package name will be used for 

892 determining the namespace. 

893 """ 

894 

895 php_metadata_namespace: str = betterproto.string_field(44) 

896 """ 

897 Use this option to change the namespace of php generated metadata classes. 

898 Default is empty. When this option is empty, the proto file name will be 

899 used for determining the namespace. 

900 """ 

901 

902 ruby_package: str = betterproto.string_field(45) 

903 """ 

904 Use this option to change the package of ruby generated classes. Default is 

905 empty. When this option is not set, the package name will be used for 

906 determining the ruby package. 

907 """ 

908 

909 uninterpreted_option: List["UninterpretedOption"] = betterproto.message_field(999) 

910 """ 

911 The parser stores options it doesn't recognize here. See the documentation 

912 for the "Options" section above. 

913 """ 

914 

915 def __post_init__(self) -> None: 

916 super().__post_init__() 

917 if self.is_set("java_generate_equals_and_hash"): 

918 warnings.warn( 

919 "FileOptions.java_generate_equals_and_hash is deprecated", 

920 DeprecationWarning, 

921 ) 

922 

923 

924@dataclass(eq=False, repr=False) 

925class MessageOptions(betterproto.Message): 

926 message_set_wire_format: bool = betterproto.bool_field(1) 

927 """ 

928 Set true to use the old proto1 MessageSet wire format for extensions. This 

929 is provided for backwards-compatibility with the MessageSet wire format. 

930 You should not use this for any other reason: It's less efficient, has 

931 fewer features, and is more complicated. The message must be defined 

932 exactly as follows: message Foo { option message_set_wire_format = 

933 true; extensions 4 to max; } Note that the message cannot have any 

934 defined fields; MessageSets only have extensions. All extensions of your 

935 type must be singular messages; e.g. they cannot be int32s, enums, or 

936 repeated messages. Because this is an option, the above two restrictions 

937 are not enforced by the protocol compiler. 

938 """ 

939 

940 no_standard_descriptor_accessor: bool = betterproto.bool_field(2) 

941 """ 

942 Disables the generation of the standard "descriptor()" accessor, which can 

943 conflict with a field of the same name. This is meant to make migration 

944 from proto1 easier; new code should avoid fields named "descriptor". 

945 """ 

946 

947 deprecated: bool = betterproto.bool_field(3) 

948 """ 

949 Is this message deprecated? Depending on the target platform, this can emit 

950 Deprecated annotations for the message, or it will be completely ignored; 

951 in the very least, this is a formalization for deprecating messages. 

952 """ 

953 

954 map_entry: bool = betterproto.bool_field(7) 

955 """ 

956 Whether the message is an automatically generated map entry type for the 

957 maps field. For maps fields: map<KeyType, ValueType> map_field = 1; The 

958 parsed descriptor looks like: message MapFieldEntry { option 

959 map_entry = true; optional KeyType key = 1; optional 

960 ValueType value = 2; } repeated MapFieldEntry map_field = 1; 

961 Implementations may choose not to generate the map_entry=true message, but 

962 use a native map in the target language to hold the keys and values. The 

963 reflection APIs in such implementations still need to work as if the field 

964 is a repeated message field. NOTE: Do not set the option in .proto files. 

965 Always use the maps syntax instead. The option should only be implicitly 

966 set by the proto compiler parser. 

967 """ 

968 

969 uninterpreted_option: List["UninterpretedOption"] = betterproto.message_field(999) 

970 """The parser stores options it doesn't recognize here. See above.""" 

971 

972 

973@dataclass(eq=False, repr=False) 

974class FieldOptions(betterproto.Message): 

975 ctype: "FieldOptionsCType" = betterproto.enum_field(1) 

976 """ 

977 The ctype option instructs the C++ code generator to use a different 

978 representation of the field than it normally would. See the specific 

979 options below. This option is not yet implemented in the open source 

980 release -- sorry, we'll try to include it in a future version! 

981 """ 

982 

983 packed: bool = betterproto.bool_field(2) 

984 """ 

985 The packed option can be enabled for repeated primitive fields to enable a 

986 more efficient representation on the wire. Rather than repeatedly writing 

987 the tag and type for each element, the entire array is encoded as a single 

988 length-delimited blob. In proto3, only explicit setting it to false will 

989 avoid using packed encoding. 

990 """ 

991 

992 jstype: "FieldOptionsJsType" = betterproto.enum_field(6) 

993 """ 

994 The jstype option determines the JavaScript type used for values of the 

995 field. The option is permitted only for 64 bit integral and fixed types 

996 (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING 

997 is represented as JavaScript string, which avoids loss of precision that 

998 can happen when a large value is converted to a floating point JavaScript. 

999 Specifying JS_NUMBER for the jstype causes the generated JavaScript code to 

1000 use the JavaScript "number" type. The behavior of the default option 

1001 JS_NORMAL is implementation dependent. This option is an enum to permit 

1002 additional types to be added, e.g. goog.math.Integer. 

1003 """ 

1004 

1005 lazy: bool = betterproto.bool_field(5) 

1006 """ 

1007 Should this field be parsed lazily? Lazy applies only to message-type 

1008 fields. It means that when the outer message is initially parsed, the 

1009 inner message's contents will not be parsed but instead stored in encoded 

1010 form. The inner message will actually be parsed when it is first accessed. 

1011 This is only a hint. Implementations are free to choose whether to use 

1012 eager or lazy parsing regardless of the value of this option. However, 

1013 setting this option true suggests that the protocol author believes that 

1014 using lazy parsing on this field is worth the additional bookkeeping 

1015 overhead typically needed to implement it. This option does not affect the 

1016 public interface of any generated code; all method signatures remain the 

1017 same. Furthermore, thread-safety of the interface is not affected by this 

1018 option; const methods remain safe to call from multiple threads 

1019 concurrently, while non-const methods continue to require exclusive access. 

1020 Note that implementations may choose not to check required fields within a 

1021 lazy sub-message. That is, calling IsInitialized() on the outer message 

1022 may return true even if the inner message has missing required fields. This 

1023 is necessary because otherwise the inner message would have to be parsed in 

1024 order to perform the check, defeating the purpose of lazy parsing. An 

1025 implementation which chooses not to check required fields must be 

1026 consistent about it. That is, for any particular sub-message, the 

1027 implementation must either *always* check its required fields, or *never* 

1028 check its required fields, regardless of whether or not the message has 

1029 been parsed. As of 2021, lazy does no correctness checks on the byte stream 

1030 during parsing. This may lead to crashes if and when an invalid byte 

1031 stream is finally parsed upon access. TODO(b/211906113): Enable validation 

1032 on lazy fields. 

1033 """ 

1034 

1035 unverified_lazy: bool = betterproto.bool_field(15) 

1036 """ 

1037 unverified_lazy does no correctness checks on the byte stream. This should 

1038 only be used where lazy with verification is prohibitive for performance 

1039 reasons. 

1040 """ 

1041 

1042 deprecated: bool = betterproto.bool_field(3) 

1043 """ 

1044 Is this field deprecated? Depending on the target platform, this can emit 

1045 Deprecated annotations for accessors, or it will be completely ignored; in 

1046 the very least, this is a formalization for deprecating fields. 

1047 """ 

1048 

1049 weak: bool = betterproto.bool_field(10) 

1050 """For Google-internal migration only. Do not use.""" 

1051 

1052 uninterpreted_option: List["UninterpretedOption"] = betterproto.message_field(999) 

1053 """The parser stores options it doesn't recognize here. See above.""" 

1054 

1055 

1056@dataclass(eq=False, repr=False) 

1057class OneofOptions(betterproto.Message): 

1058 uninterpreted_option: List["UninterpretedOption"] = betterproto.message_field(999) 

1059 """The parser stores options it doesn't recognize here. See above.""" 

1060 

1061 

1062@dataclass(eq=False, repr=False) 

1063class EnumOptions(betterproto.Message): 

1064 allow_alias: bool = betterproto.bool_field(2) 

1065 """ 

1066 Set this option to true to allow mapping different tag names to the same 

1067 value. 

1068 """ 

1069 

1070 deprecated: bool = betterproto.bool_field(3) 

1071 """ 

1072 Is this enum deprecated? Depending on the target platform, this can emit 

1073 Deprecated annotations for the enum, or it will be completely ignored; in 

1074 the very least, this is a formalization for deprecating enums. 

1075 """ 

1076 

1077 uninterpreted_option: List["UninterpretedOption"] = betterproto.message_field(999) 

1078 """The parser stores options it doesn't recognize here. See above.""" 

1079 

1080 

1081@dataclass(eq=False, repr=False) 

1082class EnumValueOptions(betterproto.Message): 

1083 deprecated: bool = betterproto.bool_field(1) 

1084 """ 

1085 Is this enum value deprecated? Depending on the target platform, this can 

1086 emit Deprecated annotations for the enum value, or it will be completely 

1087 ignored; in the very least, this is a formalization for deprecating enum 

1088 values. 

1089 """ 

1090 

1091 uninterpreted_option: List["UninterpretedOption"] = betterproto.message_field(999) 

1092 """The parser stores options it doesn't recognize here. See above.""" 

1093 

1094 

1095@dataclass(eq=False, repr=False) 

1096class ServiceOptions(betterproto.Message): 

1097 deprecated: bool = betterproto.bool_field(33) 

1098 """ 

1099 Is this service deprecated? Depending on the target platform, this can emit 

1100 Deprecated annotations for the service, or it will be completely ignored; 

1101 in the very least, this is a formalization for deprecating services. 

1102 """ 

1103 

1104 uninterpreted_option: List["UninterpretedOption"] = betterproto.message_field(999) 

1105 """The parser stores options it doesn't recognize here. See above.""" 

1106 

1107 

1108@dataclass(eq=False, repr=False) 

1109class MethodOptions(betterproto.Message): 

1110 deprecated: bool = betterproto.bool_field(33) 

1111 """ 

1112 Is this method deprecated? Depending on the target platform, this can emit 

1113 Deprecated annotations for the method, or it will be completely ignored; in 

1114 the very least, this is a formalization for deprecating methods. 

1115 """ 

1116 

1117 idempotency_level: "MethodOptionsIdempotencyLevel" = betterproto.enum_field(34) 

1118 uninterpreted_option: List["UninterpretedOption"] = betterproto.message_field(999) 

1119 """The parser stores options it doesn't recognize here. See above.""" 

1120 

1121 

1122@dataclass(eq=False, repr=False) 

1123class UninterpretedOption(betterproto.Message): 

1124 """ 

1125 A message representing a option the parser does not recognize. This only 

1126 appears in options protos created by the compiler::Parser class. 

1127 DescriptorPool resolves these when building Descriptor objects. Therefore, 

1128 options protos in descriptor objects (e.g. returned by 

1129 Descriptor::options(), or produced by Descriptor::CopyTo()) will never have 

1130 UninterpretedOptions in them. 

1131 """ 

1132 

1133 name: List["UninterpretedOptionNamePart"] = betterproto.message_field(2) 

1134 identifier_value: str = betterproto.string_field(3) 

1135 """ 

1136 The value of the uninterpreted option, in whatever type the tokenizer 

1137 identified it as during parsing. Exactly one of these should be set. 

1138 """ 

1139 

1140 positive_int_value: int = betterproto.uint64_field(4) 

1141 negative_int_value: int = betterproto.int64_field(5) 

1142 double_value: float = betterproto.double_field(6) 

1143 string_value: bytes = betterproto.bytes_field(7) 

1144 aggregate_value: str = betterproto.string_field(8) 

1145 

1146 

1147@dataclass(eq=False, repr=False) 

1148class UninterpretedOptionNamePart(betterproto.Message): 

1149 """ 

1150 The name of the uninterpreted option. Each string represents a segment in 

1151 a dot-separated name. is_extension is true iff a segment represents an 

1152 extension (denoted with parentheses in options specs in .proto files). 

1153 E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents 

1154 "foo.(bar.baz).qux". 

1155 """ 

1156 

1157 name_part: str = betterproto.string_field(1) 

1158 is_extension: bool = betterproto.bool_field(2) 

1159 

1160 

1161@dataclass(eq=False, repr=False) 

1162class SourceCodeInfo(betterproto.Message): 

1163 """ 

1164 Encapsulates information about the original source file from which a 

1165 FileDescriptorProto was generated. 

1166 """ 

1167 

1168 location: List["SourceCodeInfoLocation"] = betterproto.message_field(1) 

1169 """ 

1170 A Location identifies a piece of source code in a .proto file which 

1171 corresponds to a particular definition. This information is intended to be 

1172 useful to IDEs, code indexers, documentation generators, and similar tools. 

1173 For example, say we have a file like: message Foo { optional string 

1174 foo = 1; } Let's look at just the field definition: optional string foo 

1175 = 1; ^ ^^ ^^ ^ ^^^ a bc de f ghi We have the 

1176 following locations: span path represents [a,i) [ 4, 

1177 0, 2, 0 ] The whole field definition. [a,b) [ 4, 0, 2, 0, 4 ] The 

1178 label (optional). [c,d) [ 4, 0, 2, 0, 5 ] The type (string). [e,f) [ 

1179 4, 0, 2, 0, 1 ] The name (foo). [g,h) [ 4, 0, 2, 0, 3 ] The number 

1180 (1). Notes: - A location may refer to a repeated field itself (i.e. not to 

1181 any particular index within it). This is used whenever a set of elements 

1182 are logically enclosed in a single code segment. For example, an entire 

1183 extend block (possibly containing multiple extension definitions) will 

1184 have an outer location whose path refers to the "extensions" repeated 

1185 field without an index. - Multiple locations may have the same path. This 

1186 happens when a single logical declaration is spread out across multiple 

1187 places. The most obvious example is the "extend" block again -- there 

1188 may be multiple extend blocks in the same scope, each of which will have 

1189 the same path. - A location's span is not always a subset of its parent's 

1190 span. For example, the "extendee" of an extension declaration appears at 

1191 the beginning of the "extend" block and is shared by all extensions 

1192 within the block. - Just because a location's span is a subset of some 

1193 other location's span does not mean that it is a descendant. For 

1194 example, a "group" defines both a type and a field in a single 

1195 declaration. Thus, the locations corresponding to the type and field and 

1196 their components will overlap. - Code which tries to interpret locations 

1197 should probably be designed to ignore those that it doesn't understand, 

1198 as more types of locations could be recorded in the future. 

1199 """ 

1200 

1201 

1202@dataclass(eq=False, repr=False) 

1203class SourceCodeInfoLocation(betterproto.Message): 

1204 path: List[int] = betterproto.int32_field(1) 

1205 """ 

1206 Identifies which part of the FileDescriptorProto was defined at this 

1207 location. Each element is a field number or an index. They form a path 

1208 from the root FileDescriptorProto to the place where the definition occurs. 

1209 For example, this path: [ 4, 3, 2, 7, 1 ] refers to: 

1210 file.message_type(3) // 4, 3 .field(7) // 2, 7 .name() 

1211 // 1 This is because FileDescriptorProto.message_type has field number 4: 

1212 repeated DescriptorProto message_type = 4; and DescriptorProto.field has 

1213 field number 2: repeated FieldDescriptorProto field = 2; and 

1214 FieldDescriptorProto.name has field number 1: optional string name = 1; 

1215 Thus, the above path gives the location of a field name. If we removed the 

1216 last element: [ 4, 3, 2, 7 ] this path refers to the whole field 

1217 declaration (from the beginning of the label to the terminating semicolon). 

1218 """ 

1219 

1220 span: List[int] = betterproto.int32_field(2) 

1221 """ 

1222 Always has exactly three or four elements: start line, start column, end 

1223 line (optional, otherwise assumed same as start line), end column. These 

1224 are packed into a single field for efficiency. Note that line and column 

1225 numbers are zero-based -- typically you will want to add 1 to each before 

1226 displaying to a user. 

1227 """ 

1228 

1229 leading_comments: str = betterproto.string_field(3) 

1230 """ 

1231 If this SourceCodeInfo represents a complete declaration, these are any 

1232 comments appearing before and after the declaration which appear to be 

1233 attached to the declaration. A series of line comments appearing on 

1234 consecutive lines, with no other tokens appearing on those lines, will be 

1235 treated as a single comment. leading_detached_comments will keep paragraphs 

1236 of comments that appear before (but not connected to) the current element. 

1237 Each paragraph, separated by empty lines, will be one comment element in 

1238 the repeated field. Only the comment content is provided; comment markers 

1239 (e.g. //) are stripped out. For block comments, leading whitespace and an 

1240 asterisk will be stripped from the beginning of each line other than the 

1241 first. Newlines are included in the output. Examples: optional int32 foo 

1242 = 1; // Comment attached to foo. // Comment attached to bar. optional 

1243 int32 bar = 2; optional string baz = 3; // Comment attached to baz. 

1244 // Another line attached to baz. // Comment attached to qux. // // 

1245 Another line attached to qux. optional double qux = 4; // Detached 

1246 comment for corge. This is not leading or trailing comments // to qux or 

1247 corge because there are blank lines separating it from // both. // 

1248 Detached comment for corge paragraph 2. optional string corge = 5; /* 

1249 Block comment attached * to corge. Leading asterisks * will be 

1250 removed. */ /* Block comment attached to * grault. */ optional int32 

1251 grault = 6; // ignored detached comments. 

1252 """ 

1253 

1254 trailing_comments: str = betterproto.string_field(4) 

1255 leading_detached_comments: List[str] = betterproto.string_field(6) 

1256 

1257 

1258@dataclass(eq=False, repr=False) 

1259class GeneratedCodeInfo(betterproto.Message): 

1260 """ 

1261 Describes the relationship between generated code and its original source 

1262 file. A GeneratedCodeInfo message is associated with only one generated 

1263 source file, but may contain references to different source .proto files. 

1264 """ 

1265 

1266 annotation: List["GeneratedCodeInfoAnnotation"] = betterproto.message_field(1) 

1267 """ 

1268 An Annotation connects some span of text in generated code to an element of 

1269 its generating .proto file. 

1270 """ 

1271 

1272 

1273@dataclass(eq=False, repr=False) 

1274class GeneratedCodeInfoAnnotation(betterproto.Message): 

1275 path: List[int] = betterproto.int32_field(1) 

1276 """ 

1277 Identifies the element in the original source .proto file. This field is 

1278 formatted the same as SourceCodeInfo.Location.path. 

1279 """ 

1280 

1281 source_file: str = betterproto.string_field(2) 

1282 """Identifies the filesystem path to the original source .proto.""" 

1283 

1284 begin: int = betterproto.int32_field(3) 

1285 """ 

1286 Identifies the starting offset in bytes in the generated code that relates 

1287 to the identified object. 

1288 """ 

1289 

1290 end: int = betterproto.int32_field(4) 

1291 """ 

1292 Identifies the ending offset in bytes in the generated code that relates to 

1293 the identified offset. The end offset should be one past the last relevant 

1294 byte (so the length of the text = end - begin). 

1295 """ 

1296 

1297 

1298@dataclass(eq=False, repr=False) 

1299class Duration(betterproto.Message): 

1300 """ 

1301 A Duration represents a signed, fixed-length span of time represented as a 

1302 count of seconds and fractions of seconds at nanosecond resolution. It is 

1303 independent of any calendar and concepts like "day" or "month". It is 

1304 related to Timestamp in that the difference between two Timestamp values is 

1305 a Duration and it can be added or subtracted from a Timestamp. Range is 

1306 approximately +-10,000 years. # Examples Example 1: Compute Duration from 

1307 two Timestamps in pseudo code. Timestamp start = ...; Timestamp end 

1308 = ...; Duration duration = ...; duration.seconds = end.seconds - 

1309 start.seconds; duration.nanos = end.nanos - start.nanos; if 

1310 (duration.seconds < 0 && duration.nanos > 0) { duration.seconds += 1; 

1311 duration.nanos -= 1000000000; } else if (duration.seconds > 0 && 

1312 duration.nanos < 0) { duration.seconds -= 1; duration.nanos += 

1313 1000000000; } Example 2: Compute Timestamp from Timestamp + Duration in 

1314 pseudo code. Timestamp start = ...; Duration duration = ...; 

1315 Timestamp end = ...; end.seconds = start.seconds + duration.seconds; 

1316 end.nanos = start.nanos + duration.nanos; if (end.nanos < 0) { 

1317 end.seconds -= 1; end.nanos += 1000000000; } else if (end.nanos 

1318 >= 1000000000) { end.seconds += 1; end.nanos -= 1000000000; 

1319 } Example 3: Compute Duration from datetime.timedelta in Python. td = 

1320 datetime.timedelta(days=3, minutes=10) duration = Duration() 

1321 duration.FromTimedelta(td) # JSON Mapping In JSON format, the Duration type 

1322 is encoded as a string rather than an object, where the string ends in the 

1323 suffix "s" (indicating seconds) and is preceded by the number of seconds, 

1324 with nanoseconds expressed as fractional seconds. For example, 3 seconds 

1325 with 0 nanoseconds should be encoded in JSON format as "3s", while 3 

1326 seconds and 1 nanosecond should be expressed in JSON format as 

1327 "3.000000001s", and 3 seconds and 1 microsecond should be expressed in JSON 

1328 format as "3.000001s". 

1329 """ 

1330 

1331 seconds: int = betterproto.int64_field(1) 

1332 """ 

1333 Signed seconds of the span of time. Must be from -315,576,000,000 to 

1334 +315,576,000,000 inclusive. Note: these bounds are computed from: 60 

1335 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years 

1336 """ 

1337 

1338 nanos: int = betterproto.int32_field(2) 

1339 """ 

1340 Signed fractions of a second at nanosecond resolution of the span of time. 

1341 Durations less than one second are represented with a 0 `seconds` field and 

1342 a positive or negative `nanos` field. For durations of one second or more, 

1343 a non-zero value for the `nanos` field must be of the same sign as the 

1344 `seconds` field. Must be from -999,999,999 to +999,999,999 inclusive. 

1345 """ 

1346 

1347 

1348@dataclass(eq=False, repr=False) 

1349class Empty(betterproto.Message): 

1350 """ 

1351 A generic empty message that you can re-use to avoid defining duplicated 

1352 empty messages in your APIs. A typical example is to use it as the request 

1353 or the response type of an API method. For instance: service Foo { 

1354 rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); } The 

1355 JSON representation for `Empty` is empty JSON object `{}`. 

1356 """ 

1357 

1358 pass 

1359 

1360 

1361@dataclass(eq=False, repr=False) 

1362class FieldMask(betterproto.Message): 

1363 """ 

1364 `FieldMask` represents a set of symbolic field paths, for example: 

1365 paths: "f.a" paths: "f.b.d" Here `f` represents a field in some root 

1366 message, `a` and `b` fields in the message found in `f`, and `d` a field 

1367 found in the message in `f.b`. Field masks are used to specify a subset of 

1368 fields that should be returned by a get operation or modified by an update 

1369 operation. Field masks also have a custom JSON encoding (see below). # 

1370 Field Masks in Projections When used in the context of a projection, a 

1371 response message or sub-message is filtered by the API to only contain 

1372 those fields as specified in the mask. For example, if the mask in the 

1373 previous example is applied to a response message as follows: f { 

1374 a : 22 b { d : 1 x : 2 } y : 13 } 

1375 z: 8 The result will not contain specific values for fields x,y and z 

1376 (their value will be set to the default, and omitted in proto text output): 

1377 f { a : 22 b { d : 1 } } A repeated field is 

1378 not allowed except at the last position of a paths string. If a FieldMask 

1379 object is not present in a get operation, the operation applies to all 

1380 fields (as if a FieldMask of all fields had been specified). Note that a 

1381 field mask does not necessarily apply to the top-level response message. In 

1382 case of a REST get operation, the field mask applies directly to the 

1383 response, but in case of a REST list operation, the mask instead applies to 

1384 each individual message in the returned resource list. In case of a REST 

1385 custom method, other definitions may be used. Where the mask applies will 

1386 be clearly documented together with its declaration in the API. In any 

1387 case, the effect on the returned resource/resources is required behavior 

1388 for APIs. # Field Masks in Update Operations A field mask in update 

1389 operations specifies which fields of the targeted resource are going to be 

1390 updated. The API is required to only change the values of the fields as 

1391 specified in the mask and leave the others untouched. If a resource is 

1392 passed in to describe the updated values, the API ignores the values of all 

1393 fields not covered by the mask. If a repeated field is specified for an 

1394 update operation, new values will be appended to the existing repeated 

1395 field in the target resource. Note that a repeated field is only allowed in 

1396 the last position of a `paths` string. If a sub-message is specified in the 

1397 last position of the field mask for an update operation, then new value 

1398 will be merged into the existing sub-message in the target resource. For 

1399 example, given the target message: f { b { d: 1 

1400 x: 2 } c: [1] } And an update message: f { b { 

1401 d: 10 } c: [2] } then if the field mask is: paths: ["f.b", 

1402 "f.c"] then the result will be: f { b { d: 10 x: 

1403 2 } c: [1, 2] } An implementation may provide options to 

1404 override this default behavior for repeated and message fields. In order to 

1405 reset a field's value to the default, the field must be in the mask and set 

1406 to the default value in the provided resource. Hence, in order to reset all 

1407 fields of a resource, provide a default instance of the resource and set 

1408 all fields in the mask, or do not provide a mask as described below. If a 

1409 field mask is not present on update, the operation applies to all fields 

1410 (as if a field mask of all fields has been specified). Note that in the 

1411 presence of schema evolution, this may mean that fields the client does not 

1412 know and has therefore not filled into the request will be reset to their 

1413 default. If this is unwanted behavior, a specific service may require a 

1414 client to always specify a field mask, producing an error if not. As with 

1415 get operations, the location of the resource which describes the updated 

1416 values in the request message depends on the operation kind. In any case, 

1417 the effect of the field mask is required to be honored by the API. ## 

1418 Considerations for HTTP REST The HTTP kind of an update operation which 

1419 uses a field mask must be set to PATCH instead of PUT in order to satisfy 

1420 HTTP semantics (PUT must only be used for full updates). # JSON Encoding of 

1421 Field Masks In JSON, a field mask is encoded as a single string where paths 

1422 are separated by a comma. Fields name in each path are converted to/from 

1423 lower-camel naming conventions. As an example, consider the following 

1424 message declarations: message Profile { User user = 1; 

1425 Photo photo = 2; } message User { string display_name = 1; 

1426 string address = 2; } In proto a field mask for `Profile` may look as 

1427 such: mask { paths: "user.display_name" paths: "photo" 

1428 } In JSON, the same mask is represented as below: { mask: 

1429 "user.displayName,photo" } # Field Masks and Oneof Fields Field masks 

1430 treat fields in oneofs just as regular fields. Consider the following 

1431 message: message SampleMessage { oneof test_oneof { 

1432 string name = 4; SubMessage sub_message = 9; } } The 

1433 field mask can be: mask { paths: "name" } Or: mask { 

1434 paths: "sub_message" } Note that oneof type names ("test_oneof" in this 

1435 case) cannot be used in paths. ## Field Mask Verification The 

1436 implementation of any API method which has a FieldMask type field in the 

1437 request should verify the included field paths, and return an 

1438 `INVALID_ARGUMENT` error if any path is unmappable. 

1439 """ 

1440 

1441 paths: List[str] = betterproto.string_field(1) 

1442 """The set of field mask paths.""" 

1443 

1444 

1445@dataclass(eq=False, repr=False) 

1446class Struct(betterproto.Message): 

1447 """ 

1448 `Struct` represents a structured data value, consisting of fields which map 

1449 to dynamically typed values. In some languages, `Struct` might be supported 

1450 by a native representation. For example, in scripting languages like JS a 

1451 struct is represented as an object. The details of that representation are 

1452 described together with the proto support for the language. The JSON 

1453 representation for `Struct` is JSON object. 

1454 """ 

1455 

1456 fields: Dict[str, "Value"] = betterproto.map_field( 

1457 1, betterproto.TYPE_STRING, betterproto.TYPE_MESSAGE 

1458 ) 

1459 """Unordered map of dynamically typed values.""" 

1460 

1461 

1462@dataclass(eq=False, repr=False) 

1463class Value(betterproto.Message): 

1464 """ 

1465 `Value` represents a dynamically typed value which can be either null, a 

1466 number, a string, a boolean, a recursive struct value, or a list of values. 

1467 A producer of value is expected to set one of these variants. Absence of 

1468 any variant indicates an error. The JSON representation for `Value` is JSON 

1469 value. 

1470 """ 

1471 

1472 null_value: "NullValue" = betterproto.enum_field(1, group="kind") 

1473 """Represents a null value.""" 

1474 

1475 number_value: float = betterproto.double_field(2, group="kind") 

1476 """Represents a double value.""" 

1477 

1478 string_value: str = betterproto.string_field(3, group="kind") 

1479 """Represents a string value.""" 

1480 

1481 bool_value: bool = betterproto.bool_field(4, group="kind") 

1482 """Represents a boolean value.""" 

1483 

1484 struct_value: "Struct" = betterproto.message_field(5, group="kind") 

1485 """Represents a structured value.""" 

1486 

1487 list_value: "ListValue" = betterproto.message_field(6, group="kind") 

1488 """Represents a repeated `Value`.""" 

1489 

1490 

1491@dataclass(eq=False, repr=False) 

1492class ListValue(betterproto.Message): 

1493 """ 

1494 `ListValue` is a wrapper around a repeated field of values. The JSON 

1495 representation for `ListValue` is JSON array. 

1496 """ 

1497 

1498 values: List["Value"] = betterproto.message_field(1) 

1499 """Repeated field of dynamically typed values.""" 

1500 

1501 

1502@dataclass(eq=False, repr=False) 

1503class Timestamp(betterproto.Message): 

1504 """ 

1505 A Timestamp represents a point in time independent of any time zone or 

1506 local calendar, encoded as a count of seconds and fractions of seconds at 

1507 nanosecond resolution. The count is relative to an epoch at UTC midnight on 

1508 January 1, 1970, in the proleptic Gregorian calendar which extends the 

1509 Gregorian calendar backwards to year one. All minutes are 60 seconds long. 

1510 Leap seconds are "smeared" so that no leap second table is needed for 

1511 interpretation, using a [24-hour linear 

1512 smear](https://developers.google.com/time/smear). The range is from 

1513 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By restricting to 

1514 that range, we ensure that we can convert to and from [RFC 

1515 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. # Examples 

1516 Example 1: Compute Timestamp from POSIX `time()`. Timestamp timestamp; 

1517 timestamp.set_seconds(time(NULL)); timestamp.set_nanos(0); Example 2: 

1518 Compute Timestamp from POSIX `gettimeofday()`. struct timeval tv; 

1519 gettimeofday(&tv, NULL); Timestamp timestamp; 

1520 timestamp.set_seconds(tv.tv_sec); timestamp.set_nanos(tv.tv_usec * 

1521 1000); Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. 

1522 FILETIME ft; GetSystemTimeAsFileTime(&ft); UINT64 ticks = 

1523 (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; // A Windows 

1524 tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z // is 

1525 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. Timestamp 

1526 timestamp; timestamp.set_seconds((INT64) ((ticks / 10000000) - 

1527 11644473600LL)); timestamp.set_nanos((INT32) ((ticks % 10000000) * 

1528 100)); Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. 

1529 long millis = System.currentTimeMillis(); Timestamp timestamp = 

1530 Timestamp.newBuilder().setSeconds(millis / 1000) .setNanos((int) 

1531 ((millis % 1000) * 1000000)).build(); Example 5: Compute Timestamp from 

1532 Java `Instant.now()`. Instant now = Instant.now(); Timestamp 

1533 timestamp = Timestamp.newBuilder().setSeconds(now.getEpochSecond()) 

1534 .setNanos(now.getNano()).build(); Example 6: Compute Timestamp from current 

1535 time in Python. timestamp = Timestamp() timestamp.GetCurrentTime() 

1536 # JSON Mapping In JSON format, the Timestamp type is encoded as a string in 

1537 the [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the 

1538 format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" where 

1539 {year} is always expressed using four digits while {month}, {day}, {hour}, 

1540 {min}, and {sec} are zero-padded to two digits each. The fractional 

1541 seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), 

1542 are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone 

1543 is required. A proto3 JSON serializer should always use UTC (as indicated 

1544 by "Z") when printing the Timestamp type and a proto3 JSON parser should be 

1545 able to accept both UTC and other timezones (as indicated by an offset). 

1546 For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past 01:30 UTC 

1547 on January 15, 2017. In JavaScript, one can convert a Date object to this 

1548 format using the standard [toISOString()](https://developer.mozilla.org/en- 

1549 US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) method. 

1550 In Python, a standard `datetime.datetime` object can be converted to this 

1551 format using 

1552 [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) 

1553 with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one 

1554 can use the Joda Time's [`ISODateTimeFormat.dateTime()`]( 

1555 http://www.joda.org/joda- 

1556 time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D ) 

1557 to obtain a formatter capable of generating timestamps in this format. 

1558 """ 

1559 

1560 seconds: int = betterproto.int64_field(1) 

1561 """ 

1562 Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must 

1563 be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive. 

1564 """ 

1565 

1566 nanos: int = betterproto.int32_field(2) 

1567 """ 

1568 Non-negative fractions of a second at nanosecond resolution. Negative 

1569 second values with fractions must still have non-negative nanos values that 

1570 count forward in time. Must be from 0 to 999,999,999 inclusive. 

1571 """ 

1572 

1573 

1574@dataclass(eq=False, repr=False) 

1575class DoubleValue(betterproto.Message): 

1576 """ 

1577 Wrapper message for `double`. The JSON representation for `DoubleValue` is 

1578 JSON number. 

1579 """ 

1580 

1581 value: float = betterproto.double_field(1) 

1582 """The double value.""" 

1583 

1584 

1585@dataclass(eq=False, repr=False) 

1586class FloatValue(betterproto.Message): 

1587 """ 

1588 Wrapper message for `float`. The JSON representation for `FloatValue` is 

1589 JSON number. 

1590 """ 

1591 

1592 value: float = betterproto.float_field(1) 

1593 """The float value.""" 

1594 

1595 

1596@dataclass(eq=False, repr=False) 

1597class Int64Value(betterproto.Message): 

1598 """ 

1599 Wrapper message for `int64`. The JSON representation for `Int64Value` is 

1600 JSON string. 

1601 """ 

1602 

1603 value: int = betterproto.int64_field(1) 

1604 """The int64 value.""" 

1605 

1606 

1607@dataclass(eq=False, repr=False) 

1608class UInt64Value(betterproto.Message): 

1609 """ 

1610 Wrapper message for `uint64`. The JSON representation for `UInt64Value` is 

1611 JSON string. 

1612 """ 

1613 

1614 value: int = betterproto.uint64_field(1) 

1615 """The uint64 value.""" 

1616 

1617 

1618@dataclass(eq=False, repr=False) 

1619class Int32Value(betterproto.Message): 

1620 """ 

1621 Wrapper message for `int32`. The JSON representation for `Int32Value` is 

1622 JSON number. 

1623 """ 

1624 

1625 value: int = betterproto.int32_field(1) 

1626 """The int32 value.""" 

1627 

1628 

1629@dataclass(eq=False, repr=False) 

1630class UInt32Value(betterproto.Message): 

1631 """ 

1632 Wrapper message for `uint32`. The JSON representation for `UInt32Value` is 

1633 JSON number. 

1634 """ 

1635 

1636 value: int = betterproto.uint32_field(1) 

1637 """The uint32 value.""" 

1638 

1639 

1640@dataclass(eq=False, repr=False) 

1641class BoolValue(betterproto.Message): 

1642 """ 

1643 Wrapper message for `bool`. The JSON representation for `BoolValue` is JSON 

1644 `true` and `false`. 

1645 """ 

1646 

1647 value: bool = betterproto.bool_field(1) 

1648 """The bool value.""" 

1649 

1650 

1651@dataclass(eq=False, repr=False) 

1652class StringValue(betterproto.Message): 

1653 """ 

1654 Wrapper message for `string`. The JSON representation for `StringValue` is 

1655 JSON string. 

1656 """ 

1657 

1658 value: str = betterproto.string_field(1) 

1659 """The string value.""" 

1660 

1661 

1662@dataclass(eq=False, repr=False) 

1663class BytesValue(betterproto.Message): 

1664 """ 

1665 Wrapper message for `bytes`. The JSON representation for `BytesValue` is 

1666 JSON string. 

1667 """ 

1668 

1669 value: bytes = betterproto.bytes_field(1) 

1670 """The bytes value."""