Skip to content

Commit 8508831

Browse files
Merge branch 'main' into enable_mypy
2 parents 0af6a11 + d8e3af1 commit 8508831

38 files changed

+1604
-173
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "2.20.2"
2+
".": "2.21.0"
33
}

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@
55
[1]: https://pypi.org/project/google-cloud-firestore/#history
66

77

8+
## [2.21.0](https://github.com/googleapis/python-firestore/compare/v2.20.2...v2.21.0) (2025-05-23)
9+
10+
11+
### Features
12+
13+
* Support Sequence[float] as query_vector in FindNearest ([#908](https://github.com/googleapis/python-firestore/issues/908)) ([6c81626](https://github.com/googleapis/python-firestore/commit/6c8162685eb82fc6f814f69741a2a51ddda4c2fa))
14+
15+
16+
### Bug Fixes
17+
18+
* Add missing DocumentReference return value to .document ([#1053](https://github.com/googleapis/python-firestore/issues/1053)) ([043d9ef](https://github.com/googleapis/python-firestore/commit/043d9ef59627e5ed7f1acb5ab0c9d47dfd2178c1))
19+
820
## [2.20.2](https://github.com/googleapis/python-firestore/compare/v2.20.1...v2.20.2) (2025-04-14)
921

1022

google/cloud/firestore/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "2.20.2" # {x-release-please-version}
16+
__version__ = "2.21.0" # {x-release-please-version}

google/cloud/firestore_admin_v1/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "2.20.2" # {x-release-please-version}
16+
__version__ = "2.21.0" # {x-release-please-version}

google/cloud/firestore_bundle/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "2.20.2" # {x-release-please-version}
16+
__version__ = "2.21.0" # {x-release-please-version}

google/cloud/firestore_v1/aggregation.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
from google.cloud.firestore_v1.query_profile import ExplainMetrics
4040
from google.cloud.firestore_v1.query_profile import ExplainOptions
4141

42+
import datetime
43+
4244

4345
class AggregationQuery(BaseAggregationQuery):
4446
"""Represents an aggregation query to the Firestore API."""
@@ -56,6 +58,7 @@ def get(
5658
timeout: float | None = None,
5759
*,
5860
explain_options: Optional[ExplainOptions] = None,
61+
read_time: Optional[datetime.datetime] = None,
5962
) -> QueryResultsList[AggregationResult]:
6063
"""Runs the aggregation query.
6164
@@ -78,6 +81,10 @@ def get(
7881
(Optional[:class:`~google.cloud.firestore_v1.query_profile.ExplainOptions`]):
7982
Options to enable query profiling for this query. When set,
8083
explain_metrics will be available on the returned generator.
84+
read_time (Optional[datetime.datetime]): If set, reads documents as they were at the given
85+
time. This must be a timestamp within the past one hour, or if Point-in-Time Recovery
86+
is enabled, can additionally be a whole minute timestamp within the past 7 days. If no
87+
timezone is specified in the :class:`datetime.datetime` object, it is assumed to be UTC.
8188
8289
Returns:
8390
QueryResultsList[AggregationResult]: The aggregation query results.
@@ -90,6 +97,7 @@ def get(
9097
retry=retry,
9198
timeout=timeout,
9299
explain_options=explain_options,
100+
read_time=read_time,
93101
)
94102
result_list = list(result)
95103

@@ -100,13 +108,16 @@ def get(
100108

101109
return QueryResultsList(result_list, explain_options, explain_metrics)
102110

103-
def _get_stream_iterator(self, transaction, retry, timeout, explain_options=None):
111+
def _get_stream_iterator(
112+
self, transaction, retry, timeout, explain_options=None, read_time=None
113+
):
104114
"""Helper method for :meth:`stream`."""
105115
request, kwargs = self._prep_stream(
106116
transaction,
107117
retry,
108118
timeout,
109119
explain_options,
120+
read_time,
110121
)
111122

112123
return self._client._firestore_api.run_aggregation_query(
@@ -132,6 +143,7 @@ def _make_stream(
132143
retry: Union[retries.Retry, None, object] = gapic_v1.method.DEFAULT,
133144
timeout: Optional[float] = None,
134145
explain_options: Optional[ExplainOptions] = None,
146+
read_time: Optional[datetime.datetime] = None,
135147
) -> Generator[List[AggregationResult], Any, Optional[ExplainMetrics]]:
136148
"""Internal method for stream(). Runs the aggregation query.
137149
@@ -155,6 +167,10 @@ def _make_stream(
155167
(Optional[:class:`~google.cloud.firestore_v1.query_profile.ExplainOptions`]):
156168
Options to enable query profiling for this query. When set,
157169
explain_metrics will be available on the returned generator.
170+
read_time (Optional[datetime.datetime]): If set, reads documents as they were at the given
171+
time. This must be a timestamp within the past one hour, or if Point-in-Time Recovery
172+
is enabled, can additionally be a whole minute timestamp within the past 7 days. If no
173+
timezone is specified in the :class:`datetime.datetime` object, it is assumed to be UTC.
158174
159175
Yields:
160176
List[AggregationResult]:
@@ -172,6 +188,7 @@ def _make_stream(
172188
retry,
173189
timeout,
174190
explain_options,
191+
read_time,
175192
)
176193
while True:
177194
try:
@@ -182,6 +199,8 @@ def _make_stream(
182199
transaction,
183200
retry,
184201
timeout,
202+
explain_options,
203+
read_time,
185204
)
186205
continue
187206
else:
@@ -206,6 +225,7 @@ def stream(
206225
timeout: Optional[float] = None,
207226
*,
208227
explain_options: Optional[ExplainOptions] = None,
228+
read_time: Optional[datetime.datetime] = None,
209229
) -> StreamGenerator[List[AggregationResult]]:
210230
"""Runs the aggregation query.
211231
@@ -229,6 +249,10 @@ def stream(
229249
(Optional[:class:`~google.cloud.firestore_v1.query_profile.ExplainOptions`]):
230250
Options to enable query profiling for this query. When set,
231251
explain_metrics will be available on the returned generator.
252+
read_time (Optional[datetime.datetime]): If set, reads documents as they were at the given
253+
time. This must be a timestamp within the past one hour, or if Point-in-Time Recovery
254+
is enabled, can additionally be a whole minute timestamp within the past 7 days. If no
255+
timezone is specified in the :class:`datetime.datetime` object, it is assumed to be UTC.
232256
233257
Returns:
234258
`StreamGenerator[List[AggregationResult]]`:
@@ -239,5 +263,6 @@ def stream(
239263
retry=retry,
240264
timeout=timeout,
241265
explain_options=explain_options,
266+
read_time=read_time,
242267
)
243268
return StreamGenerator(inner_generator, explain_options)

google/cloud/firestore_v1/async_aggregation.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
from google.cloud.firestore_v1.base_aggregation import AggregationResult
3838
from google.cloud.firestore_v1.query_profile import ExplainMetrics, ExplainOptions
3939
import google.cloud.firestore_v1.types.query_profile as query_profile_pb
40+
import datetime
4041

4142

4243
class AsyncAggregationQuery(BaseAggregationQuery):
@@ -55,6 +56,7 @@ async def get(
5556
timeout: float | None = None,
5657
*,
5758
explain_options: Optional[ExplainOptions] = None,
59+
read_time: Optional[datetime.datetime] = None,
5860
) -> QueryResultsList[List[AggregationResult]]:
5961
"""Runs the aggregation query.
6062
@@ -75,6 +77,10 @@ async def get(
7577
(Optional[:class:`~google.cloud.firestore_v1.query_profile.ExplainOptions`]):
7678
Options to enable query profiling for this query. When set,
7779
explain_metrics will be available on the returned generator.
80+
read_time (Optional[datetime.datetime]): If set, reads documents as they were at the given
81+
time. This must be a timestamp within the past one hour, or if Point-in-Time Recovery
82+
is enabled, can additionally be a whole minute timestamp within the past 7 days. If no
83+
timezone is specified in the :class:`datetime.datetime` object, it is assumed to be UTC.
7884
7985
Returns:
8086
QueryResultsList[List[AggregationResult]]: The aggregation query results.
@@ -87,6 +93,7 @@ async def get(
8793
retry=retry,
8894
timeout=timeout,
8995
explain_options=explain_options,
96+
read_time=read_time,
9097
)
9198
try:
9299
result = [aggregation async for aggregation in stream_result]
@@ -106,6 +113,7 @@ async def _make_stream(
106113
retry: retries.AsyncRetry | object | None = gapic_v1.method.DEFAULT,
107114
timeout: Optional[float] = None,
108115
explain_options: Optional[ExplainOptions] = None,
116+
read_time: Optional[datetime.datetime] = None,
109117
) -> AsyncGenerator[List[AggregationResult] | query_profile_pb.ExplainMetrics, Any]:
110118
"""Internal method for stream(). Runs the aggregation query.
111119
@@ -130,6 +138,10 @@ async def _make_stream(
130138
(Optional[:class:`~google.cloud.firestore_v1.query_profile.ExplainOptions`]):
131139
Options to enable query profiling for this query. When set,
132140
explain_metrics will be available on the returned generator.
141+
read_time (Optional[datetime.datetime]): If set, reads documents as they were at the given
142+
time. This must be a timestamp within the past one hour, or if Point-in-Time Recovery
143+
is enabled, can additionally be a whole minute timestamp within the past 7 days. If no
144+
timezone is specified in the :class:`datetime.datetime` object, it is assumed to be UTC.
133145
134146
Yields:
135147
List[AggregationResult] | query_profile_pb.ExplainMetrics:
@@ -143,6 +155,7 @@ async def _make_stream(
143155
retry,
144156
timeout,
145157
explain_options,
158+
read_time,
146159
)
147160

148161
response_iterator = await self._client._firestore_api.run_aggregation_query(
@@ -167,6 +180,7 @@ def stream(
167180
timeout: Optional[float] = None,
168181
*,
169182
explain_options: Optional[ExplainOptions] = None,
183+
read_time: Optional[datetime.datetime] = None,
170184
) -> AsyncStreamGenerator[List[AggregationResult]]:
171185
"""Runs the aggregation query.
172186
@@ -190,6 +204,10 @@ def stream(
190204
(Optional[:class:`~google.cloud.firestore_v1.query_profile.ExplainOptions`]):
191205
Options to enable query profiling for this query. When set,
192206
explain_metrics will be available on the returned generator.
207+
read_time (Optional[datetime.datetime]): If set, reads documents as they were at the given
208+
time. This must be a timestamp within the past one hour, or if Point-in-Time Recovery
209+
is enabled, can additionally be a whole minute timestamp within the past 7 days. If no
210+
timezone is specified in the :class:`datetime.datetime` object, it is assumed to be UTC.
193211
194212
Returns:
195213
`AsyncStreamGenerator[List[AggregationResult]]`:
@@ -201,5 +219,6 @@ def stream(
201219
retry=retry,
202220
timeout=timeout,
203221
explain_options=explain_options,
222+
read_time=read_time,
204223
)
205224
return AsyncStreamGenerator(inner_generator, explain_options)

google/cloud/firestore_v1/async_client.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@
4848
grpc_asyncio as firestore_grpc_transport,
4949
)
5050

51-
if TYPE_CHECKING:
52-
from google.cloud.firestore_v1.bulk_writer import BulkWriter # pragma: NO COVER
51+
if TYPE_CHECKING: # pragma: NO COVER
52+
import datetime
53+
54+
from google.cloud.firestore_v1.bulk_writer import BulkWriter
5355

5456

5557
class AsyncClient(BaseClient):
@@ -227,6 +229,8 @@ async def get_all(
227229
transaction: AsyncTransaction | None = None,
228230
retry: retries.AsyncRetry | object | None = gapic_v1.method.DEFAULT,
229231
timeout: float | None = None,
232+
*,
233+
read_time: datetime.datetime | None = None,
230234
) -> AsyncGenerator[DocumentSnapshot, Any]:
231235
"""Retrieve a batch of documents.
232236
@@ -261,13 +265,17 @@ async def get_all(
261265
should be retried. Defaults to a system-specified policy.
262266
timeout (float): The timeout for this request. Defaults to a
263267
system-specified value.
268+
read_time (Optional[datetime.datetime]): If set, reads documents as they were at the given
269+
time. This must be a timestamp within the past one hour, or if Point-in-Time Recovery
270+
is enabled, can additionally be a whole minute timestamp within the past 7 days. If no
271+
timezone is specified in the :class:`datetime.datetime` object, it is assumed to be UTC.
264272
265273
Yields:
266274
.DocumentSnapshot: The next document snapshot that fulfills the
267275
query, or :data:`None` if the document does not exist.
268276
"""
269277
request, reference_map, kwargs = self._prep_get_all(
270-
references, field_paths, transaction, retry, timeout
278+
references, field_paths, transaction, retry, timeout, read_time
271279
)
272280

273281
response_iterator = await self._firestore_api.batch_get_documents(
@@ -283,6 +291,8 @@ async def collections(
283291
self,
284292
retry: retries.AsyncRetry | object | None = gapic_v1.method.DEFAULT,
285293
timeout: float | None = None,
294+
*,
295+
read_time: datetime.datetime | None = None,
286296
) -> AsyncGenerator[AsyncCollectionReference, Any]:
287297
"""List top-level collections of the client's database.
288298
@@ -291,12 +301,16 @@ async def collections(
291301
should be retried. Defaults to a system-specified policy.
292302
timeout (float): The timeout for this request. Defaults to a
293303
system-specified value.
304+
read_time (Optional[datetime.datetime]): If set, reads documents as they were at the given
305+
time. This must be a timestamp within the past one hour, or if Point-in-Time Recovery
306+
is enabled, can additionally be a whole minute timestamp within the past 7 days. If no
307+
timezone is specified in the :class:`datetime.datetime` object, it is assumed to be UTC.
294308
295309
Returns:
296310
Sequence[:class:`~google.cloud.firestore_v1.async_collection.AsyncCollectionReference`]:
297311
iterator of subcollections of the current document.
298312
"""
299-
request, kwargs = self._prep_collections(retry, timeout)
313+
request, kwargs = self._prep_collections(retry, timeout, read_time)
300314
iterator = await self._firestore_api.list_collection_ids(
301315
request=request,
302316
metadata=self._rpc_metadata,

0 commit comments

Comments
 (0)