Skip to content

Commit

Permalink
chore: add backups (via synth)
Browse files Browse the repository at this point in the history
Co-authored-by: larkee <31196561+larkee@users.noreply.github.com>
  • Loading branch information
yoshi-automation and larkee committed Mar 13, 2020
1 parent 5147921 commit a48c4b1
Show file tree
Hide file tree
Showing 16 changed files with 5,126 additions and 145 deletions.
941 changes: 929 additions & 12 deletions google/cloud/spanner_admin_database_v1/gapic/database_admin_client.py

Large diffs are not rendered by default.

Expand Up @@ -57,6 +57,46 @@
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
"CreateBackup": {
"timeout_millis": 30000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
"GetBackup": {
"timeout_millis": 30000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"UpdateBackup": {
"timeout_millis": 30000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
"DeleteBackup": {
"timeout_millis": 30000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"ListBackups": {
"timeout_millis": 30000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"RestoreDatabase": {
"timeout_millis": 30000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
"ListDatabaseOperations": {
"timeout_millis": 30000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"ListBackupOperations": {
"timeout_millis": 30000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"ListDatabases": {
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
Expand Down
38 changes: 38 additions & 0 deletions google/cloud/spanner_admin_database_v1/gapic/enums.py
Expand Up @@ -19,6 +19,36 @@
import enum


class RestoreSourceType(enum.IntEnum):
"""
Indicates the type of the restore source.
Attributes:
TYPE_UNSPECIFIED (int): No restore associated.
BACKUP (int): A backup was used as the source of the restore.
"""

TYPE_UNSPECIFIED = 0
BACKUP = 1


class Backup(object):
class State(enum.IntEnum):
"""
Indicates the current state of the backup.
Attributes:
STATE_UNSPECIFIED (int): Not specified.
CREATING (int): The pending backup is still being created. Operations on the backup may
fail with ``FAILED_PRECONDITION`` in this state.
READY (int): The backup is complete and ready for use.
"""

STATE_UNSPECIFIED = 0
CREATING = 1
READY = 2


class Database(object):
class State(enum.IntEnum):
"""
Expand All @@ -29,8 +59,16 @@ class State(enum.IntEnum):
CREATING (int): The database is still being created. Operations on the database may fail
with ``FAILED_PRECONDITION`` in this state.
READY (int): The database is fully created and ready for use.
READY_OPTIMIZING (int): The database is fully created and ready for use, but is still being
optimized for performance and cannot handle full load.
In this state, the database still references the backup it was restore
from, preventing the backup from being deleted. When optimizations are
complete, the full performance of the database will be restored, and the
database will transition to ``READY`` state.
"""

STATE_UNSPECIFIED = 0
CREATING = 1
READY = 2
READY_OPTIMIZING = 3
Expand Up @@ -173,7 +173,8 @@ def update_database_ddl(self):
def drop_database(self):
"""Return the gRPC stub for :meth:`DatabaseAdminClient.drop_database`.
Drops (aka deletes) a Cloud Spanner database.
Drops (aka deletes) a Cloud Spanner database. Completed backups for the
database will be retained according to their ``expire_time``.
Returns:
Callable: A callable which accepts the appropriate
Expand Down Expand Up @@ -201,11 +202,12 @@ def get_database_ddl(self):
def set_iam_policy(self):
"""Return the gRPC stub for :meth:`DatabaseAdminClient.set_iam_policy`.
Sets the access control policy on a database resource. Replaces any
existing policy.
Sets the access control policy on a database or backup resource.
Replaces any existing policy.
Authorization requires ``spanner.databases.setIamPolicy`` permission on
``resource``.
``resource``. For backups, authorization requires
``spanner.backups.setIamPolicy`` permission on ``resource``.
Returns:
Callable: A callable which accepts the appropriate
Expand All @@ -218,11 +220,13 @@ def set_iam_policy(self):
def get_iam_policy(self):
"""Return the gRPC stub for :meth:`DatabaseAdminClient.get_iam_policy`.
Gets the access control policy for a database resource. Returns an empty
policy if a database exists but does not have a policy set.
Gets the access control policy for a database or backup resource.
Returns an empty policy if a database or backup exists but does not have
a policy set.
Authorization requires ``spanner.databases.getIamPolicy`` permission on
``resource``.
``resource``. For backups, authorization requires
``spanner.backups.getIamPolicy`` permission on ``resource``.
Returns:
Callable: A callable which accepts the appropriate
Expand All @@ -235,13 +239,15 @@ def get_iam_policy(self):
def test_iam_permissions(self):
"""Return the gRPC stub for :meth:`DatabaseAdminClient.test_iam_permissions`.
Returns permissions that the caller has on the specified database
resource.
Returns permissions that the caller has on the specified database or
backup resource.
Attempting this RPC on a non-existent Cloud Spanner database will result
in a NOT\_FOUND error if the user has ``spanner.databases.list``
permission on the containing Cloud Spanner instance. Otherwise returns
an empty set of permissions.
an empty set of permissions. Calling this method on a backup that does
not exist will result in a NOT\_FOUND error if the user has
``spanner.backups.list`` permission on the containing instance.
Returns:
Callable: A callable which accepts the appropriate
Expand All @@ -250,6 +256,146 @@ def test_iam_permissions(self):
"""
return self._stubs["database_admin_stub"].TestIamPermissions

@property
def create_backup(self):
"""Return the gRPC stub for :meth:`DatabaseAdminClient.create_backup`.
Starts creating a new Cloud Spanner Backup. The returned backup
``long-running operation`` will have a name of the format
``projects/<project>/instances/<instance>/backups/<backup>/operations/<operation_id>``
and can be used to track creation of the backup. The ``metadata`` field
type is ``CreateBackupMetadata``. The ``response`` field type is
``Backup``, if successful. Cancelling the returned operation will stop
the creation and delete the backup. There can be only one pending backup
creation per database. Backup creation of different databases can run
concurrently.
Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
deserialized response object.
"""
return self._stubs["database_admin_stub"].CreateBackup

@property
def get_backup(self):
"""Return the gRPC stub for :meth:`DatabaseAdminClient.get_backup`.
Gets metadata on a pending or completed ``Backup``.
Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
deserialized response object.
"""
return self._stubs["database_admin_stub"].GetBackup

@property
def update_backup(self):
"""Return the gRPC stub for :meth:`DatabaseAdminClient.update_backup`.
Updates a pending or completed ``Backup``.
Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
deserialized response object.
"""
return self._stubs["database_admin_stub"].UpdateBackup

@property
def delete_backup(self):
"""Return the gRPC stub for :meth:`DatabaseAdminClient.delete_backup`.
Deletes a pending or completed ``Backup``.
Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
deserialized response object.
"""
return self._stubs["database_admin_stub"].DeleteBackup

@property
def list_backups(self):
"""Return the gRPC stub for :meth:`DatabaseAdminClient.list_backups`.
Lists completed and pending backups. Backups returned are ordered by
``create_time`` in descending order, starting from the most recent
``create_time``.
Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
deserialized response object.
"""
return self._stubs["database_admin_stub"].ListBackups

@property
def restore_database(self):
"""Return the gRPC stub for :meth:`DatabaseAdminClient.restore_database`.
Create a new database by restoring from a completed backup. The new
database must be in the same project and in an instance with the same
instance configuration as the instance containing the backup. The
returned database ``long-running operation`` has a name of the format
``projects/<project>/instances/<instance>/databases/<database>/operations/<operation_id>``,
and can be used to track the progress of the operation, and to cancel
it. The ``metadata`` field type is ``RestoreDatabaseMetadata``. The
``response`` type is ``Database``, if successful. Cancelling the
returned operation will stop the restore and delete the database. There
can be only one database being restored into an instance at a time. Once
the restore operation completes, a new restore operation can be
initiated, without waiting for the optimize operation associated with
the first restore to complete.
Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
deserialized response object.
"""
return self._stubs["database_admin_stub"].RestoreDatabase

@property
def list_database_operations(self):
"""Return the gRPC stub for :meth:`DatabaseAdminClient.list_database_operations`.
Lists database ``longrunning-operations``. A database operation has a
name of the form
``projects/<project>/instances/<instance>/databases/<database>/operations/<operation>``.
The long-running operation ``metadata`` field type ``metadata.type_url``
describes the type of the metadata. Operations returned include those
that have completed/failed/canceled within the last 7 days, and pending
operations.
Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
deserialized response object.
"""
return self._stubs["database_admin_stub"].ListDatabaseOperations

@property
def list_backup_operations(self):
"""Return the gRPC stub for :meth:`DatabaseAdminClient.list_backup_operations`.
Lists the backup ``long-running operations`` in the given instance. A
backup operation has a name of the form
``projects/<project>/instances/<instance>/backups/<backup>/operations/<operation>``.
The long-running operation ``metadata`` field type ``metadata.type_url``
describes the type of the metadata. Operations returned include those
that have completed/failed/canceled within the last 7 days, and pending
operations. Operations returned are ordered by
``operation.metadata.value.progress.start_time`` in descending order
starting from the most recently started operation.
Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
deserialized response object.
"""
return self._stubs["database_admin_stub"].ListBackupOperations

@property
def list_databases(self):
"""Return the gRPC stub for :meth:`DatabaseAdminClient.list_databases`.
Expand Down

0 comments on commit a48c4b1

Please sign in to comment.