Skip to content

Commit c57289c

Browse files
feat: Publish CBT deletion_protection field in Table, UpdateTableRequest, and UpdateTable API (googleapis#670)
* feat: Publish CBT deletion_protection field in Table, UpdateTableRequest, and UpdateTable API in **stable** proto to external customers PiperOrigin-RevId: 474010093 Source-Link: googleapis/googleapis@e210283 Source-Link: https://github.com/googleapis/googleapis-gen/commit/46d5c58b647ea9c050a00c3b6825a3cf316f8948 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDZkNWM1OGI2NDdlYTljMDUwYTAwYzNiNjgyNWEzY2YzMTZmODk0OCJ9 * 🦉 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 99d3318 commit c57289c

12 files changed

Lines changed: 633 additions & 0 deletions

File tree

google/cloud/bigtable_admin_v2/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@
7676
from .types.bigtable_table_admin import UndeleteTableMetadata
7777
from .types.bigtable_table_admin import UndeleteTableRequest
7878
from .types.bigtable_table_admin import UpdateBackupRequest
79+
from .types.bigtable_table_admin import UpdateTableMetadata
80+
from .types.bigtable_table_admin import UpdateTableRequest
7981
from .types.common import OperationProgress
8082
from .types.common import StorageType
8183
from .types.instance import AppProfile
@@ -173,4 +175,6 @@
173175
"UpdateBackupRequest",
174176
"UpdateClusterMetadata",
175177
"UpdateInstanceMetadata",
178+
"UpdateTableMetadata",
179+
"UpdateTableRequest",
176180
)

google/cloud/bigtable_admin_v2/gapic_metadata.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,11 @@
348348
"methods": [
349349
"update_backup"
350350
]
351+
},
352+
"UpdateTable": {
353+
"methods": [
354+
"update_table"
355+
]
351356
}
352357
}
353358
},
@@ -468,6 +473,11 @@
468473
"methods": [
469474
"update_backup"
470475
]
476+
},
477+
"UpdateTable": {
478+
"methods": [
479+
"update_table"
480+
]
471481
}
472482
}
473483
}

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

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,115 @@ async def get_table(
646646
# Done; return the response.
647647
return response
648648

649+
async def update_table(
650+
self,
651+
request: Union[bigtable_table_admin.UpdateTableRequest, dict] = None,
652+
*,
653+
table: gba_table.Table = None,
654+
update_mask: field_mask_pb2.FieldMask = None,
655+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
656+
timeout: float = None,
657+
metadata: Sequence[Tuple[str, str]] = (),
658+
) -> operation_async.AsyncOperation:
659+
r"""Updates a specified table.
660+
661+
Args:
662+
request (Union[google.cloud.bigtable_admin_v2.types.UpdateTableRequest, dict]):
663+
The request object. The request for
664+
[UpdateTable][google.bigtable.admin.v2.BigtableTableAdmin.UpdateTable].
665+
table (:class:`google.cloud.bigtable_admin_v2.types.Table`):
666+
Required. The table to update. The table's ``name``
667+
field is used to identify the table to update. Format:
668+
``projects/{project}/instances/{instance}/tables/[_a-zA-Z0-9][-_.a-zA-Z0-9]*``
669+
670+
This corresponds to the ``table`` field
671+
on the ``request`` instance; if ``request`` is provided, this
672+
should not be set.
673+
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
674+
Required. The list of fields to update. A mask
675+
specifying which fields (e.g. ``deletion_protection``)
676+
in the ``table`` field should be updated. This mask is
677+
relative to the ``table`` field, not to the request
678+
message. The wildcard (*) path is currently not
679+
supported. Currently UpdateTable is only supported for
680+
the following field:
681+
682+
- ``deletion_protection`` If ``column_families`` is set
683+
in ``update_mask``, it will return an UNIMPLEMENTED
684+
error.
685+
686+
This corresponds to the ``update_mask`` field
687+
on the ``request`` instance; if ``request`` is provided, this
688+
should not be set.
689+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
690+
should be retried.
691+
timeout (float): The timeout for this request.
692+
metadata (Sequence[Tuple[str, str]]): Strings which should be
693+
sent along with the request as metadata.
694+
695+
Returns:
696+
google.api_core.operation_async.AsyncOperation:
697+
An object representing a long-running operation.
698+
699+
The result type for the operation will be :class:`google.cloud.bigtable_admin_v2.types.Table` A collection of user data indexed by row, column, and timestamp.
700+
Each table is served using the resources of its
701+
parent cluster.
702+
703+
"""
704+
# Create or coerce a protobuf request object.
705+
# Quick check: If we got a request object, we should *not* have
706+
# gotten any keyword arguments that map to the request.
707+
has_flattened_params = any([table, update_mask])
708+
if request is not None and has_flattened_params:
709+
raise ValueError(
710+
"If the `request` argument is set, then none of "
711+
"the individual field arguments should be set."
712+
)
713+
714+
request = bigtable_table_admin.UpdateTableRequest(request)
715+
716+
# If we have keyword arguments corresponding to fields on the
717+
# request, apply these.
718+
if table is not None:
719+
request.table = table
720+
if update_mask is not None:
721+
request.update_mask = update_mask
722+
723+
# Wrap the RPC method; this adds retry and timeout information,
724+
# and friendly error handling.
725+
rpc = gapic_v1.method_async.wrap_method(
726+
self._client._transport.update_table,
727+
default_timeout=None,
728+
client_info=DEFAULT_CLIENT_INFO,
729+
)
730+
731+
# Certain fields should be provided within the metadata header;
732+
# add these here.
733+
metadata = tuple(metadata) + (
734+
gapic_v1.routing_header.to_grpc_metadata(
735+
(("table.name", request.table.name),)
736+
),
737+
)
738+
739+
# Send the request.
740+
response = await rpc(
741+
request,
742+
retry=retry,
743+
timeout=timeout,
744+
metadata=metadata,
745+
)
746+
747+
# Wrap the response in an operation future.
748+
response = operation_async.from_gapic(
749+
response,
750+
self._client._transport.operations_client,
751+
gba_table.Table,
752+
metadata_type=bigtable_table_admin.UpdateTableMetadata,
753+
)
754+
755+
# Done; return the response.
756+
return response
757+
649758
async def delete_table(
650759
self,
651760
request: Union[bigtable_table_admin.DeleteTableRequest, dict] = None,

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

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,115 @@ def get_table(
951951
# Done; return the response.
952952
return response
953953

954+
def update_table(
955+
self,
956+
request: Union[bigtable_table_admin.UpdateTableRequest, dict] = None,
957+
*,
958+
table: gba_table.Table = None,
959+
update_mask: field_mask_pb2.FieldMask = None,
960+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
961+
timeout: float = None,
962+
metadata: Sequence[Tuple[str, str]] = (),
963+
) -> operation.Operation:
964+
r"""Updates a specified table.
965+
966+
Args:
967+
request (Union[google.cloud.bigtable_admin_v2.types.UpdateTableRequest, dict]):
968+
The request object. The request for
969+
[UpdateTable][google.bigtable.admin.v2.BigtableTableAdmin.UpdateTable].
970+
table (google.cloud.bigtable_admin_v2.types.Table):
971+
Required. The table to update. The table's ``name``
972+
field is used to identify the table to update. Format:
973+
``projects/{project}/instances/{instance}/tables/[_a-zA-Z0-9][-_.a-zA-Z0-9]*``
974+
975+
This corresponds to the ``table`` field
976+
on the ``request`` instance; if ``request`` is provided, this
977+
should not be set.
978+
update_mask (google.protobuf.field_mask_pb2.FieldMask):
979+
Required. The list of fields to update. A mask
980+
specifying which fields (e.g. ``deletion_protection``)
981+
in the ``table`` field should be updated. This mask is
982+
relative to the ``table`` field, not to the request
983+
message. The wildcard (*) path is currently not
984+
supported. Currently UpdateTable is only supported for
985+
the following field:
986+
987+
- ``deletion_protection`` If ``column_families`` is set
988+
in ``update_mask``, it will return an UNIMPLEMENTED
989+
error.
990+
991+
This corresponds to the ``update_mask`` field
992+
on the ``request`` instance; if ``request`` is provided, this
993+
should not be set.
994+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
995+
should be retried.
996+
timeout (float): The timeout for this request.
997+
metadata (Sequence[Tuple[str, str]]): Strings which should be
998+
sent along with the request as metadata.
999+
1000+
Returns:
1001+
google.api_core.operation.Operation:
1002+
An object representing a long-running operation.
1003+
1004+
The result type for the operation will be :class:`google.cloud.bigtable_admin_v2.types.Table` A collection of user data indexed by row, column, and timestamp.
1005+
Each table is served using the resources of its
1006+
parent cluster.
1007+
1008+
"""
1009+
# Create or coerce a protobuf request object.
1010+
# Quick check: If we got a request object, we should *not* have
1011+
# gotten any keyword arguments that map to the request.
1012+
has_flattened_params = any([table, update_mask])
1013+
if request is not None and has_flattened_params:
1014+
raise ValueError(
1015+
"If the `request` argument is set, then none of "
1016+
"the individual field arguments should be set."
1017+
)
1018+
1019+
# Minor optimization to avoid making a copy if the user passes
1020+
# in a bigtable_table_admin.UpdateTableRequest.
1021+
# There's no risk of modifying the input as we've already verified
1022+
# there are no flattened fields.
1023+
if not isinstance(request, bigtable_table_admin.UpdateTableRequest):
1024+
request = bigtable_table_admin.UpdateTableRequest(request)
1025+
# If we have keyword arguments corresponding to fields on the
1026+
# request, apply these.
1027+
if table is not None:
1028+
request.table = table
1029+
if update_mask is not None:
1030+
request.update_mask = update_mask
1031+
1032+
# Wrap the RPC method; this adds retry and timeout information,
1033+
# and friendly error handling.
1034+
rpc = self._transport._wrapped_methods[self._transport.update_table]
1035+
1036+
# Certain fields should be provided within the metadata header;
1037+
# add these here.
1038+
metadata = tuple(metadata) + (
1039+
gapic_v1.routing_header.to_grpc_metadata(
1040+
(("table.name", request.table.name),)
1041+
),
1042+
)
1043+
1044+
# Send the request.
1045+
response = rpc(
1046+
request,
1047+
retry=retry,
1048+
timeout=timeout,
1049+
metadata=metadata,
1050+
)
1051+
1052+
# Wrap the response in an operation future.
1053+
response = operation.from_gapic(
1054+
response,
1055+
self._transport.operations_client,
1056+
gba_table.Table,
1057+
metadata_type=bigtable_table_admin.UpdateTableMetadata,
1058+
)
1059+
1060+
# Done; return the response.
1061+
return response
1062+
9541063
def delete_table(
9551064
self,
9561065
request: Union[bigtable_table_admin.DeleteTableRequest, dict] = None,

google/cloud/bigtable_admin_v2/services/bigtable_table_admin/transports/base.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ def _prep_wrapped_messages(self, client_info):
181181
default_timeout=60.0,
182182
client_info=client_info,
183183
),
184+
self.update_table: gapic_v1.method.wrap_method(
185+
self.update_table,
186+
default_timeout=None,
187+
client_info=client_info,
188+
),
184189
self.delete_table: gapic_v1.method.wrap_method(
185190
self.delete_table,
186191
default_timeout=60.0,
@@ -411,6 +416,15 @@ def get_table(
411416
]:
412417
raise NotImplementedError()
413418

419+
@property
420+
def update_table(
421+
self,
422+
) -> Callable[
423+
[bigtable_table_admin.UpdateTableRequest],
424+
Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]],
425+
]:
426+
raise NotImplementedError()
427+
414428
@property
415429
def delete_table(
416430
self,

google/cloud/bigtable_admin_v2/services/bigtable_table_admin/transports/grpc.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,32 @@ def get_table(
374374
)
375375
return self._stubs["get_table"]
376376

377+
@property
378+
def update_table(
379+
self,
380+
) -> Callable[[bigtable_table_admin.UpdateTableRequest], operations_pb2.Operation]:
381+
r"""Return a callable for the update table method over gRPC.
382+
383+
Updates a specified table.
384+
385+
Returns:
386+
Callable[[~.UpdateTableRequest],
387+
~.Operation]:
388+
A function that, when called, will call the underlying RPC
389+
on the server.
390+
"""
391+
# Generate a "stub function" on-the-fly which will actually make
392+
# the request.
393+
# gRPC handles serialization and deserialization, so we just need
394+
# to pass in the functions for each.
395+
if "update_table" not in self._stubs:
396+
self._stubs["update_table"] = self.grpc_channel.unary_unary(
397+
"/google.bigtable.admin.v2.BigtableTableAdmin/UpdateTable",
398+
request_serializer=bigtable_table_admin.UpdateTableRequest.serialize,
399+
response_deserializer=operations_pb2.Operation.FromString,
400+
)
401+
return self._stubs["update_table"]
402+
377403
@property
378404
def delete_table(
379405
self,

google/cloud/bigtable_admin_v2/services/bigtable_table_admin/transports/grpc_asyncio.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,34 @@ def get_table(
382382
)
383383
return self._stubs["get_table"]
384384

385+
@property
386+
def update_table(
387+
self,
388+
) -> Callable[
389+
[bigtable_table_admin.UpdateTableRequest], Awaitable[operations_pb2.Operation]
390+
]:
391+
r"""Return a callable for the update table method over gRPC.
392+
393+
Updates a specified table.
394+
395+
Returns:
396+
Callable[[~.UpdateTableRequest],
397+
Awaitable[~.Operation]]:
398+
A function that, when called, will call the underlying RPC
399+
on the server.
400+
"""
401+
# Generate a "stub function" on-the-fly which will actually make
402+
# the request.
403+
# gRPC handles serialization and deserialization, so we just need
404+
# to pass in the functions for each.
405+
if "update_table" not in self._stubs:
406+
self._stubs["update_table"] = self.grpc_channel.unary_unary(
407+
"/google.bigtable.admin.v2.BigtableTableAdmin/UpdateTable",
408+
request_serializer=bigtable_table_admin.UpdateTableRequest.serialize,
409+
response_deserializer=operations_pb2.Operation.FromString,
410+
)
411+
return self._stubs["update_table"]
412+
385413
@property
386414
def delete_table(
387415
self,

google/cloud/bigtable_admin_v2/types/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@
7373
UndeleteTableMetadata,
7474
UndeleteTableRequest,
7575
UpdateBackupRequest,
76+
UpdateTableMetadata,
77+
UpdateTableRequest,
7678
)
7779
from .common import (
7880
OperationProgress,
@@ -156,6 +158,8 @@
156158
"UndeleteTableMetadata",
157159
"UndeleteTableRequest",
158160
"UpdateBackupRequest",
161+
"UpdateTableMetadata",
162+
"UpdateTableRequest",
159163
"OperationProgress",
160164
"StorageType",
161165
"AppProfile",

0 commit comments

Comments
 (0)