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