Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ChangeStreamConfig to CreateTable and UpdateTable #786

Merged
merged 2 commits into from May 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions google/cloud/bigtable_admin/__init__.py
Expand Up @@ -200,6 +200,7 @@
from google.cloud.bigtable_admin_v2.types.instance import Instance
from google.cloud.bigtable_admin_v2.types.table import Backup
from google.cloud.bigtable_admin_v2.types.table import BackupInfo
from google.cloud.bigtable_admin_v2.types.table import ChangeStreamConfig
from google.cloud.bigtable_admin_v2.types.table import ColumnFamily
from google.cloud.bigtable_admin_v2.types.table import EncryptionInfo
from google.cloud.bigtable_admin_v2.types.table import GcRule
Expand Down Expand Up @@ -282,6 +283,7 @@
"Instance",
"Backup",
"BackupInfo",
"ChangeStreamConfig",
"ColumnFamily",
"EncryptionInfo",
"GcRule",
Expand Down
2 changes: 2 additions & 0 deletions google/cloud/bigtable_admin_v2/__init__.py
Expand Up @@ -92,6 +92,7 @@
from .types.instance import Instance
from .types.table import Backup
from .types.table import BackupInfo
from .types.table import ChangeStreamConfig
from .types.table import ColumnFamily
from .types.table import EncryptionInfo
from .types.table import GcRule
Expand All @@ -110,6 +111,7 @@
"BackupInfo",
"BigtableInstanceAdminClient",
"BigtableTableAdminClient",
"ChangeStreamConfig",
"CheckConsistencyRequest",
"CheckConsistencyResponse",
"Cluster",
Expand Down
Expand Up @@ -683,16 +683,19 @@ async def update_table(
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``)
specifying which fields (e.g. ``change_stream_config``)
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:
the following fields:

- ``deletion_protection`` If ``column_families`` is set
in ``update_mask``, it will return an UNIMPLEMENTED
error.
- ``change_stream_config``
- ``change_stream_config.retention_period``
- ``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
Expand Down
Expand Up @@ -992,16 +992,19 @@ def update_table(
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``)
specifying which fields (e.g. ``change_stream_config``)
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:
the following fields:

- ``deletion_protection`` If ``column_families`` is set
in ``update_mask``, it will return an UNIMPLEMENTED
error.
- ``change_stream_config``
- ``change_stream_config.retention_period``
- ``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
Expand Down
2 changes: 2 additions & 0 deletions google/cloud/bigtable_admin_v2/types/__init__.py
Expand Up @@ -91,6 +91,7 @@
from .table import (
Backup,
BackupInfo,
ChangeStreamConfig,
ColumnFamily,
EncryptionInfo,
GcRule,
Expand Down Expand Up @@ -170,6 +171,7 @@
"Instance",
"Backup",
"BackupInfo",
"ChangeStreamConfig",
"ColumnFamily",
"EncryptionInfo",
"GcRule",
Expand Down
20 changes: 12 additions & 8 deletions google/cloud/bigtable_admin_v2/types/bigtable_table_admin.py
Expand Up @@ -460,14 +460,18 @@ class UpdateTableRequest(proto.Message):
used to identify the table to update.
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.
which fields (e.g. ``change_stream_config``) 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 fields:

- ``change_stream_config``
- ``change_stream_config.retention_period``
- ``deletion_protection``

If ``column_families`` is set in ``update_mask``, it will
return an UNIMPLEMENTED error.
"""

table: gba_table.Table = proto.Field(
Expand Down
31 changes: 31 additions & 0 deletions google/cloud/bigtable_admin_v2/types/table.py
Expand Up @@ -29,6 +29,7 @@
manifest={
"RestoreSourceType",
"RestoreInfo",
"ChangeStreamConfig",
"Table",
"ColumnFamily",
"GcRule",
Expand Down Expand Up @@ -82,6 +83,27 @@ class RestoreInfo(proto.Message):
)


class ChangeStreamConfig(proto.Message):
r"""Change stream configuration.

Attributes:
retention_period (google.protobuf.duration_pb2.Duration):
How long the change stream should be
retained. Change stream data older than the
retention period will not be returned when
reading the change stream from the table.
Values must be at least 1 day and at most 7
days, and will be truncated to microsecond
granularity.
"""

retention_period: duration_pb2.Duration = proto.Field(
proto.MESSAGE,
number=1,
message=duration_pb2.Duration,
)


class Table(proto.Message):
r"""A collection of user data indexed by row, column, and
timestamp. Each table is served using the resources of its
Expand Down Expand Up @@ -114,6 +136,10 @@ class Table(proto.Message):
another data source (e.g. a backup), this field
will be populated with information about the
restore.
change_stream_config (google.cloud.bigtable_admin_v2.types.ChangeStreamConfig):
If specified, enable the change stream on
this table. Otherwise, the change stream is
disabled and the change stream is not retained.
deletion_protection (bool):
Set to true to make the table protected
against data loss. i.e. deleting the following
Expand Down Expand Up @@ -263,6 +289,11 @@ class ReplicationState(proto.Enum):
number=6,
message="RestoreInfo",
)
change_stream_config: "ChangeStreamConfig" = proto.Field(
proto.MESSAGE,
number=8,
message="ChangeStreamConfig",
)
deletion_protection: bool = proto.Field(
proto.BOOL,
number=9,
Expand Down
Expand Up @@ -8202,6 +8202,7 @@ def test_update_table_rest(request_type):
"source_table": "source_table_value",
},
},
"change_stream_config": {"retention_period": {"seconds": 751, "nanos": 543}},
"deletion_protection": True,
}
request = request_type(**request_init)
Expand Down Expand Up @@ -8399,6 +8400,7 @@ def test_update_table_rest_bad_request(
"source_table": "source_table_value",
},
},
"change_stream_config": {"retention_period": {"seconds": 751, "nanos": 543}},
"deletion_protection": True,
}
request = request_type(**request_init)
Expand Down