datastore.proto 13 KB

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