firestore.proto 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900
  1. // Copyright 2021 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.firestore.v1beta1;
  16. import "google/api/annotations.proto";
  17. import "google/api/client.proto";
  18. import "google/api/field_behavior.proto";
  19. import "google/firestore/v1beta1/common.proto";
  20. import "google/firestore/v1beta1/document.proto";
  21. import "google/firestore/v1beta1/query.proto";
  22. import "google/firestore/v1beta1/write.proto";
  23. import "google/protobuf/empty.proto";
  24. import "google/protobuf/timestamp.proto";
  25. import "google/rpc/status.proto";
  26. option csharp_namespace = "Google.Cloud.Firestore.V1Beta1";
  27. option go_package = "google.golang.org/genproto/googleapis/firestore/v1beta1;firestore";
  28. option java_multiple_files = true;
  29. option java_outer_classname = "FirestoreProto";
  30. option java_package = "com.google.firestore.v1beta1";
  31. option objc_class_prefix = "GCFS";
  32. option php_namespace = "Google\\Cloud\\Firestore\\V1beta1";
  33. option ruby_package = "Google::Cloud::Firestore::V1beta1";
  34. // Specification of the Firestore API.
  35. // The Cloud Firestore service.
  36. //
  37. // Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL
  38. // document database that simplifies storing, syncing, and querying data for
  39. // your mobile, web, and IoT apps at global scale. Its client libraries provide
  40. // live synchronization and offline support, while its security features and
  41. // integrations with Firebase and Google Cloud Platform (GCP) accelerate
  42. // building truly serverless apps.
  43. service Firestore {
  44. option (google.api.default_host) = "firestore.googleapis.com";
  45. option (google.api.oauth_scopes) =
  46. "https://www.googleapis.com/auth/cloud-platform,"
  47. "https://www.googleapis.com/auth/datastore";
  48. // Gets a single document.
  49. rpc GetDocument(GetDocumentRequest) returns (Document) {
  50. option (google.api.http) = {
  51. get: "/v1beta1/{name=projects/*/databases/*/documents/*/**}"
  52. };
  53. }
  54. // Lists documents.
  55. rpc ListDocuments(ListDocumentsRequest) returns (ListDocumentsResponse) {
  56. option (google.api.http) = {
  57. get: "/v1beta1/{parent=projects/*/databases/*/documents/*/**}/{collection_id}"
  58. };
  59. }
  60. // Updates or inserts a document.
  61. rpc UpdateDocument(UpdateDocumentRequest) returns (Document) {
  62. option (google.api.http) = {
  63. patch: "/v1beta1/{document.name=projects/*/databases/*/documents/*/**}"
  64. body: "document"
  65. };
  66. option (google.api.method_signature) = "document,update_mask";
  67. }
  68. // Deletes a document.
  69. rpc DeleteDocument(DeleteDocumentRequest) returns (google.protobuf.Empty) {
  70. option (google.api.http) = {
  71. delete: "/v1beta1/{name=projects/*/databases/*/documents/*/**}"
  72. };
  73. option (google.api.method_signature) = "name";
  74. }
  75. // Gets multiple documents.
  76. //
  77. // Documents returned by this method are not guaranteed to be returned in the
  78. // same order that they were requested.
  79. rpc BatchGetDocuments(BatchGetDocumentsRequest) returns (stream BatchGetDocumentsResponse) {
  80. option (google.api.http) = {
  81. post: "/v1beta1/{database=projects/*/databases/*}/documents:batchGet"
  82. body: "*"
  83. };
  84. }
  85. // Starts a new transaction.
  86. rpc BeginTransaction(BeginTransactionRequest) returns (BeginTransactionResponse) {
  87. option (google.api.http) = {
  88. post: "/v1beta1/{database=projects/*/databases/*}/documents:beginTransaction"
  89. body: "*"
  90. };
  91. option (google.api.method_signature) = "database";
  92. }
  93. // Commits a transaction, while optionally updating documents.
  94. rpc Commit(CommitRequest) returns (CommitResponse) {
  95. option (google.api.http) = {
  96. post: "/v1beta1/{database=projects/*/databases/*}/documents:commit"
  97. body: "*"
  98. };
  99. option (google.api.method_signature) = "database,writes";
  100. }
  101. // Rolls back a transaction.
  102. rpc Rollback(RollbackRequest) returns (google.protobuf.Empty) {
  103. option (google.api.http) = {
  104. post: "/v1beta1/{database=projects/*/databases/*}/documents:rollback"
  105. body: "*"
  106. };
  107. option (google.api.method_signature) = "database,transaction";
  108. }
  109. // Runs a query.
  110. rpc RunQuery(RunQueryRequest) returns (stream RunQueryResponse) {
  111. option (google.api.http) = {
  112. post: "/v1beta1/{parent=projects/*/databases/*/documents}:runQuery"
  113. body: "*"
  114. additional_bindings {
  115. post: "/v1beta1/{parent=projects/*/databases/*/documents/*/**}:runQuery"
  116. body: "*"
  117. }
  118. };
  119. }
  120. // Partitions a query by returning partition cursors that can be used to run
  121. // the query in parallel. The returned partition cursors are split points that
  122. // can be used by RunQuery as starting/end points for the query results.
  123. rpc PartitionQuery(PartitionQueryRequest) returns (PartitionQueryResponse) {
  124. option (google.api.http) = {
  125. post: "/v1beta1/{parent=projects/*/databases/*/documents}:partitionQuery"
  126. body: "*"
  127. additional_bindings {
  128. post: "/v1beta1/{parent=projects/*/databases/*/documents/*/**}:partitionQuery"
  129. body: "*"
  130. }
  131. };
  132. }
  133. // Streams batches of document updates and deletes, in order.
  134. rpc Write(stream WriteRequest) returns (stream WriteResponse) {
  135. option (google.api.http) = {
  136. post: "/v1beta1/{database=projects/*/databases/*}/documents:write"
  137. body: "*"
  138. };
  139. }
  140. // Listens to changes.
  141. rpc Listen(stream ListenRequest) returns (stream ListenResponse) {
  142. option (google.api.http) = {
  143. post: "/v1beta1/{database=projects/*/databases/*}/documents:listen"
  144. body: "*"
  145. };
  146. }
  147. // Lists all the collection IDs underneath a document.
  148. rpc ListCollectionIds(ListCollectionIdsRequest) returns (ListCollectionIdsResponse) {
  149. option (google.api.http) = {
  150. post: "/v1beta1/{parent=projects/*/databases/*/documents}:listCollectionIds"
  151. body: "*"
  152. additional_bindings {
  153. post: "/v1beta1/{parent=projects/*/databases/*/documents/*/**}:listCollectionIds"
  154. body: "*"
  155. }
  156. };
  157. option (google.api.method_signature) = "parent";
  158. }
  159. // Applies a batch of write operations.
  160. //
  161. // The BatchWrite method does not apply the write operations atomically
  162. // and can apply them out of order. Method does not allow more than one write
  163. // per document. Each write succeeds or fails independently. See the
  164. // [BatchWriteResponse][google.firestore.v1beta1.BatchWriteResponse] for the success status of each write.
  165. //
  166. // If you require an atomically applied set of writes, use
  167. // [Commit][google.firestore.v1beta1.Firestore.Commit] instead.
  168. rpc BatchWrite(BatchWriteRequest) returns (BatchWriteResponse) {
  169. option (google.api.http) = {
  170. post: "/v1beta1/{database=projects/*/databases/*}/documents:batchWrite"
  171. body: "*"
  172. };
  173. }
  174. // Creates a new document.
  175. rpc CreateDocument(CreateDocumentRequest) returns (Document) {
  176. option (google.api.http) = {
  177. post: "/v1beta1/{parent=projects/*/databases/*/documents/**}/{collection_id}"
  178. body: "document"
  179. };
  180. }
  181. }
  182. // The request for [Firestore.GetDocument][google.firestore.v1beta1.Firestore.GetDocument].
  183. message GetDocumentRequest {
  184. // Required. The resource name of the Document to get. In the format:
  185. // `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
  186. string name = 1 [(google.api.field_behavior) = REQUIRED];
  187. // The fields to return. If not set, returns all fields.
  188. //
  189. // If the document has a field that is not present in this mask, that field
  190. // will not be returned in the response.
  191. DocumentMask mask = 2;
  192. // The consistency mode for this transaction.
  193. // If not set, defaults to strong consistency.
  194. oneof consistency_selector {
  195. // Reads the document in a transaction.
  196. bytes transaction = 3;
  197. // Reads the version of the document at the given time.
  198. // This may not be older than 270 seconds.
  199. google.protobuf.Timestamp read_time = 5;
  200. }
  201. }
  202. // The request for [Firestore.ListDocuments][google.firestore.v1beta1.Firestore.ListDocuments].
  203. message ListDocumentsRequest {
  204. // Required. The parent resource name. In the format:
  205. // `projects/{project_id}/databases/{database_id}/documents` or
  206. // `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
  207. // For example:
  208. // `projects/my-project/databases/my-database/documents` or
  209. // `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
  210. string parent = 1 [(google.api.field_behavior) = REQUIRED];
  211. // Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`
  212. // or `messages`.
  213. string collection_id = 2 [(google.api.field_behavior) = REQUIRED];
  214. // The maximum number of documents to return.
  215. int32 page_size = 3;
  216. // The `next_page_token` value returned from a previous List request, if any.
  217. string page_token = 4;
  218. // The order to sort results by. For example: `priority desc, name`.
  219. string order_by = 6;
  220. // The fields to return. If not set, returns all fields.
  221. //
  222. // If a document has a field that is not present in this mask, that field
  223. // will not be returned in the response.
  224. DocumentMask mask = 7;
  225. // The consistency mode for this transaction.
  226. // If not set, defaults to strong consistency.
  227. oneof consistency_selector {
  228. // Reads documents in a transaction.
  229. bytes transaction = 8;
  230. // Reads documents as they were at the given time.
  231. // This may not be older than 270 seconds.
  232. google.protobuf.Timestamp read_time = 10;
  233. }
  234. // If the list should show missing documents. A missing document is a
  235. // document that does not exist but has sub-documents. These documents will
  236. // be returned with a key but will not have fields, [Document.create_time][google.firestore.v1beta1.Document.create_time],
  237. // or [Document.update_time][google.firestore.v1beta1.Document.update_time] set.
  238. //
  239. // Requests with `show_missing` may not specify `where` or
  240. // `order_by`.
  241. bool show_missing = 12;
  242. }
  243. // The response for [Firestore.ListDocuments][google.firestore.v1beta1.Firestore.ListDocuments].
  244. message ListDocumentsResponse {
  245. // The Documents found.
  246. repeated Document documents = 1;
  247. // The next page token.
  248. string next_page_token = 2;
  249. }
  250. // The request for [Firestore.CreateDocument][google.firestore.v1beta1.Firestore.CreateDocument].
  251. message CreateDocumentRequest {
  252. // Required. The parent resource. For example:
  253. // `projects/{project_id}/databases/{database_id}/documents` or
  254. // `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}`
  255. string parent = 1 [(google.api.field_behavior) = REQUIRED];
  256. // Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`.
  257. string collection_id = 2 [(google.api.field_behavior) = REQUIRED];
  258. // The client-assigned document ID to use for this document.
  259. //
  260. // Optional. If not specified, an ID will be assigned by the service.
  261. string document_id = 3;
  262. // Required. The document to create. `name` must not be set.
  263. Document document = 4 [(google.api.field_behavior) = REQUIRED];
  264. // The fields to return. If not set, returns all fields.
  265. //
  266. // If the document has a field that is not present in this mask, that field
  267. // will not be returned in the response.
  268. DocumentMask mask = 5;
  269. }
  270. // The request for [Firestore.UpdateDocument][google.firestore.v1beta1.Firestore.UpdateDocument].
  271. message UpdateDocumentRequest {
  272. // Required. The updated document.
  273. // Creates the document if it does not already exist.
  274. Document document = 1 [(google.api.field_behavior) = REQUIRED];
  275. // The fields to update.
  276. // None of the field paths in the mask may contain a reserved name.
  277. //
  278. // If the document exists on the server and has fields not referenced in the
  279. // mask, they are left unchanged.
  280. // Fields referenced in the mask, but not present in the input document, are
  281. // deleted from the document on the server.
  282. DocumentMask update_mask = 2;
  283. // The fields to return. If not set, returns all fields.
  284. //
  285. // If the document has a field that is not present in this mask, that field
  286. // will not be returned in the response.
  287. DocumentMask mask = 3;
  288. // An optional precondition on the document.
  289. // The request will fail if this is set and not met by the target document.
  290. Precondition current_document = 4;
  291. }
  292. // The request for [Firestore.DeleteDocument][google.firestore.v1beta1.Firestore.DeleteDocument].
  293. message DeleteDocumentRequest {
  294. // Required. The resource name of the Document to delete. In the format:
  295. // `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
  296. string name = 1 [(google.api.field_behavior) = REQUIRED];
  297. // An optional precondition on the document.
  298. // The request will fail if this is set and not met by the target document.
  299. Precondition current_document = 2;
  300. }
  301. // The request for [Firestore.BatchGetDocuments][google.firestore.v1beta1.Firestore.BatchGetDocuments].
  302. message BatchGetDocumentsRequest {
  303. // Required. The database name. In the format:
  304. // `projects/{project_id}/databases/{database_id}`.
  305. string database = 1 [(google.api.field_behavior) = REQUIRED];
  306. // The names of the documents to retrieve. In the format:
  307. // `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
  308. // The request will fail if any of the document is not a child resource of the
  309. // given `database`. Duplicate names will be elided.
  310. repeated string documents = 2;
  311. // The fields to return. If not set, returns all fields.
  312. //
  313. // If a document has a field that is not present in this mask, that field will
  314. // not be returned in the response.
  315. DocumentMask mask = 3;
  316. // The consistency mode for this transaction.
  317. // If not set, defaults to strong consistency.
  318. oneof consistency_selector {
  319. // Reads documents in a transaction.
  320. bytes transaction = 4;
  321. // Starts a new transaction and reads the documents.
  322. // Defaults to a read-only transaction.
  323. // The new transaction ID will be returned as the first response in the
  324. // stream.
  325. TransactionOptions new_transaction = 5;
  326. // Reads documents as they were at the given time.
  327. // This may not be older than 270 seconds.
  328. google.protobuf.Timestamp read_time = 7;
  329. }
  330. }
  331. // The streamed response for [Firestore.BatchGetDocuments][google.firestore.v1beta1.Firestore.BatchGetDocuments].
  332. message BatchGetDocumentsResponse {
  333. // A single result.
  334. // This can be empty if the server is just returning a transaction.
  335. oneof result {
  336. // A document that was requested.
  337. Document found = 1;
  338. // A document name that was requested but does not exist. In the format:
  339. // `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
  340. string missing = 2;
  341. }
  342. // The transaction that was started as part of this request.
  343. // Will only be set in the first response, and only if
  344. // [BatchGetDocumentsRequest.new_transaction][google.firestore.v1beta1.BatchGetDocumentsRequest.new_transaction] was set in the request.
  345. bytes transaction = 3;
  346. // The time at which the document was read.
  347. // This may be monotically increasing, in this case the previous documents in
  348. // the result stream are guaranteed not to have changed between their
  349. // read_time and this one.
  350. google.protobuf.Timestamp read_time = 4;
  351. }
  352. // The request for [Firestore.BeginTransaction][google.firestore.v1beta1.Firestore.BeginTransaction].
  353. message BeginTransactionRequest {
  354. // Required. The database name. In the format:
  355. // `projects/{project_id}/databases/{database_id}`.
  356. string database = 1 [(google.api.field_behavior) = REQUIRED];
  357. // The options for the transaction.
  358. // Defaults to a read-write transaction.
  359. TransactionOptions options = 2;
  360. }
  361. // The response for [Firestore.BeginTransaction][google.firestore.v1beta1.Firestore.BeginTransaction].
  362. message BeginTransactionResponse {
  363. // The transaction that was started.
  364. bytes transaction = 1;
  365. }
  366. // The request for [Firestore.Commit][google.firestore.v1beta1.Firestore.Commit].
  367. message CommitRequest {
  368. // Required. The database name. In the format:
  369. // `projects/{project_id}/databases/{database_id}`.
  370. string database = 1 [(google.api.field_behavior) = REQUIRED];
  371. // The writes to apply.
  372. //
  373. // Always executed atomically and in order.
  374. repeated Write writes = 2;
  375. // If set, applies all writes in this transaction, and commits it.
  376. bytes transaction = 3;
  377. }
  378. // The response for [Firestore.Commit][google.firestore.v1beta1.Firestore.Commit].
  379. message CommitResponse {
  380. // The result of applying the writes.
  381. //
  382. // This i-th write result corresponds to the i-th write in the
  383. // request.
  384. repeated WriteResult write_results = 1;
  385. // The time at which the commit occurred. Any read with an equal or greater
  386. // `read_time` is guaranteed to see the effects of the commit.
  387. google.protobuf.Timestamp commit_time = 2;
  388. }
  389. // The request for [Firestore.Rollback][google.firestore.v1beta1.Firestore.Rollback].
  390. message RollbackRequest {
  391. // Required. The database name. In the format:
  392. // `projects/{project_id}/databases/{database_id}`.
  393. string database = 1 [(google.api.field_behavior) = REQUIRED];
  394. // Required. The transaction to roll back.
  395. bytes transaction = 2 [(google.api.field_behavior) = REQUIRED];
  396. }
  397. // The request for [Firestore.RunQuery][google.firestore.v1beta1.Firestore.RunQuery].
  398. message RunQueryRequest {
  399. // Required. The parent resource name. In the format:
  400. // `projects/{project_id}/databases/{database_id}/documents` or
  401. // `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
  402. // For example:
  403. // `projects/my-project/databases/my-database/documents` or
  404. // `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
  405. string parent = 1 [(google.api.field_behavior) = REQUIRED];
  406. // The query to run.
  407. oneof query_type {
  408. // A structured query.
  409. StructuredQuery structured_query = 2;
  410. }
  411. // The consistency mode for this transaction.
  412. // If not set, defaults to strong consistency.
  413. oneof consistency_selector {
  414. // Reads documents in a transaction.
  415. bytes transaction = 5;
  416. // Starts a new transaction and reads the documents.
  417. // Defaults to a read-only transaction.
  418. // The new transaction ID will be returned as the first response in the
  419. // stream.
  420. TransactionOptions new_transaction = 6;
  421. // Reads documents as they were at the given time.
  422. // This may not be older than 270 seconds.
  423. google.protobuf.Timestamp read_time = 7;
  424. }
  425. }
  426. // The response for [Firestore.RunQuery][google.firestore.v1beta1.Firestore.RunQuery].
  427. message RunQueryResponse {
  428. // The transaction that was started as part of this request.
  429. // Can only be set in the first response, and only if
  430. // [RunQueryRequest.new_transaction][google.firestore.v1beta1.RunQueryRequest.new_transaction] was set in the request.
  431. // If set, no other fields will be set in this response.
  432. bytes transaction = 2;
  433. // A query result.
  434. // Not set when reporting partial progress.
  435. Document document = 1;
  436. // The time at which the document was read. This may be monotonically
  437. // increasing; in this case, the previous documents in the result stream are
  438. // guaranteed not to have changed between their `read_time` and this one.
  439. //
  440. // If the query returns no results, a response with `read_time` and no
  441. // `document` will be sent, and this represents the time at which the query
  442. // was run.
  443. google.protobuf.Timestamp read_time = 3;
  444. // The number of results that have been skipped due to an offset between
  445. // the last response and the current response.
  446. int32 skipped_results = 4;
  447. }
  448. // The request for [Firestore.PartitionQuery][google.firestore.v1beta1.Firestore.PartitionQuery].
  449. message PartitionQueryRequest {
  450. // Required. The parent resource name. In the format:
  451. // `projects/{project_id}/databases/{database_id}/documents`.
  452. // Document resource names are not supported; only database resource names
  453. // can be specified.
  454. string parent = 1 [(google.api.field_behavior) = REQUIRED];
  455. // The query to partition.
  456. oneof query_type {
  457. // A structured query.
  458. // Query must specify collection with all descendants and be ordered by name
  459. // ascending. Other filters, order bys, limits, offsets, and start/end
  460. // cursors are not supported.
  461. StructuredQuery structured_query = 2;
  462. }
  463. // The desired maximum number of partition points.
  464. // The partitions may be returned across multiple pages of results.
  465. // The number must be positive. The actual number of partitions
  466. // returned may be fewer.
  467. //
  468. // For example, this may be set to one fewer than the number of parallel
  469. // queries to be run, or in running a data pipeline job, one fewer than the
  470. // number of workers or compute instances available.
  471. int64 partition_count = 3;
  472. // The `next_page_token` value returned from a previous call to
  473. // PartitionQuery that may be used to get an additional set of results.
  474. // There are no ordering guarantees between sets of results. Thus, using
  475. // multiple sets of results will require merging the different result sets.
  476. //
  477. // For example, two subsequent calls using a page_token may return:
  478. //
  479. // * cursor B, cursor M, cursor Q
  480. // * cursor A, cursor U, cursor W
  481. //
  482. // To obtain a complete result set ordered with respect to the results of the
  483. // query supplied to PartitionQuery, the results sets should be merged:
  484. // cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W
  485. string page_token = 4;
  486. // The maximum number of partitions to return in this call, subject to
  487. // `partition_count`.
  488. //
  489. // For example, if `partition_count` = 10 and `page_size` = 8, the first call
  490. // to PartitionQuery will return up to 8 partitions and a `next_page_token`
  491. // if more results exist. A second call to PartitionQuery will return up to
  492. // 2 partitions, to complete the total of 10 specified in `partition_count`.
  493. int32 page_size = 5;
  494. }
  495. // The response for [Firestore.PartitionQuery][google.firestore.v1beta1.Firestore.PartitionQuery].
  496. message PartitionQueryResponse {
  497. // Partition results.
  498. // Each partition is a split point that can be used by RunQuery as a starting
  499. // or end point for the query results. The RunQuery requests must be made with
  500. // the same query supplied to this PartitionQuery request. The partition
  501. // cursors will be ordered according to same ordering as the results of the
  502. // query supplied to PartitionQuery.
  503. //
  504. // For example, if a PartitionQuery request returns partition cursors A and B,
  505. // running the following three queries will return the entire result set of
  506. // the original query:
  507. //
  508. // * query, end_at A
  509. // * query, start_at A, end_at B
  510. // * query, start_at B
  511. //
  512. // An empty result may indicate that the query has too few results to be
  513. // partitioned.
  514. repeated Cursor partitions = 1;
  515. // A page token that may be used to request an additional set of results, up
  516. // to the number specified by `partition_count` in the PartitionQuery request.
  517. // If blank, there are no more results.
  518. string next_page_token = 2;
  519. }
  520. // The request for [Firestore.Write][google.firestore.v1beta1.Firestore.Write].
  521. //
  522. // The first request creates a stream, or resumes an existing one from a token.
  523. //
  524. // When creating a new stream, the server replies with a response containing
  525. // only an ID and a token, to use in the next request.
  526. //
  527. // When resuming a stream, the server first streams any responses later than the
  528. // given token, then a response containing only an up-to-date token, to use in
  529. // the next request.
  530. message WriteRequest {
  531. // Required. The database name. In the format:
  532. // `projects/{project_id}/databases/{database_id}`.
  533. // This is only required in the first message.
  534. string database = 1 [(google.api.field_behavior) = REQUIRED];
  535. // The ID of the write stream to resume.
  536. // This may only be set in the first message. When left empty, a new write
  537. // stream will be created.
  538. string stream_id = 2;
  539. // The writes to apply.
  540. //
  541. // Always executed atomically and in order.
  542. // This must be empty on the first request.
  543. // This may be empty on the last request.
  544. // This must not be empty on all other requests.
  545. repeated Write writes = 3;
  546. // A stream token that was previously sent by the server.
  547. //
  548. // The client should set this field to the token from the most recent
  549. // [WriteResponse][google.firestore.v1beta1.WriteResponse] it has received. This acknowledges that the client has
  550. // received responses up to this token. After sending this token, earlier
  551. // tokens may not be used anymore.
  552. //
  553. // The server may close the stream if there are too many unacknowledged
  554. // responses.
  555. //
  556. // Leave this field unset when creating a new stream. To resume a stream at
  557. // a specific point, set this field and the `stream_id` field.
  558. //
  559. // Leave this field unset when creating a new stream.
  560. bytes stream_token = 4;
  561. // Labels associated with this write request.
  562. map<string, string> labels = 5;
  563. }
  564. // The response for [Firestore.Write][google.firestore.v1beta1.Firestore.Write].
  565. message WriteResponse {
  566. // The ID of the stream.
  567. // Only set on the first message, when a new stream was created.
  568. string stream_id = 1;
  569. // A token that represents the position of this response in the stream.
  570. // This can be used by a client to resume the stream at this point.
  571. //
  572. // This field is always set.
  573. bytes stream_token = 2;
  574. // The result of applying the writes.
  575. //
  576. // This i-th write result corresponds to the i-th write in the
  577. // request.
  578. repeated WriteResult write_results = 3;
  579. // The time at which the commit occurred. Any read with an equal or greater
  580. // `read_time` is guaranteed to see the effects of the write.
  581. google.protobuf.Timestamp commit_time = 4;
  582. }
  583. // A request for [Firestore.Listen][google.firestore.v1beta1.Firestore.Listen]
  584. message ListenRequest {
  585. // Required. The database name. In the format:
  586. // `projects/{project_id}/databases/{database_id}`.
  587. string database = 1 [(google.api.field_behavior) = REQUIRED];
  588. // The supported target changes.
  589. oneof target_change {
  590. // A target to add to this stream.
  591. Target add_target = 2;
  592. // The ID of a target to remove from this stream.
  593. int32 remove_target = 3;
  594. }
  595. // Labels associated with this target change.
  596. map<string, string> labels = 4;
  597. }
  598. // The response for [Firestore.Listen][google.firestore.v1beta1.Firestore.Listen].
  599. message ListenResponse {
  600. // The supported responses.
  601. oneof response_type {
  602. // Targets have changed.
  603. TargetChange target_change = 2;
  604. // A [Document][google.firestore.v1beta1.Document] has changed.
  605. DocumentChange document_change = 3;
  606. // A [Document][google.firestore.v1beta1.Document] has been deleted.
  607. DocumentDelete document_delete = 4;
  608. // A [Document][google.firestore.v1beta1.Document] has been removed from a target (because it is no longer
  609. // relevant to that target).
  610. DocumentRemove document_remove = 6;
  611. // A filter to apply to the set of documents previously returned for the
  612. // given target.
  613. //
  614. // Returned when documents may have been removed from the given target, but
  615. // the exact documents are unknown.
  616. ExistenceFilter filter = 5;
  617. }
  618. }
  619. // A specification of a set of documents to listen to.
  620. message Target {
  621. // A target specified by a set of documents names.
  622. message DocumentsTarget {
  623. // The names of the documents to retrieve. In the format:
  624. // `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
  625. // The request will fail if any of the document is not a child resource of
  626. // the given `database`. Duplicate names will be elided.
  627. repeated string documents = 2;
  628. }
  629. // A target specified by a query.
  630. message QueryTarget {
  631. // The parent resource name. In the format:
  632. // `projects/{project_id}/databases/{database_id}/documents` or
  633. // `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
  634. // For example:
  635. // `projects/my-project/databases/my-database/documents` or
  636. // `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
  637. string parent = 1;
  638. // The query to run.
  639. oneof query_type {
  640. // A structured query.
  641. StructuredQuery structured_query = 2;
  642. }
  643. }
  644. // The type of target to listen to.
  645. oneof target_type {
  646. // A target specified by a query.
  647. QueryTarget query = 2;
  648. // A target specified by a set of document names.
  649. DocumentsTarget documents = 3;
  650. }
  651. // When to start listening.
  652. //
  653. // If not specified, all matching Documents are returned before any
  654. // subsequent changes.
  655. oneof resume_type {
  656. // A resume token from a prior [TargetChange][google.firestore.v1beta1.TargetChange] for an identical target.
  657. //
  658. // Using a resume token with a different target is unsupported and may fail.
  659. bytes resume_token = 4;
  660. // Start listening after a specific `read_time`.
  661. //
  662. // The client must know the state of matching documents at this time.
  663. google.protobuf.Timestamp read_time = 11;
  664. }
  665. // The target ID that identifies the target on the stream. Must be a positive
  666. // number and non-zero.
  667. int32 target_id = 5;
  668. // If the target should be removed once it is current and consistent.
  669. bool once = 6;
  670. }
  671. // Targets being watched have changed.
  672. message TargetChange {
  673. // The type of change.
  674. enum TargetChangeType {
  675. // No change has occurred. Used only to send an updated `resume_token`.
  676. NO_CHANGE = 0;
  677. // The targets have been added.
  678. ADD = 1;
  679. // The targets have been removed.
  680. REMOVE = 2;
  681. // The targets reflect all changes committed before the targets were added
  682. // to the stream.
  683. //
  684. // This will be sent after or with a `read_time` that is greater than or
  685. // equal to the time at which the targets were added.
  686. //
  687. // Listeners can wait for this change if read-after-write semantics
  688. // are desired.
  689. CURRENT = 3;
  690. // The targets have been reset, and a new initial state for the targets
  691. // will be returned in subsequent changes.
  692. //
  693. // After the initial state is complete, `CURRENT` will be returned even
  694. // if the target was previously indicated to be `CURRENT`.
  695. RESET = 4;
  696. }
  697. // The type of change that occurred.
  698. TargetChangeType target_change_type = 1;
  699. // The target IDs of targets that have changed.
  700. //
  701. // If empty, the change applies to all targets.
  702. //
  703. // The order of the target IDs is not defined.
  704. repeated int32 target_ids = 2;
  705. // The error that resulted in this change, if applicable.
  706. google.rpc.Status cause = 3;
  707. // A token that can be used to resume the stream for the given `target_ids`,
  708. // or all targets if `target_ids` is empty.
  709. //
  710. // Not set on every target change.
  711. bytes resume_token = 4;
  712. // The consistent `read_time` for the given `target_ids` (omitted when the
  713. // target_ids are not at a consistent snapshot).
  714. //
  715. // The stream is guaranteed to send a `read_time` with `target_ids` empty
  716. // whenever the entire stream reaches a new consistent snapshot. ADD,
  717. // CURRENT, and RESET messages are guaranteed to (eventually) result in a
  718. // new consistent snapshot (while NO_CHANGE and REMOVE messages are not).
  719. //
  720. // For a given stream, `read_time` is guaranteed to be monotonically
  721. // increasing.
  722. google.protobuf.Timestamp read_time = 6;
  723. }
  724. // The request for [Firestore.ListCollectionIds][google.firestore.v1beta1.Firestore.ListCollectionIds].
  725. message ListCollectionIdsRequest {
  726. // Required. The parent document. In the format:
  727. // `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
  728. // For example:
  729. // `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
  730. string parent = 1 [(google.api.field_behavior) = REQUIRED];
  731. // The maximum number of results to return.
  732. int32 page_size = 2;
  733. // A page token. Must be a value from
  734. // [ListCollectionIdsResponse][google.firestore.v1beta1.ListCollectionIdsResponse].
  735. string page_token = 3;
  736. }
  737. // The response from [Firestore.ListCollectionIds][google.firestore.v1beta1.Firestore.ListCollectionIds].
  738. message ListCollectionIdsResponse {
  739. // The collection ids.
  740. repeated string collection_ids = 1;
  741. // A page token that may be used to continue the list.
  742. string next_page_token = 2;
  743. }
  744. // The request for [Firestore.BatchWrite][google.firestore.v1beta1.Firestore.BatchWrite].
  745. message BatchWriteRequest {
  746. // Required. The database name. In the format:
  747. // `projects/{project_id}/databases/{database_id}`.
  748. string database = 1 [(google.api.field_behavior) = REQUIRED];
  749. // The writes to apply.
  750. //
  751. // Method does not apply writes atomically and does not guarantee ordering.
  752. // Each write succeeds or fails independently. You cannot write to the same
  753. // document more than once per request.
  754. repeated Write writes = 2;
  755. // Labels associated with this batch write.
  756. map<string, string> labels = 3;
  757. }
  758. // The response from [Firestore.BatchWrite][google.firestore.v1beta1.Firestore.BatchWrite].
  759. message BatchWriteResponse {
  760. // The result of applying the writes.
  761. //
  762. // This i-th write result corresponds to the i-th write in the
  763. // request.
  764. repeated WriteResult write_results = 1;
  765. // The status of applying the writes.
  766. //
  767. // This i-th write status corresponds to the i-th write in the
  768. // request.
  769. repeated google.rpc.Status status = 2;
  770. }