Skip to content

Commit 3f044b2

Browse files
chore: Update gapic-generator-python to 1.26.2 (#1077)
* feat: add Firestore CloneDatabase support PiperOrigin-RevId: 789807783 Source-Link: googleapis/googleapis@3d37c58 Source-Link: googleapis/googleapis-gen@66d3f2f Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNjZkM2YyZjNhYTU3ZDI0MjUzNGExZjM3MjZiNTk4ZjY0YmE2OWZjYiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore: update Python generator version to 1.25.1 PiperOrigin-RevId: 800535761 Source-Link: googleapis/googleapis@4cf1f99 Source-Link: googleapis/googleapis-gen@133d25b Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMTMzZDI1YjY4ZTcxMjExNmUxYzVkYzcxZmMzZWIzYzVlNzE3MDIyYSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore: Update gapic-generator-python to 1.26.2 PiperOrigin-RevId: 802200836 Source-Link: googleapis/googleapis@d300b15 Source-Link: googleapis/googleapis-gen@a1ff0ae Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYTFmZjBhZTcyZGRjYjY4YTI1OTIxNWQ4Yzc3NjYxZTJjZGJiOWIwMiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * feat: Add support for Python 3.14 fix: Deprecate credentials_file argument chore: Update gapic-generator-python to 1.28.0 PiperOrigin-RevId: 816753840 Source-Link: googleapis/googleapis@d06cf27 Source-Link: googleapis/googleapis-gen@a524e73 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYTUyNGU3MzEwODgyYmJiOTliZmUxMzk5YjE4YmVkMzI4OTc5MjExYyJ9 * 🦉 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> Co-authored-by: Daniel Sanche <[email protected]>
1 parent f9b4367 commit 3f044b2

File tree

22 files changed

+1762
-120
lines changed

22 files changed

+1762
-120
lines changed

packages/google-cloud-firestore/google/cloud/firestore_admin_v1/gapic_metadata.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
"bulk_delete_documents"
1616
]
1717
},
18+
"CloneDatabase": {
19+
"methods": [
20+
"clone_database"
21+
]
22+
},
1823
"CreateBackupSchedule": {
1924
"methods": [
2025
"create_backup_schedule"
@@ -175,6 +180,11 @@
175180
"bulk_delete_documents"
176181
]
177182
},
183+
"CloneDatabase": {
184+
"methods": [
185+
"clone_database"
186+
]
187+
},
178188
"CreateBackupSchedule": {
179189
"methods": [
180190
"create_backup_schedule"
@@ -335,6 +345,11 @@
335345
"bulk_delete_documents"
336346
]
337347
},
348+
"CloneDatabase": {
349+
"methods": [
350+
"clone_database"
351+
]
352+
},
338353
"CreateBackupSchedule": {
339354
"methods": [
340355
"create_backup_schedule"

packages/google-cloud-firestore/google/cloud/firestore_admin_v1/services/firestore_admin/async_client.py

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4111,6 +4111,143 @@ async def sample_delete_backup_schedule():
41114111
metadata=metadata,
41124112
)
41134113

4114+
async def clone_database(
4115+
self,
4116+
request: Optional[Union[firestore_admin.CloneDatabaseRequest, dict]] = None,
4117+
*,
4118+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
4119+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
4120+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
4121+
) -> operation_async.AsyncOperation:
4122+
r"""Creates a new database by cloning an existing one.
4123+
4124+
The new database must be in the same cloud region or
4125+
multi-region location as the existing database. This behaves
4126+
similar to
4127+
[FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase]
4128+
except instead of creating a new empty database, a new database
4129+
is created with the database type, index configuration, and
4130+
documents from an existing database.
4131+
4132+
The [long-running operation][google.longrunning.Operation] can
4133+
be used to track the progress of the clone, with the Operation's
4134+
[metadata][google.longrunning.Operation.metadata] field type
4135+
being the
4136+
[CloneDatabaseMetadata][google.firestore.admin.v1.CloneDatabaseMetadata].
4137+
The [response][google.longrunning.Operation.response] type is
4138+
the [Database][google.firestore.admin.v1.Database] if the clone
4139+
was successful. The new database is not readable or writeable
4140+
until the LRO has completed.
4141+
4142+
.. code-block:: python
4143+
4144+
# This snippet has been automatically generated and should be regarded as a
4145+
# code template only.
4146+
# It will require modifications to work:
4147+
# - It may require correct/in-range values for request initialization.
4148+
# - It may require specifying regional endpoints when creating the service
4149+
# client as shown in:
4150+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
4151+
from google.cloud import firestore_admin_v1
4152+
4153+
async def sample_clone_database():
4154+
# Create a client
4155+
client = firestore_admin_v1.FirestoreAdminAsyncClient()
4156+
4157+
# Initialize request argument(s)
4158+
pitr_snapshot = firestore_admin_v1.PitrSnapshot()
4159+
pitr_snapshot.database = "database_value"
4160+
4161+
request = firestore_admin_v1.CloneDatabaseRequest(
4162+
parent="parent_value",
4163+
database_id="database_id_value",
4164+
pitr_snapshot=pitr_snapshot,
4165+
)
4166+
4167+
# Make the request
4168+
operation = client.clone_database(request=request)
4169+
4170+
print("Waiting for operation to complete...")
4171+
4172+
response = (await operation).result()
4173+
4174+
# Handle the response
4175+
print(response)
4176+
4177+
Args:
4178+
request (Optional[Union[google.cloud.firestore_admin_v1.types.CloneDatabaseRequest, dict]]):
4179+
The request object. The request message for
4180+
[FirestoreAdmin.CloneDatabase][google.firestore.admin.v1.FirestoreAdmin.CloneDatabase].
4181+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
4182+
should be retried.
4183+
timeout (float): The timeout for this request.
4184+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
4185+
sent along with the request as metadata. Normally, each value must be of type `str`,
4186+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
4187+
be of type `bytes`.
4188+
4189+
Returns:
4190+
google.api_core.operation_async.AsyncOperation:
4191+
An object representing a long-running operation.
4192+
4193+
The result type for the operation will be
4194+
:class:`google.cloud.firestore_admin_v1.types.Database`
4195+
A Cloud Firestore Database.
4196+
4197+
"""
4198+
# Create or coerce a protobuf request object.
4199+
# - Use the request object if provided (there's no risk of modifying the input as
4200+
# there are no flattened fields), or create one.
4201+
if not isinstance(request, firestore_admin.CloneDatabaseRequest):
4202+
request = firestore_admin.CloneDatabaseRequest(request)
4203+
4204+
# Wrap the RPC method; this adds retry and timeout information,
4205+
# and friendly error handling.
4206+
rpc = self._client._transport._wrapped_methods[
4207+
self._client._transport.clone_database
4208+
]
4209+
4210+
header_params = {}
4211+
4212+
routing_param_regex = re.compile("^projects/(?P<project_id>[^/]+)(?:/.*)?$")
4213+
regex_match = routing_param_regex.match(request.pitr_snapshot.database)
4214+
if regex_match and regex_match.group("project_id"):
4215+
header_params["project_id"] = regex_match.group("project_id")
4216+
4217+
routing_param_regex = re.compile(
4218+
"^projects/[^/]+/databases/(?P<database_id>[^/]+)(?:/.*)?$"
4219+
)
4220+
regex_match = routing_param_regex.match(request.pitr_snapshot.database)
4221+
if regex_match and regex_match.group("database_id"):
4222+
header_params["database_id"] = regex_match.group("database_id")
4223+
4224+
if header_params:
4225+
metadata = tuple(metadata) + (
4226+
gapic_v1.routing_header.to_grpc_metadata(header_params),
4227+
)
4228+
4229+
# Validate the universe domain.
4230+
self._client._validate_universe_domain()
4231+
4232+
# Send the request.
4233+
response = await rpc(
4234+
request,
4235+
retry=retry,
4236+
timeout=timeout,
4237+
metadata=metadata,
4238+
)
4239+
4240+
# Wrap the response in an operation future.
4241+
response = operation_async.from_gapic(
4242+
response,
4243+
self._client._transport.operations_client,
4244+
database.Database,
4245+
metadata_type=gfa_operation.CloneDatabaseMetadata,
4246+
)
4247+
4248+
# Done; return the response.
4249+
return response
4250+
41144251
async def list_operations(
41154252
self,
41164253
request: Optional[operations_pb2.ListOperationsRequest] = None,

packages/google-cloud-firestore/google/cloud/firestore_admin_v1/services/firestore_admin/client.py

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4591,6 +4591,141 @@ def sample_delete_backup_schedule():
45914591
metadata=metadata,
45924592
)
45934593

4594+
def clone_database(
4595+
self,
4596+
request: Optional[Union[firestore_admin.CloneDatabaseRequest, dict]] = None,
4597+
*,
4598+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
4599+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
4600+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
4601+
) -> gac_operation.Operation:
4602+
r"""Creates a new database by cloning an existing one.
4603+
4604+
The new database must be in the same cloud region or
4605+
multi-region location as the existing database. This behaves
4606+
similar to
4607+
[FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase]
4608+
except instead of creating a new empty database, a new database
4609+
is created with the database type, index configuration, and
4610+
documents from an existing database.
4611+
4612+
The [long-running operation][google.longrunning.Operation] can
4613+
be used to track the progress of the clone, with the Operation's
4614+
[metadata][google.longrunning.Operation.metadata] field type
4615+
being the
4616+
[CloneDatabaseMetadata][google.firestore.admin.v1.CloneDatabaseMetadata].
4617+
The [response][google.longrunning.Operation.response] type is
4618+
the [Database][google.firestore.admin.v1.Database] if the clone
4619+
was successful. The new database is not readable or writeable
4620+
until the LRO has completed.
4621+
4622+
.. code-block:: python
4623+
4624+
# This snippet has been automatically generated and should be regarded as a
4625+
# code template only.
4626+
# It will require modifications to work:
4627+
# - It may require correct/in-range values for request initialization.
4628+
# - It may require specifying regional endpoints when creating the service
4629+
# client as shown in:
4630+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
4631+
from google.cloud import firestore_admin_v1
4632+
4633+
def sample_clone_database():
4634+
# Create a client
4635+
client = firestore_admin_v1.FirestoreAdminClient()
4636+
4637+
# Initialize request argument(s)
4638+
pitr_snapshot = firestore_admin_v1.PitrSnapshot()
4639+
pitr_snapshot.database = "database_value"
4640+
4641+
request = firestore_admin_v1.CloneDatabaseRequest(
4642+
parent="parent_value",
4643+
database_id="database_id_value",
4644+
pitr_snapshot=pitr_snapshot,
4645+
)
4646+
4647+
# Make the request
4648+
operation = client.clone_database(request=request)
4649+
4650+
print("Waiting for operation to complete...")
4651+
4652+
response = operation.result()
4653+
4654+
# Handle the response
4655+
print(response)
4656+
4657+
Args:
4658+
request (Union[google.cloud.firestore_admin_v1.types.CloneDatabaseRequest, dict]):
4659+
The request object. The request message for
4660+
[FirestoreAdmin.CloneDatabase][google.firestore.admin.v1.FirestoreAdmin.CloneDatabase].
4661+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
4662+
should be retried.
4663+
timeout (float): The timeout for this request.
4664+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
4665+
sent along with the request as metadata. Normally, each value must be of type `str`,
4666+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
4667+
be of type `bytes`.
4668+
4669+
Returns:
4670+
google.api_core.operation.Operation:
4671+
An object representing a long-running operation.
4672+
4673+
The result type for the operation will be
4674+
:class:`google.cloud.firestore_admin_v1.types.Database`
4675+
A Cloud Firestore Database.
4676+
4677+
"""
4678+
# Create or coerce a protobuf request object.
4679+
# - Use the request object if provided (there's no risk of modifying the input as
4680+
# there are no flattened fields), or create one.
4681+
if not isinstance(request, firestore_admin.CloneDatabaseRequest):
4682+
request = firestore_admin.CloneDatabaseRequest(request)
4683+
4684+
# Wrap the RPC method; this adds retry and timeout information,
4685+
# and friendly error handling.
4686+
rpc = self._transport._wrapped_methods[self._transport.clone_database]
4687+
4688+
header_params = {}
4689+
4690+
routing_param_regex = re.compile("^projects/(?P<project_id>[^/]+)(?:/.*)?$")
4691+
regex_match = routing_param_regex.match(request.pitr_snapshot.database)
4692+
if regex_match and regex_match.group("project_id"):
4693+
header_params["project_id"] = regex_match.group("project_id")
4694+
4695+
routing_param_regex = re.compile(
4696+
"^projects/[^/]+/databases/(?P<database_id>[^/]+)(?:/.*)?$"
4697+
)
4698+
regex_match = routing_param_regex.match(request.pitr_snapshot.database)
4699+
if regex_match and regex_match.group("database_id"):
4700+
header_params["database_id"] = regex_match.group("database_id")
4701+
4702+
if header_params:
4703+
metadata = tuple(metadata) + (
4704+
gapic_v1.routing_header.to_grpc_metadata(header_params),
4705+
)
4706+
4707+
# Validate the universe domain.
4708+
self._validate_universe_domain()
4709+
4710+
# Send the request.
4711+
response = rpc(
4712+
request,
4713+
retry=retry,
4714+
timeout=timeout,
4715+
metadata=metadata,
4716+
)
4717+
4718+
# Wrap the response in an operation future.
4719+
response = gac_operation.from_gapic(
4720+
response,
4721+
self._transport.operations_client,
4722+
database.Database,
4723+
metadata_type=gfa_operation.CloneDatabaseMetadata,
4724+
)
4725+
4726+
# Done; return the response.
4727+
return response
4728+
45944729
def __enter__(self) -> "FirestoreAdminClient":
45954730
return self
45964731

packages/google-cloud-firestore/google/cloud/firestore_admin_v1/services/firestore_admin/transports/base.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,10 @@ def __init__(
8181
credentials identify the application to the service; if none
8282
are specified, the client will attempt to ascertain the
8383
credentials from the environment.
84-
credentials_file (Optional[str]): A file with credentials that can
84+
credentials_file (Optional[str]): Deprecated. A file with credentials that can
8585
be loaded with :func:`google.auth.load_credentials_from_file`.
86-
This argument is mutually exclusive with credentials.
86+
This argument is mutually exclusive with credentials. This argument will be
87+
removed in the next major version of this library.
8788
scopes (Optional[Sequence[str]]): A list of scopes.
8889
quota_project_id (Optional[str]): An optional project to use for billing
8990
and quota.
@@ -357,6 +358,11 @@ def _prep_wrapped_messages(self, client_info):
357358
default_timeout=None,
358359
client_info=client_info,
359360
),
361+
self.clone_database: gapic_v1.method.wrap_method(
362+
self.clone_database,
363+
default_timeout=120.0,
364+
client_info=client_info,
365+
),
360366
self.cancel_operation: gapic_v1.method.wrap_method(
361367
self.cancel_operation,
362368
default_timeout=None,
@@ -688,6 +694,15 @@ def delete_backup_schedule(
688694
]:
689695
raise NotImplementedError()
690696

697+
@property
698+
def clone_database(
699+
self,
700+
) -> Callable[
701+
[firestore_admin.CloneDatabaseRequest],
702+
Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]],
703+
]:
704+
raise NotImplementedError()
705+
691706
@property
692707
def list_operations(
693708
self,

0 commit comments

Comments
 (0)