Struct DatabaseAdmin

Source
pub struct DatabaseAdmin { /* private fields */ }
Expand description

Implements a client for 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

DatabaseAdmin has various configuration parameters, the defaults should work with most applications.

§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

Source

pub async fn new() -> Result<Self>

Creates a new client with the default configuration.

Source

pub async fn new_with_config(conf: ClientConfig) -> Result<Self>

Creates a new client with the specified configuration.

Source

pub fn from_stub<T>(stub: T) -> Self
where T: DatabaseAdmin + 'static,

Creates a new client from the provided stub.

The most common case for calling this function is when mocking the client.

Source

pub fn list_databases(&self, parent: impl Into<String>) -> ListDatabases

Lists Cloud Spanner databases.

Source

pub fn create_database(&self, parent: impl Into<String>) -> 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.

Source

pub fn get_database(&self, name: impl Into<String>) -> GetDatabase

Gets the state of a Cloud Spanner database.

Source

pub fn update_database(&self, database: impl Into<Database>) -> 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.

Source

pub fn update_database_ddl( &self, database: impl Into<String>, ) -> 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.

Source

pub fn drop_database(&self, database: impl Into<String>) -> 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.

Source

pub fn get_database_ddl(&self, database: impl Into<String>) -> 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.

Source

pub fn set_iam_policy(&self, resource: impl Into<String>) -> SetIamPolicy

Sets the access control policy on a database or backup resource. Replaces any existing policy.

Authorization requires spanner.databases.setIamPolicy permission on resource. For backups, authorization requires spanner.backups.setIamPolicy permission on resource.

Source

pub fn get_iam_policy(&self, resource: impl Into<String>) -> 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.

Source

pub fn test_iam_permissions( &self, resource: impl Into<String>, ) -> 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.

Source

pub fn create_backup(&self, parent: impl Into<String>) -> 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.

Source

pub fn copy_backup(&self, parent: impl Into<String>) -> 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.

Source

pub fn get_backup(&self, name: impl Into<String>) -> GetBackup

Gets metadata on a pending or completed Backup.

Source

pub fn update_backup(&self, backup: impl Into<Backup>) -> UpdateBackup

Updates a pending or completed Backup.

Source

pub fn delete_backup(&self, name: impl Into<String>) -> DeleteBackup

Deletes a pending or completed Backup.

Source

pub fn list_backups(&self, parent: impl Into<String>) -> ListBackups

Lists completed and pending backups. Backups returned are ordered by create_time in descending order, starting from the most recent create_time.

Source

pub fn restore_database(&self, parent: impl Into<String>) -> 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.

Source

pub fn list_database_operations( &self, parent: impl Into<String>, ) -> 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.

Source

pub fn list_backup_operations( &self, parent: impl Into<String>, ) -> 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.

Source

pub fn list_database_roles( &self, parent: impl Into<String>, ) -> ListDatabaseRoles

Lists Cloud Spanner database roles.

Source

pub fn add_split_points(&self, database: impl Into<String>) -> AddSplitPoints

Adds split points to specified tables, indexes of a database.

Source

pub fn create_backup_schedule( &self, parent: impl Into<String>, ) -> CreateBackupSchedule

Creates a new backup schedule.

Source

pub fn get_backup_schedule(&self, name: impl Into<String>) -> GetBackupSchedule

Gets backup schedule for the input schedule name.

Source

pub fn update_backup_schedule( &self, backup_schedule: impl Into<BackupSchedule>, ) -> UpdateBackupSchedule

Updates a backup schedule.

Source

pub fn delete_backup_schedule( &self, name: impl Into<String>, ) -> DeleteBackupSchedule

Deletes a backup schedule.

Source

pub fn list_backup_schedules( &self, parent: impl Into<String>, ) -> ListBackupSchedules

Lists all the backup schedules for the database.

Source

pub fn list_operations(&self, name: impl Into<String>) -> ListOperations

Provides the Operations service functionality in this service.

Source

pub fn get_operation(&self, name: impl Into<String>) -> GetOperation

Provides the Operations service functionality in this service.

Source

pub fn delete_operation(&self, name: impl Into<String>) -> DeleteOperation

Provides the Operations service functionality in this service.

Source

pub fn cancel_operation(&self, name: impl Into<String>) -> CancelOperation

Provides the Operations service functionality in this service.

Trait Implementations§

Source§

impl Clone for DatabaseAdmin

Source§

fn clone(&self) -> DatabaseAdmin

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DatabaseAdmin

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T