datastore.proto 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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/datastore/v1beta3/entity.proto";
  18. import "google/datastore/v1beta3/query.proto";
  19. option java_multiple_files = true;
  20. option java_outer_classname = "DatastoreProto";
  21. option java_package = "com.google.datastore.v1beta3";
  22. // Each RPC normalizes the partition IDs of the keys in its input entities,
  23. // and always returns entities with keys with normalized partition IDs.
  24. // This applies to all keys and entities, including those in values, except keys
  25. // with both an empty path and an empty or unset partition ID. Normalization of
  26. // input keys sets the project ID (if not already set) to the project ID from
  27. // the request.
  28. //
  29. service Datastore {
  30. // Looks up entities by key.
  31. rpc Lookup(LookupRequest) returns (LookupResponse) {
  32. option (google.api.http) = { post: "/v1beta3/projects/{project_id}:lookup" body: "*" };
  33. }
  34. // Queries for entities.
  35. rpc RunQuery(RunQueryRequest) returns (RunQueryResponse) {
  36. option (google.api.http) = { post: "/v1beta3/projects/{project_id}:runQuery" body: "*" };
  37. }
  38. // Begins a new transaction.
  39. rpc BeginTransaction(BeginTransactionRequest) returns (BeginTransactionResponse) {
  40. option (google.api.http) = { post: "/v1beta3/projects/{project_id}:beginTransaction" body: "*" };
  41. }
  42. // Commits a transaction, optionally creating, deleting or modifying some
  43. // entities.
  44. rpc Commit(CommitRequest) returns (CommitResponse) {
  45. option (google.api.http) = { post: "/v1beta3/projects/{project_id}:commit" body: "*" };
  46. }
  47. // Rolls back a transaction.
  48. rpc Rollback(RollbackRequest) returns (RollbackResponse) {
  49. option (google.api.http) = { post: "/v1beta3/projects/{project_id}:rollback" body: "*" };
  50. }
  51. // Allocates IDs for the given keys, which is useful for referencing an entity
  52. // before it is inserted.
  53. rpc AllocateIds(AllocateIdsRequest) returns (AllocateIdsResponse) {
  54. option (google.api.http) = { post: "/v1beta3/projects/{project_id}:allocateIds" body: "*" };
  55. }
  56. }
  57. // The request for [Datastore.Lookup][google.datastore.v1beta3.Datastore.Lookup].
  58. message LookupRequest {
  59. // The ID of the project against which to make the request.
  60. string project_id = 8;
  61. // The options for this lookup request.
  62. ReadOptions read_options = 1;
  63. // Keys of entities to look up.
  64. repeated Key keys = 3;
  65. }
  66. // The response for [Datastore.Lookup][google.datastore.v1beta3.Datastore.Lookup].
  67. message LookupResponse {
  68. // Entities found as `ResultType.FULL` entities. The order of results in this
  69. // field is undefined and has no relation to the order of the keys in the
  70. // input.
  71. repeated EntityResult found = 1;
  72. // Entities not found as `ResultType.KEY_ONLY` entities. The order of results
  73. // in this field is undefined and has no relation to the order of the keys
  74. // in the input.
  75. repeated EntityResult missing = 2;
  76. // A list of keys that were not looked up due to resource constraints. The
  77. // order of results in this field is undefined and has no relation to the
  78. // order of the keys in the input.
  79. repeated Key deferred = 3;
  80. }
  81. // The request for [Datastore.RunQuery][google.datastore.v1beta3.Datastore.RunQuery].
  82. message RunQueryRequest {
  83. // The ID of the project against which to make the request.
  84. string project_id = 8;
  85. // Entities are partitioned into subsets, identified by a partition ID.
  86. // Queries are scoped to a single partition.
  87. // This partition ID is normalized with the standard default context
  88. // partition ID.
  89. PartitionId partition_id = 2;
  90. // The options for this query.
  91. ReadOptions read_options = 1;
  92. // The type of query.
  93. oneof query_type {
  94. // The query to run.
  95. Query query = 3;
  96. // The GQL query to run.
  97. GqlQuery gql_query = 7;
  98. }
  99. }
  100. // The response for [Datastore.RunQuery][google.datastore.v1beta3.Datastore.RunQuery].
  101. message RunQueryResponse {
  102. // A batch of query results (always present).
  103. QueryResultBatch batch = 1;
  104. // The parsed form of the `GqlQuery` from the request, if it was set.
  105. Query query = 2;
  106. }
  107. // The request for [Datastore.BeginTransaction][google.datastore.v1beta3.Datastore.BeginTransaction].
  108. message BeginTransactionRequest {
  109. // The ID of the project against which to make the request.
  110. string project_id = 8;
  111. }
  112. // The response for [Datastore.BeginTransaction][google.datastore.v1beta3.Datastore.BeginTransaction].
  113. message BeginTransactionResponse {
  114. // The transaction identifier (always present).
  115. bytes transaction = 1;
  116. }
  117. // The request for [Datastore.Rollback][google.datastore.v1beta3.Datastore.Rollback].
  118. message RollbackRequest {
  119. // The ID of the project against which to make the request.
  120. string project_id = 8;
  121. // The transaction identifier, returned by a call to
  122. // [Datastore.BeginTransaction][google.datastore.v1beta3.Datastore.BeginTransaction].
  123. bytes transaction = 1;
  124. }
  125. // The response for [Datastore.Rollback][google.datastore.v1beta3.Datastore.Rollback].
  126. // (an empty message).
  127. message RollbackResponse {
  128. }
  129. // The request for [Datastore.Commit][google.datastore.v1beta3.Datastore.Commit].
  130. message CommitRequest {
  131. // The modes available for commits.
  132. enum Mode {
  133. // Unspecified. This value must not be used.
  134. MODE_UNSPECIFIED = 0;
  135. // Transactional: The mutations are either all applied, or none are applied.
  136. // Learn about transactions [here](https://cloud.google.com/datastore/docs/concepts/transactions).
  137. TRANSACTIONAL = 1;
  138. // Non-transactional: The mutations may not apply as all or none.
  139. NON_TRANSACTIONAL = 2;
  140. }
  141. // The ID of the project against which to make the request.
  142. string project_id = 8;
  143. // The type of commit to perform. Defaults to `TRANSACTIONAL`.
  144. Mode mode = 5;
  145. // Must be set when mode is `TRANSACTIONAL`.
  146. oneof transaction_selector {
  147. // The identifier of the transaction associated with the commit. A
  148. // transaction identifier is returned by a call to
  149. // [Datastore.BeginTransaction][google.datastore.v1beta3.Datastore.BeginTransaction].
  150. bytes transaction = 1;
  151. }
  152. // The mutations to perform.
  153. //
  154. // When mode is `TRANSACTIONAL`, mutations affecting a single entity are
  155. // applied in order. The following sequences of mutations affecting a single
  156. // entity are not permitted in a single `Commit` request:
  157. //
  158. // - `insert` followed by `insert`
  159. // - `update` followed by `insert`
  160. // - `upsert` followed by `insert`
  161. // - `delete` followed by `update`
  162. //
  163. // When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
  164. // entity.
  165. repeated Mutation mutations = 6;
  166. }
  167. // The response for [Datastore.Commit][google.datastore.v1beta3.Datastore.Commit].
  168. message CommitResponse {
  169. // The result of performing the mutations.
  170. // The i-th mutation result corresponds to the i-th mutation in the request.
  171. repeated MutationResult mutation_results = 3;
  172. // The number of index entries updated during the commit, or zero if none were
  173. // updated.
  174. int32 index_updates = 4;
  175. }
  176. // The request for [Datastore.AllocateIds][google.datastore.v1beta3.Datastore.AllocateIds].
  177. message AllocateIdsRequest {
  178. // The ID of the project against which to make the request.
  179. string project_id = 8;
  180. // A list of keys with incomplete key paths for which to allocate IDs.
  181. // No key may be reserved/read-only.
  182. repeated Key keys = 1;
  183. }
  184. // The response for [Datastore.AllocateIds][google.datastore.v1beta3.Datastore.AllocateIds].
  185. message AllocateIdsResponse {
  186. // The keys specified in the request (in the same order), each with
  187. // its key path completed with a newly allocated ID.
  188. repeated Key keys = 1;
  189. }
  190. // A mutation to apply to an entity.
  191. message Mutation {
  192. // The mutation operation.
  193. //
  194. // For `insert`, `update`, and `upsert`:
  195. // - The entity's key must not be reserved/read-only.
  196. // - No property in the entity may have a reserved name,
  197. // not even a property in an entity in a value.
  198. // - No value in the entity may have meaning 18,
  199. // not even a value in an entity in another value.
  200. oneof operation {
  201. // The entity to insert. The entity must not already exist.
  202. // The entity key's final path element may be incomplete.
  203. Entity insert = 4;
  204. // The entity to update. The entity must already exist.
  205. // Must have a complete key path.
  206. Entity update = 5;
  207. // The entity to upsert. The entity may or may not already exist.
  208. // The entity key's final path element may be incomplete.
  209. Entity upsert = 6;
  210. // The key of the entity to delete. The entity may or may not already exist.
  211. // Must have a complete key path and must not be reserved/read-only.
  212. Key delete = 7;
  213. }
  214. // When set, the server will detect whether or not this mutation conflicts
  215. // with the current version of the entity on the server. Conflicting mutations
  216. // are not applied, and are marked as such in MutationResult.
  217. oneof conflict_detection_strategy {
  218. // The version of the entity that this mutation is being applied to. If this
  219. // does not match the current version on the server, the mutation conflicts.
  220. int64 base_version = 8;
  221. }
  222. }
  223. // The result of applying a mutation.
  224. message MutationResult {
  225. // The automatically allocated key.
  226. // Set only when the mutation allocated a key.
  227. Key key = 3;
  228. // The version of the entity on the server after processing the mutation. If
  229. // the mutation doesn't change anything on the server, then the version will
  230. // be the version of the current entity or, if no entity is present, a version
  231. // that is strictly greater than the version of any previous entity and less
  232. // than the version of any possible future entity.
  233. int64 version = 4;
  234. // Whether a conflict was detected for this mutation. Always false when a
  235. // conflict detection strategy field is not set in the mutation.
  236. bool conflict_detected = 5;
  237. }
  238. // The options shared by read requests.
  239. message ReadOptions {
  240. // The possible values for read consistencies.
  241. enum ReadConsistency {
  242. // Unspecified. This value must not be used.
  243. READ_CONSISTENCY_UNSPECIFIED = 0;
  244. // Strong consistency.
  245. STRONG = 1;
  246. // Eventual consistency.
  247. EVENTUAL = 2;
  248. }
  249. // If not specified, lookups and ancestor queries default to
  250. // `read_consistency`=`STRONG`, global queries default to
  251. // `read_consistency`=`EVENTUAL`.
  252. oneof consistency_type {
  253. // The non-transactional read consistency to use.
  254. // Cannot be set to `STRONG` for global queries.
  255. ReadConsistency read_consistency = 1;
  256. // The identifier of the transaction in which to read. A
  257. // transaction identifier is returned by a call to
  258. // [Datastore.BeginTransaction][google.datastore.v1beta3.Datastore.BeginTransaction].
  259. bytes transaction = 2;
  260. }
  261. }