pub struct DatabaseAdmin { /* private fields */ }
Expand description
Implements a client for the Cloud Spanner API.
§Example
let client = DatabaseAdmin::builder().build().await?;
// use `client` to make requests to the Cloud Spanner API.
§Service Description
Cloud Spanner Database Admin API
The Cloud Spanner Database Admin API can be used to:
- create, drop, and list databases
- update the schema of pre-existing databases
- create, delete, copy and list backups for a database
- restore a database from an existing backup
§Configuration
To configure DatabaseAdmin
use the with_*
methods in the type returned
by builder(). The default configuration should
work for most applications. Common configuration changes include
- with_endpoint(): by default this client uses the global default endpoint
(
https://spanner.googleapis.com
). Applications using regional endpoints or running in restricted networks (e.g. a network configured override this default. - with_credentials(): by default this client uses Application Default Credentials. Applications using custom authentication may need to override this default.
§Pooling and Cloning
DatabaseAdmin
holds a connection pool internally, it is advised to
create one and the reuse it. You do not need to wrap DatabaseAdmin
in
an Rc or Arc to reuse it, because it
already uses an Arc
internally.
Implementations§
Source§impl DatabaseAdmin
impl DatabaseAdmin
Sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
Returns a builder for DatabaseAdmin.
let client = DatabaseAdmin::builder().build().await?;
Sourcepub fn from_stub<T>(stub: T) -> Selfwhere
T: DatabaseAdmin + 'static,
pub fn from_stub<T>(stub: T) -> Selfwhere
T: DatabaseAdmin + 'static,
Creates a new client from the provided stub.
The most common case for calling this function is in tests mocking the client’s behavior.
Sourcepub fn list_databases(&self) -> ListDatabases
pub fn list_databases(&self) -> ListDatabases
Lists Cloud Spanner databases.
Sourcepub fn create_database(&self) -> CreateDatabase
pub fn create_database(&self) -> CreateDatabase
Creates a new Cloud Spanner database and starts to prepare it for serving.
The returned long-running operation will
have a name of the format <database_name>/operations/<operation_id>
and
can be used to track preparation of the database. The
metadata field type is
CreateDatabaseMetadata.
The response field type is
Database, if successful.
§Long running operations
This method is used to start, and/or poll a long-running Operation. The Working with long-running operations chapter in the user guide covers these operations in detail.
Sourcepub fn get_database(&self) -> GetDatabase
pub fn get_database(&self) -> GetDatabase
Gets the state of a Cloud Spanner database.
Sourcepub fn update_database(&self) -> UpdateDatabase
pub fn update_database(&self) -> UpdateDatabase
Updates a Cloud Spanner database. The returned
long-running operation can be used to track
the progress of updating the database. If the named database does not
exist, returns NOT_FOUND
.
While the operation is pending:
- The database’s reconciling field is set to true.
- Cancelling the operation is best-effort. If the cancellation succeeds,
the operation metadata’s
cancel_time
is set, the updates are reverted, and the operation terminates with a
CANCELLED
status. - New UpdateDatabase requests will return a
FAILED_PRECONDITION
error until the pending operation is done (returns successfully or with error). - Reading the database via the API continues to give the pre-request values.
Upon completion of the returned operation:
- The new values are in effect and readable via the API.
- The database’s reconciling field becomes false.
The returned long-running operation will
have a name of the format
projects/<project>/instances/<instance>/databases/<database>/operations/<operation_id>
and can be used to track the database modification. The
metadata field type is
UpdateDatabaseMetadata.
The response field type is
Database, if successful.
§Long running operations
This method is used to start, and/or poll a long-running Operation. The Working with long-running operations chapter in the user guide covers these operations in detail.
Sourcepub fn update_database_ddl(&self) -> UpdateDatabaseDdl
pub fn update_database_ddl(&self) -> UpdateDatabaseDdl
Updates the schema of a Cloud Spanner database by
creating/altering/dropping tables, columns, indexes, etc. The returned
long-running operation will have a name of
the format <database_name>/operations/<operation_id>
and can be used to
track execution of the schema change(s). The
metadata field type is
UpdateDatabaseDdlMetadata.
The operation has no response.
§Long running operations
This method is used to start, and/or poll a long-running Operation. The Working with long-running operations chapter in the user guide covers these operations in detail.
Sourcepub fn drop_database(&self) -> DropDatabase
pub fn drop_database(&self) -> DropDatabase
Drops (aka deletes) a Cloud Spanner database.
Completed backups for the database will be retained according to their
expire_time
.
Note: Cloud Spanner might continue to accept requests for a few seconds
after the database has been deleted.
Sourcepub fn get_database_ddl(&self) -> GetDatabaseDdl
pub fn get_database_ddl(&self) -> GetDatabaseDdl
Returns the schema of a Cloud Spanner database as a list of formatted DDL statements. This method does not show pending schema updates, those may be queried using the Operations API.
Sourcepub fn set_iam_policy(&self) -> SetIamPolicy
pub fn set_iam_policy(&self) -> SetIamPolicy
Sourcepub fn get_iam_policy(&self) -> GetIamPolicy
pub fn get_iam_policy(&self) -> GetIamPolicy
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.
For backups, authorization requires spanner.backups.getIamPolicy
permission on resource.
Sourcepub fn test_iam_permissions(&self) -> TestIamPermissions
pub fn test_iam_permissions(&self) -> TestIamPermissions
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.
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.
Sourcepub fn create_backup(&self) -> CreateBackup
pub fn create_backup(&self) -> CreateBackup
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.
§Long running operations
This method is used to start, and/or poll a long-running Operation. The Working with long-running operations chapter in the user guide covers these operations in detail.
Sourcepub fn copy_backup(&self) -> CopyBackup
pub fn copy_backup(&self) -> CopyBackup
Starts copying a 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 copying of the backup. The operation is associated
with the destination backup.
The metadata field type is
CopyBackupMetadata.
The response field type is
Backup, if successful.
Cancelling the returned operation will stop the copying and delete the
destination backup. Concurrent CopyBackup requests can run on the same
source backup.
§Long running operations
This method is used to start, and/or poll a long-running Operation. The Working with long-running operations chapter in the user guide covers these operations in detail.
Sourcepub fn get_backup(&self) -> GetBackup
pub fn get_backup(&self) -> GetBackup
Gets metadata on a pending or completed Backup.
Sourcepub fn update_backup(&self) -> UpdateBackup
pub fn update_backup(&self) -> UpdateBackup
Updates a pending or completed Backup.
Sourcepub fn delete_backup(&self) -> DeleteBackup
pub fn delete_backup(&self) -> DeleteBackup
Deletes a pending or completed Backup.
Sourcepub fn list_backups(&self) -> ListBackups
pub fn list_backups(&self) -> ListBackups
Lists completed and pending backups.
Backups returned are ordered by create_time
in descending order,
starting from the most recent create_time
.
Sourcepub fn restore_database(&self) -> RestoreDatabase
pub fn restore_database(&self) -> RestoreDatabase
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.
§Long running operations
This method is used to start, and/or poll a long-running Operation. The Working with long-running operations chapter in the user guide covers these operations in detail.
Sourcepub fn list_database_operations(&self) -> ListDatabaseOperations
pub fn list_database_operations(&self) -> ListDatabaseOperations
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.
Sourcepub fn list_backup_operations(&self) -> ListBackupOperations
pub fn list_backup_operations(&self) -> ListBackupOperations
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.
Sourcepub fn list_database_roles(&self) -> ListDatabaseRoles
pub fn list_database_roles(&self) -> ListDatabaseRoles
Lists Cloud Spanner database roles.
Sourcepub fn add_split_points(&self) -> AddSplitPoints
pub fn add_split_points(&self) -> AddSplitPoints
Adds split points to specified tables, indexes of a database.
Sourcepub fn create_backup_schedule(&self) -> CreateBackupSchedule
pub fn create_backup_schedule(&self) -> CreateBackupSchedule
Creates a new backup schedule.
Sourcepub fn get_backup_schedule(&self) -> GetBackupSchedule
pub fn get_backup_schedule(&self) -> GetBackupSchedule
Gets backup schedule for the input schedule name.
Sourcepub fn update_backup_schedule(&self) -> UpdateBackupSchedule
pub fn update_backup_schedule(&self) -> UpdateBackupSchedule
Updates a backup schedule.
Sourcepub fn delete_backup_schedule(&self) -> DeleteBackupSchedule
pub fn delete_backup_schedule(&self) -> DeleteBackupSchedule
Deletes a backup schedule.
Sourcepub fn list_backup_schedules(&self) -> ListBackupSchedules
pub fn list_backup_schedules(&self) -> ListBackupSchedules
Lists all the backup schedules for the database.
Sourcepub fn list_operations(&self) -> ListOperations
pub fn list_operations(&self) -> ListOperations
Provides the Operations service functionality in this service.
Sourcepub fn get_operation(&self) -> GetOperation
pub fn get_operation(&self) -> GetOperation
Provides the Operations service functionality in this service.
Sourcepub fn delete_operation(&self) -> DeleteOperation
pub fn delete_operation(&self) -> DeleteOperation
Provides the Operations service functionality in this service.
Sourcepub fn cancel_operation(&self) -> CancelOperation
pub fn cancel_operation(&self) -> CancelOperation
Provides the Operations service functionality in this service.
Trait Implementations§
Source§impl Clone for DatabaseAdmin
impl Clone for DatabaseAdmin
Source§fn clone(&self) -> DatabaseAdmin
fn clone(&self) -> DatabaseAdmin
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more