struct_pb.py 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. # Copyright (c) 2025-2026 Buf Technologies, Inc.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # Generated from google/protobuf/struct.proto. DO NOT EDIT.
  15. # Generated by protoc-gen-py v0.1.1 with parameter "no_fmt_off".
  16. # ruff: noqa: PGH004
  17. # ruff: noqa
  18. from __future__ import annotations
  19. from typing import Literal, TYPE_CHECKING, TypeAlias
  20. from protobuf import Enum, Message
  21. from protobuf._codegen import file_desc
  22. from protobuf.wkt._mixin import ListValueMixin, StructMixin, ValueMixin
  23. if TYPE_CHECKING:
  24. from protobuf import DescFile, Oneof
  25. _StructFields: TypeAlias = Literal["fields"]
  26. class Struct(Message[_StructFields], StructMixin):
  27. """
  28. Represents a JSON object.
  29. An unordered key-value map, intending to perfectly capture the semantics of a
  30. JSON object. This enables parsing any arbitrary JSON payload as a message
  31. field in ProtoJSON format.
  32. This follows RFC 8259 guidelines for interoperable JSON: notably this type
  33. cannot represent large Int64 values or `NaN`/`Infinity` numbers,
  34. since the JSON format generally does not support those values in its number
  35. type.
  36. If you do not intend to parse arbitrary JSON into your message, a custom
  37. typed message should be preferred instead of using this type.
  38. ```proto
  39. message google.protobuf.Struct
  40. ```
  41. Attributes:
  42. fields:
  43. Unordered map of dynamically typed values.
  44. ```proto
  45. map<string, google.protobuf.Value> fields = 1;
  46. ```
  47. """
  48. __slots__ = ("fields",)
  49. if TYPE_CHECKING:
  50. def __init__(self, *, fields: dict[str, Value] | None = None) -> None:
  51. pass
  52. fields: dict[str, Value]
  53. _ValueFields: TypeAlias = Literal[
  54. "null_value",
  55. "number_value",
  56. "string_value",
  57. "bool_value",
  58. "struct_value",
  59. "list_value",
  60. ]
  61. class Value(Message[_ValueFields], ValueMixin):
  62. """
  63. Represents a JSON value.
  64. `Value` represents a dynamically typed value which can be either
  65. null, a number, a string, a boolean, a recursive struct value, or a
  66. list of values. A producer of value is expected to set one of these
  67. variants. Absence of any variant is an invalid state.
  68. ```proto
  69. message google.protobuf.Value
  70. ```
  71. Attributes:
  72. kind:
  73. The kind of value.
  74. ```proto
  75. oneof kind
  76. ```
  77. """
  78. __slots__ = ("kind",)
  79. if TYPE_CHECKING:
  80. def __init__(
  81. self,
  82. *,
  83. kind: Oneof[Literal["null_value"], NullValue]
  84. | Oneof[Literal["number_value"], float]
  85. | Oneof[Literal["string_value"], str]
  86. | Oneof[Literal["bool_value"], bool]
  87. | Oneof[Literal["struct_value"], Struct]
  88. | Oneof[Literal["list_value"], ListValue]
  89. | None = None,
  90. ) -> None:
  91. pass
  92. kind: (
  93. Oneof[Literal["null_value"], NullValue]
  94. | Oneof[Literal["number_value"], float]
  95. | Oneof[Literal["string_value"], str]
  96. | Oneof[Literal["bool_value"], bool]
  97. | Oneof[Literal["struct_value"], Struct]
  98. | Oneof[Literal["list_value"], ListValue]
  99. | None
  100. )
  101. _ListValueFields: TypeAlias = Literal["values"]
  102. class ListValue(Message[_ListValueFields], ListValueMixin):
  103. """
  104. Represents a JSON array.
  105. ```proto
  106. message google.protobuf.ListValue
  107. ```
  108. Attributes:
  109. values:
  110. Repeated field of dynamically typed values.
  111. ```proto
  112. repeated google.protobuf.Value values = 1;
  113. ```
  114. """
  115. __slots__ = ("values",)
  116. if TYPE_CHECKING:
  117. def __init__(self, *, values: list[Value] | None = None) -> None:
  118. pass
  119. values: list[Value]
  120. class NullValue(Enum):
  121. """
  122. Represents a JSON `null`.
  123. `NullValue` is a sentinel, using an enum with only one value to represent
  124. the null value for the `Value` type union.
  125. A field of type `NullValue` with any value other than `0` is considered
  126. invalid. Most ProtoJSON serializers will emit a Value with a `null_value` set
  127. as a JSON `null` regardless of the integer value, and so will round trip to
  128. a `0` value.
  129. ```proto
  130. enum google.protobuf.NullValue
  131. ```
  132. Attributes:
  133. NULL_VALUE:
  134. Null value.
  135. ```proto
  136. NULL_VALUE = 0
  137. ```
  138. """
  139. NULL_VALUE = 0
  140. _DESC = file_desc(
  141. b'\n\x1cgoogle/protobuf/struct.proto\x12\x0fgoogle.protobuf"\x98\x01\n\x06Struct\x12;\n\x06fields\x18\x01 \x03(\x0b2#.google.protobuf.Struct.FieldsEntryR\x06fields\x1aQ\n\x0bFieldsEntry\x12\x10\n\x03key\x18\x01 \x01(\tR\x03key\x12,\n\x05value\x18\x02 \x01(\x0b2\x16.google.protobuf.ValueR\x05value:\x028\x01"\xb2\x02\n\x05Value\x12;\n\nnull_value\x18\x01 \x01(\x0e2\x1a.google.protobuf.NullValueH\x00R\tnullValue\x12#\n\x0cnumber_value\x18\x02 \x01(\x01H\x00R\x0bnumberValue\x12#\n\x0cstring_value\x18\x03 \x01(\tH\x00R\x0bstringValue\x12\x1f\n\nbool_value\x18\x04 \x01(\x08H\x00R\tboolValue\x12<\n\x0cstruct_value\x18\x05 \x01(\x0b2\x17.google.protobuf.StructH\x00R\x0bstructValue\x12;\n\nlist_value\x18\x06 \x01(\x0b2\x1a.google.protobuf.ListValueH\x00R\tlistValueB\x06\n\x04kind";\n\tListValue\x12.\n\x06values\x18\x01 \x03(\x0b2\x16.google.protobuf.ValueR\x06values*\x1b\n\tNullValue\x12\x0e\n\nNULL_VALUE\x10\x00B\x7f\n\x13com.google.protobufB\x0bStructProtoP\x01Z/google.golang.org/protobuf/types/known/structpb\xf8\x01\x01\xa2\x02\x03GPB\xaa\x02\x1eGoogle.Protobuf.WellKnownTypesb\x06proto3',
  142. [],
  143. {"Struct": Struct, "Value": Value, "ListValue": ListValue, "NullValue": NullValue},
  144. )
  145. def desc() -> DescFile:
  146. """Returns the descriptor for the file `google/protobuf/struct.proto`."""
  147. return _DESC