any_pb.py 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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/any.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 Message
  21. from protobuf._codegen import file_desc
  22. from protobuf.wkt._mixin import AnyMixin
  23. if TYPE_CHECKING:
  24. from protobuf import DescFile
  25. _AnyFields: TypeAlias = Literal["type_url", "value"]
  26. class Any(Message[_AnyFields], AnyMixin):
  27. """
  28. `Any` contains an arbitrary serialized protocol buffer message along with a
  29. URL that describes the type of the serialized message.
  30. In its binary encoding, an `Any` is an ordinary message; but in other wire
  31. forms like JSON, it has a special encoding. The format of the type URL is
  32. described on the `type_url` field.
  33. Protobuf APIs provide utilities to interact with `Any` values:
  34. - A 'pack' operation accepts a message and constructs a generic `Any` wrapper
  35. around it.
  36. - An 'unpack' operation reads the content of an `Any` message, either into an
  37. existing message or a new one. Unpack operations must check the type of the
  38. value they unpack against the declared `type_url`.
  39. - An 'is' operation decides whether an `Any` contains a message of the given
  40. type, i.e. whether it can 'unpack' that type.
  41. The JSON format representation of an `Any` follows one of these cases:
  42. - For types without special-cased JSON encodings, the JSON format
  43. representation of the `Any` is the same as that of the message, with an
  44. additional `@type` field which contains the type URL.
  45. - For types with special-cased JSON encodings (typically called 'well-known'
  46. types, listed in https://protobuf.dev/programming-guides/json/#any), the
  47. JSON format representation has a key `@type` which contains the type URL
  48. and a key `value` which contains the JSON-serialized value.
  49. The text format representation of an `Any` is like a message with one field
  50. whose name is the type URL in brackets. For example, an `Any` containing a
  51. `foo.Bar` message may be written `[type.googleapis.com/foo.Bar] { a: 2 }`.
  52. ```proto
  53. message google.protobuf.Any
  54. ```
  55. Attributes:
  56. type_url:
  57. Identifies the type of the serialized Protobuf message with a URI reference
  58. consisting of a prefix ending in a slash and the fully-qualified type name.
  59. Example: type.googleapis.com/google.protobuf.StringValue
  60. This string must contain at least one `/` character, and the content after
  61. the last `/` must be the fully-qualified name of the type in canonical
  62. form, without a leading dot. Do not write a scheme on these URI references
  63. so that clients do not attempt to contact them.
  64. The prefix is arbitrary and Protobuf implementations are expected to
  65. simply strip off everything up to and including the last `/` to identify
  66. the type. `type.googleapis.com/` is a common default prefix that some
  67. legacy implementations require. This prefix does not indicate the origin of
  68. the type, and URIs containing it are not expected to respond to any
  69. requests.
  70. All type URL strings must be legal URI references with the additional
  71. restriction (for the text format) that the content of the reference
  72. must consist only of alphanumeric characters, percent-encoded escapes, and
  73. characters in the following set (not including the outer backticks):
  74. `/-.~_!$&()*+,;=`. Despite our allowing percent encodings, implementations
  75. should not unescape them to prevent confusion with existing parsers. For
  76. example, `type.googleapis.com%2FFoo` should be rejected.
  77. In the original design of `Any`, the possibility of launching a type
  78. resolution service at these type URLs was considered but Protobuf never
  79. implemented one and considers contacting these URLs to be problematic and
  80. a potential security issue. Do not attempt to contact type URLs.
  81. ```proto
  82. string type_url = 1;
  83. ```
  84. value:
  85. Holds a Protobuf serialization of the type described by type_url.
  86. ```proto
  87. bytes value = 2;
  88. ```
  89. """
  90. __slots__ = ("type_url", "value")
  91. if TYPE_CHECKING:
  92. def __init__(self, *, type_url: str = "", value: bytes = b"") -> None:
  93. pass
  94. type_url: str
  95. value: bytes
  96. _DESC = file_desc(
  97. b'\n\x19google/protobuf/any.proto\x12\x0fgoogle.protobuf"6\n\x03Any\x12\x19\n\x08type_url\x18\x01 \x01(\tR\x07typeUrl\x12\x14\n\x05value\x18\x02 \x01(\x0cR\x05valueBv\n\x13com.google.protobufB\x08AnyProtoP\x01Z,google.golang.org/protobuf/types/known/anypb\xa2\x02\x03GPB\xaa\x02\x1eGoogle.Protobuf.WellKnownTypesb\x06proto3',
  98. [],
  99. {"Any": Any},
  100. )
  101. def desc() -> DescFile:
  102. """Returns the descriptor for the file `google/protobuf/any.proto`."""
  103. return _DESC