Skip to content

Commit 3a624a9

Browse files
feat: expose Firestore PITR fields in Database to stable (#811)
* feat: expose Firestore PITR fields in Database to stable feat: expose Firestore snapshot_time field in export API to stable feat: expose Firestore namespace ID fields in import/export APIs to stable docs: assorted typo fixes and whitespace updates PiperOrigin-RevId: 587811576 Source-Link: googleapis/googleapis@fbe1c8e Source-Link: googleapis/googleapis-gen@5fe704d Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNWZlNzA0ZDk0ZmEyZDlhMWRjZTc1Mjk0MmI3MzA4ODczMTI0YjdkZCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent f08c3d4 commit 3a624a9

File tree

7 files changed

+173
-16
lines changed

7 files changed

+173
-16
lines changed

google/cloud/firestore_admin_v1/services/firestore_admin/async_client.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@
5555
from google.cloud.firestore_admin_v1.types import operation as gfa_operation
5656
from google.cloud.location import locations_pb2 # type: ignore
5757
from google.longrunning import operations_pb2 # type: ignore
58+
from google.protobuf import duration_pb2 # type: ignore
5859
from google.protobuf import empty_pb2 # type: ignore
5960
from google.protobuf import field_mask_pb2 # type: ignore
61+
from google.protobuf import timestamp_pb2 # type: ignore
6062
from .transports.base import FirestoreAdminTransport, DEFAULT_CLIENT_INFO
6163
from .transports.grpc_asyncio import FirestoreAdminGrpcAsyncIOTransport
6264
from .client import FirestoreAdminClient
@@ -1201,11 +1203,8 @@ async def sample_export_documents():
12011203
google.api_core.operation_async.AsyncOperation:
12021204
An object representing a long-running operation.
12031205
1204-
The result type for the operation will be
1205-
:class:`google.cloud.firestore_admin_v1.types.ExportDocumentsResponse`
1206-
Returned in the
1207-
[google.longrunning.Operation][google.longrunning.Operation]
1208-
response field.
1206+
The result type for the operation will be :class:`google.cloud.firestore_admin_v1.types.ExportDocumentsResponse` Returned in the [google.longrunning.Operation][google.longrunning.Operation]
1207+
response field.
12091208
12101209
"""
12111210
# Create or coerce a protobuf request object.

google/cloud/firestore_admin_v1/services/firestore_admin/client.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@
5959
from google.cloud.firestore_admin_v1.types import operation as gfa_operation
6060
from google.cloud.location import locations_pb2 # type: ignore
6161
from google.longrunning import operations_pb2 # type: ignore
62+
from google.protobuf import duration_pb2 # type: ignore
6263
from google.protobuf import empty_pb2 # type: ignore
6364
from google.protobuf import field_mask_pb2 # type: ignore
65+
from google.protobuf import timestamp_pb2 # type: ignore
6466
from .transports.base import FirestoreAdminTransport, DEFAULT_CLIENT_INFO
6567
from .transports.grpc import FirestoreAdminGrpcTransport
6668
from .transports.grpc_asyncio import FirestoreAdminGrpcAsyncIOTransport
@@ -1432,11 +1434,8 @@ def sample_export_documents():
14321434
google.api_core.operation.Operation:
14331435
An object representing a long-running operation.
14341436
1435-
The result type for the operation will be
1436-
:class:`google.cloud.firestore_admin_v1.types.ExportDocumentsResponse`
1437-
Returned in the
1438-
[google.longrunning.Operation][google.longrunning.Operation]
1439-
response field.
1437+
The result type for the operation will be :class:`google.cloud.firestore_admin_v1.types.ExportDocumentsResponse` Returned in the [google.longrunning.Operation][google.longrunning.Operation]
1438+
response field.
14401439
14411440
"""
14421441
# Create or coerce a protobuf request object.

google/cloud/firestore_admin_v1/types/database.py

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919

2020
import proto # type: ignore
2121

22+
from google.protobuf import duration_pb2 # type: ignore
23+
from google.protobuf import timestamp_pb2 # type: ignore
24+
2225

2326
__protobuf__ = proto.module(
2427
package="google.firestore.admin.v1",
@@ -39,7 +42,7 @@ class Database(proto.Message):
3942
``projects/{project}/databases/{database}``
4043
location_id (str):
4144
The location of the database. Available
42-
databases are listed at
45+
locations are listed at
4346
https://cloud.google.com/firestore/docs/locations.
4447
type_ (google.cloud.firestore_admin_v1.types.Database.DatabaseType):
4548
The type of the database.
@@ -49,6 +52,32 @@ class Database(proto.Message):
4952
concurrency_mode (google.cloud.firestore_admin_v1.types.Database.ConcurrencyMode):
5053
The concurrency control mode to use for this
5154
database.
55+
version_retention_period (google.protobuf.duration_pb2.Duration):
56+
Output only. The period during which past versions of data
57+
are retained in the database.
58+
59+
Any [read][google.firestore.v1.GetDocumentRequest.read_time]
60+
or
61+
[query][google.firestore.v1.ListDocumentsRequest.read_time]
62+
can specify a ``read_time`` within this window, and will
63+
read the state of the database at that time.
64+
65+
If the PITR feature is enabled, the retention period is 7
66+
days. Otherwise, the retention period is 1 hour.
67+
earliest_version_time (google.protobuf.timestamp_pb2.Timestamp):
68+
Output only. The earliest timestamp at which older versions
69+
of the data can be read from the database. See
70+
[version_retention_period] above; this field is populated
71+
with ``now - version_retention_period``.
72+
73+
This value is continuously updated, and becomes stale the
74+
moment it is queried. If you are using this value to recover
75+
data, make sure to account for the time from the moment when
76+
the value is queried to the moment when you initiate the
77+
recovery.
78+
point_in_time_recovery_enablement (google.cloud.firestore_admin_v1.types.Database.PointInTimeRecoveryEnablement):
79+
Whether to enable the PITR feature on this
80+
database.
5281
app_engine_integration_mode (google.cloud.firestore_admin_v1.types.Database.AppEngineIntegrationMode):
5382
The App Engine integration mode to use for
5483
this database.
@@ -120,6 +149,30 @@ class ConcurrencyMode(proto.Enum):
120149
PESSIMISTIC = 2
121150
OPTIMISTIC_WITH_ENTITY_GROUPS = 3
122151

152+
class PointInTimeRecoveryEnablement(proto.Enum):
153+
r"""Point In Time Recovery feature enablement.
154+
155+
Values:
156+
POINT_IN_TIME_RECOVERY_ENABLEMENT_UNSPECIFIED (0):
157+
Not used.
158+
POINT_IN_TIME_RECOVERY_ENABLED (1):
159+
Reads are supported on selected versions of the data from
160+
within the past 7 days:
161+
162+
- Reads against any timestamp within the past hour
163+
- Reads against 1-minute snapshots beyond 1 hour and within
164+
7 days
165+
166+
``version_retention_period`` and ``earliest_version_time``
167+
can be used to determine the supported versions.
168+
POINT_IN_TIME_RECOVERY_DISABLED (2):
169+
Reads are supported on any version of the
170+
data from within the past 1 hour.
171+
"""
172+
POINT_IN_TIME_RECOVERY_ENABLEMENT_UNSPECIFIED = 0
173+
POINT_IN_TIME_RECOVERY_ENABLED = 1
174+
POINT_IN_TIME_RECOVERY_DISABLED = 2
175+
123176
class AppEngineIntegrationMode(proto.Enum):
124177
r"""The type of App Engine integration mode.
125178
@@ -134,8 +187,11 @@ class AppEngineIntegrationMode(proto.Enum):
134187
database, as well as disabling writes to the
135188
database.
136189
DISABLED (2):
137-
Appengine has no affect on the ability of
190+
App Engine has no effect on the ability of
138191
this database to serve requests.
192+
193+
This is the default setting for databases
194+
created with the Firestore API.
139195
"""
140196
APP_ENGINE_INTEGRATION_MODE_UNSPECIFIED = 0
141197
ENABLED = 1
@@ -159,6 +215,21 @@ class AppEngineIntegrationMode(proto.Enum):
159215
number=15,
160216
enum=ConcurrencyMode,
161217
)
218+
version_retention_period: duration_pb2.Duration = proto.Field(
219+
proto.MESSAGE,
220+
number=17,
221+
message=duration_pb2.Duration,
222+
)
223+
earliest_version_time: timestamp_pb2.Timestamp = proto.Field(
224+
proto.MESSAGE,
225+
number=18,
226+
message=timestamp_pb2.Timestamp,
227+
)
228+
point_in_time_recovery_enablement: PointInTimeRecoveryEnablement = proto.Field(
229+
proto.ENUM,
230+
number=21,
231+
enum=PointInTimeRecoveryEnablement,
232+
)
162233
app_engine_integration_mode: AppEngineIntegrationMode = proto.Field(
163234
proto.ENUM,
164235
number=19,

google/cloud/firestore_admin_v1/types/firestore_admin.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from google.cloud.firestore_admin_v1.types import field as gfa_field
2424
from google.cloud.firestore_admin_v1.types import index as gfa_index
2525
from google.protobuf import field_mask_pb2 # type: ignore
26+
from google.protobuf import timestamp_pb2 # type: ignore
2627

2728

2829
__protobuf__ = proto.module(
@@ -412,6 +413,25 @@ class ExportDocumentsRequest(proto.Message):
412413
https://cloud.google.com/storage/docs/naming. If the URI is
413414
a bucket (without a namespace path), a prefix will be
414415
generated based on the start time.
416+
namespace_ids (MutableSequence[str]):
417+
Unspecified means all namespaces. This is the
418+
preferred usage for databases that don't use
419+
namespaces.
420+
421+
An empty string element represents the default
422+
namespace. This should be used if the database
423+
has data in non-default namespaces, but doesn't
424+
want to include them. Each namespace in this
425+
list must be unique.
426+
snapshot_time (google.protobuf.timestamp_pb2.Timestamp):
427+
The timestamp that corresponds to the version of the
428+
database to be exported. The timestamp must be in the past,
429+
rounded to the minute and not older than
430+
[earliestVersionTime][google.firestore.admin.v1.Database.earliest_version_time].
431+
If specified, then the exported documents will represent a
432+
consistent view of the database at the provided time.
433+
Otherwise, there are no guarantees about the consistency of
434+
the exported documents.
415435
"""
416436

417437
name: str = proto.Field(
@@ -426,6 +446,15 @@ class ExportDocumentsRequest(proto.Message):
426446
proto.STRING,
427447
number=3,
428448
)
449+
namespace_ids: MutableSequence[str] = proto.RepeatedField(
450+
proto.STRING,
451+
number=4,
452+
)
453+
snapshot_time: timestamp_pb2.Timestamp = proto.Field(
454+
proto.MESSAGE,
455+
number=5,
456+
message=timestamp_pb2.Timestamp,
457+
)
429458

430459

431460
class ImportDocumentsRequest(proto.Message):
@@ -444,6 +473,16 @@ class ImportDocumentsRequest(proto.Message):
444473
output_uri_prefix of an ExportDocumentsResponse from an
445474
export that has completed successfully. See:
446475
[google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix][google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix].
476+
namespace_ids (MutableSequence[str]):
477+
Unspecified means all namespaces. This is the
478+
preferred usage for databases that don't use
479+
namespaces.
480+
481+
An empty string element represents the default
482+
namespace. This should be used if the database
483+
has data in non-default namespaces, but doesn't
484+
want to include them. Each namespace in this
485+
list must be unique.
447486
"""
448487

449488
name: str = proto.Field(
@@ -458,6 +497,10 @@ class ImportDocumentsRequest(proto.Message):
458497
proto.STRING,
459498
number=3,
460499
)
500+
namespace_ids: MutableSequence[str] = proto.RepeatedField(
501+
proto.STRING,
502+
number=4,
503+
)
461504

462505

463506
__all__ = tuple(sorted(__protobuf__.manifest))

google/cloud/firestore_admin_v1/types/operation.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ class ChangeType(proto.Enum):
199199
)
200200

201201
class TtlConfigDelta(proto.Message):
202-
r"""Information about an TTL configuration change.
202+
r"""Information about a TTL configuration change.
203203
204204
Attributes:
205205
change_type (google.cloud.firestore_admin_v1.types.FieldOperationMetadata.TtlConfigDelta.ChangeType):
@@ -291,7 +291,14 @@ class ExportDocumentsMetadata(proto.Message):
291291
collection_ids (MutableSequence[str]):
292292
Which collection ids are being exported.
293293
output_uri_prefix (str):
294-
Where the entities are being exported to.
294+
Where the documents are being exported to.
295+
namespace_ids (MutableSequence[str]):
296+
Which namespace ids are being exported.
297+
snapshot_time (google.protobuf.timestamp_pb2.Timestamp):
298+
The timestamp that corresponds to the version
299+
of the database that is being exported. If
300+
unspecified, there are no guarantees about the
301+
consistency of the documents being exported.
295302
"""
296303

297304
start_time: timestamp_pb2.Timestamp = proto.Field(
@@ -327,6 +334,15 @@ class ExportDocumentsMetadata(proto.Message):
327334
proto.STRING,
328335
number=7,
329336
)
337+
namespace_ids: MutableSequence[str] = proto.RepeatedField(
338+
proto.STRING,
339+
number=8,
340+
)
341+
snapshot_time: timestamp_pb2.Timestamp = proto.Field(
342+
proto.MESSAGE,
343+
number=9,
344+
message=timestamp_pb2.Timestamp,
345+
)
330346

331347

332348
class ImportDocumentsMetadata(proto.Message):
@@ -352,6 +368,8 @@ class ImportDocumentsMetadata(proto.Message):
352368
Which collection ids are being imported.
353369
input_uri_prefix (str):
354370
The location of the documents being imported.
371+
namespace_ids (MutableSequence[str]):
372+
Which namespace ids are being imported.
355373
"""
356374

357375
start_time: timestamp_pb2.Timestamp = proto.Field(
@@ -387,6 +405,10 @@ class ImportDocumentsMetadata(proto.Message):
387405
proto.STRING,
388406
number=7,
389407
)
408+
namespace_ids: MutableSequence[str] = proto.RepeatedField(
409+
proto.STRING,
410+
number=8,
411+
)
390412

391413

392414
class ExportDocumentsResponse(proto.Message):

scripts/fixup_firestore_admin_v1_keywords.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ class firestore_adminCallTransformer(cst.CSTTransformer):
4848
'create_database': ('parent', 'database', 'database_id', ),
4949
'create_index': ('parent', 'index', ),
5050
'delete_index': ('name', ),
51-
'export_documents': ('name', 'collection_ids', 'output_uri_prefix', ),
51+
'export_documents': ('name', 'collection_ids', 'output_uri_prefix', 'namespace_ids', 'snapshot_time', ),
5252
'get_database': ('name', ),
5353
'get_field': ('name', ),
5454
'get_index': ('name', ),
55-
'import_documents': ('name', 'collection_ids', 'input_uri_prefix', ),
55+
'import_documents': ('name', 'collection_ids', 'input_uri_prefix', 'namespace_ids', ),
5656
'list_databases': ('parent', ),
5757
'list_fields': ('parent', 'filter', 'page_size', 'page_token', ),
5858
'list_indexes': ('parent', 'filter', 'page_size', 'page_token', ),

0 commit comments

Comments
 (0)