betterproto2-compiler 0.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. betterproto2_compiler/__init__.py +0 -0
  2. betterproto2_compiler/_types.py +13 -0
  3. betterproto2_compiler/casing.py +140 -0
  4. betterproto2_compiler/compile/__init__.py +0 -0
  5. betterproto2_compiler/compile/importing.py +193 -0
  6. betterproto2_compiler/compile/naming.py +21 -0
  7. betterproto2_compiler/enum.py +180 -0
  8. betterproto2_compiler/grpc/__init__.py +0 -0
  9. betterproto2_compiler/grpc/grpclib_client.py +172 -0
  10. betterproto2_compiler/grpc/grpclib_server.py +32 -0
  11. betterproto2_compiler/grpc/util/__init__.py +0 -0
  12. betterproto2_compiler/grpc/util/async_channel.py +190 -0
  13. betterproto2_compiler/lib/__init__.py +0 -0
  14. betterproto2_compiler/lib/google/__init__.py +0 -0
  15. betterproto2_compiler/lib/google/protobuf/__init__.py +1 -0
  16. betterproto2_compiler/lib/google/protobuf/compiler/__init__.py +1 -0
  17. betterproto2_compiler/lib/pydantic/__init__.py +0 -0
  18. betterproto2_compiler/lib/pydantic/google/__init__.py +0 -0
  19. betterproto2_compiler/lib/pydantic/google/protobuf/__init__.py +2690 -0
  20. betterproto2_compiler/lib/pydantic/google/protobuf/compiler/__init__.py +209 -0
  21. betterproto2_compiler/lib/std/__init__.py +0 -0
  22. betterproto2_compiler/lib/std/google/__init__.py +0 -0
  23. betterproto2_compiler/lib/std/google/protobuf/__init__.py +2517 -0
  24. betterproto2_compiler/lib/std/google/protobuf/compiler/__init__.py +197 -0
  25. betterproto2_compiler/plugin/__init__.py +3 -0
  26. betterproto2_compiler/plugin/__main__.py +3 -0
  27. betterproto2_compiler/plugin/compiler.py +59 -0
  28. betterproto2_compiler/plugin/main.py +52 -0
  29. betterproto2_compiler/plugin/models.py +709 -0
  30. betterproto2_compiler/plugin/module_validation.py +161 -0
  31. betterproto2_compiler/plugin/parser.py +263 -0
  32. betterproto2_compiler/plugin/plugin.bat +2 -0
  33. betterproto2_compiler/plugin/typing_compiler.py +167 -0
  34. betterproto2_compiler/py.typed +0 -0
  35. betterproto2_compiler/templates/header.py.j2 +50 -0
  36. betterproto2_compiler/templates/template.py.j2 +243 -0
  37. betterproto2_compiler-0.0.1.dist-info/LICENSE.md +22 -0
  38. betterproto2_compiler-0.0.1.dist-info/METADATA +35 -0
  39. betterproto2_compiler-0.0.1.dist-info/RECORD +41 -0
  40. betterproto2_compiler-0.0.1.dist-info/WHEEL +4 -0
  41. betterproto2_compiler-0.0.1.dist-info/entry_points.txt +3 -0
@@ -0,0 +1,2690 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # plugin: python-betterproto
3
+ # This file has been @generated
4
+ import warnings
5
+ from typing import (
6
+ TYPE_CHECKING,
7
+ Mapping,
8
+ )
9
+
10
+ from betterproto import hybridmethod
11
+ from typing_extensions import Self
12
+
13
+ if TYPE_CHECKING:
14
+ from dataclasses import dataclass
15
+ else:
16
+ from pydantic.dataclasses import dataclass
17
+
18
+ from typing import (
19
+ Dict,
20
+ List,
21
+ Optional,
22
+ )
23
+
24
+ from pydantic import model_validator
25
+ from pydantic.dataclasses import rebuild_dataclass
26
+
27
+ import betterproto2_compiler
28
+
29
+
30
+ class Syntax(betterproto2_compiler.Enum):
31
+ """The syntax in which a protocol buffer element is defined."""
32
+
33
+ PROTO2 = 0
34
+ """Syntax `proto2`."""
35
+
36
+ PROTO3 = 1
37
+ """Syntax `proto3`."""
38
+
39
+ EDITIONS = 2
40
+ """Syntax `editions`."""
41
+
42
+ @classmethod
43
+ def __get_pydantic_core_schema__(cls, _source_type, _handler):
44
+ from pydantic_core import core_schema
45
+
46
+ return core_schema.int_schema(ge=0)
47
+
48
+
49
+ class FieldKind(betterproto2_compiler.Enum):
50
+ """Basic field types."""
51
+
52
+ TYPE_UNKNOWN = 0
53
+ """Field type unknown."""
54
+
55
+ TYPE_DOUBLE = 1
56
+ """Field type double."""
57
+
58
+ TYPE_FLOAT = 2
59
+ """Field type float."""
60
+
61
+ TYPE_INT64 = 3
62
+ """Field type int64."""
63
+
64
+ TYPE_UINT64 = 4
65
+ """Field type uint64."""
66
+
67
+ TYPE_INT32 = 5
68
+ """Field type int32."""
69
+
70
+ TYPE_FIXED64 = 6
71
+ """Field type fixed64."""
72
+
73
+ TYPE_FIXED32 = 7
74
+ """Field type fixed32."""
75
+
76
+ TYPE_BOOL = 8
77
+ """Field type bool."""
78
+
79
+ TYPE_STRING = 9
80
+ """Field type string."""
81
+
82
+ TYPE_GROUP = 10
83
+ """Field type group. Proto2 syntax only, and deprecated."""
84
+
85
+ TYPE_MESSAGE = 11
86
+ """Field type message."""
87
+
88
+ TYPE_BYTES = 12
89
+ """Field type bytes."""
90
+
91
+ TYPE_UINT32 = 13
92
+ """Field type uint32."""
93
+
94
+ TYPE_ENUM = 14
95
+ """Field type enum."""
96
+
97
+ TYPE_SFIXED32 = 15
98
+ """Field type sfixed32."""
99
+
100
+ TYPE_SFIXED64 = 16
101
+ """Field type sfixed64."""
102
+
103
+ TYPE_SINT32 = 17
104
+ """Field type sint32."""
105
+
106
+ TYPE_SINT64 = 18
107
+ """Field type sint64."""
108
+
109
+ @classmethod
110
+ def __get_pydantic_core_schema__(cls, _source_type, _handler):
111
+ from pydantic_core import core_schema
112
+
113
+ return core_schema.int_schema(ge=0)
114
+
115
+
116
+ class FieldCardinality(betterproto2_compiler.Enum):
117
+ """Whether a field is optional, required, or repeated."""
118
+
119
+ CARDINALITY_UNKNOWN = 0
120
+ """For fields with unknown cardinality."""
121
+
122
+ CARDINALITY_OPTIONAL = 1
123
+ """For optional fields."""
124
+
125
+ CARDINALITY_REQUIRED = 2
126
+ """For required fields. Proto2 syntax only."""
127
+
128
+ CARDINALITY_REPEATED = 3
129
+ """For repeated fields."""
130
+
131
+ @classmethod
132
+ def __get_pydantic_core_schema__(cls, _source_type, _handler):
133
+ from pydantic_core import core_schema
134
+
135
+ return core_schema.int_schema(ge=0)
136
+
137
+
138
+ class Edition(betterproto2_compiler.Enum):
139
+ """The full set of known editions."""
140
+
141
+ UNKNOWN = 0
142
+ """A placeholder for an unknown edition value."""
143
+
144
+ PROTO2 = 998
145
+ """
146
+ Legacy syntax "editions". These pre-date editions, but behave much like
147
+ distinct editions. These can't be used to specify the edition of proto
148
+ files, but feature definitions must supply proto2/proto3 defaults for
149
+ backwards compatibility.
150
+ """
151
+
152
+ PROTO3 = 999
153
+ _2023 = 1000
154
+ """
155
+ Editions that have been released. The specific values are arbitrary and
156
+ should not be depended on, but they will always be time-ordered for easy
157
+ comparison.
158
+ """
159
+
160
+ _2024 = 1001
161
+ _1_TEST_ONLY = 1
162
+ """
163
+ Placeholder editions for testing feature resolution. These should not be
164
+ used or relyed on outside of tests.
165
+ """
166
+
167
+ _2_TEST_ONLY = 2
168
+ _99997_TEST_ONLY = 99997
169
+ _99998_TEST_ONLY = 99998
170
+ _99999_TEST_ONLY = 99999
171
+ MAX = 2147483647
172
+ """
173
+ Placeholder for specifying unbounded edition support. This should only
174
+ ever be used by plugins that can expect to never require any changes to
175
+ support a new edition.
176
+ """
177
+
178
+ @classmethod
179
+ def __get_pydantic_core_schema__(cls, _source_type, _handler):
180
+ from pydantic_core import core_schema
181
+
182
+ return core_schema.int_schema(ge=0)
183
+
184
+
185
+ class ExtensionRangeOptionsVerificationState(betterproto2_compiler.Enum):
186
+ """The verification state of the extension range."""
187
+
188
+ DECLARATION = 0
189
+ """All the extensions of the range must be declared."""
190
+
191
+ UNVERIFIED = 1
192
+
193
+ @classmethod
194
+ def __get_pydantic_core_schema__(cls, _source_type, _handler):
195
+ from pydantic_core import core_schema
196
+
197
+ return core_schema.int_schema(ge=0)
198
+
199
+
200
+ class FieldDescriptorProtoType(betterproto2_compiler.Enum):
201
+ TYPE_DOUBLE = 1
202
+ """
203
+ 0 is reserved for errors.
204
+ Order is weird for historical reasons.
205
+ """
206
+
207
+ TYPE_FLOAT = 2
208
+ TYPE_INT64 = 3
209
+ """
210
+ Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if
211
+ negative values are likely.
212
+ """
213
+
214
+ TYPE_UINT64 = 4
215
+ TYPE_INT32 = 5
216
+ """
217
+ Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if
218
+ negative values are likely.
219
+ """
220
+
221
+ TYPE_FIXED64 = 6
222
+ TYPE_FIXED32 = 7
223
+ TYPE_BOOL = 8
224
+ TYPE_STRING = 9
225
+ TYPE_GROUP = 10
226
+ """
227
+ Tag-delimited aggregate.
228
+ Group type is deprecated and not supported after google.protobuf. However, Proto3
229
+ implementations should still be able to parse the group wire format and
230
+ treat group fields as unknown fields. In Editions, the group wire format
231
+ can be enabled via the `message_encoding` feature.
232
+ """
233
+
234
+ TYPE_MESSAGE = 11
235
+ TYPE_BYTES = 12
236
+ """New in version 2."""
237
+
238
+ TYPE_UINT32 = 13
239
+ TYPE_ENUM = 14
240
+ TYPE_SFIXED32 = 15
241
+ TYPE_SFIXED64 = 16
242
+ TYPE_SINT32 = 17
243
+ TYPE_SINT64 = 18
244
+
245
+ @classmethod
246
+ def __get_pydantic_core_schema__(cls, _source_type, _handler):
247
+ from pydantic_core import core_schema
248
+
249
+ return core_schema.int_schema(ge=0)
250
+
251
+
252
+ class FieldDescriptorProtoLabel(betterproto2_compiler.Enum):
253
+ LABEL_OPTIONAL = 1
254
+ """0 is reserved for errors"""
255
+
256
+ LABEL_REPEATED = 3
257
+ LABEL_REQUIRED = 2
258
+ """
259
+ The required label is only allowed in google.protobuf. In proto3 and Editions
260
+ it's explicitly prohibited. In Editions, the `field_presence` feature
261
+ can be used to get this behavior.
262
+ """
263
+
264
+ @classmethod
265
+ def __get_pydantic_core_schema__(cls, _source_type, _handler):
266
+ from pydantic_core import core_schema
267
+
268
+ return core_schema.int_schema(ge=0)
269
+
270
+
271
+ class FileOptionsOptimizeMode(betterproto2_compiler.Enum):
272
+ """Generated classes can be optimized for speed or code size."""
273
+
274
+ SPEED = 1
275
+ CODE_SIZE = 2
276
+ """etc."""
277
+
278
+ LITE_RUNTIME = 3
279
+
280
+ @classmethod
281
+ def __get_pydantic_core_schema__(cls, _source_type, _handler):
282
+ from pydantic_core import core_schema
283
+
284
+ return core_schema.int_schema(ge=0)
285
+
286
+
287
+ class FieldOptionsCType(betterproto2_compiler.Enum):
288
+ STRING = 0
289
+ """Default mode."""
290
+
291
+ CORD = 1
292
+ """
293
+ The option [ctype=CORD] may be applied to a non-repeated field of type
294
+ "bytes". It indicates that in C++, the data should be stored in a Cord
295
+ instead of a string. For very large strings, this may reduce memory
296
+ fragmentation. It may also allow better performance when parsing from a
297
+ Cord, or when parsing with aliasing enabled, as the parsed Cord may then
298
+ alias the original buffer.
299
+ """
300
+
301
+ STRING_PIECE = 2
302
+
303
+ @classmethod
304
+ def __get_pydantic_core_schema__(cls, _source_type, _handler):
305
+ from pydantic_core import core_schema
306
+
307
+ return core_schema.int_schema(ge=0)
308
+
309
+
310
+ class FieldOptionsJsType(betterproto2_compiler.Enum):
311
+ JS_NORMAL = 0
312
+ """Use the default type."""
313
+
314
+ JS_STRING = 1
315
+ """Use JavaScript strings."""
316
+
317
+ JS_NUMBER = 2
318
+ """Use JavaScript numbers."""
319
+
320
+ @classmethod
321
+ def __get_pydantic_core_schema__(cls, _source_type, _handler):
322
+ from pydantic_core import core_schema
323
+
324
+ return core_schema.int_schema(ge=0)
325
+
326
+
327
+ class FieldOptionsOptionRetention(betterproto2_compiler.Enum):
328
+ """
329
+ If set to RETENTION_SOURCE, the option will be omitted from the binary.
330
+ Note: as of January 2023, support for this is in progress and does not yet
331
+ have an effect (b/264593489).
332
+ """
333
+
334
+ RETENTION_UNKNOWN = 0
335
+ RETENTION_RUNTIME = 1
336
+ RETENTION_SOURCE = 2
337
+
338
+ @classmethod
339
+ def __get_pydantic_core_schema__(cls, _source_type, _handler):
340
+ from pydantic_core import core_schema
341
+
342
+ return core_schema.int_schema(ge=0)
343
+
344
+
345
+ class FieldOptionsOptionTargetType(betterproto2_compiler.Enum):
346
+ """
347
+ This indicates the types of entities that the field may apply to when used
348
+ as an option. If it is unset, then the field may be freely used as an
349
+ option on any kind of entity. Note: as of January 2023, support for this is
350
+ in progress and does not yet have an effect (b/264593489).
351
+ """
352
+
353
+ TARGET_TYPE_UNKNOWN = 0
354
+ TARGET_TYPE_FILE = 1
355
+ TARGET_TYPE_EXTENSION_RANGE = 2
356
+ TARGET_TYPE_MESSAGE = 3
357
+ TARGET_TYPE_FIELD = 4
358
+ TARGET_TYPE_ONEOF = 5
359
+ TARGET_TYPE_ENUM = 6
360
+ TARGET_TYPE_ENUM_ENTRY = 7
361
+ TARGET_TYPE_SERVICE = 8
362
+ TARGET_TYPE_METHOD = 9
363
+
364
+ @classmethod
365
+ def __get_pydantic_core_schema__(cls, _source_type, _handler):
366
+ from pydantic_core import core_schema
367
+
368
+ return core_schema.int_schema(ge=0)
369
+
370
+
371
+ class MethodOptionsIdempotencyLevel(betterproto2_compiler.Enum):
372
+ """
373
+ Is this method side-effect-free (or safe in HTTP parlance), or idempotent,
374
+ or neither? HTTP based RPC implementation may choose GET verb for safe
375
+ methods, and PUT verb for idempotent methods instead of the default POST.
376
+ """
377
+
378
+ IDEMPOTENCY_UNKNOWN = 0
379
+ NO_SIDE_EFFECTS = 1
380
+ IDEMPOTENT = 2
381
+
382
+ @classmethod
383
+ def __get_pydantic_core_schema__(cls, _source_type, _handler):
384
+ from pydantic_core import core_schema
385
+
386
+ return core_schema.int_schema(ge=0)
387
+
388
+
389
+ class FeatureSetFieldPresence(betterproto2_compiler.Enum):
390
+ FIELD_PRESENCE_UNKNOWN = 0
391
+ EXPLICIT = 1
392
+ IMPLICIT = 2
393
+ LEGACY_REQUIRED = 3
394
+
395
+ @classmethod
396
+ def __get_pydantic_core_schema__(cls, _source_type, _handler):
397
+ from pydantic_core import core_schema
398
+
399
+ return core_schema.int_schema(ge=0)
400
+
401
+
402
+ class FeatureSetEnumType(betterproto2_compiler.Enum):
403
+ ENUM_TYPE_UNKNOWN = 0
404
+ OPEN = 1
405
+ CLOSED = 2
406
+
407
+ @classmethod
408
+ def __get_pydantic_core_schema__(cls, _source_type, _handler):
409
+ from pydantic_core import core_schema
410
+
411
+ return core_schema.int_schema(ge=0)
412
+
413
+
414
+ class FeatureSetRepeatedFieldEncoding(betterproto2_compiler.Enum):
415
+ REPEATED_FIELD_ENCODING_UNKNOWN = 0
416
+ PACKED = 1
417
+ EXPANDED = 2
418
+
419
+ @classmethod
420
+ def __get_pydantic_core_schema__(cls, _source_type, _handler):
421
+ from pydantic_core import core_schema
422
+
423
+ return core_schema.int_schema(ge=0)
424
+
425
+
426
+ class FeatureSetUtf8Validation(betterproto2_compiler.Enum):
427
+ UTF8_VALIDATION_UNKNOWN = 0
428
+ VERIFY = 2
429
+ NONE = 3
430
+
431
+ @classmethod
432
+ def __get_pydantic_core_schema__(cls, _source_type, _handler):
433
+ from pydantic_core import core_schema
434
+
435
+ return core_schema.int_schema(ge=0)
436
+
437
+
438
+ class FeatureSetMessageEncoding(betterproto2_compiler.Enum):
439
+ MESSAGE_ENCODING_UNKNOWN = 0
440
+ LENGTH_PREFIXED = 1
441
+ DELIMITED = 2
442
+
443
+ @classmethod
444
+ def __get_pydantic_core_schema__(cls, _source_type, _handler):
445
+ from pydantic_core import core_schema
446
+
447
+ return core_schema.int_schema(ge=0)
448
+
449
+
450
+ class FeatureSetJsonFormat(betterproto2_compiler.Enum):
451
+ JSON_FORMAT_UNKNOWN = 0
452
+ ALLOW = 1
453
+ LEGACY_BEST_EFFORT = 2
454
+
455
+ @classmethod
456
+ def __get_pydantic_core_schema__(cls, _source_type, _handler):
457
+ from pydantic_core import core_schema
458
+
459
+ return core_schema.int_schema(ge=0)
460
+
461
+
462
+ class GeneratedCodeInfoAnnotationSemantic(betterproto2_compiler.Enum):
463
+ """
464
+ Represents the identified object's effect on the element in the original
465
+ .proto file.
466
+ """
467
+
468
+ NONE = 0
469
+ """There is no effect or the effect is indescribable."""
470
+
471
+ SET = 1
472
+ """The element is set or otherwise mutated."""
473
+
474
+ ALIAS = 2
475
+ """An alias to the element is returned."""
476
+
477
+ @classmethod
478
+ def __get_pydantic_core_schema__(cls, _source_type, _handler):
479
+ from pydantic_core import core_schema
480
+
481
+ return core_schema.int_schema(ge=0)
482
+
483
+
484
+ class NullValue(betterproto2_compiler.Enum):
485
+ """
486
+ `NullValue` is a singleton enumeration to represent the null value for the
487
+ `Value` type union.
488
+
489
+ The JSON representation for `NullValue` is JSON `null`.
490
+ """
491
+
492
+ _ = 0
493
+ """Null value."""
494
+
495
+ @classmethod
496
+ def __get_pydantic_core_schema__(cls, _source_type, _handler):
497
+ from pydantic_core import core_schema
498
+
499
+ return core_schema.int_schema(ge=0)
500
+
501
+
502
+ @dataclass(eq=False, repr=False)
503
+ class Any(betterproto2_compiler.Message):
504
+ """
505
+ `Any` contains an arbitrary serialized protocol buffer message along with a
506
+ URL that describes the type of the serialized message.
507
+
508
+ Protobuf library provides support to pack/unpack Any values in the form
509
+ of utility functions or additional generated methods of the Any type.
510
+
511
+ Example 1: Pack and unpack a message in C++.
512
+
513
+ Foo foo = ...;
514
+ Any any;
515
+ any.PackFrom(foo);
516
+ ...
517
+ if (any.UnpackTo(&foo)) {
518
+ ...
519
+ }
520
+
521
+ Example 2: Pack and unpack a message in Java.
522
+
523
+ Foo foo = ...;
524
+ Any any = Any.pack(foo);
525
+ ...
526
+ if (any.is(Foo.class)) {
527
+ foo = any.unpack(Foo.class);
528
+ }
529
+ // or ...
530
+ if (any.isSameTypeAs(Foo.getDefaultInstance())) {
531
+ foo = any.unpack(Foo.getDefaultInstance());
532
+ }
533
+
534
+ Example 3: Pack and unpack a message in Python.
535
+
536
+ foo = Foo(...)
537
+ any = Any()
538
+ any.Pack(foo)
539
+ ...
540
+ if any.Is(Foo.DESCRIPTOR):
541
+ any.Unpack(foo)
542
+ ...
543
+
544
+ Example 4: Pack and unpack a message in Go
545
+
546
+ foo := &pb.Foo{...}
547
+ any, err := anypb.New(foo)
548
+ if err != nil {
549
+ ...
550
+ }
551
+ ...
552
+ foo := &pb.Foo{}
553
+ if err := any.UnmarshalTo(foo); err != nil {
554
+ ...
555
+ }
556
+
557
+ The pack methods provided by protobuf library will by default use
558
+ 'type.googleapis.com/full.type.name' as the type URL and the unpack
559
+ methods only use the fully qualified type name after the last '/'
560
+ in the type URL, for example "foo.bar.com/x/y.z" will yield type
561
+ name "y.z".
562
+
563
+ JSON
564
+ ====
565
+ The JSON representation of an `Any` value uses the regular
566
+ representation of the deserialized, embedded message, with an
567
+ additional field `@type` which contains the type URL. Example:
568
+
569
+ package google.profile;
570
+ message Person {
571
+ string first_name = 1;
572
+ string last_name = 2;
573
+ }
574
+
575
+ {
576
+ "@type": "type.googleapis.com/google.profile.Person",
577
+ "firstName": <string>,
578
+ "lastName": <string>
579
+ }
580
+
581
+ If the embedded message type is well-known and has a custom JSON
582
+ representation, that representation will be embedded adding a field
583
+ `value` which holds the custom JSON in addition to the `@type`
584
+ field. Example (for message [google.protobuf.Duration][]):
585
+
586
+ {
587
+ "@type": "type.googleapis.com/google.protobuf.Duration",
588
+ "value": "1.212s"
589
+ }
590
+ """
591
+
592
+ type_url: str = betterproto2_compiler.string_field(1)
593
+ """
594
+ A URL/resource name that uniquely identifies the type of the serialized
595
+ protocol buffer message. This string must contain at least
596
+ one "/" character. The last segment of the URL's path must represent
597
+ the fully qualified name of the type (as in
598
+ `path/google.protobuf.Duration`). The name should be in a canonical form
599
+ (e.g., leading "." is not accepted).
600
+
601
+ In practice, teams usually precompile into the binary all types that they
602
+ expect it to use in the context of Any. However, for URLs which use the
603
+ scheme `http`, `https`, or no scheme, one can optionally set up a type
604
+ server that maps type URLs to message definitions as follows:
605
+
606
+ * If no scheme is provided, `https` is assumed.
607
+ * An HTTP GET on the URL must yield a [google.protobuf.Type][]
608
+ value in binary format, or produce an error.
609
+ * Applications are allowed to cache lookup results based on the
610
+ URL, or have them precompiled into a binary to avoid any
611
+ lookup. Therefore, binary compatibility needs to be preserved
612
+ on changes to types. (Use versioned type names to manage
613
+ breaking changes.)
614
+
615
+ Note: this functionality is not currently available in the official
616
+ protobuf release, and it is not used for type URLs beginning with
617
+ type.googleapis.com. As of May 2023, there are no widely used type server
618
+ implementations and no plans to implement one.
619
+
620
+ Schemes other than `http`, `https` (or the empty scheme) might be
621
+ used with implementation specific semantics.
622
+ """
623
+
624
+ value: bytes = betterproto2_compiler.bytes_field(2)
625
+ """
626
+ Must be a valid serialized protocol buffer of the above specified type.
627
+ """
628
+
629
+
630
+ @dataclass(eq=False, repr=False)
631
+ class SourceContext(betterproto2_compiler.Message):
632
+ """
633
+ `SourceContext` represents information about the source of a
634
+ protobuf element, like the file in which it is defined.
635
+ """
636
+
637
+ file_name: str = betterproto2_compiler.string_field(1)
638
+ """
639
+ The path-qualified name of the .proto file that contained the associated
640
+ protobuf element. For example: `"google/protobuf/source_context.proto"`.
641
+ """
642
+
643
+
644
+ @dataclass(eq=False, repr=False)
645
+ class Type(betterproto2_compiler.Message):
646
+ """A protocol buffer message type."""
647
+
648
+ name: str = betterproto2_compiler.string_field(1)
649
+ """The fully qualified message name."""
650
+
651
+ fields: List["Field"] = betterproto2_compiler.message_field(2)
652
+ """The list of fields."""
653
+
654
+ oneofs: List[str] = betterproto2_compiler.string_field(3)
655
+ """The list of types appearing in `oneof` definitions in this type."""
656
+
657
+ options: List["Option"] = betterproto2_compiler.message_field(4)
658
+ """The protocol buffer options."""
659
+
660
+ source_context: "SourceContext" = betterproto2_compiler.message_field(5)
661
+ """The source context."""
662
+
663
+ syntax: "Syntax" = betterproto2_compiler.enum_field(6, enum_default_value=lambda: Syntax.try_value(0))
664
+ """The source syntax."""
665
+
666
+ edition: str = betterproto2_compiler.string_field(7)
667
+ """
668
+ The source edition string, only valid when syntax is SYNTAX_EDITIONS.
669
+ """
670
+
671
+
672
+ @dataclass(eq=False, repr=False)
673
+ class Field(betterproto2_compiler.Message):
674
+ """A single field of a message type."""
675
+
676
+ kind: "FieldKind" = betterproto2_compiler.enum_field(1, enum_default_value=lambda: FieldKind.try_value(0))
677
+ """The field type."""
678
+
679
+ cardinality: "FieldCardinality" = betterproto2_compiler.enum_field(
680
+ 2, enum_default_value=lambda: FieldCardinality.try_value(0)
681
+ )
682
+ """The field cardinality."""
683
+
684
+ number: int = betterproto2_compiler.int32_field(3)
685
+ """The field number."""
686
+
687
+ name: str = betterproto2_compiler.string_field(4)
688
+ """The field name."""
689
+
690
+ type_url: str = betterproto2_compiler.string_field(6)
691
+ """
692
+ The field type URL, without the scheme, for message or enumeration
693
+ types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`.
694
+ """
695
+
696
+ oneof_index: int = betterproto2_compiler.int32_field(7)
697
+ """
698
+ The index of the field type in `Type.oneofs`, for message or enumeration
699
+ types. The first type has index 1; zero means the type is not in the list.
700
+ """
701
+
702
+ packed: bool = betterproto2_compiler.bool_field(8)
703
+ """Whether to use alternative packed wire representation."""
704
+
705
+ options: List["Option"] = betterproto2_compiler.message_field(9)
706
+ """The protocol buffer options."""
707
+
708
+ json_name: str = betterproto2_compiler.string_field(10)
709
+ """The field JSON name."""
710
+
711
+ default_value: str = betterproto2_compiler.string_field(11)
712
+ """
713
+ The string value of the default value of this field. Proto2 syntax only.
714
+ """
715
+
716
+
717
+ @dataclass(eq=False, repr=False)
718
+ class Enum(betterproto2_compiler.Message):
719
+ """Enum type definition."""
720
+
721
+ name: str = betterproto2_compiler.string_field(1)
722
+ """Enum type name."""
723
+
724
+ enumvalue: List["EnumValue"] = betterproto2_compiler.message_field(2, wraps=betterproto2_compiler.TYPE_ENUM)
725
+ """Enum value definitions."""
726
+
727
+ options: List["Option"] = betterproto2_compiler.message_field(3)
728
+ """Protocol buffer options."""
729
+
730
+ source_context: "SourceContext" = betterproto2_compiler.message_field(4)
731
+ """The source context."""
732
+
733
+ syntax: "Syntax" = betterproto2_compiler.enum_field(5, enum_default_value=lambda: Syntax.try_value(0))
734
+ """The source syntax."""
735
+
736
+ edition: str = betterproto2_compiler.string_field(6)
737
+ """
738
+ The source edition string, only valid when syntax is SYNTAX_EDITIONS.
739
+ """
740
+
741
+
742
+ @dataclass(eq=False, repr=False)
743
+ class EnumValue(betterproto2_compiler.Message):
744
+ """Enum value definition."""
745
+
746
+ name: str = betterproto2_compiler.string_field(1)
747
+ """Enum value name."""
748
+
749
+ number: int = betterproto2_compiler.int32_field(2)
750
+ """Enum value number."""
751
+
752
+ options: List["Option"] = betterproto2_compiler.message_field(3)
753
+ """Protocol buffer options."""
754
+
755
+
756
+ @dataclass(eq=False, repr=False)
757
+ class Option(betterproto2_compiler.Message):
758
+ """
759
+ A protocol buffer option, which can be attached to a message, field,
760
+ enumeration, etc.
761
+ """
762
+
763
+ name: str = betterproto2_compiler.string_field(1)
764
+ """
765
+ The option's name. For protobuf built-in options (options defined in
766
+ descriptor.proto), this is the short name. For example, `"map_entry"`.
767
+ For custom options, it should be the fully-qualified name. For example,
768
+ `"google.api.http"`.
769
+ """
770
+
771
+ value: "Any" = betterproto2_compiler.message_field(2)
772
+ """
773
+ The option's value packed in an Any message. If the value is a primitive,
774
+ the corresponding wrapper type defined in google/protobuf/wrappers.proto
775
+ should be used. If the value is an enum, it should be stored as an int32
776
+ value using the google.protobuf.Int32Value type.
777
+ """
778
+
779
+
780
+ @dataclass(eq=False, repr=False)
781
+ class Api(betterproto2_compiler.Message):
782
+ """
783
+ Api is a light-weight descriptor for an API Interface.
784
+
785
+ Interfaces are also described as "protocol buffer services" in some contexts,
786
+ such as by the "service" keyword in a .proto file, but they are different
787
+ from API Services, which represent a concrete implementation of an interface
788
+ as opposed to simply a description of methods and bindings. They are also
789
+ sometimes simply referred to as "APIs" in other contexts, such as the name of
790
+ this message itself. See https://cloud.google.com/apis/design/glossary for
791
+ detailed terminology.
792
+ """
793
+
794
+ name: str = betterproto2_compiler.string_field(1)
795
+ """
796
+ The fully qualified name of this interface, including package name
797
+ followed by the interface's simple name.
798
+ """
799
+
800
+ methods: List["Method"] = betterproto2_compiler.message_field(2)
801
+ """The methods of this interface, in unspecified order."""
802
+
803
+ options: List["Option"] = betterproto2_compiler.message_field(3)
804
+ """Any metadata attached to the interface."""
805
+
806
+ version: str = betterproto2_compiler.string_field(4)
807
+ """
808
+ A version string for this interface. If specified, must have the form
809
+ `major-version.minor-version`, as in `1.10`. If the minor version is
810
+ omitted, it defaults to zero. If the entire version field is empty, the
811
+ major version is derived from the package name, as outlined below. If the
812
+ field is not empty, the version in the package name will be verified to be
813
+ consistent with what is provided here.
814
+
815
+ The versioning schema uses [semantic
816
+ versioning](http://semver.org) where the major version number
817
+ indicates a breaking change and the minor version an additive,
818
+ non-breaking change. Both version numbers are signals to users
819
+ what to expect from different versions, and should be carefully
820
+ chosen based on the product plan.
821
+
822
+ The major version is also reflected in the package name of the
823
+ interface, which must end in `v<major-version>`, as in
824
+ `google.feature.v1`. For major versions 0 and 1, the suffix can
825
+ be omitted. Zero major versions must only be used for
826
+ experimental, non-GA interfaces.
827
+ """
828
+
829
+ source_context: "SourceContext" = betterproto2_compiler.message_field(5)
830
+ """
831
+ Source context for the protocol buffer service represented by this
832
+ message.
833
+ """
834
+
835
+ mixins: List["Mixin"] = betterproto2_compiler.message_field(6)
836
+ """Included interfaces. See [Mixin][]."""
837
+
838
+ syntax: "Syntax" = betterproto2_compiler.enum_field(7, enum_default_value=lambda: Syntax.try_value(0))
839
+ """The source syntax of the service."""
840
+
841
+
842
+ @dataclass(eq=False, repr=False)
843
+ class Method(betterproto2_compiler.Message):
844
+ """Method represents a method of an API interface."""
845
+
846
+ name: str = betterproto2_compiler.string_field(1)
847
+ """The simple name of this method."""
848
+
849
+ request_type_url: str = betterproto2_compiler.string_field(2)
850
+ """A URL of the input message type."""
851
+
852
+ request_streaming: bool = betterproto2_compiler.bool_field(3)
853
+ """If true, the request is streamed."""
854
+
855
+ response_type_url: str = betterproto2_compiler.string_field(4)
856
+ """The URL of the output message type."""
857
+
858
+ response_streaming: bool = betterproto2_compiler.bool_field(5)
859
+ """If true, the response is streamed."""
860
+
861
+ options: List["Option"] = betterproto2_compiler.message_field(6)
862
+ """Any metadata attached to the method."""
863
+
864
+ syntax: "Syntax" = betterproto2_compiler.enum_field(7, enum_default_value=lambda: Syntax.try_value(0))
865
+ """The source syntax of this method."""
866
+
867
+
868
+ @dataclass(eq=False, repr=False)
869
+ class Mixin(betterproto2_compiler.Message):
870
+ """
871
+ Declares an API Interface to be included in this interface. The including
872
+ interface must redeclare all the methods from the included interface, but
873
+ documentation and options are inherited as follows:
874
+
875
+ - If after comment and whitespace stripping, the documentation
876
+ string of the redeclared method is empty, it will be inherited
877
+ from the original method.
878
+
879
+ - Each annotation belonging to the service config (http,
880
+ visibility) which is not set in the redeclared method will be
881
+ inherited.
882
+
883
+ - If an http annotation is inherited, the path pattern will be
884
+ modified as follows. Any version prefix will be replaced by the
885
+ version of the including interface plus the [root][] path if
886
+ specified.
887
+
888
+ Example of a simple mixin:
889
+
890
+ package google.acl.v1;
891
+ service AccessControl {
892
+ // Get the underlying ACL object.
893
+ rpc GetAcl(GetAclRequest) returns (Acl) {
894
+ option (google.api.http).get = "/v1/{resource=**}:getAcl";
895
+ }
896
+ }
897
+
898
+ package google.storage.v2;
899
+ service Storage {
900
+ rpc GetAcl(GetAclRequest) returns (Acl);
901
+
902
+ // Get a data record.
903
+ rpc GetData(GetDataRequest) returns (Data) {
904
+ option (google.api.http).get = "/v2/{resource=**}";
905
+ }
906
+ }
907
+
908
+ Example of a mixin configuration:
909
+
910
+ apis:
911
+ - name: google.storage.v2.Storage
912
+ mixins:
913
+ - name: google.acl.v1.AccessControl
914
+
915
+ The mixin construct implies that all methods in `AccessControl` are
916
+ also declared with same name and request/response types in
917
+ `Storage`. A documentation generator or annotation processor will
918
+ see the effective `Storage.GetAcl` method after inherting
919
+ documentation and annotations as follows:
920
+
921
+ service Storage {
922
+ // Get the underlying ACL object.
923
+ rpc GetAcl(GetAclRequest) returns (Acl) {
924
+ option (google.api.http).get = "/v2/{resource=**}:getAcl";
925
+ }
926
+ ...
927
+ }
928
+
929
+ Note how the version in the path pattern changed from `v1` to `v2`.
930
+
931
+ If the `root` field in the mixin is specified, it should be a
932
+ relative path under which inherited HTTP paths are placed. Example:
933
+
934
+ apis:
935
+ - name: google.storage.v2.Storage
936
+ mixins:
937
+ - name: google.acl.v1.AccessControl
938
+ root: acls
939
+
940
+ This implies the following inherited HTTP annotation:
941
+
942
+ service Storage {
943
+ // Get the underlying ACL object.
944
+ rpc GetAcl(GetAclRequest) returns (Acl) {
945
+ option (google.api.http).get = "/v2/acls/{resource=**}:getAcl";
946
+ }
947
+ ...
948
+ }
949
+ """
950
+
951
+ name: str = betterproto2_compiler.string_field(1)
952
+ """The fully qualified name of the interface which is included."""
953
+
954
+ root: str = betterproto2_compiler.string_field(2)
955
+ """
956
+ If non-empty specifies a path under which inherited HTTP paths
957
+ are rooted.
958
+ """
959
+
960
+
961
+ @dataclass(eq=False, repr=False)
962
+ class FileDescriptorSet(betterproto2_compiler.Message):
963
+ """
964
+ The protocol compiler can output a FileDescriptorSet containing the .proto
965
+ files it parses.
966
+ """
967
+
968
+ file: List["FileDescriptorProto"] = betterproto2_compiler.message_field(1)
969
+
970
+
971
+ @dataclass(eq=False, repr=False)
972
+ class FileDescriptorProto(betterproto2_compiler.Message):
973
+ """Describes a complete .proto file."""
974
+
975
+ name: str = betterproto2_compiler.string_field(1)
976
+ package: str = betterproto2_compiler.string_field(2)
977
+ dependency: List[str] = betterproto2_compiler.string_field(3)
978
+ """Names of files imported by this file."""
979
+
980
+ public_dependency: List[int] = betterproto2_compiler.int32_field(10)
981
+ """Indexes of the public imported files in the dependency list above."""
982
+
983
+ weak_dependency: List[int] = betterproto2_compiler.int32_field(11)
984
+ """
985
+ Indexes of the weak imported files in the dependency list.
986
+ For Google-internal migration only. Do not use.
987
+ """
988
+
989
+ message_type: List["DescriptorProto"] = betterproto2_compiler.message_field(4)
990
+ """All top-level definitions in this file."""
991
+
992
+ enum_type: List["EnumDescriptorProto"] = betterproto2_compiler.message_field(5)
993
+ service: List["ServiceDescriptorProto"] = betterproto2_compiler.message_field(6)
994
+ extension: List["FieldDescriptorProto"] = betterproto2_compiler.message_field(7)
995
+ options: "FileOptions" = betterproto2_compiler.message_field(8)
996
+ source_code_info: "SourceCodeInfo" = betterproto2_compiler.message_field(9)
997
+ """
998
+ This field contains optional information about the original source code.
999
+ You may safely remove this entire field without harming runtime
1000
+ functionality of the descriptors -- the information is needed only by
1001
+ development tools.
1002
+ """
1003
+
1004
+ syntax: str = betterproto2_compiler.string_field(12)
1005
+ """
1006
+ The syntax of the proto file.
1007
+ The supported values are "proto2", "proto3", and "editions".
1008
+
1009
+ If `edition` is present, this value must be "editions".
1010
+ """
1011
+
1012
+ edition: "Edition" = betterproto2_compiler.enum_field(14, enum_default_value=lambda: Edition.try_value(0))
1013
+ """The edition of the proto file."""
1014
+
1015
+
1016
+ @dataclass(eq=False, repr=False)
1017
+ class DescriptorProto(betterproto2_compiler.Message):
1018
+ """Describes a message type."""
1019
+
1020
+ name: str = betterproto2_compiler.string_field(1)
1021
+ field: List["FieldDescriptorProto"] = betterproto2_compiler.message_field(2)
1022
+ extension: List["FieldDescriptorProto"] = betterproto2_compiler.message_field(6)
1023
+ nested_type: List["DescriptorProto"] = betterproto2_compiler.message_field(3)
1024
+ enum_type: List["EnumDescriptorProto"] = betterproto2_compiler.message_field(4)
1025
+ extension_range: List["DescriptorProtoExtensionRange"] = betterproto2_compiler.message_field(5)
1026
+ oneof_decl: List["OneofDescriptorProto"] = betterproto2_compiler.message_field(8)
1027
+ options: "MessageOptions" = betterproto2_compiler.message_field(7)
1028
+ reserved_range: List["DescriptorProtoReservedRange"] = betterproto2_compiler.message_field(9)
1029
+ reserved_name: List[str] = betterproto2_compiler.string_field(10)
1030
+ """
1031
+ Reserved field names, which may not be used by fields in the same message.
1032
+ A given name may only be reserved once.
1033
+ """
1034
+
1035
+
1036
+ @dataclass(eq=False, repr=False)
1037
+ class DescriptorProtoExtensionRange(betterproto2_compiler.Message):
1038
+ start: int = betterproto2_compiler.int32_field(1)
1039
+ end: int = betterproto2_compiler.int32_field(2)
1040
+ options: "ExtensionRangeOptions" = betterproto2_compiler.message_field(3)
1041
+
1042
+
1043
+ @dataclass(eq=False, repr=False)
1044
+ class DescriptorProtoReservedRange(betterproto2_compiler.Message):
1045
+ """
1046
+ Range of reserved tag numbers. Reserved tag numbers may not be used by
1047
+ fields or extension ranges in the same message. Reserved ranges may
1048
+ not overlap.
1049
+ """
1050
+
1051
+ start: int = betterproto2_compiler.int32_field(1)
1052
+ end: int = betterproto2_compiler.int32_field(2)
1053
+
1054
+
1055
+ @dataclass(eq=False, repr=False)
1056
+ class ExtensionRangeOptions(betterproto2_compiler.Message):
1057
+ uninterpreted_option: List["UninterpretedOption"] = betterproto2_compiler.message_field(999)
1058
+ """The parser stores options it doesn't recognize here. See above."""
1059
+
1060
+ declaration: List["ExtensionRangeOptionsDeclaration"] = betterproto2_compiler.message_field(2)
1061
+ """
1062
+ For external users: DO NOT USE. We are in the process of open sourcing
1063
+ extension declaration and executing internal cleanups before it can be
1064
+ used externally.
1065
+ """
1066
+
1067
+ features: "FeatureSet" = betterproto2_compiler.message_field(50)
1068
+ """Any features defined in the specific edition."""
1069
+
1070
+ verification: "ExtensionRangeOptionsVerificationState" = betterproto2_compiler.enum_field(
1071
+ 3,
1072
+ enum_default_value=lambda: ExtensionRangeOptionsVerificationState.try_value(0),
1073
+ )
1074
+ """
1075
+ The verification state of the range.
1076
+ TODO: flip the default to DECLARATION once all empty ranges
1077
+ are marked as UNVERIFIED.
1078
+ """
1079
+
1080
+
1081
+ @dataclass(eq=False, repr=False)
1082
+ class ExtensionRangeOptionsDeclaration(betterproto2_compiler.Message):
1083
+ number: int = betterproto2_compiler.int32_field(1)
1084
+ """The extension number declared within the extension range."""
1085
+
1086
+ full_name: str = betterproto2_compiler.string_field(2)
1087
+ """
1088
+ The fully-qualified name of the extension field. There must be a leading
1089
+ dot in front of the full name.
1090
+ """
1091
+
1092
+ type: str = betterproto2_compiler.string_field(3)
1093
+ """
1094
+ The fully-qualified type name of the extension field. Unlike
1095
+ Metadata.type, Declaration.type must have a leading dot for messages
1096
+ and enums.
1097
+ """
1098
+
1099
+ reserved: bool = betterproto2_compiler.bool_field(5)
1100
+ """
1101
+ If true, indicates that the number is reserved in the extension range,
1102
+ and any extension field with the number will fail to compile. Set this
1103
+ when a declared extension field is deleted.
1104
+ """
1105
+
1106
+ repeated: bool = betterproto2_compiler.bool_field(6)
1107
+ """
1108
+ If true, indicates that the extension must be defined as repeated.
1109
+ Otherwise the extension must be defined as optional.
1110
+ """
1111
+
1112
+
1113
+ @dataclass(eq=False, repr=False)
1114
+ class FieldDescriptorProto(betterproto2_compiler.Message):
1115
+ """Describes a field within a message."""
1116
+
1117
+ name: str = betterproto2_compiler.string_field(1)
1118
+ number: int = betterproto2_compiler.int32_field(3)
1119
+ label: "FieldDescriptorProtoLabel" = betterproto2_compiler.enum_field(
1120
+ 4, enum_default_value=lambda: FieldDescriptorProtoLabel.try_value(0)
1121
+ )
1122
+ type: "FieldDescriptorProtoType" = betterproto2_compiler.enum_field(
1123
+ 5, enum_default_value=lambda: FieldDescriptorProtoType.try_value(0)
1124
+ )
1125
+ """
1126
+ If type_name is set, this need not be set. If both this and type_name
1127
+ are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
1128
+ """
1129
+
1130
+ type_name: str = betterproto2_compiler.string_field(6)
1131
+ """
1132
+ For message and enum types, this is the name of the type. If the name
1133
+ starts with a '.', it is fully-qualified. Otherwise, C++-like scoping
1134
+ rules are used to find the type (i.e. first the nested types within this
1135
+ message are searched, then within the parent, on up to the root
1136
+ namespace).
1137
+ """
1138
+
1139
+ extendee: str = betterproto2_compiler.string_field(2)
1140
+ """
1141
+ For extensions, this is the name of the type being extended. It is
1142
+ resolved in the same manner as type_name.
1143
+ """
1144
+
1145
+ default_value: str = betterproto2_compiler.string_field(7)
1146
+ """
1147
+ For numeric types, contains the original text representation of the value.
1148
+ For booleans, "true" or "false".
1149
+ For strings, contains the default text contents (not escaped in any way).
1150
+ For bytes, contains the C escaped value. All bytes >= 128 are escaped.
1151
+ """
1152
+
1153
+ oneof_index: int = betterproto2_compiler.int32_field(9)
1154
+ """
1155
+ If set, gives the index of a oneof in the containing type's oneof_decl
1156
+ list. This field is a member of that oneof.
1157
+ """
1158
+
1159
+ json_name: str = betterproto2_compiler.string_field(10)
1160
+ """
1161
+ JSON name of this field. The value is set by protocol compiler. If the
1162
+ user has set a "json_name" option on this field, that option's value
1163
+ will be used. Otherwise, it's deduced from the field's name by converting
1164
+ it to camelCase.
1165
+ """
1166
+
1167
+ options: "FieldOptions" = betterproto2_compiler.message_field(8)
1168
+ proto3_optional: bool = betterproto2_compiler.bool_field(17)
1169
+ """
1170
+ If true, this is a proto3 "optional". When a proto3 field is optional, it
1171
+ tracks presence regardless of field type.
1172
+
1173
+ When proto3_optional is true, this field must belong to a oneof to signal
1174
+ to old proto3 clients that presence is tracked for this field. This oneof
1175
+ is known as a "synthetic" oneof, and this field must be its sole member
1176
+ (each proto3 optional field gets its own synthetic oneof). Synthetic oneofs
1177
+ exist in the descriptor only, and do not generate any API. Synthetic oneofs
1178
+ must be ordered after all "real" oneofs.
1179
+
1180
+ For message fields, proto3_optional doesn't create any semantic change,
1181
+ since non-repeated message fields always track presence. However it still
1182
+ indicates the semantic detail of whether the user wrote "optional" or not.
1183
+ This can be useful for round-tripping the .proto file. For consistency we
1184
+ give message fields a synthetic oneof also, even though it is not required
1185
+ to track presence. This is especially important because the parser can't
1186
+ tell if a field is a message or an enum, so it must always create a
1187
+ synthetic oneof.
1188
+
1189
+ Proto2 optional fields do not set this flag, because they already indicate
1190
+ optional with `LABEL_OPTIONAL`.
1191
+ """
1192
+
1193
+
1194
+ @dataclass(eq=False, repr=False)
1195
+ class OneofDescriptorProto(betterproto2_compiler.Message):
1196
+ """Describes a oneof."""
1197
+
1198
+ name: str = betterproto2_compiler.string_field(1)
1199
+ options: "OneofOptions" = betterproto2_compiler.message_field(2)
1200
+
1201
+
1202
+ @dataclass(eq=False, repr=False)
1203
+ class EnumDescriptorProto(betterproto2_compiler.Message):
1204
+ """Describes an enum type."""
1205
+
1206
+ name: str = betterproto2_compiler.string_field(1)
1207
+ value: List["EnumValueDescriptorProto"] = betterproto2_compiler.message_field(2)
1208
+ options: "EnumOptions" = betterproto2_compiler.message_field(3)
1209
+ reserved_range: List["EnumDescriptorProtoEnumReservedRange"] = betterproto2_compiler.message_field(4)
1210
+ """
1211
+ Range of reserved numeric values. Reserved numeric values may not be used
1212
+ by enum values in the same enum declaration. Reserved ranges may not
1213
+ overlap.
1214
+ """
1215
+
1216
+ reserved_name: List[str] = betterproto2_compiler.string_field(5)
1217
+ """
1218
+ Reserved enum value names, which may not be reused. A given name may only
1219
+ be reserved once.
1220
+ """
1221
+
1222
+
1223
+ @dataclass(eq=False, repr=False)
1224
+ class EnumDescriptorProtoEnumReservedRange(betterproto2_compiler.Message):
1225
+ """
1226
+ Range of reserved numeric values. Reserved values may not be used by
1227
+ entries in the same enum. Reserved ranges may not overlap.
1228
+
1229
+ Note that this is distinct from DescriptorProto.ReservedRange in that it
1230
+ is inclusive such that it can appropriately represent the entire int32
1231
+ domain.
1232
+ """
1233
+
1234
+ start: int = betterproto2_compiler.int32_field(1)
1235
+ end: int = betterproto2_compiler.int32_field(2)
1236
+
1237
+
1238
+ @dataclass(eq=False, repr=False)
1239
+ class EnumValueDescriptorProto(betterproto2_compiler.Message):
1240
+ """Describes a value within an enum."""
1241
+
1242
+ name: str = betterproto2_compiler.string_field(1)
1243
+ number: int = betterproto2_compiler.int32_field(2)
1244
+ options: "EnumValueOptions" = betterproto2_compiler.message_field(3)
1245
+
1246
+
1247
+ @dataclass(eq=False, repr=False)
1248
+ class ServiceDescriptorProto(betterproto2_compiler.Message):
1249
+ """Describes a service."""
1250
+
1251
+ name: str = betterproto2_compiler.string_field(1)
1252
+ method: List["MethodDescriptorProto"] = betterproto2_compiler.message_field(2)
1253
+ options: "ServiceOptions" = betterproto2_compiler.message_field(3)
1254
+
1255
+
1256
+ @dataclass(eq=False, repr=False)
1257
+ class MethodDescriptorProto(betterproto2_compiler.Message):
1258
+ """Describes a method of a service."""
1259
+
1260
+ name: str = betterproto2_compiler.string_field(1)
1261
+ input_type: str = betterproto2_compiler.string_field(2)
1262
+ """
1263
+ Input and output type names. These are resolved in the same way as
1264
+ FieldDescriptorProto.type_name, but must refer to a message type.
1265
+ """
1266
+
1267
+ output_type: str = betterproto2_compiler.string_field(3)
1268
+ options: "MethodOptions" = betterproto2_compiler.message_field(4)
1269
+ client_streaming: bool = betterproto2_compiler.bool_field(5)
1270
+ """Identifies if client streams multiple client messages"""
1271
+
1272
+ server_streaming: bool = betterproto2_compiler.bool_field(6)
1273
+ """Identifies if server streams multiple server messages"""
1274
+
1275
+
1276
+ @dataclass(eq=False, repr=False)
1277
+ class FileOptions(betterproto2_compiler.Message):
1278
+ java_package: str = betterproto2_compiler.string_field(1)
1279
+ """
1280
+ Sets the Java package where classes generated from this .proto will be
1281
+ placed. By default, the proto package is used, but this is often
1282
+ inappropriate because proto packages do not normally start with backwards
1283
+ domain names.
1284
+ """
1285
+
1286
+ java_outer_classname: str = betterproto2_compiler.string_field(8)
1287
+ """
1288
+ Controls the name of the wrapper Java class generated for the .proto file.
1289
+ That class will always contain the .proto file's getDescriptor() method as
1290
+ well as any top-level extensions defined in the .proto file.
1291
+ If java_multiple_files is disabled, then all the other classes from the
1292
+ .proto file will be nested inside the single wrapper outer class.
1293
+ """
1294
+
1295
+ java_multiple_files: bool = betterproto2_compiler.bool_field(10)
1296
+ """
1297
+ If enabled, then the Java code generator will generate a separate .java
1298
+ file for each top-level message, enum, and service defined in the .proto
1299
+ file. Thus, these types will *not* be nested inside the wrapper class
1300
+ named by java_outer_classname. However, the wrapper class will still be
1301
+ generated to contain the file's getDescriptor() method as well as any
1302
+ top-level extensions defined in the file.
1303
+ """
1304
+
1305
+ java_generate_equals_and_hash: bool = betterproto2_compiler.bool_field(20)
1306
+ """This option does nothing."""
1307
+
1308
+ java_string_check_utf8: bool = betterproto2_compiler.bool_field(27)
1309
+ """
1310
+ If set true, then the Java2 code generator will generate code that
1311
+ throws an exception whenever an attempt is made to assign a non-UTF-8
1312
+ byte sequence to a string field.
1313
+ Message reflection will do the same.
1314
+ However, an extension field still accepts non-UTF-8 byte sequences.
1315
+ This option has no effect on when used with the lite runtime.
1316
+ """
1317
+
1318
+ optimize_for: "FileOptionsOptimizeMode" = betterproto2_compiler.enum_field(
1319
+ 9, enum_default_value=lambda: FileOptionsOptimizeMode.try_value(0)
1320
+ )
1321
+ go_package: str = betterproto2_compiler.string_field(11)
1322
+ """
1323
+ Sets the Go package where structs generated from this .proto will be
1324
+ placed. If omitted, the Go package will be derived from the following:
1325
+ - The basename of the package import path, if provided.
1326
+ - Otherwise, the package statement in the .proto file, if present.
1327
+ - Otherwise, the basename of the .proto file, without extension.
1328
+ """
1329
+
1330
+ cc_generic_services: bool = betterproto2_compiler.bool_field(16)
1331
+ """
1332
+ Should generic services be generated in each language? "Generic" services
1333
+ are not specific to any particular RPC system. They are generated by the
1334
+ main code generators in each language (without additional plugins).
1335
+ Generic services were the only kind of service generation supported by
1336
+ early versions of google.protobuf.
1337
+
1338
+ Generic services are now considered deprecated in favor of using plugins
1339
+ that generate code specific to your particular RPC system. Therefore,
1340
+ these default to false. Old code which depends on generic services should
1341
+ explicitly set them to true.
1342
+ """
1343
+
1344
+ java_generic_services: bool = betterproto2_compiler.bool_field(17)
1345
+ py_generic_services: bool = betterproto2_compiler.bool_field(18)
1346
+ deprecated: bool = betterproto2_compiler.bool_field(23)
1347
+ """
1348
+ Is this file deprecated?
1349
+ Depending on the target platform, this can emit Deprecated annotations
1350
+ for everything in the file, or it will be completely ignored; in the very
1351
+ least, this is a formalization for deprecating files.
1352
+ """
1353
+
1354
+ cc_enable_arenas: bool = betterproto2_compiler.bool_field(31)
1355
+ """
1356
+ Enables the use of arenas for the proto messages in this file. This applies
1357
+ only to generated classes for C++.
1358
+ """
1359
+
1360
+ objc_class_prefix: str = betterproto2_compiler.string_field(36)
1361
+ """
1362
+ Sets the objective c class prefix which is prepended to all objective c
1363
+ generated classes from this .proto. There is no default.
1364
+ """
1365
+
1366
+ csharp_namespace: str = betterproto2_compiler.string_field(37)
1367
+ """Namespace for generated classes; defaults to the package."""
1368
+
1369
+ swift_prefix: str = betterproto2_compiler.string_field(39)
1370
+ """
1371
+ By default Swift generators will take the proto package and CamelCase it
1372
+ replacing '.' with underscore and use that to prefix the types/symbols
1373
+ defined. When this options is provided, they will use this value instead
1374
+ to prefix the types/symbols defined.
1375
+ """
1376
+
1377
+ php_class_prefix: str = betterproto2_compiler.string_field(40)
1378
+ """
1379
+ Sets the php class prefix which is prepended to all php generated classes
1380
+ from this .proto. Default is empty.
1381
+ """
1382
+
1383
+ php_namespace: str = betterproto2_compiler.string_field(41)
1384
+ """
1385
+ Use this option to change the namespace of php generated classes. Default
1386
+ is empty. When this option is empty, the package name will be used for
1387
+ determining the namespace.
1388
+ """
1389
+
1390
+ php_metadata_namespace: str = betterproto2_compiler.string_field(44)
1391
+ """
1392
+ Use this option to change the namespace of php generated metadata classes.
1393
+ Default is empty. When this option is empty, the proto file name will be
1394
+ used for determining the namespace.
1395
+ """
1396
+
1397
+ ruby_package: str = betterproto2_compiler.string_field(45)
1398
+ """
1399
+ Use this option to change the package of ruby generated classes. Default
1400
+ is empty. When this option is not set, the package name will be used for
1401
+ determining the ruby package.
1402
+ """
1403
+
1404
+ features: "FeatureSet" = betterproto2_compiler.message_field(50)
1405
+ """Any features defined in the specific edition."""
1406
+
1407
+ uninterpreted_option: List["UninterpretedOption"] = betterproto2_compiler.message_field(999)
1408
+ """
1409
+ The parser stores options it doesn't recognize here.
1410
+ See the documentation for the "Options" section above.
1411
+ """
1412
+
1413
+ def __post_init__(self) -> None:
1414
+ super().__post_init__()
1415
+ if self.is_set("java_generate_equals_and_hash"):
1416
+ warnings.warn(
1417
+ "FileOptions.java_generate_equals_and_hash is deprecated",
1418
+ DeprecationWarning,
1419
+ )
1420
+
1421
+
1422
+ @dataclass(eq=False, repr=False)
1423
+ class MessageOptions(betterproto2_compiler.Message):
1424
+ message_set_wire_format: bool = betterproto2_compiler.bool_field(1)
1425
+ """
1426
+ Set true to use the old proto1 MessageSet wire format for extensions.
1427
+ This is provided for backwards-compatibility with the MessageSet wire
1428
+ format. You should not use this for any other reason: It's less
1429
+ efficient, has fewer features, and is more complicated.
1430
+
1431
+ The message must be defined exactly as follows:
1432
+ message Foo {
1433
+ option message_set_wire_format = true;
1434
+ extensions 4 to max;
1435
+ }
1436
+ Note that the message cannot have any defined fields; MessageSets only
1437
+ have extensions.
1438
+
1439
+ All extensions of your type must be singular messages; e.g. they cannot
1440
+ be int32s, enums, or repeated messages.
1441
+
1442
+ Because this is an option, the above two restrictions are not enforced by
1443
+ the protocol compiler.
1444
+ """
1445
+
1446
+ no_standard_descriptor_accessor: bool = betterproto2_compiler.bool_field(2)
1447
+ """
1448
+ Disables the generation of the standard "descriptor()" accessor, which can
1449
+ conflict with a field of the same name. This is meant to make migration
1450
+ from proto1 easier; new code should avoid fields named "descriptor".
1451
+ """
1452
+
1453
+ deprecated: bool = betterproto2_compiler.bool_field(3)
1454
+ """
1455
+ Is this message deprecated?
1456
+ Depending on the target platform, this can emit Deprecated annotations
1457
+ for the message, or it will be completely ignored; in the very least,
1458
+ this is a formalization for deprecating messages.
1459
+ """
1460
+
1461
+ map_entry: bool = betterproto2_compiler.bool_field(7)
1462
+ """
1463
+ Whether the message is an automatically generated map entry type for the
1464
+ maps field.
1465
+
1466
+ For maps fields:
1467
+ map<KeyType, ValueType> map_field = 1;
1468
+ The parsed descriptor looks like:
1469
+ message MapFieldEntry {
1470
+ option map_entry = true;
1471
+ optional KeyType key = 1;
1472
+ optional ValueType value = 2;
1473
+ }
1474
+ repeated MapFieldEntry map_field = 1;
1475
+
1476
+ Implementations may choose not to generate the map_entry=true message, but
1477
+ use a native map in the target language to hold the keys and values.
1478
+ The reflection APIs in such implementations still need to work as
1479
+ if the field is a repeated message field.
1480
+
1481
+ NOTE: Do not set the option in .proto files. Always use the maps syntax
1482
+ instead. The option should only be implicitly set by the proto compiler
1483
+ parser.
1484
+ """
1485
+
1486
+ deprecated_legacy_json_field_conflicts: bool = betterproto2_compiler.bool_field(11)
1487
+ """
1488
+ Enable the legacy handling of JSON field name conflicts. This lowercases
1489
+ and strips underscored from the fields before comparison in proto3 only.
1490
+ The new behavior takes `json_name` into account and applies to proto2 as
1491
+ well.
1492
+
1493
+ This should only be used as a temporary measure against broken builds due
1494
+ to the change in behavior for JSON field name conflicts.
1495
+
1496
+ TODO This is legacy behavior we plan to remove once downstream
1497
+ teams have had time to migrate.
1498
+ """
1499
+
1500
+ features: "FeatureSet" = betterproto2_compiler.message_field(12)
1501
+ """Any features defined in the specific edition."""
1502
+
1503
+ uninterpreted_option: List["UninterpretedOption"] = betterproto2_compiler.message_field(999)
1504
+ """The parser stores options it doesn't recognize here. See above."""
1505
+
1506
+ def __post_init__(self) -> None:
1507
+ super().__post_init__()
1508
+ if self.is_set("deprecated_legacy_json_field_conflicts"):
1509
+ warnings.warn(
1510
+ "MessageOptions.deprecated_legacy_json_field_conflicts is deprecated",
1511
+ DeprecationWarning,
1512
+ )
1513
+
1514
+
1515
+ @dataclass(eq=False, repr=False)
1516
+ class FieldOptions(betterproto2_compiler.Message):
1517
+ ctype: "FieldOptionsCType" = betterproto2_compiler.enum_field(
1518
+ 1, enum_default_value=lambda: FieldOptionsCType.try_value(0)
1519
+ )
1520
+ """
1521
+ The ctype option instructs the C++ code generator to use a different
1522
+ representation of the field than it normally would. See the specific
1523
+ options below. This option is only implemented to support use of
1524
+ [ctype=CORD] and [ctype=STRING] (the default) on non-repeated fields of
1525
+ type "bytes" in the open source release -- sorry, we'll try to include
1526
+ other types in a future version!
1527
+ """
1528
+
1529
+ packed: bool = betterproto2_compiler.bool_field(2)
1530
+ """
1531
+ The packed option can be enabled for repeated primitive fields to enable
1532
+ a more efficient representation on the wire. Rather than repeatedly
1533
+ writing the tag and type for each element, the entire array is encoded as
1534
+ a single length-delimited blob. In proto3, only explicit setting it to
1535
+ false will avoid using packed encoding. This option is prohibited in
1536
+ Editions, but the `repeated_field_encoding` feature can be used to control
1537
+ the behavior.
1538
+ """
1539
+
1540
+ jstype: "FieldOptionsJsType" = betterproto2_compiler.enum_field(
1541
+ 6, enum_default_value=lambda: FieldOptionsJsType.try_value(0)
1542
+ )
1543
+ """
1544
+ The jstype option determines the JavaScript type used for values of the
1545
+ field. The option is permitted only for 64 bit integral and fixed types
1546
+ (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING
1547
+ is represented as JavaScript string, which avoids loss of precision that
1548
+ can happen when a large value is converted to a floating point JavaScript.
1549
+ Specifying JS_NUMBER for the jstype causes the generated JavaScript code to
1550
+ use the JavaScript "number" type. The behavior of the default option
1551
+ JS_NORMAL is implementation dependent.
1552
+
1553
+ This option is an enum to permit additional types to be added, e.g.
1554
+ goog.math.Integer.
1555
+ """
1556
+
1557
+ lazy: bool = betterproto2_compiler.bool_field(5)
1558
+ """
1559
+ Should this field be parsed lazily? Lazy applies only to message-type
1560
+ fields. It means that when the outer message is initially parsed, the
1561
+ inner message's contents will not be parsed but instead stored in encoded
1562
+ form. The inner message will actually be parsed when it is first accessed.
1563
+
1564
+ This is only a hint. Implementations are free to choose whether to use
1565
+ eager or lazy parsing regardless of the value of this option. However,
1566
+ setting this option true suggests that the protocol author believes that
1567
+ using lazy parsing on this field is worth the additional bookkeeping
1568
+ overhead typically needed to implement it.
1569
+
1570
+ This option does not affect the public interface of any generated code;
1571
+ all method signatures remain the same. Furthermore, thread-safety of the
1572
+ interface is not affected by this option; const methods remain safe to
1573
+ call from multiple threads concurrently, while non-const methods continue
1574
+ to require exclusive access.
1575
+
1576
+ Note that lazy message fields are still eagerly verified to check
1577
+ ill-formed wireformat or missing required fields. Calling IsInitialized()
1578
+ on the outer message would fail if the inner message has missing required
1579
+ fields. Failed verification would result in parsing failure (except when
1580
+ uninitialized messages are acceptable).
1581
+ """
1582
+
1583
+ unverified_lazy: bool = betterproto2_compiler.bool_field(15)
1584
+ """
1585
+ unverified_lazy does no correctness checks on the byte stream. This should
1586
+ only be used where lazy with verification is prohibitive for performance
1587
+ reasons.
1588
+ """
1589
+
1590
+ deprecated: bool = betterproto2_compiler.bool_field(3)
1591
+ """
1592
+ Is this field deprecated?
1593
+ Depending on the target platform, this can emit Deprecated annotations
1594
+ for accessors, or it will be completely ignored; in the very least, this
1595
+ is a formalization for deprecating fields.
1596
+ """
1597
+
1598
+ weak: bool = betterproto2_compiler.bool_field(10)
1599
+ """For Google-internal migration only. Do not use."""
1600
+
1601
+ debug_redact: bool = betterproto2_compiler.bool_field(16)
1602
+ """
1603
+ Indicate that the field value should not be printed out when using debug
1604
+ formats, e.g. when the field contains sensitive credentials.
1605
+ """
1606
+
1607
+ retention: "FieldOptionsOptionRetention" = betterproto2_compiler.enum_field(
1608
+ 17, enum_default_value=lambda: FieldOptionsOptionRetention.try_value(0)
1609
+ )
1610
+ targets: List["FieldOptionsOptionTargetType"] = betterproto2_compiler.enum_field(
1611
+ 19, enum_default_value=lambda: FieldOptionsOptionTargetType.try_value(0)
1612
+ )
1613
+ edition_defaults: List["FieldOptionsEditionDefault"] = betterproto2_compiler.message_field(20)
1614
+ features: "FeatureSet" = betterproto2_compiler.message_field(21)
1615
+ """Any features defined in the specific edition."""
1616
+
1617
+ uninterpreted_option: List["UninterpretedOption"] = betterproto2_compiler.message_field(999)
1618
+ """The parser stores options it doesn't recognize here. See above."""
1619
+
1620
+
1621
+ @dataclass(eq=False, repr=False)
1622
+ class FieldOptionsEditionDefault(betterproto2_compiler.Message):
1623
+ edition: "Edition" = betterproto2_compiler.enum_field(3, enum_default_value=lambda: Edition.try_value(0))
1624
+ value: str = betterproto2_compiler.string_field(2)
1625
+
1626
+
1627
+ @dataclass(eq=False, repr=False)
1628
+ class OneofOptions(betterproto2_compiler.Message):
1629
+ features: "FeatureSet" = betterproto2_compiler.message_field(1)
1630
+ """Any features defined in the specific edition."""
1631
+
1632
+ uninterpreted_option: List["UninterpretedOption"] = betterproto2_compiler.message_field(999)
1633
+ """The parser stores options it doesn't recognize here. See above."""
1634
+
1635
+
1636
+ @dataclass(eq=False, repr=False)
1637
+ class EnumOptions(betterproto2_compiler.Message):
1638
+ allow_alias: bool = betterproto2_compiler.bool_field(2)
1639
+ """
1640
+ Set this option to true to allow mapping different tag names to the same
1641
+ value.
1642
+ """
1643
+
1644
+ deprecated: bool = betterproto2_compiler.bool_field(3)
1645
+ """
1646
+ Is this enum deprecated?
1647
+ Depending on the target platform, this can emit Deprecated annotations
1648
+ for the enum, or it will be completely ignored; in the very least, this
1649
+ is a formalization for deprecating enums.
1650
+ """
1651
+
1652
+ deprecated_legacy_json_field_conflicts: bool = betterproto2_compiler.bool_field(6)
1653
+ """
1654
+ Enable the legacy handling of JSON field name conflicts. This lowercases
1655
+ and strips underscored from the fields before comparison in proto3 only.
1656
+ The new behavior takes `json_name` into account and applies to proto2 as
1657
+ well.
1658
+ TODO Remove this legacy behavior once downstream teams have
1659
+ had time to migrate.
1660
+ """
1661
+
1662
+ features: "FeatureSet" = betterproto2_compiler.message_field(7)
1663
+ """Any features defined in the specific edition."""
1664
+
1665
+ uninterpreted_option: List["UninterpretedOption"] = betterproto2_compiler.message_field(999)
1666
+ """The parser stores options it doesn't recognize here. See above."""
1667
+
1668
+ def __post_init__(self) -> None:
1669
+ super().__post_init__()
1670
+ if self.is_set("deprecated_legacy_json_field_conflicts"):
1671
+ warnings.warn(
1672
+ "EnumOptions.deprecated_legacy_json_field_conflicts is deprecated",
1673
+ DeprecationWarning,
1674
+ )
1675
+
1676
+
1677
+ @dataclass(eq=False, repr=False)
1678
+ class EnumValueOptions(betterproto2_compiler.Message):
1679
+ deprecated: bool = betterproto2_compiler.bool_field(1)
1680
+ """
1681
+ Is this enum value deprecated?
1682
+ Depending on the target platform, this can emit Deprecated annotations
1683
+ for the enum value, or it will be completely ignored; in the very least,
1684
+ this is a formalization for deprecating enum values.
1685
+ """
1686
+
1687
+ features: "FeatureSet" = betterproto2_compiler.message_field(2)
1688
+ """Any features defined in the specific edition."""
1689
+
1690
+ debug_redact: bool = betterproto2_compiler.bool_field(3)
1691
+ """
1692
+ Indicate that fields annotated with this enum value should not be printed
1693
+ out when using debug formats, e.g. when the field contains sensitive
1694
+ credentials.
1695
+ """
1696
+
1697
+ uninterpreted_option: List["UninterpretedOption"] = betterproto2_compiler.message_field(999)
1698
+ """The parser stores options it doesn't recognize here. See above."""
1699
+
1700
+
1701
+ @dataclass(eq=False, repr=False)
1702
+ class ServiceOptions(betterproto2_compiler.Message):
1703
+ features: "FeatureSet" = betterproto2_compiler.message_field(34)
1704
+ """Any features defined in the specific edition."""
1705
+
1706
+ deprecated: bool = betterproto2_compiler.bool_field(33)
1707
+ """
1708
+ Is this service deprecated?
1709
+ Depending on the target platform, this can emit Deprecated annotations
1710
+ for the service, or it will be completely ignored; in the very least,
1711
+ this is a formalization for deprecating services.
1712
+ """
1713
+
1714
+ uninterpreted_option: List["UninterpretedOption"] = betterproto2_compiler.message_field(999)
1715
+ """The parser stores options it doesn't recognize here. See above."""
1716
+
1717
+
1718
+ @dataclass(eq=False, repr=False)
1719
+ class MethodOptions(betterproto2_compiler.Message):
1720
+ deprecated: bool = betterproto2_compiler.bool_field(33)
1721
+ """
1722
+ Is this method deprecated?
1723
+ Depending on the target platform, this can emit Deprecated annotations
1724
+ for the method, or it will be completely ignored; in the very least,
1725
+ this is a formalization for deprecating methods.
1726
+ """
1727
+
1728
+ idempotency_level: "MethodOptionsIdempotencyLevel" = betterproto2_compiler.enum_field(
1729
+ 34, enum_default_value=lambda: MethodOptionsIdempotencyLevel.try_value(0)
1730
+ )
1731
+ features: "FeatureSet" = betterproto2_compiler.message_field(35)
1732
+ """Any features defined in the specific edition."""
1733
+
1734
+ uninterpreted_option: List["UninterpretedOption"] = betterproto2_compiler.message_field(999)
1735
+ """The parser stores options it doesn't recognize here. See above."""
1736
+
1737
+
1738
+ @dataclass(eq=False, repr=False)
1739
+ class UninterpretedOption(betterproto2_compiler.Message):
1740
+ """
1741
+ A message representing a option the parser does not recognize. This only
1742
+ appears in options protos created by the compiler::Parser class.
1743
+ DescriptorPool resolves these when building Descriptor objects. Therefore,
1744
+ options protos in descriptor objects (e.g. returned by Descriptor::options(),
1745
+ or produced by Descriptor::CopyTo()) will never have UninterpretedOptions
1746
+ in them.
1747
+ """
1748
+
1749
+ name: List["UninterpretedOptionNamePart"] = betterproto2_compiler.message_field(2)
1750
+ identifier_value: str = betterproto2_compiler.string_field(3)
1751
+ """
1752
+ The value of the uninterpreted option, in whatever type the tokenizer
1753
+ identified it as during parsing. Exactly one of these should be set.
1754
+ """
1755
+
1756
+ positive_int_value: int = betterproto2_compiler.uint64_field(4)
1757
+ negative_int_value: int = betterproto2_compiler.int64_field(5)
1758
+ double_value: float = betterproto2_compiler.double_field(6)
1759
+ string_value: bytes = betterproto2_compiler.bytes_field(7)
1760
+ aggregate_value: str = betterproto2_compiler.string_field(8)
1761
+
1762
+
1763
+ @dataclass(eq=False, repr=False)
1764
+ class UninterpretedOptionNamePart(betterproto2_compiler.Message):
1765
+ """
1766
+ The name of the uninterpreted option. Each string represents a segment in
1767
+ a dot-separated name. is_extension is true iff a segment represents an
1768
+ extension (denoted with parentheses in options specs in .proto files).
1769
+ E.g.,{ ["foo", false], ["bar.baz", true], ["moo", false] } represents
1770
+ "foo.(bar.baz).moo".
1771
+ """
1772
+
1773
+ name_part: str = betterproto2_compiler.string_field(1)
1774
+ is_extension: bool = betterproto2_compiler.bool_field(2)
1775
+
1776
+
1777
+ @dataclass(eq=False, repr=False)
1778
+ class FeatureSet(betterproto2_compiler.Message):
1779
+ """
1780
+ TODO Enums in C++ gencode (and potentially other languages) are
1781
+ not well scoped. This means that each of the feature enums below can clash
1782
+ with each other. The short names we've chosen maximize call-site
1783
+ readability, but leave us very open to this scenario. A future feature will
1784
+ be designed and implemented to handle this, hopefully before we ever hit a
1785
+ conflict here.
1786
+ """
1787
+
1788
+ field_presence: "FeatureSetFieldPresence" = betterproto2_compiler.enum_field(
1789
+ 1, enum_default_value=lambda: FeatureSetFieldPresence.try_value(0)
1790
+ )
1791
+ enum_type: "FeatureSetEnumType" = betterproto2_compiler.enum_field(
1792
+ 2, enum_default_value=lambda: FeatureSetEnumType.try_value(0)
1793
+ )
1794
+ repeated_field_encoding: "FeatureSetRepeatedFieldEncoding" = betterproto2_compiler.enum_field(
1795
+ 3, enum_default_value=lambda: FeatureSetRepeatedFieldEncoding.try_value(0)
1796
+ )
1797
+ utf8_validation: "FeatureSetUtf8Validation" = betterproto2_compiler.enum_field(
1798
+ 4, enum_default_value=lambda: FeatureSetUtf8Validation.try_value(0)
1799
+ )
1800
+ message_encoding: "FeatureSetMessageEncoding" = betterproto2_compiler.enum_field(
1801
+ 5, enum_default_value=lambda: FeatureSetMessageEncoding.try_value(0)
1802
+ )
1803
+ json_format: "FeatureSetJsonFormat" = betterproto2_compiler.enum_field(
1804
+ 6, enum_default_value=lambda: FeatureSetJsonFormat.try_value(0)
1805
+ )
1806
+
1807
+
1808
+ @dataclass(eq=False, repr=False)
1809
+ class FeatureSetDefaults(betterproto2_compiler.Message):
1810
+ """
1811
+ A compiled specification for the defaults of a set of features. These
1812
+ messages are generated from FeatureSet extensions and can be used to seed
1813
+ feature resolution. The resolution with this object becomes a simple search
1814
+ for the closest matching edition, followed by proto merges.
1815
+ """
1816
+
1817
+ defaults: List["FeatureSetDefaultsFeatureSetEditionDefault"] = betterproto2_compiler.message_field(1)
1818
+ minimum_edition: "Edition" = betterproto2_compiler.enum_field(4, enum_default_value=lambda: Edition.try_value(0))
1819
+ """
1820
+ The minimum supported edition (inclusive) when this was constructed.
1821
+ Editions before this will not have defaults.
1822
+ """
1823
+
1824
+ maximum_edition: "Edition" = betterproto2_compiler.enum_field(5, enum_default_value=lambda: Edition.try_value(0))
1825
+ """
1826
+ The maximum known edition (inclusive) when this was constructed. Editions
1827
+ after this will not have reliable defaults.
1828
+ """
1829
+
1830
+
1831
+ @dataclass(eq=False, repr=False)
1832
+ class FeatureSetDefaultsFeatureSetEditionDefault(betterproto2_compiler.Message):
1833
+ """
1834
+ A map from every known edition with a unique set of defaults to its
1835
+ defaults. Not all editions may be contained here. For a given edition,
1836
+ the defaults at the closest matching edition ordered at or before it should
1837
+ be used. This field must be in strict ascending order by edition.
1838
+ """
1839
+
1840
+ edition: "Edition" = betterproto2_compiler.enum_field(3, enum_default_value=lambda: Edition.try_value(0))
1841
+ features: "FeatureSet" = betterproto2_compiler.message_field(2)
1842
+
1843
+
1844
+ @dataclass(eq=False, repr=False)
1845
+ class SourceCodeInfo(betterproto2_compiler.Message):
1846
+ """
1847
+ Encapsulates information about the original source file from which a
1848
+ FileDescriptorProto was generated.
1849
+ """
1850
+
1851
+ location: List["SourceCodeInfoLocation"] = betterproto2_compiler.message_field(1)
1852
+ """
1853
+ A Location identifies a piece of source code in a .proto file which
1854
+ corresponds to a particular definition. This information is intended
1855
+ to be useful to IDEs, code indexers, documentation generators, and similar
1856
+ tools.
1857
+
1858
+ For example, say we have a file like:
1859
+ message Foo {
1860
+ optional string foo = 1;
1861
+ }
1862
+ Let's look at just the field definition:
1863
+ optional string foo = 1;
1864
+ ^ ^^ ^^ ^ ^^^
1865
+ a bc de f ghi
1866
+ We have the following locations:
1867
+ span path represents
1868
+ [a,i) [ 4, 0, 2, 0 ] The whole field definition.
1869
+ [a,b) [ 4, 0, 2, 0, 4 ] The label (optional).
1870
+ [c,d) [ 4, 0, 2, 0, 5 ] The type (string).
1871
+ [e,f) [ 4, 0, 2, 0, 1 ] The name (foo).
1872
+ [g,h) [ 4, 0, 2, 0, 3 ] The number (1).
1873
+
1874
+ Notes:
1875
+ - A location may refer to a repeated field itself (i.e. not to any
1876
+ particular index within it). This is used whenever a set of elements are
1877
+ logically enclosed in a single code segment. For example, an entire
1878
+ extend block (possibly containing multiple extension definitions) will
1879
+ have an outer location whose path refers to the "extensions" repeated
1880
+ field without an index.
1881
+ - Multiple locations may have the same path. This happens when a single
1882
+ logical declaration is spread out across multiple places. The most
1883
+ obvious example is the "extend" block again -- there may be multiple
1884
+ extend blocks in the same scope, each of which will have the same path.
1885
+ - A location's span is not always a subset of its parent's span. For
1886
+ example, the "extendee" of an extension declaration appears at the
1887
+ beginning of the "extend" block and is shared by all extensions within
1888
+ the block.
1889
+ - Just because a location's span is a subset of some other location's span
1890
+ does not mean that it is a descendant. For example, a "group" defines
1891
+ both a type and a field in a single declaration. Thus, the locations
1892
+ corresponding to the type and field and their components will overlap.
1893
+ - Code which tries to interpret locations should probably be designed to
1894
+ ignore those that it doesn't understand, as more types of locations could
1895
+ be recorded in the future.
1896
+ """
1897
+
1898
+
1899
+ @dataclass(eq=False, repr=False)
1900
+ class SourceCodeInfoLocation(betterproto2_compiler.Message):
1901
+ path: List[int] = betterproto2_compiler.int32_field(1)
1902
+ """
1903
+ Identifies which part of the FileDescriptorProto was defined at this
1904
+ location.
1905
+
1906
+ Each element is a field number or an index. They form a path from
1907
+ the root FileDescriptorProto to the place where the definition appears.
1908
+ For example, this path:
1909
+ [ 4, 3, 2, 7, 1 ]
1910
+ refers to:
1911
+ file.message_type(3) // 4, 3
1912
+ .field(7) // 2, 7
1913
+ .name() // 1
1914
+ This is because FileDescriptorProto.message_type has field number 4:
1915
+ repeated DescriptorProto message_type = 4;
1916
+ and DescriptorProto.field has field number 2:
1917
+ repeated FieldDescriptorProto field = 2;
1918
+ and FieldDescriptorProto.name has field number 1:
1919
+ optional string name = 1;
1920
+
1921
+ Thus, the above path gives the location of a field name. If we removed
1922
+ the last element:
1923
+ [ 4, 3, 2, 7 ]
1924
+ this path refers to the whole field declaration (from the beginning
1925
+ of the label to the terminating semicolon).
1926
+ """
1927
+
1928
+ span: List[int] = betterproto2_compiler.int32_field(2)
1929
+ """
1930
+ Always has exactly three or four elements: start line, start column,
1931
+ end line (optional, otherwise assumed same as start line), end column.
1932
+ These are packed into a single field for efficiency. Note that line
1933
+ and column numbers are zero-based -- typically you will want to add
1934
+ 1 to each before displaying to a user.
1935
+ """
1936
+
1937
+ leading_comments: str = betterproto2_compiler.string_field(3)
1938
+ """
1939
+ If this SourceCodeInfo represents a complete declaration, these are any
1940
+ comments appearing before and after the declaration which appear to be
1941
+ attached to the declaration.
1942
+
1943
+ A series of line comments appearing on consecutive lines, with no other
1944
+ tokens appearing on those lines, will be treated as a single comment.
1945
+
1946
+ leading_detached_comments will keep paragraphs of comments that appear
1947
+ before (but not connected to) the current element. Each paragraph,
1948
+ separated by empty lines, will be one comment element in the repeated
1949
+ field.
1950
+
1951
+ Only the comment content is provided; comment markers (e.g. //) are
1952
+ stripped out. For block comments, leading whitespace and an asterisk
1953
+ will be stripped from the beginning of each line other than the first.
1954
+ Newlines are included in the output.
1955
+
1956
+ Examples:
1957
+
1958
+ optional int32 foo = 1; // Comment attached to foo.
1959
+ // Comment attached to bar.
1960
+ optional int32 bar = 2;
1961
+
1962
+ optional string baz = 3;
1963
+ // Comment attached to baz.
1964
+ // Another line attached to baz.
1965
+
1966
+ // Comment attached to moo.
1967
+ //
1968
+ // Another line attached to moo.
1969
+ optional double moo = 4;
1970
+
1971
+ // Detached comment for corge. This is not leading or trailing comments
1972
+ // to moo or corge because there are blank lines separating it from
1973
+ // both.
1974
+
1975
+ // Detached comment for corge paragraph 2.
1976
+
1977
+ optional string corge = 5;
1978
+ /* Block comment attached
1979
+ * to corge. Leading asterisks
1980
+ * will be removed. */
1981
+ /* Block comment attached to
1982
+ * grault. */
1983
+ optional int32 grault = 6;
1984
+
1985
+ // ignored detached comments.
1986
+ """
1987
+
1988
+ trailing_comments: str = betterproto2_compiler.string_field(4)
1989
+ leading_detached_comments: List[str] = betterproto2_compiler.string_field(6)
1990
+
1991
+
1992
+ @dataclass(eq=False, repr=False)
1993
+ class GeneratedCodeInfo(betterproto2_compiler.Message):
1994
+ """
1995
+ Describes the relationship between generated code and its original source
1996
+ file. A GeneratedCodeInfo message is associated with only one generated
1997
+ source file, but may contain references to different source .proto files.
1998
+ """
1999
+
2000
+ annotation: List["GeneratedCodeInfoAnnotation"] = betterproto2_compiler.message_field(1)
2001
+ """
2002
+ An Annotation connects some span of text in generated code to an element
2003
+ of its generating .proto file.
2004
+ """
2005
+
2006
+
2007
+ @dataclass(eq=False, repr=False)
2008
+ class GeneratedCodeInfoAnnotation(betterproto2_compiler.Message):
2009
+ path: List[int] = betterproto2_compiler.int32_field(1)
2010
+ """
2011
+ Identifies the element in the original source .proto file. This field
2012
+ is formatted the same as SourceCodeInfo.Location.path.
2013
+ """
2014
+
2015
+ source_file: str = betterproto2_compiler.string_field(2)
2016
+ """Identifies the filesystem path to the original source .proto."""
2017
+
2018
+ begin: int = betterproto2_compiler.int32_field(3)
2019
+ """
2020
+ Identifies the starting offset in bytes in the generated code
2021
+ that relates to the identified object.
2022
+ """
2023
+
2024
+ end: int = betterproto2_compiler.int32_field(4)
2025
+ """
2026
+ Identifies the ending offset in bytes in the generated code that
2027
+ relates to the identified object. The end offset should be one past
2028
+ the last relevant byte (so the length of the text = end - begin).
2029
+ """
2030
+
2031
+ semantic: "GeneratedCodeInfoAnnotationSemantic" = betterproto2_compiler.enum_field(
2032
+ 5, enum_default_value=lambda: GeneratedCodeInfoAnnotationSemantic.try_value(0)
2033
+ )
2034
+
2035
+
2036
+ @dataclass(eq=False, repr=False)
2037
+ class Duration(betterproto2_compiler.Message):
2038
+ """
2039
+ A Duration represents a signed, fixed-length span of time represented
2040
+ as a count of seconds and fractions of seconds at nanosecond
2041
+ resolution. It is independent of any calendar and concepts like "day"
2042
+ or "month". It is related to Timestamp in that the difference between
2043
+ two Timestamp values is a Duration and it can be added or subtracted
2044
+ from a Timestamp. Range is approximately +-10,000 years.
2045
+
2046
+ # Examples
2047
+
2048
+ Example 1: Compute Duration from two Timestamps in pseudo code.
2049
+
2050
+ Timestamp start = ...;
2051
+ Timestamp end = ...;
2052
+ Duration duration = ...;
2053
+
2054
+ duration.seconds = end.seconds - start.seconds;
2055
+ duration.nanos = end.nanos - start.nanos;
2056
+
2057
+ if (duration.seconds < 0 && duration.nanos > 0) {
2058
+ duration.seconds += 1;
2059
+ duration.nanos -= 1000000000;
2060
+ } else if (duration.seconds > 0 && duration.nanos < 0) {
2061
+ duration.seconds -= 1;
2062
+ duration.nanos += 1000000000;
2063
+ }
2064
+
2065
+ Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
2066
+
2067
+ Timestamp start = ...;
2068
+ Duration duration = ...;
2069
+ Timestamp end = ...;
2070
+
2071
+ end.seconds = start.seconds + duration.seconds;
2072
+ end.nanos = start.nanos + duration.nanos;
2073
+
2074
+ if (end.nanos < 0) {
2075
+ end.seconds -= 1;
2076
+ end.nanos += 1000000000;
2077
+ } else if (end.nanos >= 1000000000) {
2078
+ end.seconds += 1;
2079
+ end.nanos -= 1000000000;
2080
+ }
2081
+
2082
+ Example 3: Compute Duration from datetime.timedelta in Python.
2083
+
2084
+ td = datetime.timedelta(days=3, minutes=10)
2085
+ duration = Duration()
2086
+ duration.FromTimedelta(td)
2087
+
2088
+ # JSON Mapping
2089
+
2090
+ In JSON format, the Duration type is encoded as a string rather than an
2091
+ object, where the string ends in the suffix "s" (indicating seconds) and
2092
+ is preceded by the number of seconds, with nanoseconds expressed as
2093
+ fractional seconds. For example, 3 seconds with 0 nanoseconds should be
2094
+ encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
2095
+ be expressed in JSON format as "3.000000001s", and 3 seconds and 1
2096
+ microsecond should be expressed in JSON format as "3.000001s".
2097
+ """
2098
+
2099
+ seconds: int = betterproto2_compiler.int64_field(1)
2100
+ """
2101
+ Signed seconds of the span of time. Must be from -315,576,000,000
2102
+ to +315,576,000,000 inclusive. Note: these bounds are computed from:
2103
+ 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
2104
+ """
2105
+
2106
+ nanos: int = betterproto2_compiler.int32_field(2)
2107
+ """
2108
+ Signed fractions of a second at nanosecond resolution of the span
2109
+ of time. Durations less than one second are represented with a 0
2110
+ `seconds` field and a positive or negative `nanos` field. For durations
2111
+ of one second or more, a non-zero value for the `nanos` field must be
2112
+ of the same sign as the `seconds` field. Must be from -999,999,999
2113
+ to +999,999,999 inclusive.
2114
+ """
2115
+
2116
+
2117
+ @dataclass(eq=False, repr=False)
2118
+ class Empty(betterproto2_compiler.Message):
2119
+ """
2120
+ A generic empty message that you can re-use to avoid defining duplicated
2121
+ empty messages in your APIs. A typical example is to use it as the request
2122
+ or the response type of an API method. For instance:
2123
+
2124
+ service Foo {
2125
+ rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
2126
+ }
2127
+ """
2128
+
2129
+ pass
2130
+
2131
+
2132
+ @dataclass(eq=False, repr=False)
2133
+ class FieldMask(betterproto2_compiler.Message):
2134
+ """
2135
+ `FieldMask` represents a set of symbolic field paths, for example:
2136
+
2137
+ paths: "f.a"
2138
+ paths: "f.b.d"
2139
+
2140
+ Here `f` represents a field in some root message, `a` and `b`
2141
+ fields in the message found in `f`, and `d` a field found in the
2142
+ message in `f.b`.
2143
+
2144
+ Field masks are used to specify a subset of fields that should be
2145
+ returned by a get operation or modified by an update operation.
2146
+ Field masks also have a custom JSON encoding (see below).
2147
+
2148
+ # Field Masks in Projections
2149
+
2150
+ When used in the context of a projection, a response message or
2151
+ sub-message is filtered by the API to only contain those fields as
2152
+ specified in the mask. For example, if the mask in the previous
2153
+ example is applied to a response message as follows:
2154
+
2155
+ f {
2156
+ a : 22
2157
+ b {
2158
+ d : 1
2159
+ x : 2
2160
+ }
2161
+ y : 13
2162
+ }
2163
+ z: 8
2164
+
2165
+ The result will not contain specific values for fields x,y and z
2166
+ (their value will be set to the default, and omitted in proto text
2167
+ output):
2168
+
2169
+
2170
+ f {
2171
+ a : 22
2172
+ b {
2173
+ d : 1
2174
+ }
2175
+ }
2176
+
2177
+ A repeated field is not allowed except at the last position of a
2178
+ paths string.
2179
+
2180
+ If a FieldMask object is not present in a get operation, the
2181
+ operation applies to all fields (as if a FieldMask of all fields
2182
+ had been specified).
2183
+
2184
+ Note that a field mask does not necessarily apply to the
2185
+ top-level response message. In case of a REST get operation, the
2186
+ field mask applies directly to the response, but in case of a REST
2187
+ list operation, the mask instead applies to each individual message
2188
+ in the returned resource list. In case of a REST custom method,
2189
+ other definitions may be used. Where the mask applies will be
2190
+ clearly documented together with its declaration in the API. In
2191
+ any case, the effect on the returned resource/resources is required
2192
+ behavior for APIs.
2193
+
2194
+ # Field Masks in Update Operations
2195
+
2196
+ A field mask in update operations specifies which fields of the
2197
+ targeted resource are going to be updated. The API is required
2198
+ to only change the values of the fields as specified in the mask
2199
+ and leave the others untouched. If a resource is passed in to
2200
+ describe the updated values, the API ignores the values of all
2201
+ fields not covered by the mask.
2202
+
2203
+ If a repeated field is specified for an update operation, new values will
2204
+ be appended to the existing repeated field in the target resource. Note that
2205
+ a repeated field is only allowed in the last position of a `paths` string.
2206
+
2207
+ If a sub-message is specified in the last position of the field mask for an
2208
+ update operation, then new value will be merged into the existing sub-message
2209
+ in the target resource.
2210
+
2211
+ For example, given the target message:
2212
+
2213
+ f {
2214
+ b {
2215
+ d: 1
2216
+ x: 2
2217
+ }
2218
+ c: [1]
2219
+ }
2220
+
2221
+ And an update message:
2222
+
2223
+ f {
2224
+ b {
2225
+ d: 10
2226
+ }
2227
+ c: [2]
2228
+ }
2229
+
2230
+ then if the field mask is:
2231
+
2232
+ paths: ["f.b", "f.c"]
2233
+
2234
+ then the result will be:
2235
+
2236
+ f {
2237
+ b {
2238
+ d: 10
2239
+ x: 2
2240
+ }
2241
+ c: [1, 2]
2242
+ }
2243
+
2244
+ An implementation may provide options to override this default behavior for
2245
+ repeated and message fields.
2246
+
2247
+ In order to reset a field's value to the default, the field must
2248
+ be in the mask and set to the default value in the provided resource.
2249
+ Hence, in order to reset all fields of a resource, provide a default
2250
+ instance of the resource and set all fields in the mask, or do
2251
+ not provide a mask as described below.
2252
+
2253
+ If a field mask is not present on update, the operation applies to
2254
+ all fields (as if a field mask of all fields has been specified).
2255
+ Note that in the presence of schema evolution, this may mean that
2256
+ fields the client does not know and has therefore not filled into
2257
+ the request will be reset to their default. If this is unwanted
2258
+ behavior, a specific service may require a client to always specify
2259
+ a field mask, producing an error if not.
2260
+
2261
+ As with get operations, the location of the resource which
2262
+ describes the updated values in the request message depends on the
2263
+ operation kind. In any case, the effect of the field mask is
2264
+ required to be honored by the API.
2265
+
2266
+ ## Considerations for HTTP REST
2267
+
2268
+ The HTTP kind of an update operation which uses a field mask must
2269
+ be set to PATCH instead of PUT in order to satisfy HTTP semantics
2270
+ (PUT must only be used for full updates).
2271
+
2272
+ # JSON Encoding of Field Masks
2273
+
2274
+ In JSON, a field mask is encoded as a single string where paths are
2275
+ separated by a comma. Fields name in each path are converted
2276
+ to/from lower-camel naming conventions.
2277
+
2278
+ As an example, consider the following message declarations:
2279
+
2280
+ message Profile {
2281
+ User user = 1;
2282
+ Photo photo = 2;
2283
+ }
2284
+ message User {
2285
+ string display_name = 1;
2286
+ string address = 2;
2287
+ }
2288
+
2289
+ In proto a field mask for `Profile` may look as such:
2290
+
2291
+ mask {
2292
+ paths: "user.display_name"
2293
+ paths: "photo"
2294
+ }
2295
+
2296
+ In JSON, the same mask is represented as below:
2297
+
2298
+ {
2299
+ mask: "user.displayName,photo"
2300
+ }
2301
+
2302
+ # Field Masks and Oneof Fields
2303
+
2304
+ Field masks treat fields in oneofs just as regular fields. Consider the
2305
+ following message:
2306
+
2307
+ message SampleMessage {
2308
+ oneof test_oneof {
2309
+ string name = 4;
2310
+ SubMessage sub_message = 9;
2311
+ }
2312
+ }
2313
+
2314
+ The field mask can be:
2315
+
2316
+ mask {
2317
+ paths: "name"
2318
+ }
2319
+
2320
+ Or:
2321
+
2322
+ mask {
2323
+ paths: "sub_message"
2324
+ }
2325
+
2326
+ Note that oneof type names ("test_oneof" in this case) cannot be used in
2327
+ paths.
2328
+
2329
+ ## Field Mask Verification
2330
+
2331
+ The implementation of any API method which has a FieldMask type field in the
2332
+ request should verify the included field paths, and return an
2333
+ `INVALID_ARGUMENT` error if any path is unmappable.
2334
+ """
2335
+
2336
+ paths: List[str] = betterproto2_compiler.string_field(1)
2337
+ """The set of field mask paths."""
2338
+
2339
+
2340
+ @dataclass(eq=False, repr=False)
2341
+ class Struct(betterproto2_compiler.Message):
2342
+ """
2343
+ `Struct` represents a structured data value, consisting of fields
2344
+ which map to dynamically typed values. In some languages, `Struct`
2345
+ might be supported by a native representation. For example, in
2346
+ scripting languages like JS a struct is represented as an
2347
+ object. The details of that representation are described together
2348
+ with the proto support for the language.
2349
+
2350
+ The JSON representation for `Struct` is JSON object.
2351
+ """
2352
+
2353
+ fields: Dict[str, "Value"] = betterproto2_compiler.map_field(
2354
+ 1, betterproto2_compiler.TYPE_STRING, betterproto2_compiler.TYPE_MESSAGE
2355
+ )
2356
+ """Unordered map of dynamically typed values."""
2357
+
2358
+ @hybridmethod
2359
+ def from_dict(cls: "type[Self]", value: Mapping[str, Any]) -> Self: # type: ignore
2360
+ self = cls()
2361
+ return self.from_dict(value)
2362
+
2363
+ @from_dict.instancemethod
2364
+ def from_dict(self, value: Mapping[str, Any]) -> Self:
2365
+ fields = {**value}
2366
+ for k in fields:
2367
+ if hasattr(fields[k], "from_dict"):
2368
+ fields[k] = fields[k].from_dict()
2369
+
2370
+ self.fields = fields
2371
+ return self
2372
+
2373
+ def to_dict(
2374
+ self,
2375
+ casing: betterproto2_compiler.Casing = betterproto2_compiler.Casing.CAMEL,
2376
+ include_default_values: bool = False,
2377
+ ) -> Dict[str, Any]:
2378
+ output = {**self.fields}
2379
+ for k in self.fields:
2380
+ if hasattr(self.fields[k], "to_dict"):
2381
+ output[k] = self.fields[k].to_dict(casing, include_default_values)
2382
+ return output
2383
+
2384
+
2385
+ @dataclass(eq=False, repr=False)
2386
+ class Value(betterproto2_compiler.Message):
2387
+ """
2388
+ `Value` represents a dynamically typed value which can be either
2389
+ null, a number, a string, a boolean, a recursive struct value, or a
2390
+ list of values. A producer of value is expected to set one of these
2391
+ variants. Absence of any variant indicates an error.
2392
+
2393
+ The JSON representation for `Value` is JSON value.
2394
+ """
2395
+
2396
+ null_value: Optional["NullValue"] = betterproto2_compiler.enum_field(
2397
+ 1,
2398
+ enum_default_value=lambda: NullValue.try_value(0),
2399
+ optional=True,
2400
+ group="kind",
2401
+ )
2402
+ """Represents a null value."""
2403
+
2404
+ number_value: Optional[float] = betterproto2_compiler.double_field(2, optional=True, group="kind")
2405
+ """Represents a double value."""
2406
+
2407
+ string_value: Optional[str] = betterproto2_compiler.string_field(3, optional=True, group="kind")
2408
+ """Represents a string value."""
2409
+
2410
+ bool_value: Optional[bool] = betterproto2_compiler.bool_field(4, optional=True, group="kind")
2411
+ """Represents a boolean value."""
2412
+
2413
+ struct_value: Optional["Struct"] = betterproto2_compiler.message_field(5, optional=True, group="kind")
2414
+ """Represents a structured value."""
2415
+
2416
+ list_value: Optional["ListValue"] = betterproto2_compiler.message_field(6, optional=True, group="kind")
2417
+ """Represents a repeated `Value`."""
2418
+
2419
+ @model_validator(mode="after")
2420
+ def check_oneof(cls, values):
2421
+ return cls._validate_field_groups(values)
2422
+
2423
+
2424
+ @dataclass(eq=False, repr=False)
2425
+ class ListValue(betterproto2_compiler.Message):
2426
+ """
2427
+ `ListValue` is a wrapper around a repeated field of values.
2428
+
2429
+ The JSON representation for `ListValue` is JSON array.
2430
+ """
2431
+
2432
+ values: List["Value"] = betterproto2_compiler.message_field(1)
2433
+ """Repeated field of dynamically typed values."""
2434
+
2435
+
2436
+ @dataclass(eq=False, repr=False)
2437
+ class Timestamp(betterproto2_compiler.Message):
2438
+ """
2439
+ A Timestamp represents a point in time independent of any time zone or local
2440
+ calendar, encoded as a count of seconds and fractions of seconds at
2441
+ nanosecond resolution. The count is relative to an epoch at UTC midnight on
2442
+ January 1, 1970, in the proleptic Gregorian calendar which extends the
2443
+ Gregorian calendar backwards to year one.
2444
+
2445
+ All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
2446
+ second table is needed for interpretation, using a [24-hour linear
2447
+ smear](https://developers.google.com/time/smear).
2448
+
2449
+ The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
2450
+ restricting to that range, we ensure that we can convert to and from [RFC
2451
+ 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
2452
+
2453
+ # Examples
2454
+
2455
+ Example 1: Compute Timestamp from POSIX `time()`.
2456
+
2457
+ Timestamp timestamp;
2458
+ timestamp.set_seconds(time(NULL));
2459
+ timestamp.set_nanos(0);
2460
+
2461
+ Example 2: Compute Timestamp from POSIX `gettimeofday()`.
2462
+
2463
+ struct timeval tv;
2464
+ gettimeofday(&tv, NULL);
2465
+
2466
+ Timestamp timestamp;
2467
+ timestamp.set_seconds(tv.tv_sec);
2468
+ timestamp.set_nanos(tv.tv_usec * 1000);
2469
+
2470
+ Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
2471
+
2472
+ FILETIME ft;
2473
+ GetSystemTimeAsFileTime(&ft);
2474
+ UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
2475
+
2476
+ // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
2477
+ // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
2478
+ Timestamp timestamp;
2479
+ timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
2480
+ timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
2481
+
2482
+ Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
2483
+
2484
+ long millis = System.currentTimeMillis();
2485
+
2486
+ Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
2487
+ .setNanos((int) ((millis % 1000) * 1000000)).build();
2488
+
2489
+ Example 5: Compute Timestamp from Java `Instant.now()`.
2490
+
2491
+ Instant now = Instant.now();
2492
+
2493
+ Timestamp timestamp =
2494
+ Timestamp.newBuilder().setSeconds(now.getEpochSecond())
2495
+ .setNanos(now.getNano()).build();
2496
+
2497
+ Example 6: Compute Timestamp from current time in Python.
2498
+
2499
+ timestamp = Timestamp()
2500
+ timestamp.GetCurrentTime()
2501
+
2502
+ # JSON Mapping
2503
+
2504
+ In JSON format, the Timestamp type is encoded as a string in the
2505
+ [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
2506
+ format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
2507
+ where {year} is always expressed using four digits while {month}, {day},
2508
+ {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
2509
+ seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
2510
+ are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
2511
+ is required. A proto3 JSON serializer should always use UTC (as indicated by
2512
+ "Z") when printing the Timestamp type and a proto3 JSON parser should be
2513
+ able to accept both UTC and other timezones (as indicated by an offset).
2514
+
2515
+ For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
2516
+ 01:30 UTC on January 15, 2017.
2517
+
2518
+ In JavaScript, one can convert a Date object to this format using the
2519
+ standard
2520
+ [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
2521
+ method. In Python, a standard `datetime.datetime` object can be converted
2522
+ to this format using
2523
+ [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
2524
+ the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
2525
+ the Joda Time's [`ISODateTimeFormat.dateTime()`](
2526
+ http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()
2527
+ ) to obtain a formatter capable of generating timestamps in this format.
2528
+ """
2529
+
2530
+ seconds: int = betterproto2_compiler.int64_field(1)
2531
+ """
2532
+ Represents seconds of UTC time since Unix epoch
2533
+ 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
2534
+ 9999-12-31T23:59:59Z inclusive.
2535
+ """
2536
+
2537
+ nanos: int = betterproto2_compiler.int32_field(2)
2538
+ """
2539
+ Non-negative fractions of a second at nanosecond resolution. Negative
2540
+ second values with fractions must still have non-negative nanos values
2541
+ that count forward in time. Must be from 0 to 999,999,999
2542
+ inclusive.
2543
+ """
2544
+
2545
+
2546
+ @dataclass(eq=False, repr=False)
2547
+ class DoubleValue(betterproto2_compiler.Message):
2548
+ """
2549
+ Wrapper message for `double`.
2550
+
2551
+ The JSON representation for `DoubleValue` is JSON number.
2552
+ """
2553
+
2554
+ value: float = betterproto2_compiler.double_field(1)
2555
+ """The double value."""
2556
+
2557
+
2558
+ @dataclass(eq=False, repr=False)
2559
+ class FloatValue(betterproto2_compiler.Message):
2560
+ """
2561
+ Wrapper message for `float`.
2562
+
2563
+ The JSON representation for `FloatValue` is JSON number.
2564
+ """
2565
+
2566
+ value: float = betterproto2_compiler.float_field(1)
2567
+ """The float value."""
2568
+
2569
+
2570
+ @dataclass(eq=False, repr=False)
2571
+ class Int64Value(betterproto2_compiler.Message):
2572
+ """
2573
+ Wrapper message for `int64`.
2574
+
2575
+ The JSON representation for `Int64Value` is JSON string.
2576
+ """
2577
+
2578
+ value: int = betterproto2_compiler.int64_field(1)
2579
+ """The int64 value."""
2580
+
2581
+
2582
+ @dataclass(eq=False, repr=False)
2583
+ class UInt64Value(betterproto2_compiler.Message):
2584
+ """
2585
+ Wrapper message for `uint64`.
2586
+
2587
+ The JSON representation for `UInt64Value` is JSON string.
2588
+ """
2589
+
2590
+ value: int = betterproto2_compiler.uint64_field(1)
2591
+ """The uint64 value."""
2592
+
2593
+
2594
+ @dataclass(eq=False, repr=False)
2595
+ class Int32Value(betterproto2_compiler.Message):
2596
+ """
2597
+ Wrapper message for `int32`.
2598
+
2599
+ The JSON representation for `Int32Value` is JSON number.
2600
+ """
2601
+
2602
+ value: int = betterproto2_compiler.int32_field(1)
2603
+ """The int32 value."""
2604
+
2605
+
2606
+ @dataclass(eq=False, repr=False)
2607
+ class UInt32Value(betterproto2_compiler.Message):
2608
+ """
2609
+ Wrapper message for `uint32`.
2610
+
2611
+ The JSON representation for `UInt32Value` is JSON number.
2612
+ """
2613
+
2614
+ value: int = betterproto2_compiler.uint32_field(1)
2615
+ """The uint32 value."""
2616
+
2617
+
2618
+ @dataclass(eq=False, repr=False)
2619
+ class BoolValue(betterproto2_compiler.Message):
2620
+ """
2621
+ Wrapper message for `bool`.
2622
+
2623
+ The JSON representation for `BoolValue` is JSON `true` and `false`.
2624
+ """
2625
+
2626
+ value: bool = betterproto2_compiler.bool_field(1)
2627
+ """The bool value."""
2628
+
2629
+
2630
+ @dataclass(eq=False, repr=False)
2631
+ class StringValue(betterproto2_compiler.Message):
2632
+ """
2633
+ Wrapper message for `string`.
2634
+
2635
+ The JSON representation for `StringValue` is JSON string.
2636
+ """
2637
+
2638
+ value: str = betterproto2_compiler.string_field(1)
2639
+ """The string value."""
2640
+
2641
+
2642
+ @dataclass(eq=False, repr=False)
2643
+ class BytesValue(betterproto2_compiler.Message):
2644
+ """
2645
+ Wrapper message for `bytes`.
2646
+
2647
+ The JSON representation for `BytesValue` is JSON string.
2648
+ """
2649
+
2650
+ value: bytes = betterproto2_compiler.bytes_field(1)
2651
+ """The bytes value."""
2652
+
2653
+
2654
+ rebuild_dataclass(Type) # type: ignore
2655
+ rebuild_dataclass(Field) # type: ignore
2656
+ rebuild_dataclass(Enum) # type: ignore
2657
+ rebuild_dataclass(EnumValue) # type: ignore
2658
+ rebuild_dataclass(Option) # type: ignore
2659
+ rebuild_dataclass(Api) # type: ignore
2660
+ rebuild_dataclass(Method) # type: ignore
2661
+ rebuild_dataclass(FileDescriptorSet) # type: ignore
2662
+ rebuild_dataclass(FileDescriptorProto) # type: ignore
2663
+ rebuild_dataclass(DescriptorProto) # type: ignore
2664
+ rebuild_dataclass(DescriptorProtoExtensionRange) # type: ignore
2665
+ rebuild_dataclass(ExtensionRangeOptions) # type: ignore
2666
+ rebuild_dataclass(FieldDescriptorProto) # type: ignore
2667
+ rebuild_dataclass(OneofDescriptorProto) # type: ignore
2668
+ rebuild_dataclass(EnumDescriptorProto) # type: ignore
2669
+ rebuild_dataclass(EnumValueDescriptorProto) # type: ignore
2670
+ rebuild_dataclass(ServiceDescriptorProto) # type: ignore
2671
+ rebuild_dataclass(MethodDescriptorProto) # type: ignore
2672
+ rebuild_dataclass(FileOptions) # type: ignore
2673
+ rebuild_dataclass(MessageOptions) # type: ignore
2674
+ rebuild_dataclass(FieldOptions) # type: ignore
2675
+ rebuild_dataclass(FieldOptionsEditionDefault) # type: ignore
2676
+ rebuild_dataclass(OneofOptions) # type: ignore
2677
+ rebuild_dataclass(EnumOptions) # type: ignore
2678
+ rebuild_dataclass(EnumValueOptions) # type: ignore
2679
+ rebuild_dataclass(ServiceOptions) # type: ignore
2680
+ rebuild_dataclass(MethodOptions) # type: ignore
2681
+ rebuild_dataclass(UninterpretedOption) # type: ignore
2682
+ rebuild_dataclass(FeatureSet) # type: ignore
2683
+ rebuild_dataclass(FeatureSetDefaults) # type: ignore
2684
+ rebuild_dataclass(FeatureSetDefaultsFeatureSetEditionDefault) # type: ignore
2685
+ rebuild_dataclass(SourceCodeInfo) # type: ignore
2686
+ rebuild_dataclass(GeneratedCodeInfo) # type: ignore
2687
+ rebuild_dataclass(GeneratedCodeInfoAnnotation) # type: ignore
2688
+ rebuild_dataclass(Struct) # type: ignore
2689
+ rebuild_dataclass(Value) # type: ignore
2690
+ rebuild_dataclass(ListValue) # type: ignore