entity.proto 6.8 KB

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