Skip to content

Commit

Permalink
feat: Publish CBT deletion_protection field in Table, UpdateTableRequ…
Browse files Browse the repository at this point in the history
…est, and UpdateTable API (#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: googleapis/googleapis-gen@46d5c58
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>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] committed Sep 13, 2022
1 parent 99d3318 commit c57289c
Show file tree
Hide file tree
Showing 12 changed files with 633 additions and 0 deletions.
4 changes: 4 additions & 0 deletions google/cloud/bigtable_admin_v2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
from .types.bigtable_table_admin import UndeleteTableMetadata
from .types.bigtable_table_admin import UndeleteTableRequest
from .types.bigtable_table_admin import UpdateBackupRequest
from .types.bigtable_table_admin import UpdateTableMetadata
from .types.bigtable_table_admin import UpdateTableRequest
from .types.common import OperationProgress
from .types.common import StorageType
from .types.instance import AppProfile
Expand Down Expand Up @@ -173,4 +175,6 @@
"UpdateBackupRequest",
"UpdateClusterMetadata",
"UpdateInstanceMetadata",
"UpdateTableMetadata",
"UpdateTableRequest",
)
10 changes: 10 additions & 0 deletions google/cloud/bigtable_admin_v2/gapic_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,11 @@
"methods": [
"update_backup"
]
},
"UpdateTable": {
"methods": [
"update_table"
]
}
}
},
Expand Down Expand Up @@ -468,6 +473,11 @@
"methods": [
"update_backup"
]
},
"UpdateTable": {
"methods": [
"update_table"
]
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,115 @@ async def get_table(
# Done; return the response.
return response

async def update_table(
self,
request: Union[bigtable_table_admin.UpdateTableRequest, dict] = None,
*,
table: gba_table.Table = None,
update_mask: field_mask_pb2.FieldMask = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Updates a specified table.
Args:
request (Union[google.cloud.bigtable_admin_v2.types.UpdateTableRequest, dict]):
The request object. The request for
[UpdateTable][google.bigtable.admin.v2.BigtableTableAdmin.UpdateTable].
table (:class:`google.cloud.bigtable_admin_v2.types.Table`):
Required. The table to update. The table's ``name``
field is used to identify the table to update. Format:
``projects/{project}/instances/{instance}/tables/[_a-zA-Z0-9][-_.a-zA-Z0-9]*``
This corresponds to the ``table`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
Required. The list of fields to update. A mask
specifying which fields (e.g. ``deletion_protection``)
in the ``table`` field should be updated. This mask is
relative to the ``table`` field, not to the request
message. The wildcard (*) path is currently not
supported. Currently UpdateTable is only supported for
the following field:
- ``deletion_protection`` If ``column_families`` is set
in ``update_mask``, it will return an UNIMPLEMENTED
error.
This corresponds to the ``update_mask`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
google.api_core.operation_async.AsyncOperation:
An object representing a long-running operation.
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.
Each table is served using the resources of its
parent cluster.
"""
# Create or coerce a protobuf request object.
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([table, update_mask])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)

request = bigtable_table_admin.UpdateTableRequest(request)

# If we have keyword arguments corresponding to fields on the
# request, apply these.
if table is not None:
request.table = table
if update_mask is not None:
request.update_mask = update_mask

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.update_table,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
)

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("table.name", request.table.name),)
),
)

# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Wrap the response in an operation future.
response = operation_async.from_gapic(
response,
self._client._transport.operations_client,
gba_table.Table,
metadata_type=bigtable_table_admin.UpdateTableMetadata,
)

# Done; return the response.
return response

async def delete_table(
self,
request: Union[bigtable_table_admin.DeleteTableRequest, dict] = None,
Expand Down
109 changes: 109 additions & 0 deletions google/cloud/bigtable_admin_v2/services/bigtable_table_admin/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,115 @@ def get_table(
# Done; return the response.
return response

def update_table(
self,
request: Union[bigtable_table_admin.UpdateTableRequest, dict] = None,
*,
table: gba_table.Table = None,
update_mask: field_mask_pb2.FieldMask = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
r"""Updates a specified table.
Args:
request (Union[google.cloud.bigtable_admin_v2.types.UpdateTableRequest, dict]):
The request object. The request for
[UpdateTable][google.bigtable.admin.v2.BigtableTableAdmin.UpdateTable].
table (google.cloud.bigtable_admin_v2.types.Table):
Required. The table to update. The table's ``name``
field is used to identify the table to update. Format:
``projects/{project}/instances/{instance}/tables/[_a-zA-Z0-9][-_.a-zA-Z0-9]*``
This corresponds to the ``table`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
update_mask (google.protobuf.field_mask_pb2.FieldMask):
Required. The list of fields to update. A mask
specifying which fields (e.g. ``deletion_protection``)
in the ``table`` field should be updated. This mask is
relative to the ``table`` field, not to the request
message. The wildcard (*) path is currently not
supported. Currently UpdateTable is only supported for
the following field:
- ``deletion_protection`` If ``column_families`` is set
in ``update_mask``, it will return an UNIMPLEMENTED
error.
This corresponds to the ``update_mask`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
google.api_core.operation.Operation:
An object representing a long-running operation.
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.
Each table is served using the resources of its
parent cluster.
"""
# Create or coerce a protobuf request object.
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([table, update_mask])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)

# Minor optimization to avoid making a copy if the user passes
# in a bigtable_table_admin.UpdateTableRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
if not isinstance(request, bigtable_table_admin.UpdateTableRequest):
request = bigtable_table_admin.UpdateTableRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if table is not None:
request.table = table
if update_mask is not None:
request.update_mask = update_mask

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._transport._wrapped_methods[self._transport.update_table]

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("table.name", request.table.name),)
),
)

# Send the request.
response = rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Wrap the response in an operation future.
response = operation.from_gapic(
response,
self._transport.operations_client,
gba_table.Table,
metadata_type=bigtable_table_admin.UpdateTableMetadata,
)

# Done; return the response.
return response

def delete_table(
self,
request: Union[bigtable_table_admin.DeleteTableRequest, dict] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ def _prep_wrapped_messages(self, client_info):
default_timeout=60.0,
client_info=client_info,
),
self.update_table: gapic_v1.method.wrap_method(
self.update_table,
default_timeout=None,
client_info=client_info,
),
self.delete_table: gapic_v1.method.wrap_method(
self.delete_table,
default_timeout=60.0,
Expand Down Expand Up @@ -411,6 +416,15 @@ def get_table(
]:
raise NotImplementedError()

@property
def update_table(
self,
) -> Callable[
[bigtable_table_admin.UpdateTableRequest],
Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]],
]:
raise NotImplementedError()

@property
def delete_table(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,32 @@ def get_table(
)
return self._stubs["get_table"]

@property
def update_table(
self,
) -> Callable[[bigtable_table_admin.UpdateTableRequest], operations_pb2.Operation]:
r"""Return a callable for the update table method over gRPC.
Updates a specified table.
Returns:
Callable[[~.UpdateTableRequest],
~.Operation]:
A function that, when called, will call the underlying RPC
on the server.
"""
# Generate a "stub function" on-the-fly which will actually make
# the request.
# gRPC handles serialization and deserialization, so we just need
# to pass in the functions for each.
if "update_table" not in self._stubs:
self._stubs["update_table"] = self.grpc_channel.unary_unary(
"/google.bigtable.admin.v2.BigtableTableAdmin/UpdateTable",
request_serializer=bigtable_table_admin.UpdateTableRequest.serialize,
response_deserializer=operations_pb2.Operation.FromString,
)
return self._stubs["update_table"]

@property
def delete_table(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,34 @@ def get_table(
)
return self._stubs["get_table"]

@property
def update_table(
self,
) -> Callable[
[bigtable_table_admin.UpdateTableRequest], Awaitable[operations_pb2.Operation]
]:
r"""Return a callable for the update table method over gRPC.
Updates a specified table.
Returns:
Callable[[~.UpdateTableRequest],
Awaitable[~.Operation]]:
A function that, when called, will call the underlying RPC
on the server.
"""
# Generate a "stub function" on-the-fly which will actually make
# the request.
# gRPC handles serialization and deserialization, so we just need
# to pass in the functions for each.
if "update_table" not in self._stubs:
self._stubs["update_table"] = self.grpc_channel.unary_unary(
"/google.bigtable.admin.v2.BigtableTableAdmin/UpdateTable",
request_serializer=bigtable_table_admin.UpdateTableRequest.serialize,
response_deserializer=operations_pb2.Operation.FromString,
)
return self._stubs["update_table"]

@property
def delete_table(
self,
Expand Down
4 changes: 4 additions & 0 deletions google/cloud/bigtable_admin_v2/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
UndeleteTableMetadata,
UndeleteTableRequest,
UpdateBackupRequest,
UpdateTableMetadata,
UpdateTableRequest,
)
from .common import (
OperationProgress,
Expand Down Expand Up @@ -156,6 +158,8 @@
"UndeleteTableMetadata",
"UndeleteTableRequest",
"UpdateBackupRequest",
"UpdateTableMetadata",
"UpdateTableRequest",
"OperationProgress",
"StorageType",
"AppProfile",
Expand Down
Loading

0 comments on commit c57289c

Please sign in to comment.