pyspiral 0.5.0__cp310-abi3-macosx_11_0_arm64.whl → 0.6.0__cp310-abi3-macosx_11_0_arm64.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 (86) hide show
  1. {pyspiral-0.5.0.dist-info → pyspiral-0.6.0.dist-info}/METADATA +7 -3
  2. pyspiral-0.6.0.dist-info/RECORD +99 -0
  3. {pyspiral-0.5.0.dist-info → pyspiral-0.6.0.dist-info}/WHEEL +1 -1
  4. spiral/__init__.py +10 -3
  5. spiral/_lib.abi3.so +0 -0
  6. spiral/adbc.py +6 -6
  7. spiral/api/__init__.py +8 -2
  8. spiral/api/client.py +1 -1
  9. spiral/api/key_space_indexes.py +23 -0
  10. spiral/api/projects.py +15 -0
  11. spiral/api/text_indexes.py +1 -1
  12. spiral/cli/__init__.py +15 -6
  13. spiral/cli/admin.py +2 -4
  14. spiral/cli/app.py +4 -2
  15. spiral/cli/fs.py +5 -6
  16. spiral/cli/iceberg.py +97 -0
  17. spiral/cli/key_spaces.py +68 -0
  18. spiral/cli/login.py +6 -7
  19. spiral/cli/orgs.py +7 -8
  20. spiral/cli/printer.py +3 -3
  21. spiral/cli/projects.py +5 -6
  22. spiral/cli/tables.py +131 -0
  23. spiral/cli/telemetry.py +3 -4
  24. spiral/cli/text.py +115 -0
  25. spiral/cli/types.py +3 -4
  26. spiral/cli/workloads.py +7 -8
  27. spiral/client.py +111 -8
  28. spiral/core/authn/__init__.pyi +27 -0
  29. spiral/core/client/__init__.pyi +135 -63
  30. spiral/core/table/__init__.pyi +34 -24
  31. spiral/core/table/metastore/__init__.pyi +0 -4
  32. spiral/core/table/spec/__init__.pyi +0 -2
  33. spiral/{tables/dataset.py → dataset.py} +13 -7
  34. spiral/{tables/debug → debug}/manifests.py +17 -6
  35. spiral/{tables/debug → debug}/scan.py +3 -3
  36. spiral/expressions/base.py +3 -3
  37. spiral/expressions/udf.py +1 -1
  38. spiral/{iceberg/client.py → iceberg.py} +1 -3
  39. spiral/key_space_index.py +44 -0
  40. spiral/project.py +171 -18
  41. spiral/protogen/_/arrow/flight/protocol/sql/__init__.py +1668 -1110
  42. spiral/protogen/_/google/protobuf/__init__.py +2190 -0
  43. spiral/protogen/_/message_pool.py +3 -0
  44. spiral/protogen/_/py.typed +0 -0
  45. spiral/protogen/_/scandal/__init__.py +138 -126
  46. spiral/protogen/_/spfs/__init__.py +72 -0
  47. spiral/protogen/_/spql/__init__.py +61 -0
  48. spiral/protogen/_/substrait/__init__.py +5256 -2459
  49. spiral/protogen/_/substrait/extensions/__init__.py +103 -49
  50. spiral/{tables/scan.py → scan.py} +37 -44
  51. spiral/settings.py +14 -3
  52. spiral/snapshot.py +55 -0
  53. spiral/streaming_/__init__.py +3 -0
  54. spiral/streaming_/reader.py +117 -0
  55. spiral/streaming_/stream.py +146 -0
  56. spiral/substrait_.py +9 -9
  57. spiral/table.py +257 -0
  58. spiral/text_index.py +17 -0
  59. spiral/{tables/transaction.py → transaction.py} +11 -15
  60. pyspiral-0.5.0.dist-info/RECORD +0 -103
  61. spiral/cli/iceberg/__init__.py +0 -7
  62. spiral/cli/iceberg/namespaces.py +0 -47
  63. spiral/cli/iceberg/tables.py +0 -60
  64. spiral/cli/indexes/__init__.py +0 -40
  65. spiral/cli/indexes/args.py +0 -39
  66. spiral/cli/indexes/workers.py +0 -59
  67. spiral/cli/tables/__init__.py +0 -88
  68. spiral/cli/tables/args.py +0 -42
  69. spiral/core/index/__init__.pyi +0 -7
  70. spiral/iceberg/__init__.py +0 -3
  71. spiral/indexes/__init__.py +0 -5
  72. spiral/indexes/client.py +0 -137
  73. spiral/indexes/index.py +0 -28
  74. spiral/indexes/scan.py +0 -22
  75. spiral/protogen/_/spiral/table/__init__.py +0 -22
  76. spiral/protogen/substrait/__init__.py +0 -3399
  77. spiral/protogen/substrait/extensions/__init__.py +0 -115
  78. spiral/tables/__init__.py +0 -12
  79. spiral/tables/client.py +0 -133
  80. spiral/tables/maintenance.py +0 -12
  81. spiral/tables/snapshot.py +0 -78
  82. spiral/tables/table.py +0 -145
  83. {pyspiral-0.5.0.dist-info → pyspiral-0.6.0.dist-info}/entry_points.txt +0 -0
  84. /spiral/{protogen/_/spiral → debug}/__init__.py +0 -0
  85. /spiral/{tables/debug → debug}/metrics.py +0 -0
  86. /spiral/{tables/debug → protogen/_/google}/__init__.py +0 -0
@@ -0,0 +1,2190 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # sources: google/protobuf/any.proto, google/protobuf/descriptor.proto, google/protobuf/empty.proto
3
+ # plugin: python-betterproto2
4
+ # This file has been @generated
5
+
6
+ __all__ = (
7
+ "Any",
8
+ "DescriptorProto",
9
+ "DescriptorProtoExtensionRange",
10
+ "DescriptorProtoReservedRange",
11
+ "Edition",
12
+ "Empty",
13
+ "EnumDescriptorProto",
14
+ "EnumDescriptorProtoEnumReservedRange",
15
+ "EnumOptions",
16
+ "EnumValueDescriptorProto",
17
+ "EnumValueOptions",
18
+ "ExtensionRangeOptions",
19
+ "ExtensionRangeOptionsDeclaration",
20
+ "ExtensionRangeOptionsVerificationState",
21
+ "FeatureSet",
22
+ "FeatureSetDefaults",
23
+ "FeatureSetDefaultsFeatureSetEditionDefault",
24
+ "FeatureSetEnumType",
25
+ "FeatureSetFieldPresence",
26
+ "FeatureSetJsonFormat",
27
+ "FeatureSetMessageEncoding",
28
+ "FeatureSetRepeatedFieldEncoding",
29
+ "FeatureSetUtf8Validation",
30
+ "FieldDescriptorProto",
31
+ "FieldDescriptorProtoLabel",
32
+ "FieldDescriptorProtoType",
33
+ "FieldOptions",
34
+ "FieldOptionsCType",
35
+ "FieldOptionsEditionDefault",
36
+ "FieldOptionsFeatureSupport",
37
+ "FieldOptionsJsType",
38
+ "FieldOptionsOptionRetention",
39
+ "FieldOptionsOptionTargetType",
40
+ "FileDescriptorProto",
41
+ "FileDescriptorSet",
42
+ "FileOptions",
43
+ "FileOptionsOptimizeMode",
44
+ "GeneratedCodeInfo",
45
+ "GeneratedCodeInfoAnnotation",
46
+ "GeneratedCodeInfoAnnotationSemantic",
47
+ "MessageOptions",
48
+ "MethodDescriptorProto",
49
+ "MethodOptions",
50
+ "MethodOptionsIdempotencyLevel",
51
+ "OneofDescriptorProto",
52
+ "OneofOptions",
53
+ "ServiceDescriptorProto",
54
+ "ServiceOptions",
55
+ "SourceCodeInfo",
56
+ "SourceCodeInfoLocation",
57
+ "UninterpretedOption",
58
+ "UninterpretedOptionNamePart",
59
+ )
60
+
61
+ import typing
62
+ import warnings
63
+ from dataclasses import dataclass
64
+
65
+ import betterproto2
66
+
67
+ from ...message_pool import default_message_pool
68
+
69
+ _COMPILER_VERSION = "0.8.0"
70
+ betterproto2.check_compiler_version(_COMPILER_VERSION)
71
+
72
+
73
+ class Edition(betterproto2.Enum):
74
+ """
75
+ The full set of known editions.
76
+ """
77
+
78
+ UNKNOWN = 0
79
+ """
80
+ A placeholder for an unknown edition value.
81
+ """
82
+
83
+ LEGACY = 900
84
+ """
85
+ A placeholder edition for specifying default behaviors *before* a feature
86
+ was first introduced. This is effectively an "infinite past".
87
+ """
88
+
89
+ PROTO2 = 998
90
+ """
91
+ Legacy syntax "editions". These pre-date editions, but behave much like
92
+ distinct editions. These can't be used to specify the edition of proto
93
+ files, but feature definitions must supply proto2/proto3 defaults for
94
+ backwards compatibility.
95
+ """
96
+
97
+ PROTO3 = 999
98
+
99
+ _2023 = 1000
100
+ """
101
+ Editions that have been released. The specific values are arbitrary and
102
+ should not be depended on, but they will always be time-ordered for easy
103
+ comparison.
104
+ """
105
+
106
+ _2024 = 1001
107
+
108
+ _1_TEST_ONLY = 1
109
+ """
110
+ Placeholder editions for testing feature resolution. These should not be
111
+ used or relied on outside of tests.
112
+ """
113
+
114
+ _2_TEST_ONLY = 2
115
+
116
+ _99997_TEST_ONLY = 99997
117
+
118
+ _99998_TEST_ONLY = 99998
119
+
120
+ _99999_TEST_ONLY = 99999
121
+
122
+ MAX = 2147483647
123
+ """
124
+ Placeholder for specifying unbounded edition support. This should only
125
+ ever be used by plugins that can expect to never require any changes to
126
+ support a new edition.
127
+ """
128
+
129
+ @classmethod
130
+ def betterproto_value_to_renamed_proto_names(cls) -> dict[int, str]:
131
+ return {
132
+ 0: "EDITION_UNKNOWN",
133
+ 900: "EDITION_LEGACY",
134
+ 998: "EDITION_PROTO2",
135
+ 999: "EDITION_PROTO3",
136
+ 1000: "EDITION_2023",
137
+ 1001: "EDITION_2024",
138
+ 1: "EDITION_1_TEST_ONLY",
139
+ 2: "EDITION_2_TEST_ONLY",
140
+ 99997: "EDITION_99997_TEST_ONLY",
141
+ 99998: "EDITION_99998_TEST_ONLY",
142
+ 99999: "EDITION_99999_TEST_ONLY",
143
+ 2147483647: "EDITION_MAX",
144
+ }
145
+
146
+ @classmethod
147
+ def betterproto_renamed_proto_names_to_value(cls) -> dict[str, int]:
148
+ return {
149
+ "EDITION_UNKNOWN": 0,
150
+ "EDITION_LEGACY": 900,
151
+ "EDITION_PROTO2": 998,
152
+ "EDITION_PROTO3": 999,
153
+ "EDITION_2023": 1000,
154
+ "EDITION_2024": 1001,
155
+ "EDITION_1_TEST_ONLY": 1,
156
+ "EDITION_2_TEST_ONLY": 2,
157
+ "EDITION_99997_TEST_ONLY": 99997,
158
+ "EDITION_99998_TEST_ONLY": 99998,
159
+ "EDITION_99999_TEST_ONLY": 99999,
160
+ "EDITION_MAX": 2147483647,
161
+ }
162
+
163
+
164
+ class ExtensionRangeOptionsVerificationState(betterproto2.Enum):
165
+ """
166
+ The verification state of the extension range.
167
+ """
168
+
169
+ DECLARATION = 0
170
+ """
171
+ All the extensions of the range must be declared.
172
+ """
173
+
174
+ UNVERIFIED = 1
175
+
176
+
177
+ class FeatureSetEnumType(betterproto2.Enum):
178
+ ENUM_TYPE_UNKNOWN = 0
179
+
180
+ OPEN = 1
181
+
182
+ CLOSED = 2
183
+
184
+
185
+ class FeatureSetFieldPresence(betterproto2.Enum):
186
+ FIELD_PRESENCE_UNKNOWN = 0
187
+
188
+ EXPLICIT = 1
189
+
190
+ IMPLICIT = 2
191
+
192
+ LEGACY_REQUIRED = 3
193
+
194
+
195
+ class FeatureSetJsonFormat(betterproto2.Enum):
196
+ JSON_FORMAT_UNKNOWN = 0
197
+
198
+ ALLOW = 1
199
+
200
+ LEGACY_BEST_EFFORT = 2
201
+
202
+
203
+ class FeatureSetMessageEncoding(betterproto2.Enum):
204
+ MESSAGE_ENCODING_UNKNOWN = 0
205
+
206
+ LENGTH_PREFIXED = 1
207
+
208
+ DELIMITED = 2
209
+
210
+
211
+ class FeatureSetRepeatedFieldEncoding(betterproto2.Enum):
212
+ REPEATED_FIELD_ENCODING_UNKNOWN = 0
213
+
214
+ PACKED = 1
215
+
216
+ EXPANDED = 2
217
+
218
+
219
+ class FeatureSetUtf8Validation(betterproto2.Enum):
220
+ UTF8_VALIDATION_UNKNOWN = 0
221
+
222
+ VERIFY = 2
223
+
224
+ NONE = 3
225
+
226
+
227
+ class FieldDescriptorProtoLabel(betterproto2.Enum):
228
+ OPTIONAL = 1
229
+ """
230
+ 0 is reserved for errors
231
+ """
232
+
233
+ REPEATED = 3
234
+
235
+ REQUIRED = 2
236
+ """
237
+ The required label is only allowed in google.protobuf. In proto3 and Editions
238
+ it's explicitly prohibited. In Editions, the `field_presence` feature
239
+ can be used to get this behavior.
240
+ """
241
+
242
+ @classmethod
243
+ def betterproto_value_to_renamed_proto_names(cls) -> dict[int, str]:
244
+ return {
245
+ 1: "LABEL_OPTIONAL",
246
+ 3: "LABEL_REPEATED",
247
+ 2: "LABEL_REQUIRED",
248
+ }
249
+
250
+ @classmethod
251
+ def betterproto_renamed_proto_names_to_value(cls) -> dict[str, int]:
252
+ return {
253
+ "LABEL_OPTIONAL": 1,
254
+ "LABEL_REPEATED": 3,
255
+ "LABEL_REQUIRED": 2,
256
+ }
257
+
258
+
259
+ class FieldDescriptorProtoType(betterproto2.Enum):
260
+ DOUBLE = 1
261
+ """
262
+ 0 is reserved for errors.
263
+ Order is weird for historical reasons.
264
+ """
265
+
266
+ FLOAT = 2
267
+
268
+ INT64 = 3
269
+ """
270
+ Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if
271
+ negative values are likely.
272
+ """
273
+
274
+ UINT64 = 4
275
+
276
+ INT32 = 5
277
+ """
278
+ Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if
279
+ negative values are likely.
280
+ """
281
+
282
+ FIXED64 = 6
283
+
284
+ FIXED32 = 7
285
+
286
+ BOOL = 8
287
+
288
+ STRING = 9
289
+
290
+ GROUP = 10
291
+ """
292
+ Tag-delimited aggregate.
293
+ Group type is deprecated and not supported after google.protobuf. However, Proto3
294
+ implementations should still be able to parse the group wire format and
295
+ treat group fields as unknown fields. In Editions, the group wire format
296
+ can be enabled via the `message_encoding` feature.
297
+ """
298
+
299
+ MESSAGE = 11
300
+ """
301
+ Length-delimited aggregate.
302
+ """
303
+
304
+ BYTES = 12
305
+ """
306
+ New in version 2.
307
+ """
308
+
309
+ UINT32 = 13
310
+
311
+ ENUM = 14
312
+
313
+ SFIXED32 = 15
314
+
315
+ SFIXED64 = 16
316
+
317
+ SINT32 = 17
318
+ """
319
+ Uses ZigZag encoding.
320
+ """
321
+
322
+ SINT64 = 18
323
+ """
324
+ Uses ZigZag encoding.
325
+ """
326
+
327
+ @classmethod
328
+ def betterproto_value_to_renamed_proto_names(cls) -> dict[int, str]:
329
+ return {
330
+ 1: "TYPE_DOUBLE",
331
+ 2: "TYPE_FLOAT",
332
+ 3: "TYPE_INT64",
333
+ 4: "TYPE_UINT64",
334
+ 5: "TYPE_INT32",
335
+ 6: "TYPE_FIXED64",
336
+ 7: "TYPE_FIXED32",
337
+ 8: "TYPE_BOOL",
338
+ 9: "TYPE_STRING",
339
+ 10: "TYPE_GROUP",
340
+ 11: "TYPE_MESSAGE",
341
+ 12: "TYPE_BYTES",
342
+ 13: "TYPE_UINT32",
343
+ 14: "TYPE_ENUM",
344
+ 15: "TYPE_SFIXED32",
345
+ 16: "TYPE_SFIXED64",
346
+ 17: "TYPE_SINT32",
347
+ 18: "TYPE_SINT64",
348
+ }
349
+
350
+ @classmethod
351
+ def betterproto_renamed_proto_names_to_value(cls) -> dict[str, int]:
352
+ return {
353
+ "TYPE_DOUBLE": 1,
354
+ "TYPE_FLOAT": 2,
355
+ "TYPE_INT64": 3,
356
+ "TYPE_UINT64": 4,
357
+ "TYPE_INT32": 5,
358
+ "TYPE_FIXED64": 6,
359
+ "TYPE_FIXED32": 7,
360
+ "TYPE_BOOL": 8,
361
+ "TYPE_STRING": 9,
362
+ "TYPE_GROUP": 10,
363
+ "TYPE_MESSAGE": 11,
364
+ "TYPE_BYTES": 12,
365
+ "TYPE_UINT32": 13,
366
+ "TYPE_ENUM": 14,
367
+ "TYPE_SFIXED32": 15,
368
+ "TYPE_SFIXED64": 16,
369
+ "TYPE_SINT32": 17,
370
+ "TYPE_SINT64": 18,
371
+ }
372
+
373
+
374
+ class FieldOptionsCType(betterproto2.Enum):
375
+ STRING = 0
376
+ """
377
+ Default mode.
378
+ """
379
+
380
+ CORD = 1
381
+ """
382
+ The option [ctype=CORD] may be applied to a non-repeated field of type
383
+ "bytes". It indicates that in C++, the data should be stored in a Cord
384
+ instead of a string. For very large strings, this may reduce memory
385
+ fragmentation. It may also allow better performance when parsing from a
386
+ Cord, or when parsing with aliasing enabled, as the parsed Cord may then
387
+ alias the original buffer.
388
+ """
389
+
390
+ STRING_PIECE = 2
391
+
392
+
393
+ class FieldOptionsJsType(betterproto2.Enum):
394
+ JS_NORMAL = 0
395
+ """
396
+ Use the default type.
397
+ """
398
+
399
+ JS_STRING = 1
400
+ """
401
+ Use JavaScript strings.
402
+ """
403
+
404
+ JS_NUMBER = 2
405
+ """
406
+ Use JavaScript numbers.
407
+ """
408
+
409
+
410
+ class FieldOptionsOptionRetention(betterproto2.Enum):
411
+ """
412
+ If set to RETENTION_SOURCE, the option will be omitted from the binary.
413
+ """
414
+
415
+ RETENTION_UNKNOWN = 0
416
+
417
+ RETENTION_RUNTIME = 1
418
+
419
+ RETENTION_SOURCE = 2
420
+
421
+
422
+ class FieldOptionsOptionTargetType(betterproto2.Enum):
423
+ """
424
+ This indicates the types of entities that the field may apply to when used
425
+ as an option. If it is unset, then the field may be freely used as an
426
+ option on any kind of entity.
427
+ """
428
+
429
+ TARGET_TYPE_UNKNOWN = 0
430
+
431
+ TARGET_TYPE_FILE = 1
432
+
433
+ TARGET_TYPE_EXTENSION_RANGE = 2
434
+
435
+ TARGET_TYPE_MESSAGE = 3
436
+
437
+ TARGET_TYPE_FIELD = 4
438
+
439
+ TARGET_TYPE_ONEOF = 5
440
+
441
+ TARGET_TYPE_ENUM = 6
442
+
443
+ TARGET_TYPE_ENUM_ENTRY = 7
444
+
445
+ TARGET_TYPE_SERVICE = 8
446
+
447
+ TARGET_TYPE_METHOD = 9
448
+
449
+
450
+ class FileOptionsOptimizeMode(betterproto2.Enum):
451
+ """
452
+ Generated classes can be optimized for speed or code size.
453
+ """
454
+
455
+ SPEED = 1
456
+ """
457
+ Generate complete code for parsing, serialization,
458
+ """
459
+
460
+ CODE_SIZE = 2
461
+ """
462
+ etc.
463
+
464
+ Use ReflectionOps to implement these methods.
465
+ """
466
+
467
+ LITE_RUNTIME = 3
468
+ """
469
+ Generate code using MessageLite and the lite runtime.
470
+ """
471
+
472
+
473
+ class GeneratedCodeInfoAnnotationSemantic(betterproto2.Enum):
474
+ """
475
+ Represents the identified object's effect on the element in the original
476
+ .proto file.
477
+ """
478
+
479
+ NONE = 0
480
+ """
481
+ There is no effect or the effect is indescribable.
482
+ """
483
+
484
+ SET = 1
485
+ """
486
+ The element is set or otherwise mutated.
487
+ """
488
+
489
+ ALIAS = 2
490
+ """
491
+ An alias to the element is returned.
492
+ """
493
+
494
+
495
+ class MethodOptionsIdempotencyLevel(betterproto2.Enum):
496
+ """
497
+ Is this method side-effect-free (or safe in HTTP parlance), or idempotent,
498
+ or neither? HTTP based RPC implementation may choose GET verb for safe
499
+ methods, and PUT verb for idempotent methods instead of the default POST.
500
+ """
501
+
502
+ IDEMPOTENCY_UNKNOWN = 0
503
+
504
+ NO_SIDE_EFFECTS = 1
505
+ """
506
+ implies idempotent
507
+ """
508
+
509
+ IDEMPOTENT = 2
510
+ """
511
+ idempotent, but may have side effects
512
+ """
513
+
514
+
515
+ @dataclass(eq=False, repr=False)
516
+ class Any(betterproto2.Message):
517
+ """
518
+ `Any` contains an arbitrary serialized protocol buffer message along with a
519
+ URL that describes the type of the serialized message.
520
+
521
+ Protobuf library provides support to pack/unpack Any values in the form
522
+ of utility functions or additional generated methods of the Any type.
523
+
524
+ Example 1: Pack and unpack a message in C++.
525
+
526
+ Foo foo = ...;
527
+ Any any;
528
+ any.PackFrom(foo);
529
+ ...
530
+ if (any.UnpackTo(&foo)) {
531
+ ...
532
+ }
533
+
534
+ Example 2: Pack and unpack a message in Java.
535
+
536
+ Foo foo = ...;
537
+ Any any = Any.pack(foo);
538
+ ...
539
+ if (any.is(Foo.class)) {
540
+ foo = any.unpack(Foo.class);
541
+ }
542
+ // or ...
543
+ if (any.isSameTypeAs(Foo.getDefaultInstance())) {
544
+ foo = any.unpack(Foo.getDefaultInstance());
545
+ }
546
+
547
+ Example 3: Pack and unpack a message in Python.
548
+
549
+ foo = Foo(...)
550
+ any = Any()
551
+ any.Pack(foo)
552
+ ...
553
+ if any.Is(Foo.DESCRIPTOR):
554
+ any.Unpack(foo)
555
+ ...
556
+
557
+ Example 4: Pack and unpack a message in Go
558
+
559
+ foo := &pb.Foo{...}
560
+ any, err := anypb.New(foo)
561
+ if err != nil {
562
+ ...
563
+ }
564
+ ...
565
+ foo := &pb.Foo{}
566
+ if err := any.UnmarshalTo(foo); err != nil {
567
+ ...
568
+ }
569
+
570
+ The pack methods provided by protobuf library will by default use
571
+ 'type.googleapis.com/full.type.name' as the type URL and the unpack
572
+ methods only use the fully qualified type name after the last '/'
573
+ in the type URL, for example "foo.bar.com/x/y.z" will yield type
574
+ name "y.z".
575
+
576
+ JSON
577
+ ====
578
+ The JSON representation of an `Any` value uses the regular
579
+ representation of the deserialized, embedded message, with an
580
+ additional field `@type` which contains the type URL. Example:
581
+
582
+ package google.profile;
583
+ message Person {
584
+ string first_name = 1;
585
+ string last_name = 2;
586
+ }
587
+
588
+ {
589
+ "@type": "type.googleapis.com/google.profile.Person",
590
+ "firstName": <string>,
591
+ "lastName": <string>
592
+ }
593
+
594
+ If the embedded message type is well-known and has a custom JSON
595
+ representation, that representation will be embedded adding a field
596
+ `value` which holds the custom JSON in addition to the `@type`
597
+ field. Example (for message [google.protobuf.Duration][]):
598
+
599
+ {
600
+ "@type": "type.googleapis.com/google.protobuf.Duration",
601
+ "value": "1.212s"
602
+ }
603
+ """
604
+
605
+ type_url: "str" = betterproto2.field(1, betterproto2.TYPE_STRING)
606
+ """
607
+ A URL/resource name that uniquely identifies the type of the serialized
608
+ protocol buffer message. This string must contain at least
609
+ one "/" character. The last segment of the URL's path must represent
610
+ the fully qualified name of the type (as in
611
+ `path/google.protobuf.Duration`). The name should be in a canonical form
612
+ (e.g., leading "." is not accepted).
613
+
614
+ In practice, teams usually precompile into the binary all types that they
615
+ expect it to use in the context of Any. However, for URLs which use the
616
+ scheme `http`, `https`, or no scheme, one can optionally set up a type
617
+ server that maps type URLs to message definitions as follows:
618
+
619
+ * If no scheme is provided, `https` is assumed.
620
+ * An HTTP GET on the URL must yield a [google.protobuf.Type][]
621
+ value in binary format, or produce an error.
622
+ * Applications are allowed to cache lookup results based on the
623
+ URL, or have them precompiled into a binary to avoid any
624
+ lookup. Therefore, binary compatibility needs to be preserved
625
+ on changes to types. (Use versioned type names to manage
626
+ breaking changes.)
627
+
628
+ Note: this functionality is not currently available in the official
629
+ protobuf release, and it is not used for type URLs beginning with
630
+ type.googleapis.com. As of May 2023, there are no widely used type server
631
+ implementations and no plans to implement one.
632
+
633
+ Schemes other than `http`, `https` (or the empty scheme) might be
634
+ used with implementation specific semantics.
635
+ """
636
+
637
+ value: "bytes" = betterproto2.field(2, betterproto2.TYPE_BYTES)
638
+ """
639
+ Must be a valid serialized protocol buffer of the above specified type.
640
+ """
641
+
642
+ @classmethod
643
+ def pack(cls, message: betterproto2.Message, message_pool: "betterproto2.MessagePool | None" = None) -> "Any":
644
+ """
645
+ Pack the given message in the `Any` object.
646
+
647
+ The message type must be registered in the message pool, which is done automatically when the module defining
648
+ the message type is imported.
649
+ """
650
+ message_pool = message_pool or default_message_pool
651
+
652
+ type_url = message_pool.type_to_url[type(message)]
653
+ value = bytes(message)
654
+
655
+ return cls(type_url=type_url, value=value)
656
+
657
+ def unpack(self, message_pool: "betterproto2.MessagePool | None" = None) -> betterproto2.Message | None:
658
+ """
659
+ Return the message packed inside the `Any` object.
660
+
661
+ The target message type must be registered in the message pool, which is done automatically when the module
662
+ defining the message type is imported.
663
+ """
664
+ if not self.type_url:
665
+ return None
666
+
667
+ message_pool = message_pool or default_message_pool
668
+
669
+ try:
670
+ message_type = message_pool.url_to_type[self.type_url]
671
+ except KeyError:
672
+ raise TypeError(f"Can't unpack unregistered type: {self.type_url}")
673
+
674
+ return message_type.parse(self.value)
675
+
676
+ def to_dict(self, **kwargs) -> dict[str, typing.Any]:
677
+ # TODO allow passing a message pool to `to_dict`
678
+ output: dict[str, typing.Any] = {"@type": self.type_url}
679
+
680
+ value = self.unpack()
681
+
682
+ if value is None:
683
+ return output
684
+
685
+ if type(value).to_dict == betterproto2.Message.to_dict:
686
+ output.update(value.to_dict(**kwargs))
687
+ else:
688
+ output["value"] = value.to_dict(**kwargs)
689
+
690
+ return output
691
+
692
+ @classmethod
693
+ def from_dict(cls, value, *, ignore_unknown_fields: bool = False):
694
+ value = dict(value) # Make a copy
695
+
696
+ type_url = value.pop("@type", None)
697
+ msg_cls = default_message_pool.url_to_type.get(type_url, None)
698
+
699
+ if not msg_cls:
700
+ raise TypeError(f"Can't unpack unregistered type: {type_url}")
701
+
702
+ if not msg_cls.to_dict == betterproto2.Message.to_dict:
703
+ value = value["value"]
704
+
705
+ return cls(
706
+ type_url=type_url, value=bytes(msg_cls.from_dict(value, ignore_unknown_fields=ignore_unknown_fields))
707
+ )
708
+
709
+
710
+ default_message_pool.register_message("google.protobuf", "Any", Any)
711
+
712
+
713
+ @dataclass(eq=False, repr=False)
714
+ class DescriptorProto(betterproto2.Message):
715
+ """
716
+ Describes a message type.
717
+ """
718
+
719
+ name: "str" = betterproto2.field(1, betterproto2.TYPE_STRING)
720
+
721
+ field: "list[FieldDescriptorProto]" = betterproto2.field(2, betterproto2.TYPE_MESSAGE, repeated=True)
722
+
723
+ extension: "list[FieldDescriptorProto]" = betterproto2.field(6, betterproto2.TYPE_MESSAGE, repeated=True)
724
+
725
+ nested_type: "list[DescriptorProto]" = betterproto2.field(3, betterproto2.TYPE_MESSAGE, repeated=True)
726
+
727
+ enum_type: "list[EnumDescriptorProto]" = betterproto2.field(4, betterproto2.TYPE_MESSAGE, repeated=True)
728
+
729
+ extension_range: "list[DescriptorProtoExtensionRange]" = betterproto2.field(
730
+ 5, betterproto2.TYPE_MESSAGE, repeated=True
731
+ )
732
+
733
+ oneof_decl: "list[OneofDescriptorProto]" = betterproto2.field(8, betterproto2.TYPE_MESSAGE, repeated=True)
734
+
735
+ options: "MessageOptions | None" = betterproto2.field(7, betterproto2.TYPE_MESSAGE, optional=True)
736
+
737
+ reserved_range: "list[DescriptorProtoReservedRange]" = betterproto2.field(
738
+ 9, betterproto2.TYPE_MESSAGE, repeated=True
739
+ )
740
+
741
+ reserved_name: "list[str]" = betterproto2.field(10, betterproto2.TYPE_STRING, repeated=True)
742
+ """
743
+ Reserved field names, which may not be used by fields in the same message.
744
+ A given name may only be reserved once.
745
+ """
746
+
747
+
748
+ default_message_pool.register_message("google.protobuf", "DescriptorProto", DescriptorProto)
749
+
750
+
751
+ @dataclass(eq=False, repr=False)
752
+ class DescriptorProtoExtensionRange(betterproto2.Message):
753
+ start: "int" = betterproto2.field(1, betterproto2.TYPE_INT32)
754
+ """
755
+ Inclusive.
756
+ """
757
+
758
+ end: "int" = betterproto2.field(2, betterproto2.TYPE_INT32)
759
+ """
760
+ Exclusive.
761
+ """
762
+
763
+ options: "ExtensionRangeOptions | None" = betterproto2.field(3, betterproto2.TYPE_MESSAGE, optional=True)
764
+
765
+
766
+ default_message_pool.register_message(
767
+ "google.protobuf", "DescriptorProto.ExtensionRange", DescriptorProtoExtensionRange
768
+ )
769
+
770
+
771
+ @dataclass(eq=False, repr=False)
772
+ class DescriptorProtoReservedRange(betterproto2.Message):
773
+ """
774
+ Range of reserved tag numbers. Reserved tag numbers may not be used by
775
+ fields or extension ranges in the same message. Reserved ranges may
776
+ not overlap.
777
+ """
778
+
779
+ start: "int" = betterproto2.field(1, betterproto2.TYPE_INT32)
780
+ """
781
+ Inclusive.
782
+ """
783
+
784
+ end: "int" = betterproto2.field(2, betterproto2.TYPE_INT32)
785
+ """
786
+ Exclusive.
787
+ """
788
+
789
+
790
+ default_message_pool.register_message("google.protobuf", "DescriptorProto.ReservedRange", DescriptorProtoReservedRange)
791
+
792
+
793
+ @dataclass(eq=False, repr=False)
794
+ class Empty(betterproto2.Message):
795
+ """
796
+ A generic empty message that you can re-use to avoid defining duplicated
797
+ empty messages in your APIs. A typical example is to use it as the request
798
+ or the response type of an API method. For instance:
799
+
800
+ service Foo {
801
+ rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
802
+ }
803
+ """
804
+
805
+ pass
806
+
807
+
808
+ default_message_pool.register_message("google.protobuf", "Empty", Empty)
809
+
810
+
811
+ @dataclass(eq=False, repr=False)
812
+ class EnumDescriptorProto(betterproto2.Message):
813
+ """
814
+ Describes an enum type.
815
+ """
816
+
817
+ name: "str" = betterproto2.field(1, betterproto2.TYPE_STRING)
818
+
819
+ value: "list[EnumValueDescriptorProto]" = betterproto2.field(2, betterproto2.TYPE_MESSAGE, repeated=True)
820
+
821
+ options: "EnumOptions | None" = betterproto2.field(3, betterproto2.TYPE_MESSAGE, optional=True)
822
+
823
+ reserved_range: "list[EnumDescriptorProtoEnumReservedRange]" = betterproto2.field(
824
+ 4, betterproto2.TYPE_MESSAGE, repeated=True
825
+ )
826
+ """
827
+ Range of reserved numeric values. Reserved numeric values may not be used
828
+ by enum values in the same enum declaration. Reserved ranges may not
829
+ overlap.
830
+ """
831
+
832
+ reserved_name: "list[str]" = betterproto2.field(5, betterproto2.TYPE_STRING, repeated=True)
833
+ """
834
+ Reserved enum value names, which may not be reused. A given name may only
835
+ be reserved once.
836
+ """
837
+
838
+
839
+ default_message_pool.register_message("google.protobuf", "EnumDescriptorProto", EnumDescriptorProto)
840
+
841
+
842
+ @dataclass(eq=False, repr=False)
843
+ class EnumDescriptorProtoEnumReservedRange(betterproto2.Message):
844
+ """
845
+ Range of reserved numeric values. Reserved values may not be used by
846
+ entries in the same enum. Reserved ranges may not overlap.
847
+
848
+ Note that this is distinct from DescriptorProto.ReservedRange in that it
849
+ is inclusive such that it can appropriately represent the entire int32
850
+ domain.
851
+ """
852
+
853
+ start: "int" = betterproto2.field(1, betterproto2.TYPE_INT32)
854
+ """
855
+ Inclusive.
856
+ """
857
+
858
+ end: "int" = betterproto2.field(2, betterproto2.TYPE_INT32)
859
+ """
860
+ Inclusive.
861
+ """
862
+
863
+
864
+ default_message_pool.register_message(
865
+ "google.protobuf", "EnumDescriptorProto.EnumReservedRange", EnumDescriptorProtoEnumReservedRange
866
+ )
867
+
868
+
869
+ @dataclass(eq=False, repr=False)
870
+ class EnumOptions(betterproto2.Message):
871
+ allow_alias: "bool" = betterproto2.field(2, betterproto2.TYPE_BOOL)
872
+ """
873
+ Set this option to true to allow mapping different tag names to the same
874
+ value.
875
+ """
876
+
877
+ deprecated: "bool" = betterproto2.field(3, betterproto2.TYPE_BOOL)
878
+ """
879
+ Is this enum deprecated?
880
+ Depending on the target platform, this can emit Deprecated annotations
881
+ for the enum, or it will be completely ignored; in the very least, this
882
+ is a formalization for deprecating enums.
883
+ """
884
+
885
+ deprecated_legacy_json_field_conflicts: "bool" = betterproto2.field(6, betterproto2.TYPE_BOOL)
886
+ """
887
+ Enable the legacy handling of JSON field name conflicts. This lowercases
888
+ and strips underscored from the fields before comparison in proto3 only.
889
+ The new behavior takes `json_name` into account and applies to proto2 as
890
+ well.
891
+ TODO Remove this legacy behavior once downstream teams have
892
+ had time to migrate.
893
+ """
894
+
895
+ features: "FeatureSet | None" = betterproto2.field(7, betterproto2.TYPE_MESSAGE, optional=True)
896
+ """
897
+ Any features defined in the specific edition.
898
+ """
899
+
900
+ uninterpreted_option: "list[UninterpretedOption]" = betterproto2.field(
901
+ 999, betterproto2.TYPE_MESSAGE, repeated=True
902
+ )
903
+ """
904
+ The parser stores options it doesn't recognize here. See above.
905
+ """
906
+
907
+ def __post_init__(self) -> None:
908
+ super().__post_init__()
909
+ if self.is_set("deprecated_legacy_json_field_conflicts"):
910
+ warnings.warn("EnumOptions.deprecated_legacy_json_field_conflicts is deprecated", DeprecationWarning)
911
+
912
+
913
+ default_message_pool.register_message("google.protobuf", "EnumOptions", EnumOptions)
914
+
915
+
916
+ @dataclass(eq=False, repr=False)
917
+ class EnumValueDescriptorProto(betterproto2.Message):
918
+ """
919
+ Describes a value within an enum.
920
+ """
921
+
922
+ name: "str" = betterproto2.field(1, betterproto2.TYPE_STRING)
923
+
924
+ number: "int" = betterproto2.field(2, betterproto2.TYPE_INT32)
925
+
926
+ options: "EnumValueOptions | None" = betterproto2.field(3, betterproto2.TYPE_MESSAGE, optional=True)
927
+
928
+
929
+ default_message_pool.register_message("google.protobuf", "EnumValueDescriptorProto", EnumValueDescriptorProto)
930
+
931
+
932
+ @dataclass(eq=False, repr=False)
933
+ class EnumValueOptions(betterproto2.Message):
934
+ deprecated: "bool" = betterproto2.field(1, betterproto2.TYPE_BOOL)
935
+ """
936
+ Is this enum value deprecated?
937
+ Depending on the target platform, this can emit Deprecated annotations
938
+ for the enum value, or it will be completely ignored; in the very least,
939
+ this is a formalization for deprecating enum values.
940
+ """
941
+
942
+ features: "FeatureSet | None" = betterproto2.field(2, betterproto2.TYPE_MESSAGE, optional=True)
943
+ """
944
+ Any features defined in the specific edition.
945
+ """
946
+
947
+ debug_redact: "bool" = betterproto2.field(3, betterproto2.TYPE_BOOL)
948
+ """
949
+ Indicate that fields annotated with this enum value should not be printed
950
+ out when using debug formats, e.g. when the field contains sensitive
951
+ credentials.
952
+ """
953
+
954
+ feature_support: "FieldOptionsFeatureSupport | None" = betterproto2.field(
955
+ 4, betterproto2.TYPE_MESSAGE, optional=True
956
+ )
957
+ """
958
+ Information about the support window of a feature value.
959
+ """
960
+
961
+ uninterpreted_option: "list[UninterpretedOption]" = betterproto2.field(
962
+ 999, betterproto2.TYPE_MESSAGE, repeated=True
963
+ )
964
+ """
965
+ The parser stores options it doesn't recognize here. See above.
966
+ """
967
+
968
+
969
+ default_message_pool.register_message("google.protobuf", "EnumValueOptions", EnumValueOptions)
970
+
971
+
972
+ @dataclass(eq=False, repr=False)
973
+ class ExtensionRangeOptions(betterproto2.Message):
974
+ uninterpreted_option: "list[UninterpretedOption]" = betterproto2.field(
975
+ 999, betterproto2.TYPE_MESSAGE, repeated=True
976
+ )
977
+ """
978
+ The parser stores options it doesn't recognize here. See above.
979
+ """
980
+
981
+ declaration: "list[ExtensionRangeOptionsDeclaration]" = betterproto2.field(
982
+ 2, betterproto2.TYPE_MESSAGE, repeated=True
983
+ )
984
+ """
985
+ For external users: DO NOT USE. We are in the process of open sourcing
986
+ extension declaration and executing internal cleanups before it can be
987
+ used externally.
988
+ """
989
+
990
+ features: "FeatureSet | None" = betterproto2.field(50, betterproto2.TYPE_MESSAGE, optional=True)
991
+ """
992
+ Any features defined in the specific edition.
993
+ """
994
+
995
+ verification: "ExtensionRangeOptionsVerificationState" = betterproto2.field(
996
+ 3, betterproto2.TYPE_ENUM, default_factory=lambda: ExtensionRangeOptionsVerificationState(0)
997
+ )
998
+ """
999
+ The verification state of the range.
1000
+ TODO: flip the default to DECLARATION once all empty ranges
1001
+ are marked as UNVERIFIED.
1002
+ """
1003
+
1004
+
1005
+ default_message_pool.register_message("google.protobuf", "ExtensionRangeOptions", ExtensionRangeOptions)
1006
+
1007
+
1008
+ @dataclass(eq=False, repr=False)
1009
+ class ExtensionRangeOptionsDeclaration(betterproto2.Message):
1010
+ number: "int" = betterproto2.field(1, betterproto2.TYPE_INT32)
1011
+ """
1012
+ The extension number declared within the extension range.
1013
+ """
1014
+
1015
+ full_name: "str" = betterproto2.field(2, betterproto2.TYPE_STRING)
1016
+ """
1017
+ The fully-qualified name of the extension field. There must be a leading
1018
+ dot in front of the full name.
1019
+ """
1020
+
1021
+ type: "str" = betterproto2.field(3, betterproto2.TYPE_STRING)
1022
+ """
1023
+ The fully-qualified type name of the extension field. Unlike
1024
+ Metadata.type, Declaration.type must have a leading dot for messages
1025
+ and enums.
1026
+ """
1027
+
1028
+ reserved: "bool" = betterproto2.field(5, betterproto2.TYPE_BOOL)
1029
+ """
1030
+ If true, indicates that the number is reserved in the extension range,
1031
+ and any extension field with the number will fail to compile. Set this
1032
+ when a declared extension field is deleted.
1033
+ """
1034
+
1035
+ repeated: "bool" = betterproto2.field(6, betterproto2.TYPE_BOOL)
1036
+ """
1037
+ If true, indicates that the extension must be defined as repeated.
1038
+ Otherwise the extension must be defined as optional.
1039
+ """
1040
+
1041
+
1042
+ default_message_pool.register_message(
1043
+ "google.protobuf", "ExtensionRangeOptions.Declaration", ExtensionRangeOptionsDeclaration
1044
+ )
1045
+
1046
+
1047
+ @dataclass(eq=False, repr=False)
1048
+ class FeatureSet(betterproto2.Message):
1049
+ """
1050
+ ===================================================================
1051
+ Features
1052
+
1053
+ TODO Enums in C++ gencode (and potentially other languages) are
1054
+ not well scoped. This means that each of the feature enums below can clash
1055
+ with each other. The short names we've chosen maximize call-site
1056
+ readability, but leave us very open to this scenario. A future feature will
1057
+ be designed and implemented to handle this, hopefully before we ever hit a
1058
+ conflict here.
1059
+ """
1060
+
1061
+ field_presence: "FeatureSetFieldPresence" = betterproto2.field(
1062
+ 1, betterproto2.TYPE_ENUM, default_factory=lambda: FeatureSetFieldPresence(0)
1063
+ )
1064
+
1065
+ enum_type: "FeatureSetEnumType" = betterproto2.field(
1066
+ 2, betterproto2.TYPE_ENUM, default_factory=lambda: FeatureSetEnumType(0)
1067
+ )
1068
+
1069
+ repeated_field_encoding: "FeatureSetRepeatedFieldEncoding" = betterproto2.field(
1070
+ 3, betterproto2.TYPE_ENUM, default_factory=lambda: FeatureSetRepeatedFieldEncoding(0)
1071
+ )
1072
+
1073
+ utf8_validation: "FeatureSetUtf8Validation" = betterproto2.field(
1074
+ 4, betterproto2.TYPE_ENUM, default_factory=lambda: FeatureSetUtf8Validation(0)
1075
+ )
1076
+
1077
+ message_encoding: "FeatureSetMessageEncoding" = betterproto2.field(
1078
+ 5, betterproto2.TYPE_ENUM, default_factory=lambda: FeatureSetMessageEncoding(0)
1079
+ )
1080
+
1081
+ json_format: "FeatureSetJsonFormat" = betterproto2.field(
1082
+ 6, betterproto2.TYPE_ENUM, default_factory=lambda: FeatureSetJsonFormat(0)
1083
+ )
1084
+
1085
+
1086
+ default_message_pool.register_message("google.protobuf", "FeatureSet", FeatureSet)
1087
+
1088
+
1089
+ @dataclass(eq=False, repr=False)
1090
+ class FeatureSetDefaults(betterproto2.Message):
1091
+ """
1092
+ A compiled specification for the defaults of a set of features. These
1093
+ messages are generated from FeatureSet extensions and can be used to seed
1094
+ feature resolution. The resolution with this object becomes a simple search
1095
+ for the closest matching edition, followed by proto merges.
1096
+ """
1097
+
1098
+ defaults: "list[FeatureSetDefaultsFeatureSetEditionDefault]" = betterproto2.field(
1099
+ 1, betterproto2.TYPE_MESSAGE, repeated=True
1100
+ )
1101
+
1102
+ minimum_edition: "Edition" = betterproto2.field(4, betterproto2.TYPE_ENUM, default_factory=lambda: Edition(0))
1103
+ """
1104
+ The minimum supported edition (inclusive) when this was constructed.
1105
+ Editions before this will not have defaults.
1106
+ """
1107
+
1108
+ maximum_edition: "Edition" = betterproto2.field(5, betterproto2.TYPE_ENUM, default_factory=lambda: Edition(0))
1109
+ """
1110
+ The maximum known edition (inclusive) when this was constructed. Editions
1111
+ after this will not have reliable defaults.
1112
+ """
1113
+
1114
+
1115
+ default_message_pool.register_message("google.protobuf", "FeatureSetDefaults", FeatureSetDefaults)
1116
+
1117
+
1118
+ @dataclass(eq=False, repr=False)
1119
+ class FeatureSetDefaultsFeatureSetEditionDefault(betterproto2.Message):
1120
+ """
1121
+ A map from every known edition with a unique set of defaults to its
1122
+ defaults. Not all editions may be contained here. For a given edition,
1123
+ the defaults at the closest matching edition ordered at or before it should
1124
+ be used. This field must be in strict ascending order by edition.
1125
+ """
1126
+
1127
+ edition: "Edition" = betterproto2.field(3, betterproto2.TYPE_ENUM, default_factory=lambda: Edition(0))
1128
+
1129
+ overridable_features: "FeatureSet | None" = betterproto2.field(4, betterproto2.TYPE_MESSAGE, optional=True)
1130
+ """
1131
+ Defaults of features that can be overridden in this edition.
1132
+ """
1133
+
1134
+ fixed_features: "FeatureSet | None" = betterproto2.field(5, betterproto2.TYPE_MESSAGE, optional=True)
1135
+ """
1136
+ Defaults of features that can't be overridden in this edition.
1137
+ """
1138
+
1139
+
1140
+ default_message_pool.register_message(
1141
+ "google.protobuf", "FeatureSetDefaults.FeatureSetEditionDefault", FeatureSetDefaultsFeatureSetEditionDefault
1142
+ )
1143
+
1144
+
1145
+ @dataclass(eq=False, repr=False)
1146
+ class FieldDescriptorProto(betterproto2.Message):
1147
+ """
1148
+ Describes a field within a message.
1149
+ """
1150
+
1151
+ name: "str" = betterproto2.field(1, betterproto2.TYPE_STRING)
1152
+
1153
+ number: "int" = betterproto2.field(3, betterproto2.TYPE_INT32)
1154
+
1155
+ label: "FieldDescriptorProtoLabel" = betterproto2.field(
1156
+ 4, betterproto2.TYPE_ENUM, default_factory=lambda: FieldDescriptorProtoLabel(0)
1157
+ )
1158
+
1159
+ type: "FieldDescriptorProtoType" = betterproto2.field(
1160
+ 5, betterproto2.TYPE_ENUM, default_factory=lambda: FieldDescriptorProtoType(0)
1161
+ )
1162
+ """
1163
+ If type_name is set, this need not be set. If both this and type_name
1164
+ are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
1165
+ """
1166
+
1167
+ type_name: "str" = betterproto2.field(6, betterproto2.TYPE_STRING)
1168
+ """
1169
+ For message and enum types, this is the name of the type. If the name
1170
+ starts with a '.', it is fully-qualified. Otherwise, C++-like scoping
1171
+ rules are used to find the type (i.e. first the nested types within this
1172
+ message are searched, then within the parent, on up to the root
1173
+ namespace).
1174
+ """
1175
+
1176
+ extendee: "str" = betterproto2.field(2, betterproto2.TYPE_STRING)
1177
+ """
1178
+ For extensions, this is the name of the type being extended. It is
1179
+ resolved in the same manner as type_name.
1180
+ """
1181
+
1182
+ default_value: "str" = betterproto2.field(7, betterproto2.TYPE_STRING)
1183
+ """
1184
+ For numeric types, contains the original text representation of the value.
1185
+ For booleans, "true" or "false".
1186
+ For strings, contains the default text contents (not escaped in any way).
1187
+ For bytes, contains the C escaped value. All bytes >= 128 are escaped.
1188
+ """
1189
+
1190
+ oneof_index: "int" = betterproto2.field(9, betterproto2.TYPE_INT32)
1191
+ """
1192
+ If set, gives the index of a oneof in the containing type's oneof_decl
1193
+ list. This field is a member of that oneof.
1194
+ """
1195
+
1196
+ json_name: "str" = betterproto2.field(10, betterproto2.TYPE_STRING)
1197
+ """
1198
+ JSON name of this field. The value is set by protocol compiler. If the
1199
+ user has set a "json_name" option on this field, that option's value
1200
+ will be used. Otherwise, it's deduced from the field's name by converting
1201
+ it to camelCase.
1202
+ """
1203
+
1204
+ options: "FieldOptions | None" = betterproto2.field(8, betterproto2.TYPE_MESSAGE, optional=True)
1205
+
1206
+ proto3_optional: "bool" = betterproto2.field(17, betterproto2.TYPE_BOOL)
1207
+ """
1208
+ If true, this is a proto3 "optional". When a proto3 field is optional, it
1209
+ tracks presence regardless of field type.
1210
+
1211
+ When proto3_optional is true, this field must belong to a oneof to signal
1212
+ to old proto3 clients that presence is tracked for this field. This oneof
1213
+ is known as a "synthetic" oneof, and this field must be its sole member
1214
+ (each proto3 optional field gets its own synthetic oneof). Synthetic oneofs
1215
+ exist in the descriptor only, and do not generate any API. Synthetic oneofs
1216
+ must be ordered after all "real" oneofs.
1217
+
1218
+ For message fields, proto3_optional doesn't create any semantic change,
1219
+ since non-repeated message fields always track presence. However it still
1220
+ indicates the semantic detail of whether the user wrote "optional" or not.
1221
+ This can be useful for round-tripping the .proto file. For consistency we
1222
+ give message fields a synthetic oneof also, even though it is not required
1223
+ to track presence. This is especially important because the parser can't
1224
+ tell if a field is a message or an enum, so it must always create a
1225
+ synthetic oneof.
1226
+
1227
+ Proto2 optional fields do not set this flag, because they already indicate
1228
+ optional with `LABEL_OPTIONAL`.
1229
+ """
1230
+
1231
+
1232
+ default_message_pool.register_message("google.protobuf", "FieldDescriptorProto", FieldDescriptorProto)
1233
+
1234
+
1235
+ @dataclass(eq=False, repr=False)
1236
+ class FieldOptions(betterproto2.Message):
1237
+ ctype: "FieldOptionsCType" = betterproto2.field(
1238
+ 1, betterproto2.TYPE_ENUM, default_factory=lambda: FieldOptionsCType(0)
1239
+ )
1240
+ """
1241
+ NOTE: ctype is deprecated. Use `features.(pb.cpp).string_type` instead.
1242
+ The ctype option instructs the C++ code generator to use a different
1243
+ representation of the field than it normally would. See the specific
1244
+ options below. This option is only implemented to support use of
1245
+ [ctype=CORD] and [ctype=STRING] (the default) on non-repeated fields of
1246
+ type "bytes" in the open source release.
1247
+ TODO: make ctype actually deprecated.
1248
+ """
1249
+
1250
+ packed: "bool" = betterproto2.field(2, betterproto2.TYPE_BOOL)
1251
+ """
1252
+ The packed option can be enabled for repeated primitive fields to enable
1253
+ a more efficient representation on the wire. Rather than repeatedly
1254
+ writing the tag and type for each element, the entire array is encoded as
1255
+ a single length-delimited blob. In proto3, only explicit setting it to
1256
+ false will avoid using packed encoding. This option is prohibited in
1257
+ Editions, but the `repeated_field_encoding` feature can be used to control
1258
+ the behavior.
1259
+ """
1260
+
1261
+ jstype: "FieldOptionsJsType" = betterproto2.field(
1262
+ 6, betterproto2.TYPE_ENUM, default_factory=lambda: FieldOptionsJsType(0)
1263
+ )
1264
+ """
1265
+ The jstype option determines the JavaScript type used for values of the
1266
+ field. The option is permitted only for 64 bit integral and fixed types
1267
+ (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING
1268
+ is represented as JavaScript string, which avoids loss of precision that
1269
+ can happen when a large value is converted to a floating point JavaScript.
1270
+ Specifying JS_NUMBER for the jstype causes the generated JavaScript code to
1271
+ use the JavaScript "number" type. The behavior of the default option
1272
+ JS_NORMAL is implementation dependent.
1273
+
1274
+ This option is an enum to permit additional types to be added, e.g.
1275
+ goog.math.Integer.
1276
+ """
1277
+
1278
+ lazy: "bool" = betterproto2.field(5, betterproto2.TYPE_BOOL)
1279
+ """
1280
+ Should this field be parsed lazily? Lazy applies only to message-type
1281
+ fields. It means that when the outer message is initially parsed, the
1282
+ inner message's contents will not be parsed but instead stored in encoded
1283
+ form. The inner message will actually be parsed when it is first accessed.
1284
+
1285
+ This is only a hint. Implementations are free to choose whether to use
1286
+ eager or lazy parsing regardless of the value of this option. However,
1287
+ setting this option true suggests that the protocol author believes that
1288
+ using lazy parsing on this field is worth the additional bookkeeping
1289
+ overhead typically needed to implement it.
1290
+
1291
+ This option does not affect the public interface of any generated code;
1292
+ all method signatures remain the same. Furthermore, thread-safety of the
1293
+ interface is not affected by this option; const methods remain safe to
1294
+ call from multiple threads concurrently, while non-const methods continue
1295
+ to require exclusive access.
1296
+
1297
+ Note that lazy message fields are still eagerly verified to check
1298
+ ill-formed wireformat or missing required fields. Calling IsInitialized()
1299
+ on the outer message would fail if the inner message has missing required
1300
+ fields. Failed verification would result in parsing failure (except when
1301
+ uninitialized messages are acceptable).
1302
+ """
1303
+
1304
+ unverified_lazy: "bool" = betterproto2.field(15, betterproto2.TYPE_BOOL)
1305
+ """
1306
+ unverified_lazy does no correctness checks on the byte stream. This should
1307
+ only be used where lazy with verification is prohibitive for performance
1308
+ reasons.
1309
+ """
1310
+
1311
+ deprecated: "bool" = betterproto2.field(3, betterproto2.TYPE_BOOL)
1312
+ """
1313
+ Is this field deprecated?
1314
+ Depending on the target platform, this can emit Deprecated annotations
1315
+ for accessors, or it will be completely ignored; in the very least, this
1316
+ is a formalization for deprecating fields.
1317
+ """
1318
+
1319
+ weak: "bool" = betterproto2.field(10, betterproto2.TYPE_BOOL)
1320
+ """
1321
+ For Google-internal migration only. Do not use.
1322
+ """
1323
+
1324
+ debug_redact: "bool" = betterproto2.field(16, betterproto2.TYPE_BOOL)
1325
+ """
1326
+ Indicate that the field value should not be printed out when using debug
1327
+ formats, e.g. when the field contains sensitive credentials.
1328
+ """
1329
+
1330
+ retention: "FieldOptionsOptionRetention" = betterproto2.field(
1331
+ 17, betterproto2.TYPE_ENUM, default_factory=lambda: FieldOptionsOptionRetention(0)
1332
+ )
1333
+
1334
+ targets: "list[FieldOptionsOptionTargetType]" = betterproto2.field(19, betterproto2.TYPE_ENUM, repeated=True)
1335
+
1336
+ edition_defaults: "list[FieldOptionsEditionDefault]" = betterproto2.field(
1337
+ 20, betterproto2.TYPE_MESSAGE, repeated=True
1338
+ )
1339
+
1340
+ features: "FeatureSet | None" = betterproto2.field(21, betterproto2.TYPE_MESSAGE, optional=True)
1341
+ """
1342
+ Any features defined in the specific edition.
1343
+ """
1344
+
1345
+ feature_support: "FieldOptionsFeatureSupport | None" = betterproto2.field(
1346
+ 22, betterproto2.TYPE_MESSAGE, optional=True
1347
+ )
1348
+
1349
+ uninterpreted_option: "list[UninterpretedOption]" = betterproto2.field(
1350
+ 999, betterproto2.TYPE_MESSAGE, repeated=True
1351
+ )
1352
+ """
1353
+ The parser stores options it doesn't recognize here. See above.
1354
+ """
1355
+
1356
+
1357
+ default_message_pool.register_message("google.protobuf", "FieldOptions", FieldOptions)
1358
+
1359
+
1360
+ @dataclass(eq=False, repr=False)
1361
+ class FieldOptionsEditionDefault(betterproto2.Message):
1362
+ edition: "Edition" = betterproto2.field(3, betterproto2.TYPE_ENUM, default_factory=lambda: Edition(0))
1363
+
1364
+ value: "str" = betterproto2.field(2, betterproto2.TYPE_STRING)
1365
+ """
1366
+ Textproto value.
1367
+ """
1368
+
1369
+
1370
+ default_message_pool.register_message("google.protobuf", "FieldOptions.EditionDefault", FieldOptionsEditionDefault)
1371
+
1372
+
1373
+ @dataclass(eq=False, repr=False)
1374
+ class FieldOptionsFeatureSupport(betterproto2.Message):
1375
+ """
1376
+ Information about the support window of a feature.
1377
+ """
1378
+
1379
+ edition_introduced: "Edition" = betterproto2.field(1, betterproto2.TYPE_ENUM, default_factory=lambda: Edition(0))
1380
+ """
1381
+ The edition that this feature was first available in. In editions
1382
+ earlier than this one, the default assigned to EDITION_LEGACY will be
1383
+ used, and proto files will not be able to override it.
1384
+ """
1385
+
1386
+ edition_deprecated: "Edition" = betterproto2.field(2, betterproto2.TYPE_ENUM, default_factory=lambda: Edition(0))
1387
+ """
1388
+ The edition this feature becomes deprecated in. Using this after this
1389
+ edition may trigger warnings.
1390
+ """
1391
+
1392
+ deprecation_warning: "str" = betterproto2.field(3, betterproto2.TYPE_STRING)
1393
+ """
1394
+ The deprecation warning text if this feature is used after the edition it
1395
+ was marked deprecated in.
1396
+ """
1397
+
1398
+ edition_removed: "Edition" = betterproto2.field(4, betterproto2.TYPE_ENUM, default_factory=lambda: Edition(0))
1399
+ """
1400
+ The edition this feature is no longer available in. In editions after
1401
+ this one, the last default assigned will be used, and proto files will
1402
+ not be able to override it.
1403
+ """
1404
+
1405
+
1406
+ default_message_pool.register_message("google.protobuf", "FieldOptions.FeatureSupport", FieldOptionsFeatureSupport)
1407
+
1408
+
1409
+ @dataclass(eq=False, repr=False)
1410
+ class FileDescriptorProto(betterproto2.Message):
1411
+ """
1412
+ Describes a complete .proto file.
1413
+ """
1414
+
1415
+ name: "str" = betterproto2.field(1, betterproto2.TYPE_STRING)
1416
+ """
1417
+ file name, relative to root of source tree
1418
+ """
1419
+
1420
+ package: "str" = betterproto2.field(2, betterproto2.TYPE_STRING)
1421
+ """
1422
+ e.g. "foo", "foo.bar", etc.
1423
+ """
1424
+
1425
+ dependency: "list[str]" = betterproto2.field(3, betterproto2.TYPE_STRING, repeated=True)
1426
+ """
1427
+ Names of files imported by this file.
1428
+ """
1429
+
1430
+ public_dependency: "list[int]" = betterproto2.field(10, betterproto2.TYPE_INT32, repeated=True)
1431
+ """
1432
+ Indexes of the public imported files in the dependency list above.
1433
+ """
1434
+
1435
+ weak_dependency: "list[int]" = betterproto2.field(11, betterproto2.TYPE_INT32, repeated=True)
1436
+ """
1437
+ Indexes of the weak imported files in the dependency list.
1438
+ For Google-internal migration only. Do not use.
1439
+ """
1440
+
1441
+ message_type: "list[DescriptorProto]" = betterproto2.field(4, betterproto2.TYPE_MESSAGE, repeated=True)
1442
+ """
1443
+ All top-level definitions in this file.
1444
+ """
1445
+
1446
+ enum_type: "list[EnumDescriptorProto]" = betterproto2.field(5, betterproto2.TYPE_MESSAGE, repeated=True)
1447
+
1448
+ service: "list[ServiceDescriptorProto]" = betterproto2.field(6, betterproto2.TYPE_MESSAGE, repeated=True)
1449
+
1450
+ extension: "list[FieldDescriptorProto]" = betterproto2.field(7, betterproto2.TYPE_MESSAGE, repeated=True)
1451
+
1452
+ options: "FileOptions | None" = betterproto2.field(8, betterproto2.TYPE_MESSAGE, optional=True)
1453
+
1454
+ source_code_info: "SourceCodeInfo | None" = betterproto2.field(9, betterproto2.TYPE_MESSAGE, optional=True)
1455
+ """
1456
+ This field contains optional information about the original source code.
1457
+ You may safely remove this entire field without harming runtime
1458
+ functionality of the descriptors -- the information is needed only by
1459
+ development tools.
1460
+ """
1461
+
1462
+ syntax: "str" = betterproto2.field(12, betterproto2.TYPE_STRING)
1463
+ """
1464
+ The syntax of the proto file.
1465
+ The supported values are "proto2", "proto3", and "editions".
1466
+
1467
+ If `edition` is present, this value must be "editions".
1468
+ """
1469
+
1470
+ edition: "Edition" = betterproto2.field(14, betterproto2.TYPE_ENUM, default_factory=lambda: Edition(0))
1471
+ """
1472
+ The edition of the proto file.
1473
+ """
1474
+
1475
+
1476
+ default_message_pool.register_message("google.protobuf", "FileDescriptorProto", FileDescriptorProto)
1477
+
1478
+
1479
+ @dataclass(eq=False, repr=False)
1480
+ class FileDescriptorSet(betterproto2.Message):
1481
+ """
1482
+ The protocol compiler can output a FileDescriptorSet containing the .proto
1483
+ files it parses.
1484
+ """
1485
+
1486
+ file: "list[FileDescriptorProto]" = betterproto2.field(1, betterproto2.TYPE_MESSAGE, repeated=True)
1487
+
1488
+
1489
+ default_message_pool.register_message("google.protobuf", "FileDescriptorSet", FileDescriptorSet)
1490
+
1491
+
1492
+ @dataclass(eq=False, repr=False)
1493
+ class FileOptions(betterproto2.Message):
1494
+ """
1495
+ ===================================================================
1496
+ Options
1497
+
1498
+ Each of the definitions above may have "options" attached. These are
1499
+ just annotations which may cause code to be generated slightly differently
1500
+ or may contain hints for code that manipulates protocol messages.
1501
+
1502
+ Clients may define custom options as extensions of the *Options messages.
1503
+ These extensions may not yet be known at parsing time, so the parser cannot
1504
+ store the values in them. Instead it stores them in a field in the *Options
1505
+ message called uninterpreted_option. This field must have the same name
1506
+ across all *Options messages. We then use this field to populate the
1507
+ extensions when we build a descriptor, at which point all protos have been
1508
+ parsed and so all extensions are known.
1509
+
1510
+ Extension numbers for custom options may be chosen as follows:
1511
+ * For options which will only be used within a single application or
1512
+ organization, or for experimental options, use field numbers 50000
1513
+ through 99999. It is up to you to ensure that you do not use the
1514
+ same number for multiple options.
1515
+ * For options which will be published and used publicly by multiple
1516
+ independent entities, e-mail protobuf-global-extension-registry@google.com
1517
+ to reserve extension numbers. Simply provide your project name (e.g.
1518
+ Objective-C plugin) and your project website (if available) -- there's no
1519
+ need to explain how you intend to use them. Usually you only need one
1520
+ extension number. You can declare multiple options with only one extension
1521
+ number by putting them in a sub-message. See the Custom Options section of
1522
+ the docs for examples:
1523
+ https://developers.google.com/protocol-buffers/docs/proto#options
1524
+ If this turns out to be popular, a web service will be set up
1525
+ to automatically assign option numbers.
1526
+ """
1527
+
1528
+ java_package: "str" = betterproto2.field(1, betterproto2.TYPE_STRING)
1529
+ """
1530
+ Sets the Java package where classes generated from this .proto will be
1531
+ placed. By default, the proto package is used, but this is often
1532
+ inappropriate because proto packages do not normally start with backwards
1533
+ domain names.
1534
+ """
1535
+
1536
+ java_outer_classname: "str" = betterproto2.field(8, betterproto2.TYPE_STRING)
1537
+ """
1538
+ Controls the name of the wrapper Java class generated for the .proto file.
1539
+ That class will always contain the .proto file's getDescriptor() method as
1540
+ well as any top-level extensions defined in the .proto file.
1541
+ If java_multiple_files is disabled, then all the other classes from the
1542
+ .proto file will be nested inside the single wrapper outer class.
1543
+ """
1544
+
1545
+ java_multiple_files: "bool" = betterproto2.field(10, betterproto2.TYPE_BOOL)
1546
+ """
1547
+ If enabled, then the Java code generator will generate a separate .java
1548
+ file for each top-level message, enum, and service defined in the .proto
1549
+ file. Thus, these types will *not* be nested inside the wrapper class
1550
+ named by java_outer_classname. However, the wrapper class will still be
1551
+ generated to contain the file's getDescriptor() method as well as any
1552
+ top-level extensions defined in the file.
1553
+ """
1554
+
1555
+ java_generate_equals_and_hash: "bool" = betterproto2.field(20, betterproto2.TYPE_BOOL)
1556
+ """
1557
+ This option does nothing.
1558
+ """
1559
+
1560
+ java_string_check_utf8: "bool" = betterproto2.field(27, betterproto2.TYPE_BOOL)
1561
+ """
1562
+ A proto2 file can set this to true to opt in to UTF-8 checking for Java,
1563
+ which will throw an exception if invalid UTF-8 is parsed from the wire or
1564
+ assigned to a string field.
1565
+
1566
+ TODO: clarify exactly what kinds of field types this option
1567
+ applies to, and update these docs accordingly.
1568
+
1569
+ Proto3 files already perform these checks. Setting the option explicitly to
1570
+ false has no effect: it cannot be used to opt proto3 files out of UTF-8
1571
+ checks.
1572
+ """
1573
+
1574
+ optimize_for: "FileOptionsOptimizeMode" = betterproto2.field(
1575
+ 9, betterproto2.TYPE_ENUM, default_factory=lambda: FileOptionsOptimizeMode(0)
1576
+ )
1577
+
1578
+ go_package: "str" = betterproto2.field(11, betterproto2.TYPE_STRING)
1579
+ """
1580
+ Sets the Go package where structs generated from this .proto will be
1581
+ placed. If omitted, the Go package will be derived from the following:
1582
+ - The basename of the package import path, if provided.
1583
+ - Otherwise, the package statement in the .proto file, if present.
1584
+ - Otherwise, the basename of the .proto file, without extension.
1585
+ """
1586
+
1587
+ cc_generic_services: "bool" = betterproto2.field(16, betterproto2.TYPE_BOOL)
1588
+ """
1589
+ Should generic services be generated in each language? "Generic" services
1590
+ are not specific to any particular RPC system. They are generated by the
1591
+ main code generators in each language (without additional plugins).
1592
+ Generic services were the only kind of service generation supported by
1593
+ early versions of google.protobuf.
1594
+
1595
+ Generic services are now considered deprecated in favor of using plugins
1596
+ that generate code specific to your particular RPC system. Therefore,
1597
+ these default to false. Old code which depends on generic services should
1598
+ explicitly set them to true.
1599
+ """
1600
+
1601
+ java_generic_services: "bool" = betterproto2.field(17, betterproto2.TYPE_BOOL)
1602
+
1603
+ py_generic_services: "bool" = betterproto2.field(18, betterproto2.TYPE_BOOL)
1604
+
1605
+ deprecated: "bool" = betterproto2.field(23, betterproto2.TYPE_BOOL)
1606
+ """
1607
+ Is this file deprecated?
1608
+ Depending on the target platform, this can emit Deprecated annotations
1609
+ for everything in the file, or it will be completely ignored; in the very
1610
+ least, this is a formalization for deprecating files.
1611
+ """
1612
+
1613
+ cc_enable_arenas: "bool" = betterproto2.field(31, betterproto2.TYPE_BOOL)
1614
+ """
1615
+ Enables the use of arenas for the proto messages in this file. This applies
1616
+ only to generated classes for C++.
1617
+ """
1618
+
1619
+ objc_class_prefix: "str" = betterproto2.field(36, betterproto2.TYPE_STRING)
1620
+ """
1621
+ Sets the objective c class prefix which is prepended to all objective c
1622
+ generated classes from this .proto. There is no default.
1623
+ """
1624
+
1625
+ csharp_namespace: "str" = betterproto2.field(37, betterproto2.TYPE_STRING)
1626
+ """
1627
+ Namespace for generated classes; defaults to the package.
1628
+ """
1629
+
1630
+ swift_prefix: "str" = betterproto2.field(39, betterproto2.TYPE_STRING)
1631
+ """
1632
+ By default Swift generators will take the proto package and CamelCase it
1633
+ replacing '.' with underscore and use that to prefix the types/symbols
1634
+ defined. When this options is provided, they will use this value instead
1635
+ to prefix the types/symbols defined.
1636
+ """
1637
+
1638
+ php_class_prefix: "str" = betterproto2.field(40, betterproto2.TYPE_STRING)
1639
+ """
1640
+ Sets the php class prefix which is prepended to all php generated classes
1641
+ from this .proto. Default is empty.
1642
+ """
1643
+
1644
+ php_namespace: "str" = betterproto2.field(41, betterproto2.TYPE_STRING)
1645
+ """
1646
+ Use this option to change the namespace of php generated classes. Default
1647
+ is empty. When this option is empty, the package name will be used for
1648
+ determining the namespace.
1649
+ """
1650
+
1651
+ php_metadata_namespace: "str" = betterproto2.field(44, betterproto2.TYPE_STRING)
1652
+ """
1653
+ Use this option to change the namespace of php generated metadata classes.
1654
+ Default is empty. When this option is empty, the proto file name will be
1655
+ used for determining the namespace.
1656
+ """
1657
+
1658
+ ruby_package: "str" = betterproto2.field(45, betterproto2.TYPE_STRING)
1659
+ """
1660
+ Use this option to change the package of ruby generated classes. Default
1661
+ is empty. When this option is not set, the package name will be used for
1662
+ determining the ruby package.
1663
+ """
1664
+
1665
+ features: "FeatureSet | None" = betterproto2.field(50, betterproto2.TYPE_MESSAGE, optional=True)
1666
+ """
1667
+ Any features defined in the specific edition.
1668
+ """
1669
+
1670
+ uninterpreted_option: "list[UninterpretedOption]" = betterproto2.field(
1671
+ 999, betterproto2.TYPE_MESSAGE, repeated=True
1672
+ )
1673
+ """
1674
+ The parser stores options it doesn't recognize here.
1675
+ See the documentation for the "Options" section above.
1676
+ """
1677
+
1678
+ def __post_init__(self) -> None:
1679
+ super().__post_init__()
1680
+ if self.is_set("java_generate_equals_and_hash"):
1681
+ warnings.warn("FileOptions.java_generate_equals_and_hash is deprecated", DeprecationWarning)
1682
+
1683
+
1684
+ default_message_pool.register_message("google.protobuf", "FileOptions", FileOptions)
1685
+
1686
+
1687
+ @dataclass(eq=False, repr=False)
1688
+ class GeneratedCodeInfo(betterproto2.Message):
1689
+ """
1690
+ Describes the relationship between generated code and its original source
1691
+ file. A GeneratedCodeInfo message is associated with only one generated
1692
+ source file, but may contain references to different source .proto files.
1693
+ """
1694
+
1695
+ annotation: "list[GeneratedCodeInfoAnnotation]" = betterproto2.field(1, betterproto2.TYPE_MESSAGE, repeated=True)
1696
+ """
1697
+ An Annotation connects some span of text in generated code to an element
1698
+ of its generating .proto file.
1699
+ """
1700
+
1701
+
1702
+ default_message_pool.register_message("google.protobuf", "GeneratedCodeInfo", GeneratedCodeInfo)
1703
+
1704
+
1705
+ @dataclass(eq=False, repr=False)
1706
+ class GeneratedCodeInfoAnnotation(betterproto2.Message):
1707
+ path: "list[int]" = betterproto2.field(1, betterproto2.TYPE_INT32, repeated=True)
1708
+ """
1709
+ Identifies the element in the original source .proto file. This field
1710
+ is formatted the same as SourceCodeInfo.Location.path.
1711
+ """
1712
+
1713
+ source_file: "str" = betterproto2.field(2, betterproto2.TYPE_STRING)
1714
+ """
1715
+ Identifies the filesystem path to the original source .proto.
1716
+ """
1717
+
1718
+ begin: "int" = betterproto2.field(3, betterproto2.TYPE_INT32)
1719
+ """
1720
+ Identifies the starting offset in bytes in the generated code
1721
+ that relates to the identified object.
1722
+ """
1723
+
1724
+ end: "int" = betterproto2.field(4, betterproto2.TYPE_INT32)
1725
+ """
1726
+ Identifies the ending offset in bytes in the generated code that
1727
+ relates to the identified object. The end offset should be one past
1728
+ the last relevant byte (so the length of the text = end - begin).
1729
+ """
1730
+
1731
+ semantic: "GeneratedCodeInfoAnnotationSemantic" = betterproto2.field(
1732
+ 5, betterproto2.TYPE_ENUM, default_factory=lambda: GeneratedCodeInfoAnnotationSemantic(0)
1733
+ )
1734
+
1735
+
1736
+ default_message_pool.register_message("google.protobuf", "GeneratedCodeInfo.Annotation", GeneratedCodeInfoAnnotation)
1737
+
1738
+
1739
+ @dataclass(eq=False, repr=False)
1740
+ class MessageOptions(betterproto2.Message):
1741
+ message_set_wire_format: "bool" = betterproto2.field(1, betterproto2.TYPE_BOOL)
1742
+ """
1743
+ Set true to use the old proto1 MessageSet wire format for extensions.
1744
+ This is provided for backwards-compatibility with the MessageSet wire
1745
+ format. You should not use this for any other reason: It's less
1746
+ efficient, has fewer features, and is more complicated.
1747
+
1748
+ The message must be defined exactly as follows:
1749
+ message Foo {
1750
+ option message_set_wire_format = true;
1751
+ extensions 4 to max;
1752
+ }
1753
+ Note that the message cannot have any defined fields; MessageSets only
1754
+ have extensions.
1755
+
1756
+ All extensions of your type must be singular messages; e.g. they cannot
1757
+ be int32s, enums, or repeated messages.
1758
+
1759
+ Because this is an option, the above two restrictions are not enforced by
1760
+ the protocol compiler.
1761
+ """
1762
+
1763
+ no_standard_descriptor_accessor: "bool" = betterproto2.field(2, betterproto2.TYPE_BOOL)
1764
+ """
1765
+ Disables the generation of the standard "descriptor()" accessor, which can
1766
+ conflict with a field of the same name. This is meant to make migration
1767
+ from proto1 easier; new code should avoid fields named "descriptor".
1768
+ """
1769
+
1770
+ deprecated: "bool" = betterproto2.field(3, betterproto2.TYPE_BOOL)
1771
+ """
1772
+ Is this message deprecated?
1773
+ Depending on the target platform, this can emit Deprecated annotations
1774
+ for the message, or it will be completely ignored; in the very least,
1775
+ this is a formalization for deprecating messages.
1776
+ """
1777
+
1778
+ map_entry: "bool" = betterproto2.field(7, betterproto2.TYPE_BOOL)
1779
+ """
1780
+ Whether the message is an automatically generated map entry type for the
1781
+ maps field.
1782
+
1783
+ For maps fields:
1784
+ map<KeyType, ValueType> map_field = 1;
1785
+ The parsed descriptor looks like:
1786
+ message MapFieldEntry {
1787
+ option map_entry = true;
1788
+ optional KeyType key = 1;
1789
+ optional ValueType value = 2;
1790
+ }
1791
+ repeated MapFieldEntry map_field = 1;
1792
+
1793
+ Implementations may choose not to generate the map_entry=true message, but
1794
+ use a native map in the target language to hold the keys and values.
1795
+ The reflection APIs in such implementations still need to work as
1796
+ if the field is a repeated message field.
1797
+
1798
+ NOTE: Do not set the option in .proto files. Always use the maps syntax
1799
+ instead. The option should only be implicitly set by the proto compiler
1800
+ parser.
1801
+ """
1802
+
1803
+ deprecated_legacy_json_field_conflicts: "bool" = betterproto2.field(11, betterproto2.TYPE_BOOL)
1804
+ """
1805
+ Enable the legacy handling of JSON field name conflicts. This lowercases
1806
+ and strips underscored from the fields before comparison in proto3 only.
1807
+ The new behavior takes `json_name` into account and applies to proto2 as
1808
+ well.
1809
+
1810
+ This should only be used as a temporary measure against broken builds due
1811
+ to the change in behavior for JSON field name conflicts.
1812
+
1813
+ TODO This is legacy behavior we plan to remove once downstream
1814
+ teams have had time to migrate.
1815
+ """
1816
+
1817
+ features: "FeatureSet | None" = betterproto2.field(12, betterproto2.TYPE_MESSAGE, optional=True)
1818
+ """
1819
+ Any features defined in the specific edition.
1820
+ """
1821
+
1822
+ uninterpreted_option: "list[UninterpretedOption]" = betterproto2.field(
1823
+ 999, betterproto2.TYPE_MESSAGE, repeated=True
1824
+ )
1825
+ """
1826
+ The parser stores options it doesn't recognize here. See above.
1827
+ """
1828
+
1829
+ def __post_init__(self) -> None:
1830
+ super().__post_init__()
1831
+ if self.is_set("deprecated_legacy_json_field_conflicts"):
1832
+ warnings.warn("MessageOptions.deprecated_legacy_json_field_conflicts is deprecated", DeprecationWarning)
1833
+
1834
+
1835
+ default_message_pool.register_message("google.protobuf", "MessageOptions", MessageOptions)
1836
+
1837
+
1838
+ @dataclass(eq=False, repr=False)
1839
+ class MethodDescriptorProto(betterproto2.Message):
1840
+ """
1841
+ Describes a method of a service.
1842
+ """
1843
+
1844
+ name: "str" = betterproto2.field(1, betterproto2.TYPE_STRING)
1845
+
1846
+ input_type: "str" = betterproto2.field(2, betterproto2.TYPE_STRING)
1847
+ """
1848
+ Input and output type names. These are resolved in the same way as
1849
+ FieldDescriptorProto.type_name, but must refer to a message type.
1850
+ """
1851
+
1852
+ output_type: "str" = betterproto2.field(3, betterproto2.TYPE_STRING)
1853
+
1854
+ options: "MethodOptions | None" = betterproto2.field(4, betterproto2.TYPE_MESSAGE, optional=True)
1855
+
1856
+ client_streaming: "bool" = betterproto2.field(5, betterproto2.TYPE_BOOL)
1857
+ """
1858
+ Identifies if client streams multiple client messages
1859
+ """
1860
+
1861
+ server_streaming: "bool" = betterproto2.field(6, betterproto2.TYPE_BOOL)
1862
+ """
1863
+ Identifies if server streams multiple server messages
1864
+ """
1865
+
1866
+
1867
+ default_message_pool.register_message("google.protobuf", "MethodDescriptorProto", MethodDescriptorProto)
1868
+
1869
+
1870
+ @dataclass(eq=False, repr=False)
1871
+ class MethodOptions(betterproto2.Message):
1872
+ deprecated: "bool" = betterproto2.field(33, betterproto2.TYPE_BOOL)
1873
+ """
1874
+ Note: Field numbers 1 through 32 are reserved for Google's internal RPC
1875
+ framework. We apologize for hoarding these numbers to ourselves, but
1876
+ we were already using them long before we decided to release Protocol
1877
+ Buffers.
1878
+
1879
+ Is this method deprecated?
1880
+ Depending on the target platform, this can emit Deprecated annotations
1881
+ for the method, or it will be completely ignored; in the very least,
1882
+ this is a formalization for deprecating methods.
1883
+ """
1884
+
1885
+ idempotency_level: "MethodOptionsIdempotencyLevel" = betterproto2.field(
1886
+ 34, betterproto2.TYPE_ENUM, default_factory=lambda: MethodOptionsIdempotencyLevel(0)
1887
+ )
1888
+
1889
+ features: "FeatureSet | None" = betterproto2.field(35, betterproto2.TYPE_MESSAGE, optional=True)
1890
+ """
1891
+ Any features defined in the specific edition.
1892
+ """
1893
+
1894
+ uninterpreted_option: "list[UninterpretedOption]" = betterproto2.field(
1895
+ 999, betterproto2.TYPE_MESSAGE, repeated=True
1896
+ )
1897
+ """
1898
+ The parser stores options it doesn't recognize here. See above.
1899
+ """
1900
+
1901
+
1902
+ default_message_pool.register_message("google.protobuf", "MethodOptions", MethodOptions)
1903
+
1904
+
1905
+ @dataclass(eq=False, repr=False)
1906
+ class OneofDescriptorProto(betterproto2.Message):
1907
+ """
1908
+ Describes a oneof.
1909
+ """
1910
+
1911
+ name: "str" = betterproto2.field(1, betterproto2.TYPE_STRING)
1912
+
1913
+ options: "OneofOptions | None" = betterproto2.field(2, betterproto2.TYPE_MESSAGE, optional=True)
1914
+
1915
+
1916
+ default_message_pool.register_message("google.protobuf", "OneofDescriptorProto", OneofDescriptorProto)
1917
+
1918
+
1919
+ @dataclass(eq=False, repr=False)
1920
+ class OneofOptions(betterproto2.Message):
1921
+ features: "FeatureSet | None" = betterproto2.field(1, betterproto2.TYPE_MESSAGE, optional=True)
1922
+ """
1923
+ Any features defined in the specific edition.
1924
+ """
1925
+
1926
+ uninterpreted_option: "list[UninterpretedOption]" = betterproto2.field(
1927
+ 999, betterproto2.TYPE_MESSAGE, repeated=True
1928
+ )
1929
+ """
1930
+ The parser stores options it doesn't recognize here. See above.
1931
+ """
1932
+
1933
+
1934
+ default_message_pool.register_message("google.protobuf", "OneofOptions", OneofOptions)
1935
+
1936
+
1937
+ @dataclass(eq=False, repr=False)
1938
+ class ServiceDescriptorProto(betterproto2.Message):
1939
+ """
1940
+ Describes a service.
1941
+ """
1942
+
1943
+ name: "str" = betterproto2.field(1, betterproto2.TYPE_STRING)
1944
+
1945
+ method: "list[MethodDescriptorProto]" = betterproto2.field(2, betterproto2.TYPE_MESSAGE, repeated=True)
1946
+
1947
+ options: "ServiceOptions | None" = betterproto2.field(3, betterproto2.TYPE_MESSAGE, optional=True)
1948
+
1949
+
1950
+ default_message_pool.register_message("google.protobuf", "ServiceDescriptorProto", ServiceDescriptorProto)
1951
+
1952
+
1953
+ @dataclass(eq=False, repr=False)
1954
+ class ServiceOptions(betterproto2.Message):
1955
+ features: "FeatureSet | None" = betterproto2.field(34, betterproto2.TYPE_MESSAGE, optional=True)
1956
+ """
1957
+ Any features defined in the specific edition.
1958
+ """
1959
+
1960
+ deprecated: "bool" = betterproto2.field(33, betterproto2.TYPE_BOOL)
1961
+ """
1962
+ Note: Field numbers 1 through 32 are reserved for Google's internal RPC
1963
+ framework. We apologize for hoarding these numbers to ourselves, but
1964
+ we were already using them long before we decided to release Protocol
1965
+ Buffers.
1966
+
1967
+ Is this service deprecated?
1968
+ Depending on the target platform, this can emit Deprecated annotations
1969
+ for the service, or it will be completely ignored; in the very least,
1970
+ this is a formalization for deprecating services.
1971
+ """
1972
+
1973
+ uninterpreted_option: "list[UninterpretedOption]" = betterproto2.field(
1974
+ 999, betterproto2.TYPE_MESSAGE, repeated=True
1975
+ )
1976
+ """
1977
+ The parser stores options it doesn't recognize here. See above.
1978
+ """
1979
+
1980
+
1981
+ default_message_pool.register_message("google.protobuf", "ServiceOptions", ServiceOptions)
1982
+
1983
+
1984
+ @dataclass(eq=False, repr=False)
1985
+ class SourceCodeInfo(betterproto2.Message):
1986
+ """
1987
+ ===================================================================
1988
+ Optional source code info
1989
+
1990
+ Encapsulates information about the original source file from which a
1991
+ FileDescriptorProto was generated.
1992
+ """
1993
+
1994
+ location: "list[SourceCodeInfoLocation]" = betterproto2.field(1, betterproto2.TYPE_MESSAGE, repeated=True)
1995
+ """
1996
+ A Location identifies a piece of source code in a .proto file which
1997
+ corresponds to a particular definition. This information is intended
1998
+ to be useful to IDEs, code indexers, documentation generators, and similar
1999
+ tools.
2000
+
2001
+ For example, say we have a file like:
2002
+ message Foo {
2003
+ optional string foo = 1;
2004
+ }
2005
+ Let's look at just the field definition:
2006
+ optional string foo = 1;
2007
+ ^ ^^ ^^ ^ ^^^
2008
+ a bc de f ghi
2009
+ We have the following locations:
2010
+ span path represents
2011
+ [a,i) [ 4, 0, 2, 0 ] The whole field definition.
2012
+ [a,b) [ 4, 0, 2, 0, 4 ] The label (optional).
2013
+ [c,d) [ 4, 0, 2, 0, 5 ] The type (string).
2014
+ [e,f) [ 4, 0, 2, 0, 1 ] The name (foo).
2015
+ [g,h) [ 4, 0, 2, 0, 3 ] The number (1).
2016
+
2017
+ Notes:
2018
+ - A location may refer to a repeated field itself (i.e. not to any
2019
+ particular index within it). This is used whenever a set of elements are
2020
+ logically enclosed in a single code segment. For example, an entire
2021
+ extend block (possibly containing multiple extension definitions) will
2022
+ have an outer location whose path refers to the "extensions" repeated
2023
+ field without an index.
2024
+ - Multiple locations may have the same path. This happens when a single
2025
+ logical declaration is spread out across multiple places. The most
2026
+ obvious example is the "extend" block again -- there may be multiple
2027
+ extend blocks in the same scope, each of which will have the same path.
2028
+ - A location's span is not always a subset of its parent's span. For
2029
+ example, the "extendee" of an extension declaration appears at the
2030
+ beginning of the "extend" block and is shared by all extensions within
2031
+ the block.
2032
+ - Just because a location's span is a subset of some other location's span
2033
+ does not mean that it is a descendant. For example, a "group" defines
2034
+ both a type and a field in a single declaration. Thus, the locations
2035
+ corresponding to the type and field and their components will overlap.
2036
+ - Code which tries to interpret locations should probably be designed to
2037
+ ignore those that it doesn't understand, as more types of locations could
2038
+ be recorded in the future.
2039
+ """
2040
+
2041
+
2042
+ default_message_pool.register_message("google.protobuf", "SourceCodeInfo", SourceCodeInfo)
2043
+
2044
+
2045
+ @dataclass(eq=False, repr=False)
2046
+ class SourceCodeInfoLocation(betterproto2.Message):
2047
+ path: "list[int]" = betterproto2.field(1, betterproto2.TYPE_INT32, repeated=True)
2048
+ """
2049
+ Identifies which part of the FileDescriptorProto was defined at this
2050
+ location.
2051
+
2052
+ Each element is a field number or an index. They form a path from
2053
+ the root FileDescriptorProto to the place where the definition appears.
2054
+ For example, this path:
2055
+ [ 4, 3, 2, 7, 1 ]
2056
+ refers to:
2057
+ file.message_type(3) // 4, 3
2058
+ .field(7) // 2, 7
2059
+ .name() // 1
2060
+ This is because FileDescriptorProto.message_type has field number 4:
2061
+ repeated DescriptorProto message_type = 4;
2062
+ and DescriptorProto.field has field number 2:
2063
+ repeated FieldDescriptorProto field = 2;
2064
+ and FieldDescriptorProto.name has field number 1:
2065
+ optional string name = 1;
2066
+
2067
+ Thus, the above path gives the location of a field name. If we removed
2068
+ the last element:
2069
+ [ 4, 3, 2, 7 ]
2070
+ this path refers to the whole field declaration (from the beginning
2071
+ of the label to the terminating semicolon).
2072
+ """
2073
+
2074
+ span: "list[int]" = betterproto2.field(2, betterproto2.TYPE_INT32, repeated=True)
2075
+ """
2076
+ Always has exactly three or four elements: start line, start column,
2077
+ end line (optional, otherwise assumed same as start line), end column.
2078
+ These are packed into a single field for efficiency. Note that line
2079
+ and column numbers are zero-based -- typically you will want to add
2080
+ 1 to each before displaying to a user.
2081
+ """
2082
+
2083
+ leading_comments: "str" = betterproto2.field(3, betterproto2.TYPE_STRING)
2084
+ """
2085
+ If this SourceCodeInfo represents a complete declaration, these are any
2086
+ comments appearing before and after the declaration which appear to be
2087
+ attached to the declaration.
2088
+
2089
+ A series of line comments appearing on consecutive lines, with no other
2090
+ tokens appearing on those lines, will be treated as a single comment.
2091
+
2092
+ leading_detached_comments will keep paragraphs of comments that appear
2093
+ before (but not connected to) the current element. Each paragraph,
2094
+ separated by empty lines, will be one comment element in the repeated
2095
+ field.
2096
+
2097
+ Only the comment content is provided; comment markers (e.g. //) are
2098
+ stripped out. For block comments, leading whitespace and an asterisk
2099
+ will be stripped from the beginning of each line other than the first.
2100
+ Newlines are included in the output.
2101
+
2102
+ Examples:
2103
+
2104
+ optional int32 foo = 1; // Comment attached to foo.
2105
+ // Comment attached to bar.
2106
+ optional int32 bar = 2;
2107
+
2108
+ optional string baz = 3;
2109
+ // Comment attached to baz.
2110
+ // Another line attached to baz.
2111
+
2112
+ // Comment attached to moo.
2113
+ //
2114
+ // Another line attached to moo.
2115
+ optional double moo = 4;
2116
+
2117
+ // Detached comment for corge. This is not leading or trailing comments
2118
+ // to moo or corge because there are blank lines separating it from
2119
+ // both.
2120
+
2121
+ // Detached comment for corge paragraph 2.
2122
+
2123
+ optional string corge = 5;
2124
+ /* Block comment attached
2125
+ * to corge. Leading asterisks
2126
+ * will be removed. */
2127
+ /* Block comment attached to
2128
+ * grault. */
2129
+ optional int32 grault = 6;
2130
+
2131
+ // ignored detached comments.
2132
+ """
2133
+
2134
+ trailing_comments: "str" = betterproto2.field(4, betterproto2.TYPE_STRING)
2135
+
2136
+ leading_detached_comments: "list[str]" = betterproto2.field(6, betterproto2.TYPE_STRING, repeated=True)
2137
+
2138
+
2139
+ default_message_pool.register_message("google.protobuf", "SourceCodeInfo.Location", SourceCodeInfoLocation)
2140
+
2141
+
2142
+ @dataclass(eq=False, repr=False)
2143
+ class UninterpretedOption(betterproto2.Message):
2144
+ """
2145
+ A message representing a option the parser does not recognize. This only
2146
+ appears in options protos created by the compiler::Parser class.
2147
+ DescriptorPool resolves these when building Descriptor objects. Therefore,
2148
+ options protos in descriptor objects (e.g. returned by Descriptor::options(),
2149
+ or produced by Descriptor::CopyTo()) will never have UninterpretedOptions
2150
+ in them.
2151
+ """
2152
+
2153
+ name: "list[UninterpretedOptionNamePart]" = betterproto2.field(2, betterproto2.TYPE_MESSAGE, repeated=True)
2154
+
2155
+ identifier_value: "str" = betterproto2.field(3, betterproto2.TYPE_STRING)
2156
+ """
2157
+ The value of the uninterpreted option, in whatever type the tokenizer
2158
+ identified it as during parsing. Exactly one of these should be set.
2159
+ """
2160
+
2161
+ positive_int_value: "int" = betterproto2.field(4, betterproto2.TYPE_UINT64)
2162
+
2163
+ negative_int_value: "int" = betterproto2.field(5, betterproto2.TYPE_INT64)
2164
+
2165
+ double_value: "float" = betterproto2.field(6, betterproto2.TYPE_DOUBLE)
2166
+
2167
+ string_value: "bytes" = betterproto2.field(7, betterproto2.TYPE_BYTES)
2168
+
2169
+ aggregate_value: "str" = betterproto2.field(8, betterproto2.TYPE_STRING)
2170
+
2171
+
2172
+ default_message_pool.register_message("google.protobuf", "UninterpretedOption", UninterpretedOption)
2173
+
2174
+
2175
+ @dataclass(eq=False, repr=False)
2176
+ class UninterpretedOptionNamePart(betterproto2.Message):
2177
+ """
2178
+ The name of the uninterpreted option. Each string represents a segment in
2179
+ a dot-separated name. is_extension is true iff a segment represents an
2180
+ extension (denoted with parentheses in options specs in .proto files).
2181
+ E.g.,{ ["foo", false], ["bar.baz", true], ["moo", false] } represents
2182
+ "foo.(bar.baz).moo".
2183
+ """
2184
+
2185
+ name_part: "str" = betterproto2.field(1, betterproto2.TYPE_STRING)
2186
+
2187
+ is_extension: "bool" = betterproto2.field(2, betterproto2.TYPE_BOOL)
2188
+
2189
+
2190
+ default_message_pool.register_message("google.protobuf", "UninterpretedOption.NamePart", UninterpretedOptionNamePart)