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