Skip to content

Commit 4105df7

Browse files
feat: publish CopyBackup protos to external customers (#855)
* feat: publish CopyBackup protos to external customers PiperOrigin-RevId: 557192020 Source-Link: googleapis/googleapis@b4c238f Source-Link: googleapis/googleapis-gen@feccb30 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZmVjY2IzMGUzMTc3ZGE4YjdiN2U2ODE0OWNhNGJiOTE0ZjhmYWYyYSJ9 * 🦉 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 9b1f9c2 commit 4105df7

File tree

14 files changed

+1221
-37
lines changed

14 files changed

+1221
-37
lines changed

google/cloud/bigtable_admin/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@
115115
from google.cloud.bigtable_admin_v2.types.bigtable_table_admin import (
116116
CheckConsistencyResponse,
117117
)
118+
from google.cloud.bigtable_admin_v2.types.bigtable_table_admin import CopyBackupMetadata
119+
from google.cloud.bigtable_admin_v2.types.bigtable_table_admin import CopyBackupRequest
118120
from google.cloud.bigtable_admin_v2.types.bigtable_table_admin import (
119121
CreateBackupMetadata,
120122
)
@@ -242,6 +244,8 @@
242244
"UpdateInstanceMetadata",
243245
"CheckConsistencyRequest",
244246
"CheckConsistencyResponse",
247+
"CopyBackupMetadata",
248+
"CopyBackupRequest",
245249
"CreateBackupMetadata",
246250
"CreateBackupRequest",
247251
"CreateTableFromSnapshotMetadata",

google/cloud/bigtable_admin_v2/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
from .types.bigtable_instance_admin import UpdateInstanceMetadata
5252
from .types.bigtable_table_admin import CheckConsistencyRequest
5353
from .types.bigtable_table_admin import CheckConsistencyResponse
54+
from .types.bigtable_table_admin import CopyBackupMetadata
55+
from .types.bigtable_table_admin import CopyBackupRequest
5456
from .types.bigtable_table_admin import CreateBackupMetadata
5557
from .types.bigtable_table_admin import CreateBackupRequest
5658
from .types.bigtable_table_admin import CreateTableFromSnapshotMetadata
@@ -116,6 +118,8 @@
116118
"CheckConsistencyResponse",
117119
"Cluster",
118120
"ColumnFamily",
121+
"CopyBackupMetadata",
122+
"CopyBackupRequest",
119123
"CreateAppProfileRequest",
120124
"CreateBackupMetadata",
121125
"CreateBackupRequest",

google/cloud/bigtable_admin_v2/gapic_metadata.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,11 @@
349349
"check_consistency"
350350
]
351351
},
352+
"CopyBackup": {
353+
"methods": [
354+
"copy_backup"
355+
]
356+
},
352357
"CreateBackup": {
353358
"methods": [
354359
"create_backup"
@@ -474,6 +479,11 @@
474479
"check_consistency"
475480
]
476481
},
482+
"CopyBackup": {
483+
"methods": [
484+
"copy_backup"
485+
]
486+
},
477487
"CreateBackup": {
478488
"methods": [
479489
"create_backup"
@@ -599,6 +609,11 @@
599609
"check_consistency"
600610
]
601611
},
612+
"CopyBackup": {
613+
"methods": [
614+
"copy_backup"
615+
]
616+
},
602617
"CreateBackup": {
603618
"methods": [
604619
"create_backup"

google/cloud/bigtable_admin_v2/services/bigtable_table_admin/async_client.py

Lines changed: 138 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2143,7 +2143,7 @@ async def list_backups(
21432143
Returns:
21442144
google.cloud.bigtable_admin_v2.services.bigtable_table_admin.pagers.ListBackupsAsyncPager:
21452145
The response for
2146-
[ListBackups][google.bigtable.admin.v2.BigtableTableAdmin.ListBackups].
2146+
[ListBackups][google.bigtable.admin.v2.BigtableTableAdmin.ListBackups].
21472147
21482148
Iterating over this object will yield results and
21492149
resolve additional pages automatically.
@@ -2218,9 +2218,8 @@ async def restore_table(
22182218
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
22192219
metadata: Sequence[Tuple[str, str]] = (),
22202220
) -> operation_async.AsyncOperation:
2221-
r"""Create a new table by restoring from a completed backup. The new
2222-
table must be in the same project as the instance containing the
2223-
backup. The returned table [long-running
2221+
r"""Create a new table by restoring from a completed backup. The
2222+
returned table [long-running
22242223
operation][google.longrunning.Operation] can be used to track
22252224
the progress of the operation, and to cancel it. The
22262225
[metadata][google.longrunning.Operation.metadata] field type is
@@ -2283,6 +2282,141 @@ async def restore_table(
22832282
# Done; return the response.
22842283
return response
22852284

2285+
async def copy_backup(
2286+
self,
2287+
request: Optional[Union[bigtable_table_admin.CopyBackupRequest, dict]] = None,
2288+
*,
2289+
parent: Optional[str] = None,
2290+
backup_id: Optional[str] = None,
2291+
source_backup: Optional[str] = None,
2292+
expire_time: Optional[timestamp_pb2.Timestamp] = None,
2293+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
2294+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2295+
metadata: Sequence[Tuple[str, str]] = (),
2296+
) -> operation_async.AsyncOperation:
2297+
r"""Copy a Cloud Bigtable backup to a new backup in the
2298+
destination cluster located in the destination instance
2299+
and project.
2300+
2301+
Args:
2302+
request (Optional[Union[google.cloud.bigtable_admin_v2.types.CopyBackupRequest, dict]]):
2303+
The request object. The request for
2304+
[CopyBackup][google.bigtable.admin.v2.BigtableTableAdmin.CopyBackup].
2305+
parent (:class:`str`):
2306+
Required. The name of the destination cluster that will
2307+
contain the backup copy. The cluster must already
2308+
exists. Values are of the form:
2309+
``projects/{project}/instances/{instance}/clusters/{cluster}``.
2310+
2311+
This corresponds to the ``parent`` field
2312+
on the ``request`` instance; if ``request`` is provided, this
2313+
should not be set.
2314+
backup_id (:class:`str`):
2315+
Required. The id of the new backup. The ``backup_id``
2316+
along with ``parent`` are combined as
2317+
{parent}/backups/{backup_id} to create the full backup
2318+
name, of the form:
2319+
``projects/{project}/instances/{instance}/clusters/{cluster}/backups/{backup_id}``.
2320+
This string must be between 1 and 50 characters in
2321+
length and match the regex [*a-zA-Z0-9][-*.a-zA-Z0-9]*.
2322+
2323+
This corresponds to the ``backup_id`` field
2324+
on the ``request`` instance; if ``request`` is provided, this
2325+
should not be set.
2326+
source_backup (:class:`str`):
2327+
Required. The source backup to be copied from. The
2328+
source backup needs to be in READY state for it to be
2329+
copied. Copying a copied backup is not allowed. Once
2330+
CopyBackup is in progress, the source backup cannot be
2331+
deleted or cleaned up on expiration until CopyBackup is
2332+
finished. Values are of the form:
2333+
``projects/<project>/instances/<instance>/clusters/<cluster>/backups/<backup>``.
2334+
2335+
This corresponds to the ``source_backup`` field
2336+
on the ``request`` instance; if ``request`` is provided, this
2337+
should not be set.
2338+
expire_time (:class:`google.protobuf.timestamp_pb2.Timestamp`):
2339+
Required. Required. The expiration time of the copied
2340+
backup with microsecond granularity that must be at
2341+
least 6 hours and at most 30 days from the time the
2342+
request is received. Once the ``expire_time`` has
2343+
passed, Cloud Bigtable will delete the backup and free
2344+
the resources used by the backup.
2345+
2346+
This corresponds to the ``expire_time`` field
2347+
on the ``request`` instance; if ``request`` is provided, this
2348+
should not be set.
2349+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
2350+
should be retried.
2351+
timeout (float): The timeout for this request.
2352+
metadata (Sequence[Tuple[str, str]]): Strings which should be
2353+
sent along with the request as metadata.
2354+
2355+
Returns:
2356+
google.api_core.operation_async.AsyncOperation:
2357+
An object representing a long-running operation.
2358+
2359+
The result type for the operation will be
2360+
:class:`google.cloud.bigtable_admin_v2.types.Backup` A
2361+
backup of a Cloud Bigtable table.
2362+
2363+
"""
2364+
# Create or coerce a protobuf request object.
2365+
# Quick check: If we got a request object, we should *not* have
2366+
# gotten any keyword arguments that map to the request.
2367+
has_flattened_params = any([parent, backup_id, source_backup, expire_time])
2368+
if request is not None and has_flattened_params:
2369+
raise ValueError(
2370+
"If the `request` argument is set, then none of "
2371+
"the individual field arguments should be set."
2372+
)
2373+
2374+
request = bigtable_table_admin.CopyBackupRequest(request)
2375+
2376+
# If we have keyword arguments corresponding to fields on the
2377+
# request, apply these.
2378+
if parent is not None:
2379+
request.parent = parent
2380+
if backup_id is not None:
2381+
request.backup_id = backup_id
2382+
if source_backup is not None:
2383+
request.source_backup = source_backup
2384+
if expire_time is not None:
2385+
request.expire_time = expire_time
2386+
2387+
# Wrap the RPC method; this adds retry and timeout information,
2388+
# and friendly error handling.
2389+
rpc = gapic_v1.method_async.wrap_method(
2390+
self._client._transport.copy_backup,
2391+
default_timeout=None,
2392+
client_info=DEFAULT_CLIENT_INFO,
2393+
)
2394+
2395+
# Certain fields should be provided within the metadata header;
2396+
# add these here.
2397+
metadata = tuple(metadata) + (
2398+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
2399+
)
2400+
2401+
# Send the request.
2402+
response = await rpc(
2403+
request,
2404+
retry=retry,
2405+
timeout=timeout,
2406+
metadata=metadata,
2407+
)
2408+
2409+
# Wrap the response in an operation future.
2410+
response = operation_async.from_gapic(
2411+
response,
2412+
self._client._transport.operations_client,
2413+
table.Backup,
2414+
metadata_type=bigtable_table_admin.CopyBackupMetadata,
2415+
)
2416+
2417+
# Done; return the response.
2418+
return response
2419+
22862420
async def get_iam_policy(
22872421
self,
22882422
request: Optional[Union[iam_policy_pb2.GetIamPolicyRequest, dict]] = None,

google/cloud/bigtable_admin_v2/services/bigtable_table_admin/client.py

Lines changed: 138 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2407,7 +2407,7 @@ def list_backups(
24072407
Returns:
24082408
google.cloud.bigtable_admin_v2.services.bigtable_table_admin.pagers.ListBackupsPager:
24092409
The response for
2410-
[ListBackups][google.bigtable.admin.v2.BigtableTableAdmin.ListBackups].
2410+
[ListBackups][google.bigtable.admin.v2.BigtableTableAdmin.ListBackups].
24112411
24122412
Iterating over this object will yield results and
24132413
resolve additional pages automatically.
@@ -2472,9 +2472,8 @@ def restore_table(
24722472
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
24732473
metadata: Sequence[Tuple[str, str]] = (),
24742474
) -> operation.Operation:
2475-
r"""Create a new table by restoring from a completed backup. The new
2476-
table must be in the same project as the instance containing the
2477-
backup. The returned table [long-running
2475+
r"""Create a new table by restoring from a completed backup. The
2476+
returned table [long-running
24782477
operation][google.longrunning.Operation] can be used to track
24792478
the progress of the operation, and to cancel it. The
24802479
[metadata][google.longrunning.Operation.metadata] field type is
@@ -2538,6 +2537,141 @@ def restore_table(
25382537
# Done; return the response.
25392538
return response
25402539

2540+
def copy_backup(
2541+
self,
2542+
request: Optional[Union[bigtable_table_admin.CopyBackupRequest, dict]] = None,
2543+
*,
2544+
parent: Optional[str] = None,
2545+
backup_id: Optional[str] = None,
2546+
source_backup: Optional[str] = None,
2547+
expire_time: Optional[timestamp_pb2.Timestamp] = None,
2548+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
2549+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2550+
metadata: Sequence[Tuple[str, str]] = (),
2551+
) -> operation.Operation:
2552+
r"""Copy a Cloud Bigtable backup to a new backup in the
2553+
destination cluster located in the destination instance
2554+
and project.
2555+
2556+
Args:
2557+
request (Union[google.cloud.bigtable_admin_v2.types.CopyBackupRequest, dict]):
2558+
The request object. The request for
2559+
[CopyBackup][google.bigtable.admin.v2.BigtableTableAdmin.CopyBackup].
2560+
parent (str):
2561+
Required. The name of the destination cluster that will
2562+
contain the backup copy. The cluster must already
2563+
exists. Values are of the form:
2564+
``projects/{project}/instances/{instance}/clusters/{cluster}``.
2565+
2566+
This corresponds to the ``parent`` field
2567+
on the ``request`` instance; if ``request`` is provided, this
2568+
should not be set.
2569+
backup_id (str):
2570+
Required. The id of the new backup. The ``backup_id``
2571+
along with ``parent`` are combined as
2572+
{parent}/backups/{backup_id} to create the full backup
2573+
name, of the form:
2574+
``projects/{project}/instances/{instance}/clusters/{cluster}/backups/{backup_id}``.
2575+
This string must be between 1 and 50 characters in
2576+
length and match the regex [*a-zA-Z0-9][-*.a-zA-Z0-9]*.
2577+
2578+
This corresponds to the ``backup_id`` field
2579+
on the ``request`` instance; if ``request`` is provided, this
2580+
should not be set.
2581+
source_backup (str):
2582+
Required. The source backup to be copied from. The
2583+
source backup needs to be in READY state for it to be
2584+
copied. Copying a copied backup is not allowed. Once
2585+
CopyBackup is in progress, the source backup cannot be
2586+
deleted or cleaned up on expiration until CopyBackup is
2587+
finished. Values are of the form:
2588+
``projects/<project>/instances/<instance>/clusters/<cluster>/backups/<backup>``.
2589+
2590+
This corresponds to the ``source_backup`` field
2591+
on the ``request`` instance; if ``request`` is provided, this
2592+
should not be set.
2593+
expire_time (google.protobuf.timestamp_pb2.Timestamp):
2594+
Required. Required. The expiration time of the copied
2595+
backup with microsecond granularity that must be at
2596+
least 6 hours and at most 30 days from the time the
2597+
request is received. Once the ``expire_time`` has
2598+
passed, Cloud Bigtable will delete the backup and free
2599+
the resources used by the backup.
2600+
2601+
This corresponds to the ``expire_time`` field
2602+
on the ``request`` instance; if ``request`` is provided, this
2603+
should not be set.
2604+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
2605+
should be retried.
2606+
timeout (float): The timeout for this request.
2607+
metadata (Sequence[Tuple[str, str]]): Strings which should be
2608+
sent along with the request as metadata.
2609+
2610+
Returns:
2611+
google.api_core.operation.Operation:
2612+
An object representing a long-running operation.
2613+
2614+
The result type for the operation will be
2615+
:class:`google.cloud.bigtable_admin_v2.types.Backup` A
2616+
backup of a Cloud Bigtable table.
2617+
2618+
"""
2619+
# Create or coerce a protobuf request object.
2620+
# Quick check: If we got a request object, we should *not* have
2621+
# gotten any keyword arguments that map to the request.
2622+
has_flattened_params = any([parent, backup_id, source_backup, expire_time])
2623+
if request is not None and has_flattened_params:
2624+
raise ValueError(
2625+
"If the `request` argument is set, then none of "
2626+
"the individual field arguments should be set."
2627+
)
2628+
2629+
# Minor optimization to avoid making a copy if the user passes
2630+
# in a bigtable_table_admin.CopyBackupRequest.
2631+
# There's no risk of modifying the input as we've already verified
2632+
# there are no flattened fields.
2633+
if not isinstance(request, bigtable_table_admin.CopyBackupRequest):
2634+
request = bigtable_table_admin.CopyBackupRequest(request)
2635+
# If we have keyword arguments corresponding to fields on the
2636+
# request, apply these.
2637+
if parent is not None:
2638+
request.parent = parent
2639+
if backup_id is not None:
2640+
request.backup_id = backup_id
2641+
if source_backup is not None:
2642+
request.source_backup = source_backup
2643+
if expire_time is not None:
2644+
request.expire_time = expire_time
2645+
2646+
# Wrap the RPC method; this adds retry and timeout information,
2647+
# and friendly error handling.
2648+
rpc = self._transport._wrapped_methods[self._transport.copy_backup]
2649+
2650+
# Certain fields should be provided within the metadata header;
2651+
# add these here.
2652+
metadata = tuple(metadata) + (
2653+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
2654+
)
2655+
2656+
# Send the request.
2657+
response = rpc(
2658+
request,
2659+
retry=retry,
2660+
timeout=timeout,
2661+
metadata=metadata,
2662+
)
2663+
2664+
# Wrap the response in an operation future.
2665+
response = operation.from_gapic(
2666+
response,
2667+
self._transport.operations_client,
2668+
table.Backup,
2669+
metadata_type=bigtable_table_admin.CopyBackupMetadata,
2670+
)
2671+
2672+
# Done; return the response.
2673+
return response
2674+
25412675
def get_iam_policy(
25422676
self,
25432677
request: Optional[Union[iam_policy_pb2.GetIamPolicyRequest, dict]] = None,

0 commit comments

Comments
 (0)