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(spanner): Add resource reference annotation to backup schedules #1176

Merged
merged 10 commits into from
Aug 19, 2024
2 changes: 2 additions & 0 deletions google/cloud/spanner_admin_database_v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from .types.backup import DeleteBackupRequest
from .types.backup import FullBackupSpec
from .types.backup import GetBackupRequest
from .types.backup import IncrementalBackupSpec
from .types.backup import ListBackupOperationsRequest
from .types.backup import ListBackupOperationsResponse
from .types.backup import ListBackupsRequest
Expand Down Expand Up @@ -108,6 +109,7 @@
"GetDatabaseDdlRequest",
"GetDatabaseDdlResponse",
"GetDatabaseRequest",
"IncrementalBackupSpec",
"ListBackupOperationsRequest",
"ListBackupOperationsResponse",
"ListBackupSchedulesRequest",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# limitations under the License.
#
from collections import OrderedDict
import functools
import re
from typing import (
Dict,
Expand Down Expand Up @@ -230,9 +229,7 @@ def universe_domain(self) -> str:
"""
return self._client._universe_domain

get_transport_class = functools.partial(
type(DatabaseAdminClient).get_transport_class, type(DatabaseAdminClient)
)
get_transport_class = DatabaseAdminClient.get_transport_class

def __init__(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ def __init__(
transport_init: Union[
Type[DatabaseAdminTransport], Callable[..., DatabaseAdminTransport]
] = (
type(self).get_transport_class(transport)
DatabaseAdminClient.get_transport_class(transport)
if isinstance(transport, str) or transport is None
else cast(Callable[..., DatabaseAdminTransport], transport)
)
Expand Down
2 changes: 2 additions & 0 deletions google/cloud/spanner_admin_database_v1/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
DeleteBackupRequest,
FullBackupSpec,
GetBackupRequest,
IncrementalBackupSpec,
ListBackupOperationsRequest,
ListBackupOperationsResponse,
ListBackupsRequest,
Expand Down Expand Up @@ -88,6 +89,7 @@
"DeleteBackupRequest",
"FullBackupSpec",
"GetBackupRequest",
"IncrementalBackupSpec",
"ListBackupOperationsRequest",
"ListBackupOperationsResponse",
"ListBackupsRequest",
Expand Down
74 changes: 74 additions & 0 deletions google/cloud/spanner_admin_database_v1/types/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"CreateBackupEncryptionConfig",
"CopyBackupEncryptionConfig",
"FullBackupSpec",
"IncrementalBackupSpec",
},
)

Expand Down Expand Up @@ -98,6 +99,30 @@ class Backup(proto.Message):
equivalent to the ``create_time``.
size_bytes (int):
Output only. Size of the backup in bytes.
freeable_size_bytes (int):
Output only. The number of bytes that will be
freed by deleting this backup. This value will
be zero if, for example, this backup is part of
an incremental backup chain and younger backups
in the chain require that we keep its data. For
backups not in an incremental backup chain, this
is always the size of the backup. This value may
change if backups on the same chain get created,
deleted or expired.
exclusive_size_bytes (int):
Output only. For a backup in an incremental
backup chain, this is the storage space needed
to keep the data that has changed since the
previous backup. For all other backups, this is
always the size of the backup. This value may
change if backups on the same chain get deleted
or expired.

This field can be used to calculate the total
storage space used by a set of backups. For
example, the total space used by all backups of
a database can be computed by summing up this
field.
state (google.cloud.spanner_admin_database_v1.types.Backup.State):
Output only. The current state of the backup.
referencing_databases (MutableSequence[str]):
Expand Down Expand Up @@ -156,6 +181,24 @@ class Backup(proto.Message):
If collapsing is not done, then this field
captures the single backup schedule URI
associated with creating this backup.
incremental_backup_chain_id (str):
Output only. Populated only for backups in an incremental
backup chain. Backups share the same chain id if and only if
they belong to the same incremental backup chain. Use this
field to determine which backups are part of the same
incremental backup chain. The ordering of backups in the
chain can be determined by ordering the backup
``version_time``.
oldest_version_time (google.protobuf.timestamp_pb2.Timestamp):
Output only. Data deleted at a time older
than this is guaranteed not to be retained in
order to support this backup. For a backup in an
incremental backup chain, this is the version
time of the oldest backup that exists or ever
existed in the chain. For all other backups,
this is the version time of the backup. This
field can be used to understand what data is
being retained by the backup system.
"""

class State(proto.Enum):
Expand Down Expand Up @@ -201,6 +244,14 @@ class State(proto.Enum):
proto.INT64,
number=5,
)
freeable_size_bytes: int = proto.Field(
proto.INT64,
number=15,
)
exclusive_size_bytes: int = proto.Field(
proto.INT64,
number=16,
)
state: State = proto.Field(
proto.ENUM,
number=6,
Expand Down Expand Up @@ -240,6 +291,15 @@ class State(proto.Enum):
proto.STRING,
number=14,
)
incremental_backup_chain_id: str = proto.Field(
proto.STRING,
number=17,
)
oldest_version_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=18,
message=timestamp_pb2.Timestamp,
)


class CreateBackupRequest(proto.Message):
Expand Down Expand Up @@ -553,6 +613,7 @@ class ListBackupsRequest(proto.Message):
- ``version_time`` (and values are of the format
YYYY-MM-DDTHH:MM:SSZ)
- ``size_bytes``
- ``backup_schedules``

You can combine multiple expressions by enclosing each
expression in parentheses. By default, expressions are
Expand All @@ -576,6 +637,8 @@ class ListBackupsRequest(proto.Message):
``expire_time`` is before 2018-03-28T14:50:00Z.
- ``size_bytes > 10000000000`` - The backup's size is
greater than 10GB
- ``backup_schedules:daily`` - The backup is created from a
schedule with "daily" in its name.
page_size (int):
Number of backups to be returned in the
response. If 0 or less, defaults to the server's
Expand Down Expand Up @@ -999,4 +1062,15 @@ class FullBackupSpec(proto.Message):
"""


class IncrementalBackupSpec(proto.Message):
r"""The specification for incremental backup chains.
An incremental backup stores the delta of changes between a
previous backup and the database contents at a given version
time. An incremental backup chain consists of a full backup and
zero or more successive incremental backups. The first backup
created for an incremental backup chain is always a full backup.

"""


__all__ = tuple(sorted(__protobuf__.manifest))
15 changes: 15 additions & 0 deletions google/cloud/spanner_admin_database_v1/types/backup_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ class BackupSchedule(proto.Message):
specification for a Spanner database.
Next ID: 10

This message has `oneof`_ fields (mutually exclusive fields).
For each oneof, at most one member field can be set at the same time.
Setting any member of the oneof automatically clears all other
members.

.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields

Expand Down Expand Up @@ -96,6 +100,11 @@ class BackupSchedule(proto.Message):
full_backup_spec (google.cloud.spanner_admin_database_v1.types.FullBackupSpec):
The schedule creates only full backups.

This field is a member of `oneof`_ ``backup_type_spec``.
incremental_backup_spec (google.cloud.spanner_admin_database_v1.types.IncrementalBackupSpec):
The schedule creates incremental backup
chains.

This field is a member of `oneof`_ ``backup_type_spec``.
update_time (google.protobuf.timestamp_pb2.Timestamp):
Output only. The timestamp at which the
Expand Down Expand Up @@ -129,6 +138,12 @@ class BackupSchedule(proto.Message):
oneof="backup_type_spec",
message=backup.FullBackupSpec,
)
incremental_backup_spec: backup.IncrementalBackupSpec = proto.Field(
proto.MESSAGE,
number=8,
oneof="backup_type_spec",
message=backup.IncrementalBackupSpec,
)
update_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=9,
Expand Down
6 changes: 6 additions & 0 deletions google/cloud/spanner_admin_instance_v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
from .types.spanner_instance_admin import ListInstancePartitionsResponse
from .types.spanner_instance_admin import ListInstancesRequest
from .types.spanner_instance_admin import ListInstancesResponse
from .types.spanner_instance_admin import MoveInstanceMetadata
from .types.spanner_instance_admin import MoveInstanceRequest
from .types.spanner_instance_admin import MoveInstanceResponse
from .types.spanner_instance_admin import ReplicaInfo
from .types.spanner_instance_admin import UpdateInstanceConfigMetadata
from .types.spanner_instance_admin import UpdateInstanceConfigRequest
Expand Down Expand Up @@ -87,6 +90,9 @@
"ListInstancePartitionsResponse",
"ListInstancesRequest",
"ListInstancesResponse",
"MoveInstanceMetadata",
"MoveInstanceRequest",
"MoveInstanceResponse",
"OperationProgress",
"ReplicaInfo",
"UpdateInstanceConfigMetadata",
Expand Down
15 changes: 15 additions & 0 deletions google/cloud/spanner_admin_instance_v1/gapic_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@
"list_instances"
]
},
"MoveInstance": {
"methods": [
"move_instance"
]
},
"SetIamPolicy": {
"methods": [
"set_iam_policy"
Expand Down Expand Up @@ -190,6 +195,11 @@
"list_instances"
]
},
"MoveInstance": {
"methods": [
"move_instance"
]
},
"SetIamPolicy": {
"methods": [
"set_iam_policy"
Expand Down Expand Up @@ -295,6 +305,11 @@
"list_instances"
]
},
"MoveInstance": {
"methods": [
"move_instance"
]
},
"SetIamPolicy": {
"methods": [
"set_iam_policy"
Expand Down
Loading