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.protobuf import timestamp_pb2 # type: ignore
23
24
25__protobuf__ = proto.module(
26 package="google.firestore.v1",
27 manifest={
28 "DocumentMask",
29 "Precondition",
30 "TransactionOptions",
31 },
32)
33
34
35class DocumentMask(proto.Message):
36 r"""A set of field paths on a document. Used to restrict a get or update
37 operation on a document to a subset of its fields. This is different
38 from standard field masks, as this is always scoped to a
39 [Document][google.firestore.v1.Document], and takes in account the
40 dynamic nature of [Value][google.firestore.v1.Value].
41
42 Attributes:
43 field_paths (MutableSequence[str]):
44 The list of field paths in the mask. See
45 [Document.fields][google.firestore.v1.Document.fields] for a
46 field path syntax reference.
47 """
48
49 field_paths: MutableSequence[str] = proto.RepeatedField(
50 proto.STRING,
51 number=1,
52 )
53
54
55class Precondition(proto.Message):
56 r"""A precondition on a document, used for conditional
57 operations.
58
59 This message has `oneof`_ fields (mutually exclusive fields).
60 For each oneof, at most one member field can be set at the same time.
61 Setting any member of the oneof automatically clears all other
62 members.
63
64 .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
65
66 Attributes:
67 exists (bool):
68 When set to ``true``, the target document must exist. When
69 set to ``false``, the target document must not exist.
70
71 This field is a member of `oneof`_ ``condition_type``.
72 update_time (google.protobuf.timestamp_pb2.Timestamp):
73 When set, the target document must exist and
74 have been last updated at that time. Timestamp
75 must be microsecond aligned.
76
77 This field is a member of `oneof`_ ``condition_type``.
78 """
79
80 exists: bool = proto.Field(
81 proto.BOOL,
82 number=1,
83 oneof="condition_type",
84 )
85 update_time: timestamp_pb2.Timestamp = proto.Field(
86 proto.MESSAGE,
87 number=2,
88 oneof="condition_type",
89 message=timestamp_pb2.Timestamp,
90 )
91
92
93class TransactionOptions(proto.Message):
94 r"""Options for creating a new transaction.
95
96 This message has `oneof`_ fields (mutually exclusive fields).
97 For each oneof, at most one member field can be set at the same time.
98 Setting any member of the oneof automatically clears all other
99 members.
100
101 .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
102
103 Attributes:
104 read_only (google.cloud.firestore_v1.types.TransactionOptions.ReadOnly):
105 The transaction can only be used for read
106 operations.
107
108 This field is a member of `oneof`_ ``mode``.
109 read_write (google.cloud.firestore_v1.types.TransactionOptions.ReadWrite):
110 The transaction can be used for both read and
111 write operations.
112
113 This field is a member of `oneof`_ ``mode``.
114 """
115
116 class ReadWrite(proto.Message):
117 r"""Options for a transaction that can be used to read and write
118 documents.
119 Firestore does not allow 3rd party auth requests to create
120 read-write. transactions.
121
122 Attributes:
123 retry_transaction (bytes):
124 An optional transaction to retry.
125 """
126
127 retry_transaction: bytes = proto.Field(
128 proto.BYTES,
129 number=1,
130 )
131
132 class ReadOnly(proto.Message):
133 r"""Options for a transaction that can only be used to read
134 documents.
135
136
137 .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
138
139 Attributes:
140 read_time (google.protobuf.timestamp_pb2.Timestamp):
141 Reads documents at the given time.
142
143 This must be a microsecond precision timestamp
144 within the past one hour, or if Point-in-Time
145 Recovery is enabled, can additionally be a whole
146 minute timestamp within the past 7 days.
147
148 This field is a member of `oneof`_ ``consistency_selector``.
149 """
150
151 read_time: timestamp_pb2.Timestamp = proto.Field(
152 proto.MESSAGE,
153 number=2,
154 oneof="consistency_selector",
155 message=timestamp_pb2.Timestamp,
156 )
157
158 read_only: ReadOnly = proto.Field(
159 proto.MESSAGE,
160 number=2,
161 oneof="mode",
162 message=ReadOnly,
163 )
164 read_write: ReadWrite = proto.Field(
165 proto.MESSAGE,
166 number=3,
167 oneof="mode",
168 message=ReadWrite,
169 )
170
171
172__all__ = tuple(sorted(__protobuf__.manifest))