entity.proto 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. // Copyright 2022 Google LLC
  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. syntax = "proto3";
  15. package google.datastore.v1;
  16. import "google/protobuf/struct.proto";
  17. import "google/protobuf/timestamp.proto";
  18. import "google/type/latlng.proto";
  19. option csharp_namespace = "Google.Cloud.Datastore.V1";
  20. option go_package = "google.golang.org/genproto/googleapis/datastore/v1;datastore";
  21. option java_multiple_files = true;
  22. option java_outer_classname = "EntityProto";
  23. option java_package = "com.google.datastore.v1";
  24. option php_namespace = "Google\\Cloud\\Datastore\\V1";
  25. option ruby_package = "Google::Cloud::Datastore::V1";
  26. // A partition ID identifies a grouping of entities. The grouping is always
  27. // by project and namespace, however the namespace ID may be empty.
  28. //
  29. // A partition ID contains several dimensions:
  30. // project ID and namespace ID.
  31. //
  32. // Partition dimensions:
  33. //
  34. // - May be `""`.
  35. // - Must be valid UTF-8 bytes.
  36. // - Must have values that match regex `[A-Za-z\d\.\-_]{1,100}`
  37. // If the value of any dimension matches regex `__.*__`, the partition is
  38. // reserved/read-only.
  39. // A reserved/read-only partition ID is forbidden in certain documented
  40. // contexts.
  41. //
  42. // Foreign partition IDs (in which the project ID does
  43. // not match the context project ID ) are discouraged.
  44. // Reads and writes of foreign partition IDs may fail if the project is not in an active state.
  45. message PartitionId {
  46. // The ID of the project to which the entities belong.
  47. string project_id = 2;
  48. // If not empty, the ID of the database to which the entities
  49. // belong.
  50. string database_id = 3;
  51. // If not empty, the ID of the namespace to which the entities belong.
  52. string namespace_id = 4;
  53. }
  54. // A unique identifier for an entity.
  55. // If a key's partition ID or any of its path kinds or names are
  56. // reserved/read-only, the key is reserved/read-only.
  57. // A reserved/read-only key is forbidden in certain documented contexts.
  58. message Key {
  59. // A (kind, ID/name) pair used to construct a key path.
  60. //
  61. // If either name or ID is set, the element is complete.
  62. // If neither is set, the element is incomplete.
  63. message PathElement {
  64. // The kind of the entity.
  65. //
  66. // A kind matching regex `__.*__` is reserved/read-only.
  67. // A kind must not contain more than 1500 bytes when UTF-8 encoded.
  68. // Cannot be `""`.
  69. //
  70. // Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are
  71. // encoded as `__bytes<X>__` where `<X>` is the base-64 encoding of the
  72. // bytes.
  73. string kind = 1;
  74. // The type of ID.
  75. oneof id_type {
  76. // The auto-allocated ID of the entity.
  77. //
  78. // Never equal to zero. Values less than zero are discouraged and may not
  79. // be supported in the future.
  80. int64 id = 2;
  81. // The name of the entity.
  82. //
  83. // A name matching regex `__.*__` is reserved/read-only.
  84. // A name must not be more than 1500 bytes when UTF-8 encoded.
  85. // Cannot be `""`.
  86. //
  87. // Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are
  88. // encoded as `__bytes<X>__` where `<X>` is the base-64 encoding of the
  89. // bytes.
  90. string name = 3;
  91. }
  92. }
  93. // Entities are partitioned into subsets, currently identified by a project
  94. // ID and namespace ID.
  95. // Queries are scoped to a single partition.
  96. PartitionId partition_id = 1;
  97. // The entity path.
  98. // An entity path consists of one or more elements composed of a kind and a
  99. // string or numerical identifier, which identify entities. The first
  100. // element identifies a _root entity_, the second element identifies
  101. // a _child_ of the root entity, the third element identifies a child of the
  102. // second entity, and so forth. The entities identified by all prefixes of
  103. // the path are called the element's _ancestors_.
  104. //
  105. // An entity path is always fully complete: *all* of the entity's ancestors
  106. // are required to be in the path along with the entity identifier itself.
  107. // The only exception is that in some documented cases, the identifier in the
  108. // last path element (for the entity) itself may be omitted. For example,
  109. // the last path element of the key of `Mutation.insert` may have no
  110. // identifier.
  111. //
  112. // A path can never be empty, and a path can have at most 100 elements.
  113. repeated PathElement path = 2;
  114. }
  115. // An array value.
  116. message ArrayValue {
  117. // Values in the array.
  118. // The order of values in an array is preserved as long as all values have
  119. // identical settings for 'exclude_from_indexes'.
  120. repeated Value values = 1;
  121. }
  122. // A message that can hold any of the supported value types and associated
  123. // metadata.
  124. message Value {
  125. // Must have a value set.
  126. oneof value_type {
  127. // A null value.
  128. google.protobuf.NullValue null_value = 11;
  129. // A boolean value.
  130. bool boolean_value = 1;
  131. // An integer value.
  132. int64 integer_value = 2;
  133. // A double value.
  134. double double_value = 3;
  135. // A timestamp value.
  136. // When stored in the Datastore, precise only to microseconds;
  137. // any additional precision is rounded down.
  138. google.protobuf.Timestamp timestamp_value = 10;
  139. // A key value.
  140. Key key_value = 5;
  141. // A UTF-8 encoded string value.
  142. // When `exclude_from_indexes` is false (it is indexed) , may have at most 1500 bytes.
  143. // Otherwise, may be set to at most 1,000,000 bytes.
  144. string string_value = 17;
  145. // A blob value.
  146. // May have at most 1,000,000 bytes.
  147. // When `exclude_from_indexes` is false, may have at most 1500 bytes.
  148. // In JSON requests, must be base64-encoded.
  149. bytes blob_value = 18;
  150. // A geo point value representing a point on the surface of Earth.
  151. google.type.LatLng geo_point_value = 8;
  152. // An entity value.
  153. //
  154. // - May have no key.
  155. // - May have a key with an incomplete key path.
  156. // - May have a reserved/read-only key.
  157. Entity entity_value = 6;
  158. // An array value.
  159. // Cannot contain another array value.
  160. // A `Value` instance that sets field `array_value` must not set fields
  161. // `meaning` or `exclude_from_indexes`.
  162. ArrayValue array_value = 9;
  163. }
  164. // The `meaning` field should only be populated for backwards compatibility.
  165. int32 meaning = 14;
  166. // If the value should be excluded from all indexes including those defined
  167. // explicitly.
  168. bool exclude_from_indexes = 19;
  169. }
  170. // A Datastore data object.
  171. //
  172. // An entity is limited to 1 megabyte when stored. That _roughly_
  173. // corresponds to a limit of 1 megabyte for the serialized form of this
  174. // message.
  175. message Entity {
  176. // The entity's key.
  177. //
  178. // An entity must have a key, unless otherwise documented (for example,
  179. // an entity in `Value.entity_value` may have no key).
  180. // An entity's kind is its key path's last element's kind,
  181. // or null if it has no key.
  182. Key key = 1;
  183. // The entity's properties.
  184. // The map's keys are property names.
  185. // A property name matching regex `__.*__` is reserved.
  186. // A reserved property name is forbidden in certain documented contexts.
  187. // The name must not contain more than 500 characters.
  188. // The name cannot be `""`.
  189. map<string, Value> properties = 3;
  190. }