1# -*- coding: utf-8 -*-
2# Copyright 2025 Google LLC
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16from __future__ import annotations
17
18from typing import MutableMapping, MutableSequence
19
20import proto # type: ignore
21
22from google.cloud.firestore_v1.types import aggregation_result
23from google.cloud.firestore_v1.types import common
24from google.cloud.firestore_v1.types import document as gf_document
25from google.cloud.firestore_v1.types import query as gf_query
26from google.cloud.firestore_v1.types import query_profile
27from google.cloud.firestore_v1.types import write
28from google.protobuf import timestamp_pb2 # type: ignore
29from google.protobuf import wrappers_pb2 # type: ignore
30from google.rpc import status_pb2 # type: ignore
31
32
33__protobuf__ = proto.module(
34 package="google.firestore.v1",
35 manifest={
36 "GetDocumentRequest",
37 "ListDocumentsRequest",
38 "ListDocumentsResponse",
39 "CreateDocumentRequest",
40 "UpdateDocumentRequest",
41 "DeleteDocumentRequest",
42 "BatchGetDocumentsRequest",
43 "BatchGetDocumentsResponse",
44 "BeginTransactionRequest",
45 "BeginTransactionResponse",
46 "CommitRequest",
47 "CommitResponse",
48 "RollbackRequest",
49 "RunQueryRequest",
50 "RunQueryResponse",
51 "RunAggregationQueryRequest",
52 "RunAggregationQueryResponse",
53 "PartitionQueryRequest",
54 "PartitionQueryResponse",
55 "WriteRequest",
56 "WriteResponse",
57 "ListenRequest",
58 "ListenResponse",
59 "Target",
60 "TargetChange",
61 "ListCollectionIdsRequest",
62 "ListCollectionIdsResponse",
63 "BatchWriteRequest",
64 "BatchWriteResponse",
65 },
66)
67
68
69class GetDocumentRequest(proto.Message):
70 r"""The request for
71 [Firestore.GetDocument][google.firestore.v1.Firestore.GetDocument].
72
73 This message has `oneof`_ fields (mutually exclusive fields).
74 For each oneof, at most one member field can be set at the same time.
75 Setting any member of the oneof automatically clears all other
76 members.
77
78 .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
79
80 Attributes:
81 name (str):
82 Required. The resource name of the Document to get. In the
83 format:
84 ``projects/{project_id}/databases/{database_id}/documents/{document_path}``.
85 mask (google.cloud.firestore_v1.types.DocumentMask):
86 The fields to return. If not set, returns all
87 fields.
88 If the document has a field that is not present
89 in this mask, that field will not be returned in
90 the response.
91 transaction (bytes):
92 Reads the document in a transaction.
93
94 This field is a member of `oneof`_ ``consistency_selector``.
95 read_time (google.protobuf.timestamp_pb2.Timestamp):
96 Reads the version of the document at the
97 given time.
98 This must be a microsecond precision timestamp
99 within the past one hour, or if Point-in-Time
100 Recovery is enabled, can additionally be a whole
101 minute timestamp within the past 7 days.
102
103 This field is a member of `oneof`_ ``consistency_selector``.
104 """
105
106 name: str = proto.Field(
107 proto.STRING,
108 number=1,
109 )
110 mask: common.DocumentMask = proto.Field(
111 proto.MESSAGE,
112 number=2,
113 message=common.DocumentMask,
114 )
115 transaction: bytes = proto.Field(
116 proto.BYTES,
117 number=3,
118 oneof="consistency_selector",
119 )
120 read_time: timestamp_pb2.Timestamp = proto.Field(
121 proto.MESSAGE,
122 number=5,
123 oneof="consistency_selector",
124 message=timestamp_pb2.Timestamp,
125 )
126
127
128class ListDocumentsRequest(proto.Message):
129 r"""The request for
130 [Firestore.ListDocuments][google.firestore.v1.Firestore.ListDocuments].
131
132 This message has `oneof`_ fields (mutually exclusive fields).
133 For each oneof, at most one member field can be set at the same time.
134 Setting any member of the oneof automatically clears all other
135 members.
136
137 .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
138
139 Attributes:
140 parent (str):
141 Required. The parent resource name. In the format:
142 ``projects/{project_id}/databases/{database_id}/documents``
143 or
144 ``projects/{project_id}/databases/{database_id}/documents/{document_path}``.
145
146 For example:
147 ``projects/my-project/databases/my-database/documents`` or
148 ``projects/my-project/databases/my-database/documents/chatrooms/my-chatroom``
149 collection_id (str):
150 Optional. The collection ID, relative to ``parent``, to
151 list.
152
153 For example: ``chatrooms`` or ``messages``.
154
155 This is optional, and when not provided, Firestore will list
156 documents from all collections under the provided
157 ``parent``.
158 page_size (int):
159 Optional. The maximum number of documents to
160 return in a single response.
161 Firestore may return fewer than this value.
162 page_token (str):
163 Optional. A page token, received from a previous
164 ``ListDocuments`` response.
165
166 Provide this to retrieve the subsequent page. When
167 paginating, all other parameters (with the exception of
168 ``page_size``) must match the values set in the request that
169 generated the page token.
170 order_by (str):
171 Optional. The optional ordering of the documents to return.
172
173 For example: ``priority desc, __name__ desc``.
174
175 This mirrors the
176 [``ORDER BY``][google.firestore.v1.StructuredQuery.order_by]
177 used in Firestore queries but in a string representation.
178 When absent, documents are ordered based on
179 ``__name__ ASC``.
180 mask (google.cloud.firestore_v1.types.DocumentMask):
181 Optional. The fields to return. If not set,
182 returns all fields.
183 If a document has a field that is not present in
184 this mask, that field will not be returned in
185 the response.
186 transaction (bytes):
187 Perform the read as part of an already active
188 transaction.
189
190 This field is a member of `oneof`_ ``consistency_selector``.
191 read_time (google.protobuf.timestamp_pb2.Timestamp):
192 Perform the read at the provided time.
193
194 This must be a microsecond precision timestamp
195 within the past one hour, or if Point-in-Time
196 Recovery is enabled, can additionally be a whole
197 minute timestamp within the past 7 days.
198
199 This field is a member of `oneof`_ ``consistency_selector``.
200 show_missing (bool):
201 If the list should show missing documents.
202
203 A document is missing if it does not exist, but there are
204 sub-documents nested underneath it. When true, such missing
205 documents will be returned with a key but will not have
206 fields,
207 [``create_time``][google.firestore.v1.Document.create_time],
208 or
209 [``update_time``][google.firestore.v1.Document.update_time]
210 set.
211
212 Requests with ``show_missing`` may not specify ``where`` or
213 ``order_by``.
214 """
215
216 parent: str = proto.Field(
217 proto.STRING,
218 number=1,
219 )
220 collection_id: str = proto.Field(
221 proto.STRING,
222 number=2,
223 )
224 page_size: int = proto.Field(
225 proto.INT32,
226 number=3,
227 )
228 page_token: str = proto.Field(
229 proto.STRING,
230 number=4,
231 )
232 order_by: str = proto.Field(
233 proto.STRING,
234 number=6,
235 )
236 mask: common.DocumentMask = proto.Field(
237 proto.MESSAGE,
238 number=7,
239 message=common.DocumentMask,
240 )
241 transaction: bytes = proto.Field(
242 proto.BYTES,
243 number=8,
244 oneof="consistency_selector",
245 )
246 read_time: timestamp_pb2.Timestamp = proto.Field(
247 proto.MESSAGE,
248 number=10,
249 oneof="consistency_selector",
250 message=timestamp_pb2.Timestamp,
251 )
252 show_missing: bool = proto.Field(
253 proto.BOOL,
254 number=12,
255 )
256
257
258class ListDocumentsResponse(proto.Message):
259 r"""The response for
260 [Firestore.ListDocuments][google.firestore.v1.Firestore.ListDocuments].
261
262 Attributes:
263 documents (MutableSequence[google.cloud.firestore_v1.types.Document]):
264 The Documents found.
265 next_page_token (str):
266 A token to retrieve the next page of
267 documents.
268 If this field is omitted, there are no
269 subsequent pages.
270 """
271
272 @property
273 def raw_page(self):
274 return self
275
276 documents: MutableSequence[gf_document.Document] = proto.RepeatedField(
277 proto.MESSAGE,
278 number=1,
279 message=gf_document.Document,
280 )
281 next_page_token: str = proto.Field(
282 proto.STRING,
283 number=2,
284 )
285
286
287class CreateDocumentRequest(proto.Message):
288 r"""The request for
289 [Firestore.CreateDocument][google.firestore.v1.Firestore.CreateDocument].
290
291 Attributes:
292 parent (str):
293 Required. The parent resource. For example:
294 ``projects/{project_id}/databases/{database_id}/documents``
295 or
296 ``projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}``
297 collection_id (str):
298 Required. The collection ID, relative to ``parent``, to
299 list. For example: ``chatrooms``.
300 document_id (str):
301 The client-assigned document ID to use for
302 this document.
303 Optional. If not specified, an ID will be
304 assigned by the service.
305 document (google.cloud.firestore_v1.types.Document):
306 Required. The document to create. ``name`` must not be set.
307 mask (google.cloud.firestore_v1.types.DocumentMask):
308 The fields to return. If not set, returns all
309 fields.
310 If the document has a field that is not present
311 in this mask, that field will not be returned in
312 the response.
313 """
314
315 parent: str = proto.Field(
316 proto.STRING,
317 number=1,
318 )
319 collection_id: str = proto.Field(
320 proto.STRING,
321 number=2,
322 )
323 document_id: str = proto.Field(
324 proto.STRING,
325 number=3,
326 )
327 document: gf_document.Document = proto.Field(
328 proto.MESSAGE,
329 number=4,
330 message=gf_document.Document,
331 )
332 mask: common.DocumentMask = proto.Field(
333 proto.MESSAGE,
334 number=5,
335 message=common.DocumentMask,
336 )
337
338
339class UpdateDocumentRequest(proto.Message):
340 r"""The request for
341 [Firestore.UpdateDocument][google.firestore.v1.Firestore.UpdateDocument].
342
343 Attributes:
344 document (google.cloud.firestore_v1.types.Document):
345 Required. The updated document.
346 Creates the document if it does not already
347 exist.
348 update_mask (google.cloud.firestore_v1.types.DocumentMask):
349 The fields to update.
350 None of the field paths in the mask may contain
351 a reserved name.
352
353 If the document exists on the server and has
354 fields not referenced in the mask, they are left
355 unchanged.
356 Fields referenced in the mask, but not present
357 in the input document, are deleted from the
358 document on the server.
359 mask (google.cloud.firestore_v1.types.DocumentMask):
360 The fields to return. If not set, returns all
361 fields.
362 If the document has a field that is not present
363 in this mask, that field will not be returned in
364 the response.
365 current_document (google.cloud.firestore_v1.types.Precondition):
366 An optional precondition on the document.
367 The request will fail if this is set and not met
368 by the target document.
369 """
370
371 document: gf_document.Document = proto.Field(
372 proto.MESSAGE,
373 number=1,
374 message=gf_document.Document,
375 )
376 update_mask: common.DocumentMask = proto.Field(
377 proto.MESSAGE,
378 number=2,
379 message=common.DocumentMask,
380 )
381 mask: common.DocumentMask = proto.Field(
382 proto.MESSAGE,
383 number=3,
384 message=common.DocumentMask,
385 )
386 current_document: common.Precondition = proto.Field(
387 proto.MESSAGE,
388 number=4,
389 message=common.Precondition,
390 )
391
392
393class DeleteDocumentRequest(proto.Message):
394 r"""The request for
395 [Firestore.DeleteDocument][google.firestore.v1.Firestore.DeleteDocument].
396
397 Attributes:
398 name (str):
399 Required. The resource name of the Document to delete. In
400 the format:
401 ``projects/{project_id}/databases/{database_id}/documents/{document_path}``.
402 current_document (google.cloud.firestore_v1.types.Precondition):
403 An optional precondition on the document.
404 The request will fail if this is set and not met
405 by the target document.
406 """
407
408 name: str = proto.Field(
409 proto.STRING,
410 number=1,
411 )
412 current_document: common.Precondition = proto.Field(
413 proto.MESSAGE,
414 number=2,
415 message=common.Precondition,
416 )
417
418
419class BatchGetDocumentsRequest(proto.Message):
420 r"""The request for
421 [Firestore.BatchGetDocuments][google.firestore.v1.Firestore.BatchGetDocuments].
422
423 This message has `oneof`_ fields (mutually exclusive fields).
424 For each oneof, at most one member field can be set at the same time.
425 Setting any member of the oneof automatically clears all other
426 members.
427
428 .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
429
430 Attributes:
431 database (str):
432 Required. The database name. In the format:
433 ``projects/{project_id}/databases/{database_id}``.
434 documents (MutableSequence[str]):
435 The names of the documents to retrieve. In the format:
436 ``projects/{project_id}/databases/{database_id}/documents/{document_path}``.
437 The request will fail if any of the document is not a child
438 resource of the given ``database``. Duplicate names will be
439 elided.
440 mask (google.cloud.firestore_v1.types.DocumentMask):
441 The fields to return. If not set, returns all
442 fields.
443 If a document has a field that is not present in
444 this mask, that field will not be returned in
445 the response.
446 transaction (bytes):
447 Reads documents in a transaction.
448
449 This field is a member of `oneof`_ ``consistency_selector``.
450 new_transaction (google.cloud.firestore_v1.types.TransactionOptions):
451 Starts a new transaction and reads the
452 documents. Defaults to a read-only transaction.
453 The new transaction ID will be returned as the
454 first response in the stream.
455
456 This field is a member of `oneof`_ ``consistency_selector``.
457 read_time (google.protobuf.timestamp_pb2.Timestamp):
458 Reads documents as they were at the given
459 time.
460 This must be a microsecond precision timestamp
461 within the past one hour, or if Point-in-Time
462 Recovery is enabled, can additionally be a whole
463 minute timestamp within the past 7 days.
464
465 This field is a member of `oneof`_ ``consistency_selector``.
466 """
467
468 database: str = proto.Field(
469 proto.STRING,
470 number=1,
471 )
472 documents: MutableSequence[str] = proto.RepeatedField(
473 proto.STRING,
474 number=2,
475 )
476 mask: common.DocumentMask = proto.Field(
477 proto.MESSAGE,
478 number=3,
479 message=common.DocumentMask,
480 )
481 transaction: bytes = proto.Field(
482 proto.BYTES,
483 number=4,
484 oneof="consistency_selector",
485 )
486 new_transaction: common.TransactionOptions = proto.Field(
487 proto.MESSAGE,
488 number=5,
489 oneof="consistency_selector",
490 message=common.TransactionOptions,
491 )
492 read_time: timestamp_pb2.Timestamp = proto.Field(
493 proto.MESSAGE,
494 number=7,
495 oneof="consistency_selector",
496 message=timestamp_pb2.Timestamp,
497 )
498
499
500class BatchGetDocumentsResponse(proto.Message):
501 r"""The streamed response for
502 [Firestore.BatchGetDocuments][google.firestore.v1.Firestore.BatchGetDocuments].
503
504 This message has `oneof`_ fields (mutually exclusive fields).
505 For each oneof, at most one member field can be set at the same time.
506 Setting any member of the oneof automatically clears all other
507 members.
508
509 .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
510
511 Attributes:
512 found (google.cloud.firestore_v1.types.Document):
513 A document that was requested.
514
515 This field is a member of `oneof`_ ``result``.
516 missing (str):
517 A document name that was requested but does not exist. In
518 the format:
519 ``projects/{project_id}/databases/{database_id}/documents/{document_path}``.
520
521 This field is a member of `oneof`_ ``result``.
522 transaction (bytes):
523 The transaction that was started as part of this request.
524 Will only be set in the first response, and only if
525 [BatchGetDocumentsRequest.new_transaction][google.firestore.v1.BatchGetDocumentsRequest.new_transaction]
526 was set in the request.
527 read_time (google.protobuf.timestamp_pb2.Timestamp):
528 The time at which the document was read. This may be
529 monotically increasing, in this case the previous documents
530 in the result stream are guaranteed not to have changed
531 between their read_time and this one.
532 """
533
534 found: gf_document.Document = proto.Field(
535 proto.MESSAGE,
536 number=1,
537 oneof="result",
538 message=gf_document.Document,
539 )
540 missing: str = proto.Field(
541 proto.STRING,
542 number=2,
543 oneof="result",
544 )
545 transaction: bytes = proto.Field(
546 proto.BYTES,
547 number=3,
548 )
549 read_time: timestamp_pb2.Timestamp = proto.Field(
550 proto.MESSAGE,
551 number=4,
552 message=timestamp_pb2.Timestamp,
553 )
554
555
556class BeginTransactionRequest(proto.Message):
557 r"""The request for
558 [Firestore.BeginTransaction][google.firestore.v1.Firestore.BeginTransaction].
559
560 Attributes:
561 database (str):
562 Required. The database name. In the format:
563 ``projects/{project_id}/databases/{database_id}``.
564 options (google.cloud.firestore_v1.types.TransactionOptions):
565 The options for the transaction.
566 Defaults to a read-write transaction.
567 """
568
569 database: str = proto.Field(
570 proto.STRING,
571 number=1,
572 )
573 options: common.TransactionOptions = proto.Field(
574 proto.MESSAGE,
575 number=2,
576 message=common.TransactionOptions,
577 )
578
579
580class BeginTransactionResponse(proto.Message):
581 r"""The response for
582 [Firestore.BeginTransaction][google.firestore.v1.Firestore.BeginTransaction].
583
584 Attributes:
585 transaction (bytes):
586 The transaction that was started.
587 """
588
589 transaction: bytes = proto.Field(
590 proto.BYTES,
591 number=1,
592 )
593
594
595class CommitRequest(proto.Message):
596 r"""The request for
597 [Firestore.Commit][google.firestore.v1.Firestore.Commit].
598
599 Attributes:
600 database (str):
601 Required. The database name. In the format:
602 ``projects/{project_id}/databases/{database_id}``.
603 writes (MutableSequence[google.cloud.firestore_v1.types.Write]):
604 The writes to apply.
605
606 Always executed atomically and in order.
607 transaction (bytes):
608 If set, applies all writes in this
609 transaction, and commits it.
610 """
611
612 database: str = proto.Field(
613 proto.STRING,
614 number=1,
615 )
616 writes: MutableSequence[write.Write] = proto.RepeatedField(
617 proto.MESSAGE,
618 number=2,
619 message=write.Write,
620 )
621 transaction: bytes = proto.Field(
622 proto.BYTES,
623 number=3,
624 )
625
626
627class CommitResponse(proto.Message):
628 r"""The response for
629 [Firestore.Commit][google.firestore.v1.Firestore.Commit].
630
631 Attributes:
632 write_results (MutableSequence[google.cloud.firestore_v1.types.WriteResult]):
633 The result of applying the writes.
634
635 This i-th write result corresponds to the i-th
636 write in the request.
637 commit_time (google.protobuf.timestamp_pb2.Timestamp):
638 The time at which the commit occurred. Any read with an
639 equal or greater ``read_time`` is guaranteed to see the
640 effects of the commit.
641 """
642
643 write_results: MutableSequence[write.WriteResult] = proto.RepeatedField(
644 proto.MESSAGE,
645 number=1,
646 message=write.WriteResult,
647 )
648 commit_time: timestamp_pb2.Timestamp = proto.Field(
649 proto.MESSAGE,
650 number=2,
651 message=timestamp_pb2.Timestamp,
652 )
653
654
655class RollbackRequest(proto.Message):
656 r"""The request for
657 [Firestore.Rollback][google.firestore.v1.Firestore.Rollback].
658
659 Attributes:
660 database (str):
661 Required. The database name. In the format:
662 ``projects/{project_id}/databases/{database_id}``.
663 transaction (bytes):
664 Required. The transaction to roll back.
665 """
666
667 database: str = proto.Field(
668 proto.STRING,
669 number=1,
670 )
671 transaction: bytes = proto.Field(
672 proto.BYTES,
673 number=2,
674 )
675
676
677class RunQueryRequest(proto.Message):
678 r"""The request for
679 [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery].
680
681 This message has `oneof`_ fields (mutually exclusive fields).
682 For each oneof, at most one member field can be set at the same time.
683 Setting any member of the oneof automatically clears all other
684 members.
685
686 .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
687
688 Attributes:
689 parent (str):
690 Required. The parent resource name. In the format:
691 ``projects/{project_id}/databases/{database_id}/documents``
692 or
693 ``projects/{project_id}/databases/{database_id}/documents/{document_path}``.
694 For example:
695 ``projects/my-project/databases/my-database/documents`` or
696 ``projects/my-project/databases/my-database/documents/chatrooms/my-chatroom``
697 structured_query (google.cloud.firestore_v1.types.StructuredQuery):
698 A structured query.
699
700 This field is a member of `oneof`_ ``query_type``.
701 transaction (bytes):
702 Run the query within an already active
703 transaction.
704 The value here is the opaque transaction ID to
705 execute the query in.
706
707 This field is a member of `oneof`_ ``consistency_selector``.
708 new_transaction (google.cloud.firestore_v1.types.TransactionOptions):
709 Starts a new transaction and reads the
710 documents. Defaults to a read-only transaction.
711 The new transaction ID will be returned as the
712 first response in the stream.
713
714 This field is a member of `oneof`_ ``consistency_selector``.
715 read_time (google.protobuf.timestamp_pb2.Timestamp):
716 Reads documents as they were at the given
717 time.
718 This must be a microsecond precision timestamp
719 within the past one hour, or if Point-in-Time
720 Recovery is enabled, can additionally be a whole
721 minute timestamp within the past 7 days.
722
723 This field is a member of `oneof`_ ``consistency_selector``.
724 explain_options (google.cloud.firestore_v1.types.ExplainOptions):
725 Optional. Explain options for the query. If
726 set, additional query statistics will be
727 returned. If not, only query results will be
728 returned.
729 """
730
731 parent: str = proto.Field(
732 proto.STRING,
733 number=1,
734 )
735 structured_query: gf_query.StructuredQuery = proto.Field(
736 proto.MESSAGE,
737 number=2,
738 oneof="query_type",
739 message=gf_query.StructuredQuery,
740 )
741 transaction: bytes = proto.Field(
742 proto.BYTES,
743 number=5,
744 oneof="consistency_selector",
745 )
746 new_transaction: common.TransactionOptions = proto.Field(
747 proto.MESSAGE,
748 number=6,
749 oneof="consistency_selector",
750 message=common.TransactionOptions,
751 )
752 read_time: timestamp_pb2.Timestamp = proto.Field(
753 proto.MESSAGE,
754 number=7,
755 oneof="consistency_selector",
756 message=timestamp_pb2.Timestamp,
757 )
758 explain_options: query_profile.ExplainOptions = proto.Field(
759 proto.MESSAGE,
760 number=10,
761 message=query_profile.ExplainOptions,
762 )
763
764
765class RunQueryResponse(proto.Message):
766 r"""The response for
767 [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery].
768
769
770 .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
771
772 Attributes:
773 transaction (bytes):
774 The transaction that was started as part of this request.
775 Can only be set in the first response, and only if
776 [RunQueryRequest.new_transaction][google.firestore.v1.RunQueryRequest.new_transaction]
777 was set in the request. If set, no other fields will be set
778 in this response.
779 document (google.cloud.firestore_v1.types.Document):
780 A query result, not set when reporting
781 partial progress.
782 read_time (google.protobuf.timestamp_pb2.Timestamp):
783 The time at which the document was read. This may be
784 monotonically increasing; in this case, the previous
785 documents in the result stream are guaranteed not to have
786 changed between their ``read_time`` and this one.
787
788 If the query returns no results, a response with
789 ``read_time`` and no ``document`` will be sent, and this
790 represents the time at which the query was run.
791 skipped_results (int):
792 The number of results that have been skipped
793 due to an offset between the last response and
794 the current response.
795 done (bool):
796 If present, Firestore has completely finished
797 the request and no more documents will be
798 returned.
799
800 This field is a member of `oneof`_ ``continuation_selector``.
801 explain_metrics (google.cloud.firestore_v1.types.ExplainMetrics):
802 Query explain metrics. This is only present when the
803 [RunQueryRequest.explain_options][google.firestore.v1.RunQueryRequest.explain_options]
804 is provided, and it is sent only once with the last response
805 in the stream.
806 """
807
808 transaction: bytes = proto.Field(
809 proto.BYTES,
810 number=2,
811 )
812 document: gf_document.Document = proto.Field(
813 proto.MESSAGE,
814 number=1,
815 message=gf_document.Document,
816 )
817 read_time: timestamp_pb2.Timestamp = proto.Field(
818 proto.MESSAGE,
819 number=3,
820 message=timestamp_pb2.Timestamp,
821 )
822 skipped_results: int = proto.Field(
823 proto.INT32,
824 number=4,
825 )
826 done: bool = proto.Field(
827 proto.BOOL,
828 number=6,
829 oneof="continuation_selector",
830 )
831 explain_metrics: query_profile.ExplainMetrics = proto.Field(
832 proto.MESSAGE,
833 number=11,
834 message=query_profile.ExplainMetrics,
835 )
836
837
838class RunAggregationQueryRequest(proto.Message):
839 r"""The request for
840 [Firestore.RunAggregationQuery][google.firestore.v1.Firestore.RunAggregationQuery].
841
842 This message has `oneof`_ fields (mutually exclusive fields).
843 For each oneof, at most one member field can be set at the same time.
844 Setting any member of the oneof automatically clears all other
845 members.
846
847 .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
848
849 Attributes:
850 parent (str):
851 Required. The parent resource name. In the format:
852 ``projects/{project_id}/databases/{database_id}/documents``
853 or
854 ``projects/{project_id}/databases/{database_id}/documents/{document_path}``.
855 For example:
856 ``projects/my-project/databases/my-database/documents`` or
857 ``projects/my-project/databases/my-database/documents/chatrooms/my-chatroom``
858 structured_aggregation_query (google.cloud.firestore_v1.types.StructuredAggregationQuery):
859 An aggregation query.
860
861 This field is a member of `oneof`_ ``query_type``.
862 transaction (bytes):
863 Run the aggregation within an already active
864 transaction.
865 The value here is the opaque transaction ID to
866 execute the query in.
867
868 This field is a member of `oneof`_ ``consistency_selector``.
869 new_transaction (google.cloud.firestore_v1.types.TransactionOptions):
870 Starts a new transaction as part of the
871 query, defaulting to read-only.
872 The new transaction ID will be returned as the
873 first response in the stream.
874
875 This field is a member of `oneof`_ ``consistency_selector``.
876 read_time (google.protobuf.timestamp_pb2.Timestamp):
877 Executes the query at the given timestamp.
878
879 This must be a microsecond precision timestamp
880 within the past one hour, or if Point-in-Time
881 Recovery is enabled, can additionally be a whole
882 minute timestamp within the past 7 days.
883
884 This field is a member of `oneof`_ ``consistency_selector``.
885 explain_options (google.cloud.firestore_v1.types.ExplainOptions):
886 Optional. Explain options for the query. If
887 set, additional query statistics will be
888 returned. If not, only query results will be
889 returned.
890 """
891
892 parent: str = proto.Field(
893 proto.STRING,
894 number=1,
895 )
896 structured_aggregation_query: gf_query.StructuredAggregationQuery = proto.Field(
897 proto.MESSAGE,
898 number=2,
899 oneof="query_type",
900 message=gf_query.StructuredAggregationQuery,
901 )
902 transaction: bytes = proto.Field(
903 proto.BYTES,
904 number=4,
905 oneof="consistency_selector",
906 )
907 new_transaction: common.TransactionOptions = proto.Field(
908 proto.MESSAGE,
909 number=5,
910 oneof="consistency_selector",
911 message=common.TransactionOptions,
912 )
913 read_time: timestamp_pb2.Timestamp = proto.Field(
914 proto.MESSAGE,
915 number=6,
916 oneof="consistency_selector",
917 message=timestamp_pb2.Timestamp,
918 )
919 explain_options: query_profile.ExplainOptions = proto.Field(
920 proto.MESSAGE,
921 number=8,
922 message=query_profile.ExplainOptions,
923 )
924
925
926class RunAggregationQueryResponse(proto.Message):
927 r"""The response for
928 [Firestore.RunAggregationQuery][google.firestore.v1.Firestore.RunAggregationQuery].
929
930 Attributes:
931 result (google.cloud.firestore_v1.types.AggregationResult):
932 A single aggregation result.
933
934 Not present when reporting partial progress.
935 transaction (bytes):
936 The transaction that was started as part of
937 this request.
938 Only present on the first response when the
939 request requested to start a new transaction.
940 read_time (google.protobuf.timestamp_pb2.Timestamp):
941 The time at which the aggregate result was computed. This is
942 always monotonically increasing; in this case, the previous
943 AggregationResult in the result stream are guaranteed not to
944 have changed between their ``read_time`` and this one.
945
946 If the query returns no results, a response with
947 ``read_time`` and no ``result`` will be sent, and this
948 represents the time at which the query was run.
949 explain_metrics (google.cloud.firestore_v1.types.ExplainMetrics):
950 Query explain metrics. This is only present when the
951 [RunAggregationQueryRequest.explain_options][google.firestore.v1.RunAggregationQueryRequest.explain_options]
952 is provided, and it is sent only once with the last response
953 in the stream.
954 """
955
956 result: aggregation_result.AggregationResult = proto.Field(
957 proto.MESSAGE,
958 number=1,
959 message=aggregation_result.AggregationResult,
960 )
961 transaction: bytes = proto.Field(
962 proto.BYTES,
963 number=2,
964 )
965 read_time: timestamp_pb2.Timestamp = proto.Field(
966 proto.MESSAGE,
967 number=3,
968 message=timestamp_pb2.Timestamp,
969 )
970 explain_metrics: query_profile.ExplainMetrics = proto.Field(
971 proto.MESSAGE,
972 number=10,
973 message=query_profile.ExplainMetrics,
974 )
975
976
977class PartitionQueryRequest(proto.Message):
978 r"""The request for
979 [Firestore.PartitionQuery][google.firestore.v1.Firestore.PartitionQuery].
980
981
982 .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
983
984 Attributes:
985 parent (str):
986 Required. The parent resource name. In the format:
987 ``projects/{project_id}/databases/{database_id}/documents``.
988 Document resource names are not supported; only database
989 resource names can be specified.
990 structured_query (google.cloud.firestore_v1.types.StructuredQuery):
991 A structured query.
992 Query must specify collection with all
993 descendants and be ordered by name ascending.
994 Other filters, order bys, limits, offsets, and
995 start/end cursors are not supported.
996
997 This field is a member of `oneof`_ ``query_type``.
998 partition_count (int):
999 The desired maximum number of partition
1000 points. The partitions may be returned across
1001 multiple pages of results. The number must be
1002 positive. The actual number of partitions
1003 returned may be fewer.
1004
1005 For example, this may be set to one fewer than
1006 the number of parallel queries to be run, or in
1007 running a data pipeline job, one fewer than the
1008 number of workers or compute instances
1009 available.
1010 page_token (str):
1011 The ``next_page_token`` value returned from a previous call
1012 to PartitionQuery that may be used to get an additional set
1013 of results. There are no ordering guarantees between sets of
1014 results. Thus, using multiple sets of results will require
1015 merging the different result sets.
1016
1017 For example, two subsequent calls using a page_token may
1018 return:
1019
1020 - cursor B, cursor M, cursor Q
1021 - cursor A, cursor U, cursor W
1022
1023 To obtain a complete result set ordered with respect to the
1024 results of the query supplied to PartitionQuery, the results
1025 sets should be merged: cursor A, cursor B, cursor M, cursor
1026 Q, cursor U, cursor W
1027 page_size (int):
1028 The maximum number of partitions to return in this call,
1029 subject to ``partition_count``.
1030
1031 For example, if ``partition_count`` = 10 and ``page_size`` =
1032 8, the first call to PartitionQuery will return up to 8
1033 partitions and a ``next_page_token`` if more results exist.
1034 A second call to PartitionQuery will return up to 2
1035 partitions, to complete the total of 10 specified in
1036 ``partition_count``.
1037 read_time (google.protobuf.timestamp_pb2.Timestamp):
1038 Reads documents as they were at the given
1039 time.
1040 This must be a microsecond precision timestamp
1041 within the past one hour, or if Point-in-Time
1042 Recovery is enabled, can additionally be a whole
1043 minute timestamp within the past 7 days.
1044
1045 This field is a member of `oneof`_ ``consistency_selector``.
1046 """
1047
1048 parent: str = proto.Field(
1049 proto.STRING,
1050 number=1,
1051 )
1052 structured_query: gf_query.StructuredQuery = proto.Field(
1053 proto.MESSAGE,
1054 number=2,
1055 oneof="query_type",
1056 message=gf_query.StructuredQuery,
1057 )
1058 partition_count: int = proto.Field(
1059 proto.INT64,
1060 number=3,
1061 )
1062 page_token: str = proto.Field(
1063 proto.STRING,
1064 number=4,
1065 )
1066 page_size: int = proto.Field(
1067 proto.INT32,
1068 number=5,
1069 )
1070 read_time: timestamp_pb2.Timestamp = proto.Field(
1071 proto.MESSAGE,
1072 number=6,
1073 oneof="consistency_selector",
1074 message=timestamp_pb2.Timestamp,
1075 )
1076
1077
1078class PartitionQueryResponse(proto.Message):
1079 r"""The response for
1080 [Firestore.PartitionQuery][google.firestore.v1.Firestore.PartitionQuery].
1081
1082 Attributes:
1083 partitions (MutableSequence[google.cloud.firestore_v1.types.Cursor]):
1084 Partition results. Each partition is a split point that can
1085 be used by RunQuery as a starting or end point for the query
1086 results. The RunQuery requests must be made with the same
1087 query supplied to this PartitionQuery request. The partition
1088 cursors will be ordered according to same ordering as the
1089 results of the query supplied to PartitionQuery.
1090
1091 For example, if a PartitionQuery request returns partition
1092 cursors A and B, running the following three queries will
1093 return the entire result set of the original query:
1094
1095 - query, end_at A
1096 - query, start_at A, end_at B
1097 - query, start_at B
1098
1099 An empty result may indicate that the query has too few
1100 results to be partitioned, or that the query is not yet
1101 supported for partitioning.
1102 next_page_token (str):
1103 A page token that may be used to request an additional set
1104 of results, up to the number specified by
1105 ``partition_count`` in the PartitionQuery request. If blank,
1106 there are no more results.
1107 """
1108
1109 @property
1110 def raw_page(self):
1111 return self
1112
1113 partitions: MutableSequence[gf_query.Cursor] = proto.RepeatedField(
1114 proto.MESSAGE,
1115 number=1,
1116 message=gf_query.Cursor,
1117 )
1118 next_page_token: str = proto.Field(
1119 proto.STRING,
1120 number=2,
1121 )
1122
1123
1124class WriteRequest(proto.Message):
1125 r"""The request for
1126 [Firestore.Write][google.firestore.v1.Firestore.Write].
1127
1128 The first request creates a stream, or resumes an existing one from
1129 a token.
1130
1131 When creating a new stream, the server replies with a response
1132 containing only an ID and a token, to use in the next request.
1133
1134 When resuming a stream, the server first streams any responses later
1135 than the given token, then a response containing only an up-to-date
1136 token, to use in the next request.
1137
1138 Attributes:
1139 database (str):
1140 Required. The database name. In the format:
1141 ``projects/{project_id}/databases/{database_id}``. This is
1142 only required in the first message.
1143 stream_id (str):
1144 The ID of the write stream to resume.
1145 This may only be set in the first message. When
1146 left empty, a new write stream will be created.
1147 writes (MutableSequence[google.cloud.firestore_v1.types.Write]):
1148 The writes to apply.
1149
1150 Always executed atomically and in order.
1151 This must be empty on the first request.
1152 This may be empty on the last request.
1153 This must not be empty on all other requests.
1154 stream_token (bytes):
1155 A stream token that was previously sent by the server.
1156
1157 The client should set this field to the token from the most
1158 recent [WriteResponse][google.firestore.v1.WriteResponse] it
1159 has received. This acknowledges that the client has received
1160 responses up to this token. After sending this token,
1161 earlier tokens may not be used anymore.
1162
1163 The server may close the stream if there are too many
1164 unacknowledged responses.
1165
1166 Leave this field unset when creating a new stream. To resume
1167 a stream at a specific point, set this field and the
1168 ``stream_id`` field.
1169
1170 Leave this field unset when creating a new stream.
1171 labels (MutableMapping[str, str]):
1172 Labels associated with this write request.
1173 """
1174
1175 database: str = proto.Field(
1176 proto.STRING,
1177 number=1,
1178 )
1179 stream_id: str = proto.Field(
1180 proto.STRING,
1181 number=2,
1182 )
1183 writes: MutableSequence[write.Write] = proto.RepeatedField(
1184 proto.MESSAGE,
1185 number=3,
1186 message=write.Write,
1187 )
1188 stream_token: bytes = proto.Field(
1189 proto.BYTES,
1190 number=4,
1191 )
1192 labels: MutableMapping[str, str] = proto.MapField(
1193 proto.STRING,
1194 proto.STRING,
1195 number=5,
1196 )
1197
1198
1199class WriteResponse(proto.Message):
1200 r"""The response for
1201 [Firestore.Write][google.firestore.v1.Firestore.Write].
1202
1203 Attributes:
1204 stream_id (str):
1205 The ID of the stream.
1206 Only set on the first message, when a new stream
1207 was created.
1208 stream_token (bytes):
1209 A token that represents the position of this
1210 response in the stream. This can be used by a
1211 client to resume the stream at this point.
1212
1213 This field is always set.
1214 write_results (MutableSequence[google.cloud.firestore_v1.types.WriteResult]):
1215 The result of applying the writes.
1216
1217 This i-th write result corresponds to the i-th
1218 write in the request.
1219 commit_time (google.protobuf.timestamp_pb2.Timestamp):
1220 The time at which the commit occurred. Any read with an
1221 equal or greater ``read_time`` is guaranteed to see the
1222 effects of the write.
1223 """
1224
1225 stream_id: str = proto.Field(
1226 proto.STRING,
1227 number=1,
1228 )
1229 stream_token: bytes = proto.Field(
1230 proto.BYTES,
1231 number=2,
1232 )
1233 write_results: MutableSequence[write.WriteResult] = proto.RepeatedField(
1234 proto.MESSAGE,
1235 number=3,
1236 message=write.WriteResult,
1237 )
1238 commit_time: timestamp_pb2.Timestamp = proto.Field(
1239 proto.MESSAGE,
1240 number=4,
1241 message=timestamp_pb2.Timestamp,
1242 )
1243
1244
1245class ListenRequest(proto.Message):
1246 r"""A request for
1247 [Firestore.Listen][google.firestore.v1.Firestore.Listen]
1248
1249 This message has `oneof`_ fields (mutually exclusive fields).
1250 For each oneof, at most one member field can be set at the same time.
1251 Setting any member of the oneof automatically clears all other
1252 members.
1253
1254 .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
1255
1256 Attributes:
1257 database (str):
1258 Required. The database name. In the format:
1259 ``projects/{project_id}/databases/{database_id}``.
1260 add_target (google.cloud.firestore_v1.types.Target):
1261 A target to add to this stream.
1262
1263 This field is a member of `oneof`_ ``target_change``.
1264 remove_target (int):
1265 The ID of a target to remove from this
1266 stream.
1267
1268 This field is a member of `oneof`_ ``target_change``.
1269 labels (MutableMapping[str, str]):
1270 Labels associated with this target change.
1271 """
1272
1273 database: str = proto.Field(
1274 proto.STRING,
1275 number=1,
1276 )
1277 add_target: "Target" = proto.Field(
1278 proto.MESSAGE,
1279 number=2,
1280 oneof="target_change",
1281 message="Target",
1282 )
1283 remove_target: int = proto.Field(
1284 proto.INT32,
1285 number=3,
1286 oneof="target_change",
1287 )
1288 labels: MutableMapping[str, str] = proto.MapField(
1289 proto.STRING,
1290 proto.STRING,
1291 number=4,
1292 )
1293
1294
1295class ListenResponse(proto.Message):
1296 r"""The response for
1297 [Firestore.Listen][google.firestore.v1.Firestore.Listen].
1298
1299 This message has `oneof`_ fields (mutually exclusive fields).
1300 For each oneof, at most one member field can be set at the same time.
1301 Setting any member of the oneof automatically clears all other
1302 members.
1303
1304 .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
1305
1306 Attributes:
1307 target_change (google.cloud.firestore_v1.types.TargetChange):
1308 Targets have changed.
1309
1310 This field is a member of `oneof`_ ``response_type``.
1311 document_change (google.cloud.firestore_v1.types.DocumentChange):
1312 A [Document][google.firestore.v1.Document] has changed.
1313
1314 This field is a member of `oneof`_ ``response_type``.
1315 document_delete (google.cloud.firestore_v1.types.DocumentDelete):
1316 A [Document][google.firestore.v1.Document] has been deleted.
1317
1318 This field is a member of `oneof`_ ``response_type``.
1319 document_remove (google.cloud.firestore_v1.types.DocumentRemove):
1320 A [Document][google.firestore.v1.Document] has been removed
1321 from a target (because it is no longer relevant to that
1322 target).
1323
1324 This field is a member of `oneof`_ ``response_type``.
1325 filter (google.cloud.firestore_v1.types.ExistenceFilter):
1326 A filter to apply to the set of documents
1327 previously returned for the given target.
1328
1329 Returned when documents may have been removed
1330 from the given target, but the exact documents
1331 are unknown.
1332
1333 This field is a member of `oneof`_ ``response_type``.
1334 """
1335
1336 target_change: "TargetChange" = proto.Field(
1337 proto.MESSAGE,
1338 number=2,
1339 oneof="response_type",
1340 message="TargetChange",
1341 )
1342 document_change: write.DocumentChange = proto.Field(
1343 proto.MESSAGE,
1344 number=3,
1345 oneof="response_type",
1346 message=write.DocumentChange,
1347 )
1348 document_delete: write.DocumentDelete = proto.Field(
1349 proto.MESSAGE,
1350 number=4,
1351 oneof="response_type",
1352 message=write.DocumentDelete,
1353 )
1354 document_remove: write.DocumentRemove = proto.Field(
1355 proto.MESSAGE,
1356 number=6,
1357 oneof="response_type",
1358 message=write.DocumentRemove,
1359 )
1360 filter: write.ExistenceFilter = proto.Field(
1361 proto.MESSAGE,
1362 number=5,
1363 oneof="response_type",
1364 message=write.ExistenceFilter,
1365 )
1366
1367
1368class Target(proto.Message):
1369 r"""A specification of a set of documents to listen to.
1370
1371 This message has `oneof`_ fields (mutually exclusive fields).
1372 For each oneof, at most one member field can be set at the same time.
1373 Setting any member of the oneof automatically clears all other
1374 members.
1375
1376 .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
1377
1378 Attributes:
1379 query (google.cloud.firestore_v1.types.Target.QueryTarget):
1380 A target specified by a query.
1381
1382 This field is a member of `oneof`_ ``target_type``.
1383 documents (google.cloud.firestore_v1.types.Target.DocumentsTarget):
1384 A target specified by a set of document
1385 names.
1386
1387 This field is a member of `oneof`_ ``target_type``.
1388 resume_token (bytes):
1389 A resume token from a prior
1390 [TargetChange][google.firestore.v1.TargetChange] for an
1391 identical target.
1392
1393 Using a resume token with a different target is unsupported
1394 and may fail.
1395
1396 This field is a member of `oneof`_ ``resume_type``.
1397 read_time (google.protobuf.timestamp_pb2.Timestamp):
1398 Start listening after a specific ``read_time``.
1399
1400 The client must know the state of matching documents at this
1401 time.
1402
1403 This field is a member of `oneof`_ ``resume_type``.
1404 target_id (int):
1405 The target ID that identifies the target on the stream. Must
1406 be a positive number and non-zero.
1407
1408 If ``target_id`` is 0 (or unspecified), the server will
1409 assign an ID for this target and return that in a
1410 ``TargetChange::ADD`` event. Once a target with
1411 ``target_id=0`` is added, all subsequent targets must also
1412 have ``target_id=0``. If an ``AddTarget`` request with
1413 ``target_id != 0`` is sent to the server after a target with
1414 ``target_id=0`` is added, the server will immediately send a
1415 response with a ``TargetChange::Remove`` event.
1416
1417 Note that if the client sends multiple ``AddTarget``
1418 requests without an ID, the order of IDs returned in
1419 ``TargetChage.target_ids`` are undefined. Therefore, clients
1420 should provide a target ID instead of relying on the server
1421 to assign one.
1422
1423 If ``target_id`` is non-zero, there must not be an existing
1424 active target on this stream with the same ID.
1425 once (bool):
1426 If the target should be removed once it is
1427 current and consistent.
1428 expected_count (google.protobuf.wrappers_pb2.Int32Value):
1429 The number of documents that last matched the query at the
1430 resume token or read time.
1431
1432 This value is only relevant when a ``resume_type`` is
1433 provided. This value being present and greater than zero
1434 signals that the client wants
1435 ``ExistenceFilter.unchanged_names`` to be included in the
1436 response.
1437 """
1438
1439 class DocumentsTarget(proto.Message):
1440 r"""A target specified by a set of documents names.
1441
1442 Attributes:
1443 documents (MutableSequence[str]):
1444 The names of the documents to retrieve. In the format:
1445 ``projects/{project_id}/databases/{database_id}/documents/{document_path}``.
1446 The request will fail if any of the document is not a child
1447 resource of the given ``database``. Duplicate names will be
1448 elided.
1449 """
1450
1451 documents: MutableSequence[str] = proto.RepeatedField(
1452 proto.STRING,
1453 number=2,
1454 )
1455
1456 class QueryTarget(proto.Message):
1457 r"""A target specified by a query.
1458
1459 .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
1460
1461 Attributes:
1462 parent (str):
1463 The parent resource name. In the format:
1464 ``projects/{project_id}/databases/{database_id}/documents``
1465 or
1466 ``projects/{project_id}/databases/{database_id}/documents/{document_path}``.
1467 For example:
1468 ``projects/my-project/databases/my-database/documents`` or
1469 ``projects/my-project/databases/my-database/documents/chatrooms/my-chatroom``
1470 structured_query (google.cloud.firestore_v1.types.StructuredQuery):
1471 A structured query.
1472
1473 This field is a member of `oneof`_ ``query_type``.
1474 """
1475
1476 parent: str = proto.Field(
1477 proto.STRING,
1478 number=1,
1479 )
1480 structured_query: gf_query.StructuredQuery = proto.Field(
1481 proto.MESSAGE,
1482 number=2,
1483 oneof="query_type",
1484 message=gf_query.StructuredQuery,
1485 )
1486
1487 query: QueryTarget = proto.Field(
1488 proto.MESSAGE,
1489 number=2,
1490 oneof="target_type",
1491 message=QueryTarget,
1492 )
1493 documents: DocumentsTarget = proto.Field(
1494 proto.MESSAGE,
1495 number=3,
1496 oneof="target_type",
1497 message=DocumentsTarget,
1498 )
1499 resume_token: bytes = proto.Field(
1500 proto.BYTES,
1501 number=4,
1502 oneof="resume_type",
1503 )
1504 read_time: timestamp_pb2.Timestamp = proto.Field(
1505 proto.MESSAGE,
1506 number=11,
1507 oneof="resume_type",
1508 message=timestamp_pb2.Timestamp,
1509 )
1510 target_id: int = proto.Field(
1511 proto.INT32,
1512 number=5,
1513 )
1514 once: bool = proto.Field(
1515 proto.BOOL,
1516 number=6,
1517 )
1518 expected_count: wrappers_pb2.Int32Value = proto.Field(
1519 proto.MESSAGE,
1520 number=12,
1521 message=wrappers_pb2.Int32Value,
1522 )
1523
1524
1525class TargetChange(proto.Message):
1526 r"""Targets being watched have changed.
1527
1528 Attributes:
1529 target_change_type (google.cloud.firestore_v1.types.TargetChange.TargetChangeType):
1530 The type of change that occurred.
1531 target_ids (MutableSequence[int]):
1532 The target IDs of targets that have changed.
1533
1534 If empty, the change applies to all targets.
1535
1536 The order of the target IDs is not defined.
1537 cause (google.rpc.status_pb2.Status):
1538 The error that resulted in this change, if
1539 applicable.
1540 resume_token (bytes):
1541 A token that can be used to resume the stream for the given
1542 ``target_ids``, or all targets if ``target_ids`` is empty.
1543
1544 Not set on every target change.
1545 read_time (google.protobuf.timestamp_pb2.Timestamp):
1546 The consistent ``read_time`` for the given ``target_ids``
1547 (omitted when the target_ids are not at a consistent
1548 snapshot).
1549
1550 The stream is guaranteed to send a ``read_time`` with
1551 ``target_ids`` empty whenever the entire stream reaches a
1552 new consistent snapshot. ADD, CURRENT, and RESET messages
1553 are guaranteed to (eventually) result in a new consistent
1554 snapshot (while NO_CHANGE and REMOVE messages are not).
1555
1556 For a given stream, ``read_time`` is guaranteed to be
1557 monotonically increasing.
1558 """
1559
1560 class TargetChangeType(proto.Enum):
1561 r"""The type of change.
1562
1563 Values:
1564 NO_CHANGE (0):
1565 No change has occurred. Used only to send an updated
1566 ``resume_token``.
1567 ADD (1):
1568 The targets have been added.
1569 REMOVE (2):
1570 The targets have been removed.
1571 CURRENT (3):
1572 The targets reflect all changes committed before the targets
1573 were added to the stream.
1574
1575 This will be sent after or with a ``read_time`` that is
1576 greater than or equal to the time at which the targets were
1577 added.
1578
1579 Listeners can wait for this change if read-after-write
1580 semantics are desired.
1581 RESET (4):
1582 The targets have been reset, and a new initial state for the
1583 targets will be returned in subsequent changes.
1584
1585 After the initial state is complete, ``CURRENT`` will be
1586 returned even if the target was previously indicated to be
1587 ``CURRENT``.
1588 """
1589 NO_CHANGE = 0
1590 ADD = 1
1591 REMOVE = 2
1592 CURRENT = 3
1593 RESET = 4
1594
1595 target_change_type: TargetChangeType = proto.Field(
1596 proto.ENUM,
1597 number=1,
1598 enum=TargetChangeType,
1599 )
1600 target_ids: MutableSequence[int] = proto.RepeatedField(
1601 proto.INT32,
1602 number=2,
1603 )
1604 cause: status_pb2.Status = proto.Field(
1605 proto.MESSAGE,
1606 number=3,
1607 message=status_pb2.Status,
1608 )
1609 resume_token: bytes = proto.Field(
1610 proto.BYTES,
1611 number=4,
1612 )
1613 read_time: timestamp_pb2.Timestamp = proto.Field(
1614 proto.MESSAGE,
1615 number=6,
1616 message=timestamp_pb2.Timestamp,
1617 )
1618
1619
1620class ListCollectionIdsRequest(proto.Message):
1621 r"""The request for
1622 [Firestore.ListCollectionIds][google.firestore.v1.Firestore.ListCollectionIds].
1623
1624
1625 .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
1626
1627 Attributes:
1628 parent (str):
1629 Required. The parent document. In the format:
1630 ``projects/{project_id}/databases/{database_id}/documents/{document_path}``.
1631 For example:
1632 ``projects/my-project/databases/my-database/documents/chatrooms/my-chatroom``
1633 page_size (int):
1634 The maximum number of results to return.
1635 page_token (str):
1636 A page token. Must be a value from
1637 [ListCollectionIdsResponse][google.firestore.v1.ListCollectionIdsResponse].
1638 read_time (google.protobuf.timestamp_pb2.Timestamp):
1639 Reads documents as they were at the given
1640 time.
1641 This must be a microsecond precision timestamp
1642 within the past one hour, or if Point-in-Time
1643 Recovery is enabled, can additionally be a whole
1644 minute timestamp within the past 7 days.
1645
1646 This field is a member of `oneof`_ ``consistency_selector``.
1647 """
1648
1649 parent: str = proto.Field(
1650 proto.STRING,
1651 number=1,
1652 )
1653 page_size: int = proto.Field(
1654 proto.INT32,
1655 number=2,
1656 )
1657 page_token: str = proto.Field(
1658 proto.STRING,
1659 number=3,
1660 )
1661 read_time: timestamp_pb2.Timestamp = proto.Field(
1662 proto.MESSAGE,
1663 number=4,
1664 oneof="consistency_selector",
1665 message=timestamp_pb2.Timestamp,
1666 )
1667
1668
1669class ListCollectionIdsResponse(proto.Message):
1670 r"""The response from
1671 [Firestore.ListCollectionIds][google.firestore.v1.Firestore.ListCollectionIds].
1672
1673 Attributes:
1674 collection_ids (MutableSequence[str]):
1675 The collection ids.
1676 next_page_token (str):
1677 A page token that may be used to continue the
1678 list.
1679 """
1680
1681 @property
1682 def raw_page(self):
1683 return self
1684
1685 collection_ids: MutableSequence[str] = proto.RepeatedField(
1686 proto.STRING,
1687 number=1,
1688 )
1689 next_page_token: str = proto.Field(
1690 proto.STRING,
1691 number=2,
1692 )
1693
1694
1695class BatchWriteRequest(proto.Message):
1696 r"""The request for
1697 [Firestore.BatchWrite][google.firestore.v1.Firestore.BatchWrite].
1698
1699 Attributes:
1700 database (str):
1701 Required. The database name. In the format:
1702 ``projects/{project_id}/databases/{database_id}``.
1703 writes (MutableSequence[google.cloud.firestore_v1.types.Write]):
1704 The writes to apply.
1705
1706 Method does not apply writes atomically and does
1707 not guarantee ordering. Each write succeeds or
1708 fails independently. You cannot write to the
1709 same document more than once per request.
1710 labels (MutableMapping[str, str]):
1711 Labels associated with this batch write.
1712 """
1713
1714 database: str = proto.Field(
1715 proto.STRING,
1716 number=1,
1717 )
1718 writes: MutableSequence[write.Write] = proto.RepeatedField(
1719 proto.MESSAGE,
1720 number=2,
1721 message=write.Write,
1722 )
1723 labels: MutableMapping[str, str] = proto.MapField(
1724 proto.STRING,
1725 proto.STRING,
1726 number=3,
1727 )
1728
1729
1730class BatchWriteResponse(proto.Message):
1731 r"""The response from
1732 [Firestore.BatchWrite][google.firestore.v1.Firestore.BatchWrite].
1733
1734 Attributes:
1735 write_results (MutableSequence[google.cloud.firestore_v1.types.WriteResult]):
1736 The result of applying the writes.
1737
1738 This i-th write result corresponds to the i-th
1739 write in the request.
1740 status (MutableSequence[google.rpc.status_pb2.Status]):
1741 The status of applying the writes.
1742
1743 This i-th write status corresponds to the i-th
1744 write in the request.
1745 """
1746
1747 write_results: MutableSequence[write.WriteResult] = proto.RepeatedField(
1748 proto.MESSAGE,
1749 number=1,
1750 message=write.WriteResult,
1751 )
1752 status: MutableSequence[status_pb2.Status] = proto.RepeatedField(
1753 proto.MESSAGE,
1754 number=2,
1755 message=status_pb2.Status,
1756 )
1757
1758
1759__all__ = tuple(sorted(__protobuf__.manifest))