Skip to content

Commit

Permalink
feat: add fields and the BackupType proto for Hot Backups (#1010)
Browse files Browse the repository at this point in the history
* feat: add fields and the BackupType proto for Hot Backups
docs: clarify comments and fix typos

PiperOrigin-RevId: 658791576

Source-Link: googleapis/googleapis@c93b54f

Source-Link: googleapis/googleapis-gen@e52ba38
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZTUyYmEzOGE5NWE4MmY3NTg4ZDBkZDNhMjI4NGM5ODg1MGRhYjllMSJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* 🦉 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] authored Aug 8, 2024
1 parent 6686abf commit b95801f
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2777,7 +2777,7 @@ async def restore_table(
operation][google.longrunning.Operation] can be used to track
the progress of the operation, and to cancel it. The
[metadata][google.longrunning.Operation.metadata] field type is
[RestoreTableMetadata][google.bigtable.admin.RestoreTableMetadata].
[RestoreTableMetadata][google.bigtable.admin.v2.RestoreTableMetadata].
The [response][google.longrunning.Operation.response] type is
[Table][google.bigtable.admin.v2.Table], if successful.
Expand Down Expand Up @@ -2862,8 +2862,8 @@ async def copy_backup(
[CopyBackup][google.bigtable.admin.v2.BigtableTableAdmin.CopyBackup].
parent (:class:`str`):
Required. The name of the destination cluster that will
contain the backup copy. The cluster must already
exists. Values are of the form:
contain the backup copy. The cluster must already exist.
Values are of the form:
``projects/{project}/instances/{instance}/clusters/{cluster}``.
This corresponds to the ``parent`` field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3245,7 +3245,7 @@ def restore_table(
operation][google.longrunning.Operation] can be used to track
the progress of the operation, and to cancel it. The
[metadata][google.longrunning.Operation.metadata] field type is
[RestoreTableMetadata][google.bigtable.admin.RestoreTableMetadata].
[RestoreTableMetadata][google.bigtable.admin.v2.RestoreTableMetadata].
The [response][google.longrunning.Operation.response] type is
[Table][google.bigtable.admin.v2.Table], if successful.
Expand Down Expand Up @@ -3328,8 +3328,8 @@ def copy_backup(
[CopyBackup][google.bigtable.admin.v2.BigtableTableAdmin.CopyBackup].
parent (str):
Required. The name of the destination cluster that will
contain the backup copy. The cluster must already
exists. Values are of the form:
contain the backup copy. The cluster must already exist.
Values are of the form:
``projects/{project}/instances/{instance}/clusters/{cluster}``.
This corresponds to the ``parent`` field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ def restore_table(
operation][google.longrunning.Operation] can be used to track
the progress of the operation, and to cancel it. The
[metadata][google.longrunning.Operation.metadata] field type is
[RestoreTableMetadata][google.bigtable.admin.RestoreTableMetadata].
[RestoreTableMetadata][google.bigtable.admin.v2.RestoreTableMetadata].
The [response][google.longrunning.Operation.response] type is
[Table][google.bigtable.admin.v2.Table], if successful.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ def restore_table(
operation][google.longrunning.Operation] can be used to track
the progress of the operation, and to cancel it. The
[metadata][google.longrunning.Operation.metadata] field type is
[RestoreTableMetadata][google.bigtable.admin.RestoreTableMetadata].
[RestoreTableMetadata][google.bigtable.admin.v2.RestoreTableMetadata].
The [response][google.longrunning.Operation.response] type is
[Table][google.bigtable.admin.v2.Table], if successful.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1356,7 +1356,7 @@ class CopyBackupRequest(proto.Message):
Attributes:
parent (str):
Required. The name of the destination cluster that will
contain the backup copy. The cluster must already exists.
contain the backup copy. The cluster must already exist.
Values are of the form:
``projects/{project}/instances/{instance}/clusters/{cluster}``.
backup_id (str):
Expand Down
66 changes: 59 additions & 7 deletions google/cloud/bigtable_admin_v2/types/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,13 +781,18 @@ class Backup(proto.Message):
this backup was copied. If a backup is not
created by copying a backup, this field will be
empty. Values are of the form:
projects/<project>/instances/<instance>/backups/<backup>.
projects/<project>/instances/<instance>/clusters/<cluster>/backups/<backup>
expire_time (google.protobuf.timestamp_pb2.Timestamp):
Required. The expiration time of the backup, with
microseconds granularity that must be at least 6 hours and
at most 90 days from the time the request is received. Once
the ``expire_time`` has passed, Cloud Bigtable will delete
the backup and free the resources used by the backup.
Required. The expiration time of the backup. When creating a
backup or updating its ``expire_time``, the value must be
greater than the backup creation time by:
- At least 6 hours
- At most 90 days
Once the ``expire_time`` has passed, Cloud Bigtable will
delete the backup.
start_time (google.protobuf.timestamp_pb2.Timestamp):
Output only. ``start_time`` is the time that the backup was
started (i.e. approximately the time the
Expand All @@ -805,6 +810,20 @@ class Backup(proto.Message):
encryption_info (google.cloud.bigtable_admin_v2.types.EncryptionInfo):
Output only. The encryption information for
the backup.
backup_type (google.cloud.bigtable_admin_v2.types.Backup.BackupType):
Indicates the backup type of the backup.
hot_to_standard_time (google.protobuf.timestamp_pb2.Timestamp):
The time at which the hot backup will be converted to a
standard backup. Once the ``hot_to_standard_time`` has
passed, Cloud Bigtable will convert the hot backup to a
standard backup. This value must be greater than the backup
creation time by:
- At least 24 hours
This field only applies for hot backups. When creating or
updating a standard backup, attempting to set this field
will fail the request.
"""

class State(proto.Enum):
Expand All @@ -823,6 +842,28 @@ class State(proto.Enum):
CREATING = 1
READY = 2

class BackupType(proto.Enum):
r"""The type of the backup.
Values:
BACKUP_TYPE_UNSPECIFIED (0):
Not specified.
STANDARD (1):
The default type for Cloud Bigtable managed
backups. Supported for backups created in both
HDD and SSD instances. Requires optimization
when restored to a table in an SSD instance.
HOT (2):
A backup type with faster restore to SSD
performance. Only supported for backups created
in SSD instances. A new SSD table restored from
a hot backup reaches production performance more
quickly than a standard backup.
"""
BACKUP_TYPE_UNSPECIFIED = 0
STANDARD = 1
HOT = 2

name: str = proto.Field(
proto.STRING,
number=1,
Expand Down Expand Up @@ -864,6 +905,16 @@ class State(proto.Enum):
number=9,
message="EncryptionInfo",
)
backup_type: BackupType = proto.Field(
proto.ENUM,
number=11,
enum=BackupType,
)
hot_to_standard_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=12,
message=timestamp_pb2.Timestamp,
)


class BackupInfo(proto.Message):
Expand All @@ -888,7 +939,8 @@ class BackupInfo(proto.Message):
this backup was copied. If a backup is not
created by copying a backup, this field will be
empty. Values are of the form:
projects/<project>/instances/<instance>/backups/<backup>.
projects/<project>/instances/<instance>/clusters/<cluster>/backups/<backup>
"""

backup: str = proto.Field(
Expand Down
18 changes: 18 additions & 0 deletions tests/unit/gapic/bigtable_admin_v2/test_bigtable_table_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9753,6 +9753,7 @@ def test_get_backup(request_type, transport: str = "grpc"):
source_backup="source_backup_value",
size_bytes=1089,
state=table.Backup.State.CREATING,
backup_type=table.Backup.BackupType.STANDARD,
)
response = client.get_backup(request)

Expand All @@ -9769,6 +9770,7 @@ def test_get_backup(request_type, transport: str = "grpc"):
assert response.source_backup == "source_backup_value"
assert response.size_bytes == 1089
assert response.state == table.Backup.State.CREATING
assert response.backup_type == table.Backup.BackupType.STANDARD


def test_get_backup_empty_call():
Expand Down Expand Up @@ -9872,6 +9874,7 @@ async def test_get_backup_empty_call_async():
source_backup="source_backup_value",
size_bytes=1089,
state=table.Backup.State.CREATING,
backup_type=table.Backup.BackupType.STANDARD,
)
)
response = await client.get_backup()
Expand Down Expand Up @@ -9942,6 +9945,7 @@ async def test_get_backup_async(
source_backup="source_backup_value",
size_bytes=1089,
state=table.Backup.State.CREATING,
backup_type=table.Backup.BackupType.STANDARD,
)
)
response = await client.get_backup(request)
Expand All @@ -9959,6 +9963,7 @@ async def test_get_backup_async(
assert response.source_backup == "source_backup_value"
assert response.size_bytes == 1089
assert response.state == table.Backup.State.CREATING
assert response.backup_type == table.Backup.BackupType.STANDARD


@pytest.mark.asyncio
Expand Down Expand Up @@ -10131,6 +10136,7 @@ def test_update_backup(request_type, transport: str = "grpc"):
source_backup="source_backup_value",
size_bytes=1089,
state=table.Backup.State.CREATING,
backup_type=table.Backup.BackupType.STANDARD,
)
response = client.update_backup(request)

Expand All @@ -10147,6 +10153,7 @@ def test_update_backup(request_type, transport: str = "grpc"):
assert response.source_backup == "source_backup_value"
assert response.size_bytes == 1089
assert response.state == table.Backup.State.CREATING
assert response.backup_type == table.Backup.BackupType.STANDARD


def test_update_backup_empty_call():
Expand Down Expand Up @@ -10246,6 +10253,7 @@ async def test_update_backup_empty_call_async():
source_backup="source_backup_value",
size_bytes=1089,
state=table.Backup.State.CREATING,
backup_type=table.Backup.BackupType.STANDARD,
)
)
response = await client.update_backup()
Expand Down Expand Up @@ -10319,6 +10327,7 @@ async def test_update_backup_async(
source_backup="source_backup_value",
size_bytes=1089,
state=table.Backup.State.CREATING,
backup_type=table.Backup.BackupType.STANDARD,
)
)
response = await client.update_backup(request)
Expand All @@ -10336,6 +10345,7 @@ async def test_update_backup_async(
assert response.source_backup == "source_backup_value"
assert response.size_bytes == 1089
assert response.state == table.Backup.State.CREATING
assert response.backup_type == table.Backup.BackupType.STANDARD


@pytest.mark.asyncio
Expand Down Expand Up @@ -19957,6 +19967,8 @@ def test_create_backup_rest(request_type):
},
"kms_key_version": "kms_key_version_value",
},
"backup_type": 1,
"hot_to_standard_time": {},
}
# The version of a generated dependency at test runtime may differ from the version used during generation.
# Delete any fields which are not present in the current runtime dependency
Expand Down Expand Up @@ -20368,6 +20380,7 @@ def test_get_backup_rest(request_type):
source_backup="source_backup_value",
size_bytes=1089,
state=table.Backup.State.CREATING,
backup_type=table.Backup.BackupType.STANDARD,
)

# Wrap the value into a proper Response obj
Expand All @@ -20388,6 +20401,7 @@ def test_get_backup_rest(request_type):
assert response.source_backup == "source_backup_value"
assert response.size_bytes == 1089
assert response.state == table.Backup.State.CREATING
assert response.backup_type == table.Backup.BackupType.STANDARD


def test_get_backup_rest_use_cached_wrapped_rpc():
Expand Down Expand Up @@ -20697,6 +20711,8 @@ def test_update_backup_rest(request_type):
},
"kms_key_version": "kms_key_version_value",
},
"backup_type": 1,
"hot_to_standard_time": {},
}
# The version of a generated dependency at test runtime may differ from the version used during generation.
# Delete any fields which are not present in the current runtime dependency
Expand Down Expand Up @@ -20776,6 +20792,7 @@ def get_message_fields(field):
source_backup="source_backup_value",
size_bytes=1089,
state=table.Backup.State.CREATING,
backup_type=table.Backup.BackupType.STANDARD,
)

# Wrap the value into a proper Response obj
Expand All @@ -20796,6 +20813,7 @@ def get_message_fields(field):
assert response.source_backup == "source_backup_value"
assert response.size_bytes == 1089
assert response.state == table.Backup.State.CREATING
assert response.backup_type == table.Backup.BackupType.STANDARD


def test_update_backup_rest_use_cached_wrapped_rpc():
Expand Down

0 comments on commit b95801f

Please sign in to comment.